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);
24 treeview->setColumnWidth (0,350);
26 selModel=treeview->selectionModel();
27 model->setSelectionModel (selModel);
29 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
30 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
32 // Create good old MapEditor
33 MapEditor* me=model->getMapEditor();
34 if (!me) me=new MapEditor (model);
36 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
37 me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
40 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
41 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
46 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
47 me,SLOT (updateData(const QModelIndex &) ) );
49 // VymModel may want to update selection or other data, e.g. during animation
51 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
52 me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
54 model, SIGNAL (newChildObject(QModelIndex) ),
55 this,SLOT (updateChilds (QModelIndex) ) );
57 model, SIGNAL (noteHasChanged(QModelIndex) ),
58 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
61 //me->viewport()->setFocus(); //FIXME-3 needed?
62 me->setAntiAlias (mainWindow->isAliased());
63 me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
75 QItemSelectionModel* VymView::selectionModel()
80 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
85 void VymView::updateChilds (QModelIndex ix)
87 treeview->setExpanded (ix,true);
90 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
93 cout <<"VymView::changeSelection (";
94 if (!newsel.indexes().isEmpty() )
95 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
97 if (!oldsel.indexes().isEmpty() )
98 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
102 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
103 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?