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 &) ) );
45 model, SIGNAL (sortFilterChanged (const QString &)),
46 treeEditor, SLOT (setSortFilter (const QString &) ) );
48 // VymModel may want to update selection or other data, e.g. during animation
50 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
51 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
54 model, SIGNAL (noteHasChanged(QModelIndex) ),
55 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
58 model, SIGNAL (expandAll() ),
59 this, SLOT (expandAll () ) );
62 model, SIGNAL (showSelection() ),
63 this, SLOT (showSelection() ) );
66 mapEditor->setAntiAlias (mainWindow->isAliased());
67 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
69 addWidget (treeEditor);
70 addWidget (mapEditor);
74 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this);
75 proxyModel->setDynamicSortFilter (true);
76 proxyModel->setSourceModel(model);
77 //proxyModel->setFilterFixedString ("a",Qt::CaseInsensitive,QRegExp::FixedString);
78 proxyModel->setFilterRegExp(QRegExp("e", Qt::CaseInsensitive));
79 proxyModel->setFilterKeyColumn(0);
80 tv->setModel (proxyModel);
93 //cout << "Destructor VymView\n";
96 VymModel* VymView::getModel()
101 MapEditor* VymView::getMapEditor()
106 void VymView::initFocus()
108 mapEditor->setFocus();
111 QItemSelectionModel* VymView::selectionModel()
116 std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
120 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
122 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
123 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly?
124 // would require to also get current model in mainWindow
126 showSelection(); // if called here, no tmpParObj can be set...
129 void VymView::expandAll()
131 treeEditor->expandAll();
135 void VymView::showSelection()
137 QModelIndex ix=model->getSelectedIndex();
138 treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
139 mapEditor->scrollTo ( ix);