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,150);
23 treeEditor->setAnimated (true);
26 selModel=treeEditor->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=model->getMapEditor();
34 if (!mapEditor) mapEditor=new MapEditor (model);
36 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
37 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
40 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
41 mapEditor,SLOT (updateData(const QModelIndex &) ) );
43 // VymModel may want to update selection or other data, e.g. during animation
45 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
46 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
49 model, SIGNAL (noteHasChanged(QModelIndex) ),
50 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
53 model, SIGNAL (expandAll() ),
54 this, SLOT (expandAll () ) );
57 model, SIGNAL (showSelection() ),
58 this, SLOT (showSelection() ) );
61 mapEditor->setAntiAlias (mainWindow->isAliased());
62 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
64 addWidget (treeEditor);
65 addWidget (mapEditor);
69 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this);
70 proxyModel->setDynamicSortFilter (true);
71 proxyModel->setSourceModel(model);
72 //proxyModel->setFilterFixedString ("a",Qt::CaseInsensitive,QRegExp::FixedString);
73 proxyModel->setFilterRegExp(QRegExp("e", Qt::CaseInsensitive));
74 proxyModel->setFilterKeyColumn(0);
75 tv->setModel (proxyModel);
88 //cout << "Destructor VymView\n";
91 VymModel* VymView::getModel()
96 MapEditor* VymView::getMapEditor()
101 void VymView::initFocus()
103 mapEditor->setFocus();
106 QItemSelectionModel* VymView::selectionModel()
111 std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
115 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
117 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
118 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly?
119 // would require to also get current model in mainWindow
121 //showSelection(); // if called here, no tmpParObj can be set...
124 void VymView::expandAll()
126 treeEditor->expandAll();
130 void VymView::showSelection()
132 QModelIndex ix=model->getSelectedIndex();
133 treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
134 mapEditor->scrollTo ( ix);