6 #include "mainwindow.h"
8 #include "treeeditor.h"
10 extern Main *mainWindow;
13 VymView::VymView(VymModel *m)
18 treeEditor=new TreeEditor (model);
19 treeEditor->setModel ((QAbstractItemModel*)model);
20 //treeEditor->setMinimumWidth (50);
22 treeEditor->setColumnWidth (0,350);
24 selModel=treeEditor->selectionModel();
25 model->setSelectionModel (selModel);
27 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
28 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
30 // Create good old MapEditor
31 mapEditor=model->getMapEditor();
32 if (!mapEditor) mapEditor=new MapEditor (model);
34 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
35 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
38 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
39 model,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
42 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
43 mapEditor,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 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
51 model, SIGNAL (noteHasChanged(QModelIndex) ),
52 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
55 model, SIGNAL (expandAll() ),
56 this, SLOT (expandAll () ) );
59 model, SIGNAL (showSelection() ),
60 this, SLOT (showSelection() ) );
63 mapEditor->setAntiAlias (mainWindow->isAliased());
64 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
66 addWidget (treeEditor);
67 addWidget (mapEditor);
78 //cout << "Destructor VymView\n";
81 VymModel* VymView::getModel()
86 MapEditor* VymView::getMapEditor()
91 void VymView::initFocus()
93 mapEditor->setFocus();
96 QItemSelectionModel* VymView::selectionModel()
101 std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
105 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
107 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
108 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly?
109 // would require to also get current model in mainWindow
114 void VymView::expandAll()
116 treeEditor->expandAll();
119 void VymView::showSelection()
121 QModelIndex ix=model->getSelectedIndex();
122 treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
123 mapEditor->scrollTo ( ix);