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 (50);
21 treeview->setColumnWidth (0,350);
23 selModel=treeview->selectionModel();
24 model->setSelectionModel (selModel);
26 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
27 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
29 // Create good old MapEditor
30 mapEditor=model->getMapEditor();
31 if (!mapEditor) mapEditor=new MapEditor (model);
33 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
34 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
37 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
38 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
43 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
44 mapEditor,SLOT (updateData(const QModelIndex &) ) );
46 // VymModel may want to update selection or other data, e.g. during animation
48 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
49 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
53 model, SIGNAL (newChildObject(QModelIndex) ),
54 this,SLOT (updateChilds (QModelIndex) ) );
58 model, SIGNAL (noteHasChanged(QModelIndex) ),
59 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
62 //mapEditor->viewport()->setFocus(); //FIXmapEditor-3 needed?
63 mapEditor->setAntiAlias (mainWindow->isAliased());
64 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
67 addWidget (mapEditor);
76 QItemSelectionModel* VymView::selectionModel()
81 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
86 void VymView::updateChilds (QModelIndex ix) //FIXME-4 not needed?
88 cout << "VV::updateChilds \n";
89 //treeview->setExpanded (ix,true); // This is expensive...
92 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
95 cout <<"VymView::changeSelection (";
96 if (!newsel.indexes().isEmpty() )
97 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
99 if (!oldsel.indexes().isEmpty() )
100 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
104 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
105 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?