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 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
39 mapEditor,SLOT (updateData(const QModelIndex &) ) );
41 // VymModel may want to update selection or other data, e.g. during animation
43 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
44 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
47 model, SIGNAL (noteHasChanged(QModelIndex) ),
48 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
51 model, SIGNAL (expandAll() ),
52 this, SLOT (expandAll () ) );
55 model, SIGNAL (showSelection() ),
56 this, SLOT (showSelection() ) );
59 mapEditor->setAntiAlias (mainWindow->isAliased());
60 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
62 addWidget (treeEditor);
63 addWidget (mapEditor);
74 //cout << "Destructor VymView\n";
77 VymModel* VymView::getModel()
82 MapEditor* VymView::getMapEditor()
87 void VymView::initFocus()
89 mapEditor->setFocus();
92 QItemSelectionModel* VymView::selectionModel()
97 std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
101 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
103 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
104 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?
108 void VymView::expandAll()
110 treeEditor->expandAll();
113 void VymView::showSelection()
115 QModelIndex ix=model->getSelectedIndex();
116 treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
117 mapEditor->scrollTo ( ix);