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 &)));
36 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
37 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
42 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
43 me,SLOT (updateData(const QModelIndex &) ) );
45 // VymModel may want to update selection or other data, e.g. during animation
47 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
48 me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
50 model, SIGNAL (newChildObject(QModelIndex) ),
51 this,SLOT (updateChilds (QModelIndex) ) );
53 model, SIGNAL (noteHasChanged(QModelIndex) ),
54 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
57 //me->viewport()->setFocus(); //FIXME-3 needed?
58 me->setAntiAlias (mainWindow->isAliased());
59 me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
71 QItemSelectionModel* VymView::selectionModel()
76 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
81 void VymView::updateChilds (QModelIndex ix)
83 treeview->setExpanded (ix,true);
86 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
89 cout <<"VymView::changeSelection (";
90 if (!newsel.indexes().isEmpty() )
91 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
93 if (!oldsel.indexes().isEmpty() )
94 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
98 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
99 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?