6 #include "linkablemapobj.h"
7 #include "mainwindow.h"
9 #include "treeeditor.h"
11 extern Main *mainWindow;
14 VymView::VymView(VymModel *m)
19 treeEditor=new TreeEditor (model);
20 treeEditor->setModel ((QAbstractItemModel*)model);
21 //treeEditor->setMinimumWidth (50);
23 treeEditor->setColumnWidth (0,350);
25 selModel=treeEditor->selectionModel();
26 model->setSelectionModel (selModel);
28 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
29 this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
31 // Create good old MapEditor
32 mapEditor=model->getMapEditor();
33 if (!mapEditor) mapEditor=new MapEditor (model);
35 selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
36 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
39 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
40 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
45 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
46 mapEditor,SLOT (updateData(const QModelIndex &) ) );
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);
79 void VymView::initFocus()
81 mapEditor->setFocus();
84 QItemSelectionModel* VymView::selectionModel()
89 std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
93 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
96 cout <<"VymView::changeSelection (";
97 if (!newsel.indexes().isEmpty() )
98 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
100 if (!oldsel.indexes().isEmpty() )
101 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
105 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
106 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?
110 void VymView::expandAll()
112 treeEditor->expandAll();
115 void VymView::showSelection()
117 treeEditor->scrollTo(
118 model->getSelectedIndex(),
119 //QAbstractItemView::PositionAtCenter
120 QAbstractItemView::EnsureVisible
123 LinkableMapObj* lmo=model->getSelectedLMO();
125 mapEditor->setScrollBarPosTarget (lmo->getBBox() );