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 &)));
54 model, SIGNAL (newChildObject(QModelIndex) ),
55 this,SLOT (updateChilds (QModelIndex) ) );
59 model, SIGNAL (noteHasChanged(QModelIndex) ),
60 mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
63 model, SIGNAL (expandAll() ),
64 this, SLOT (expandAll () ) );
67 model, SIGNAL (showSelection() ),
68 this, SLOT (showSelection() ) );
71 //mapEditor->viewport()->setFocus(); //FIXmapEditor-3 needed?
72 mapEditor->setAntiAlias (mainWindow->isAliased());
73 mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
76 addWidget (mapEditor);
85 QItemSelectionModel* VymView::selectionModel()
90 std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
95 void VymView::updateChilds (QModelIndex ix) //FIXME-4 not needed?
97 cout << "VV::updateChilds \n";
98 //treeview->setExpanded (ix,true); // This is expensive...
101 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
104 cout <<"VymView::changeSelection (";
105 if (!newsel.indexes().isEmpty() )
106 cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
108 if (!oldsel.indexes().isEmpty() )
109 cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
113 // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
114 mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?
117 void VymView::expandAll()
119 treeview->expandAll();
122 void VymView::showSelection()
125 model->getSelectedIndex(),
126 //QAbstractItemView::PositionAtCenter
127 QAbstractItemView::EnsureVisible
130 LinkableMapObj* lmo=model->getSelectedLMO();
132 mapEditor->ensureVisible(lmo->getBBox() );