6 #include "mainwindow.h"
9 extern Main *mainWindow;
12 VymView::VymView(VymModel *m)
17 treeview=new QTreeView;
18 treeview->setModel ((QAbstractItemModel*)model);
19 treeview->setMinimumWidth (350);
20 treeview->setColumnWidth (0,350);
22 selModel=treeview->selectionModel();
23 model->setSelectionModel (selModel);
25 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
26 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
28 // Create good old MapEditor
29 MapEditor* me=model->getMapEditor();
30 if (!me) me=new MapEditor (model);
32 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
33 me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
35 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
36 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
38 // VymModel may want to update selection or other data, e.g. during animation
40 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
41 me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
43 model, SIGNAL (newChildObject(QModelIndex) ),
44 this,SLOT (updateChilds (QModelIndex) ) );
46 model, SIGNAL (contentHasChanged(QModelIndex) ),
47 mainWindow, SLOT (updateContent(QModelIndex) ) );
50 //me->viewport()->setFocus(); //FIXME-3 needed?
51 me->setAntiAlias (mainWindow->isAliased());
52 me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
64 QItemSelectionModel* VymView::selectionModel()
69 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
74 void VymView::updateChilds (QModelIndex ix)
76 treeview->setExpanded (ix,true);
79 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
82 cout <<"VymView::changeSelection (";
83 if (!newsel.indexes().isEmpty() )
84 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
86 if (!oldsel.indexes().isEmpty() )
87 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
91 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
92 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?