vymview.cpp
author insilmaril
Fri, 30 Jan 2009 09:14:12 +0000
changeset 738 716a777c1c98
parent 735 84ae10f6e3a3
child 742 54d44ecd6097
permissions -rw-r--r--
fixes for selecting branches
     1 #include "vymview.h"
     2 
     3 #include <iostream>
     4 
     5 #include "mainwindow.h"
     6 #include "mapeditor.h"
     7 
     8 extern Main *mainWindow;
     9 
    10 
    11 VymView::VymView(VymModel *model)
    12 {
    13 	// Create TreeView
    14 	treeview=new QTreeView;
    15 	treeview->setModel ((QAbstractItemModel*)model);
    16 	treeview->setMinimumWidth (350);
    17 	treeview->setColumnWidth (0,350);
    18 
    19 	selModel=treeview->selectionModel();
    20 	model->setSelectionModel (selModel);
    21 	connect (
    22 		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    23 		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
    24 
    25 	// Create good old MapEditor
    26 	MapEditor* me=model->getMapEditor();
    27 	if (!me) me=new MapEditor (model);
    28 	connect (
    29 		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    30 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    31 	connect (
    32 		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
    33 		me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
    34 
    35 	// VymModel may want to update selection, e.g. during animation
    36 	connect (
    37 		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    38 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    39 
    40 	//me->viewport()->setFocus();	//FIXME needed?
    41 	me->setAntiAlias (mainWindow->isAliased());
    42 	me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
    43 
    44 	addWidget (treeview);
    45 	addWidget (me);
    46 
    47 	// Set geometry
    48 	QList <int> sizes;
    49 	sizes.append (120);
    50 	sizes.append (600);
    51 	setSizes (sizes);
    52 }
    53 
    54 QItemSelectionModel* VymView::selectionModel() 
    55 {
    56 	if (treeview) 
    57 		return selModel;
    58 	else 
    59 		std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
    60 	return NULL;
    61 }
    62 
    63 
    64 void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
    65 {
    66 	// FIXME Currently this works only from treeview->ME
    67 	treeview->expandAll();	//FIXME only for testing
    68 
    69 	//((VymModel*)treeview->model())->select ();
    70 }
    71