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);
25 proxySelModel=treeEditor->selectionModel();
26 selModel=new QItemSelectionModel (model);
28 //model->setSelectionModel (proxySelModel);
29 model->setSelectionModel (selModel);
31 // Create good old MapEditor
32 mapEditor=model->getMapEditor();
33 if (!mapEditor) mapEditor=new MapEditor (model);
39 proxySelModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
40 this,SLOT (changeProxySelection(const QItemSelection &,const QItemSelection &)));
44 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
45 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
48 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
49 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
50 //FIXME-3 above and below necessary???
52 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
53 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
55 // Connect data changed signals
57 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
58 mapEditor,SLOT (updateData(const QModelIndex &) ) );
61 model, SIGNAL (sortFilterChanged (const QString &)),
62 treeEditor, SLOT (setSortFilter (const QString &) ) );
65 model, SIGNAL (noteHasChanged(QModelIndex) ),
66 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
69 model, SIGNAL (expandAll() ),
70 this, SLOT (expandAll () ) );
73 model, SIGNAL (showSelection() ),
74 this, SLOT (showSelection() ) );
77 mapEditor->setAntiAlias (mainWindow->isAliased());
78 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
80 addWidget (treeEditor);
81 addWidget (mapEditor);
92 //cout << "Destructor VymView\n";
95 VymModel* VymView::getModel()
100 MapEditor* VymView::getMapEditor()
105 void VymView::initFocus()
107 mapEditor->setFocus();
110 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
112 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
113 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly?
114 // would require to also get current model in mainWindow
115 proxySelModel->select (
116 treeEditor->getProxyModel()->mapSelectionFromSource (newsel),
117 QItemSelectionModel::ClearAndSelect );
121 void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &oldsel)
123 // Notify mainwindow to update satellites, but map selection to
124 // original model first
126 // Re-emit but map selection first
127 model->emitSelectionChanged (treeEditor->getProxyModel()->mapSelectionToSource (newsel));
130 void VymView::expandAll()
132 treeEditor->expandAll();
135 void VymView::showSelection()
137 QModelIndex ix=model->getSelectedIndex();
138 treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
139 mapEditor->scrollTo ( ix);