insilmaril@726
|
1 |
#include "vymview.h"
|
insilmaril@726
|
2 |
|
insilmaril@727
|
3 |
#include <iostream>
|
insilmaril@727
|
4 |
|
insilmaril@732
|
5 |
#include "mainwindow.h"
|
insilmaril@726
|
6 |
#include "mapeditor.h"
|
insilmaril@726
|
7 |
|
insilmaril@732
|
8 |
extern Main *mainWindow;
|
insilmaril@732
|
9 |
|
insilmaril@732
|
10 |
|
insilmaril@726
|
11 |
VymView::VymView(VymModel *model)
|
insilmaril@726
|
12 |
{
|
insilmaril@726
|
13 |
// Create TreeView
|
insilmaril@727
|
14 |
treeview=new QTreeView;
|
insilmaril@726
|
15 |
treeview->setModel ((QAbstractItemModel*)model);
|
insilmaril@726
|
16 |
treeview->setMinimumWidth (350);
|
insilmaril@726
|
17 |
treeview->setColumnWidth (0,350);
|
insilmaril@726
|
18 |
|
insilmaril@727
|
19 |
selModel=treeview->selectionModel();
|
insilmaril@728
|
20 |
model->setSelectionModel (selModel);
|
insilmaril@727
|
21 |
connect (
|
insilmaril@727
|
22 |
selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@727
|
23 |
this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@727
|
24 |
|
insilmaril@726
|
25 |
// Create good old MapEditor
|
insilmaril@726
|
26 |
MapEditor* me=model->getMapEditor();
|
insilmaril@726
|
27 |
if (!me) me=new MapEditor (model);
|
insilmaril@728
|
28 |
connect (
|
insilmaril@728
|
29 |
selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@728
|
30 |
me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@729
|
31 |
connect (
|
insilmaril@729
|
32 |
selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)),
|
insilmaril@729
|
33 |
me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
|
insilmaril@726
|
34 |
|
insilmaril@728
|
35 |
// VymModel may want to update selection, e.g. during animation
|
insilmaril@728
|
36 |
connect (
|
insilmaril@728
|
37 |
model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@728
|
38 |
me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@726
|
39 |
|
insilmaril@735
|
40 |
//me->viewport()->setFocus(); //FIXME needed?
|
insilmaril@732
|
41 |
me->setAntiAlias (mainWindow->isAliased());
|
insilmaril@732
|
42 |
me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
|
insilmaril@726
|
43 |
|
insilmaril@726
|
44 |
addWidget (treeview);
|
insilmaril@726
|
45 |
addWidget (me);
|
insilmaril@726
|
46 |
|
insilmaril@726
|
47 |
// Set geometry
|
insilmaril@726
|
48 |
QList <int> sizes;
|
insilmaril@735
|
49 |
sizes.append (120);
|
insilmaril@726
|
50 |
sizes.append (600);
|
insilmaril@726
|
51 |
setSizes (sizes);
|
insilmaril@726
|
52 |
}
|
insilmaril@726
|
53 |
|
insilmaril@726
|
54 |
QItemSelectionModel* VymView::selectionModel()
|
insilmaril@726
|
55 |
{
|
insilmaril@728
|
56 |
if (treeview)
|
insilmaril@728
|
57 |
return selModel;
|
insilmaril@728
|
58 |
else
|
insilmaril@728
|
59 |
std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
|
insilmaril@726
|
60 |
return NULL;
|
insilmaril@726
|
61 |
}
|
insilmaril@726
|
62 |
|
insilmaril@726
|
63 |
|
insilmaril@727
|
64 |
void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
|
insilmaril@727
|
65 |
{
|
insilmaril@727
|
66 |
// FIXME Currently this works only from treeview->ME
|
insilmaril@727
|
67 |
treeview->expandAll(); //FIXME only for testing
|
insilmaril@727
|
68 |
|
insilmaril@735
|
69 |
//((VymModel*)treeview->model())->select ();
|
insilmaril@727
|
70 |
}
|
insilmaril@727
|
71 |
|