6 #include "linkablemapobj.h"
7 #include "mainwindow.h"
10 extern Main *mainWindow;
13 VymView::VymView(VymModel *m)
18 treeview=new QTreeView;
19 treeview->setModel ((QAbstractItemModel*)model);
20 //treeview->setMinimumWidth (50);
22 treeview->setColumnWidth (0,350);
24 selModel=treeview->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 selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
39 me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
44 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
45 mapEditor,SLOT (updateData(const QModelIndex &) ) );
47 // VymModel may want to update selection or other data, e.g. during animation
49 model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
50 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
53 model, SIGNAL (noteHasChanged(QModelIndex) ),
54 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
57 model, SIGNAL (expandAll() ),
58 this, SLOT (expandAll () ) );
61 model, SIGNAL (showSelection() ),
62 this, SLOT (showSelection() ) );
65 //mapEditor->viewport()->setFocus(); //FIXmapEditor-3 needed?
66 mapEditor->setAntiAlias (mainWindow->isAliased());
67 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
70 addWidget (mapEditor);
79 QItemSelectionModel* VymView::selectionModel()
84 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
88 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
91 cout <<"VymView::changeSelection (";
92 if (!newsel.indexes().isEmpty() )
93 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
95 if (!oldsel.indexes().isEmpty() )
96 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
100 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
101 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?
105 void VymView::expandAll()
107 treeview->expandAll();
110 void VymView::showSelection()
113 model->getSelectedIndex(),
114 //QAbstractItemView::PositionAtCenter
115 QAbstractItemView::EnsureVisible
118 LinkableMapObj* lmo=model->getSelectedLMO();
120 mapEditor->setScrollBarPosTarget (lmo->getBBox() );