insilmaril@726
|
1 |
#include "vymview.h"
|
insilmaril@726
|
2 |
|
insilmaril@727
|
3 |
#include <iostream>
|
insilmaril@742
|
4 |
using namespace std;
|
insilmaril@727
|
5 |
|
insilmaril@732
|
6 |
#include "mainwindow.h"
|
insilmaril@726
|
7 |
#include "mapeditor.h"
|
insilmaril@769
|
8 |
#include "treeeditor.h"
|
insilmaril@726
|
9 |
|
insilmaril@732
|
10 |
extern Main *mainWindow;
|
insilmaril@732
|
11 |
|
insilmaril@732
|
12 |
|
insilmaril@742
|
13 |
VymView::VymView(VymModel *m)
|
insilmaril@726
|
14 |
{
|
insilmaril@742
|
15 |
model=m;
|
insilmaril@742
|
16 |
|
insilmaril@726
|
17 |
// Create TreeView
|
insilmaril@769
|
18 |
treeEditor=new TreeEditor (model);
|
insilmaril@769
|
19 |
treeEditor->setModel ((QAbstractItemModel*)model);
|
insilmaril@769
|
20 |
//treeEditor->setMinimumWidth (50);
|
insilmaril@761
|
21 |
|
insilmaril@769
|
22 |
treeEditor->setColumnWidth (0,350);
|
insilmaril@726
|
23 |
|
insilmaril@769
|
24 |
selModel=treeEditor->selectionModel();
|
insilmaril@728
|
25 |
model->setSelectionModel (selModel);
|
insilmaril@727
|
26 |
connect (
|
insilmaril@727
|
27 |
selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@727
|
28 |
this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@727
|
29 |
|
insilmaril@726
|
30 |
// Create good old MapEditor
|
insilmaril@761
|
31 |
mapEditor=model->getMapEditor();
|
insilmaril@761
|
32 |
if (!mapEditor) mapEditor=new MapEditor (model);
|
insilmaril@728
|
33 |
connect (
|
insilmaril@728
|
34 |
selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@761
|
35 |
mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@772
|
36 |
|
insilmaril@753
|
37 |
connect (
|
insilmaril@775
|
38 |
selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@775
|
39 |
model,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@775
|
40 |
|
insilmaril@775
|
41 |
connect (
|
insilmaril@753
|
42 |
model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
|
insilmaril@761
|
43 |
mapEditor,SLOT (updateData(const QModelIndex &) ) );
|
insilmaril@726
|
44 |
|
insilmaril@746
|
45 |
// VymModel may want to update selection or other data, e.g. during animation
|
insilmaril@728
|
46 |
connect (
|
insilmaril@728
|
47 |
model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
|
insilmaril@761
|
48 |
mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
|
insilmaril@761
|
49 |
|
insilmaril@746
|
50 |
connect (
|
insilmaril@753
|
51 |
model, SIGNAL (noteHasChanged(QModelIndex) ),
|
insilmaril@753
|
52 |
mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
|
insilmaril@746
|
53 |
|
insilmaril@763
|
54 |
connect (
|
insilmaril@763
|
55 |
model, SIGNAL (expandAll() ),
|
insilmaril@763
|
56 |
this, SLOT (expandAll () ) );
|
insilmaril@763
|
57 |
|
insilmaril@763
|
58 |
connect (
|
insilmaril@763
|
59 |
model, SIGNAL (showSelection() ),
|
insilmaril@763
|
60 |
this, SLOT (showSelection() ) );
|
insilmaril@763
|
61 |
|
insilmaril@726
|
62 |
|
insilmaril@761
|
63 |
mapEditor->setAntiAlias (mainWindow->isAliased());
|
insilmaril@761
|
64 |
mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
|
insilmaril@726
|
65 |
|
insilmaril@769
|
66 |
addWidget (treeEditor);
|
insilmaril@761
|
67 |
addWidget (mapEditor);
|
insilmaril@726
|
68 |
|
insilmaril@726
|
69 |
// Set geometry
|
insilmaril@761
|
70 |
QList <int> widths;
|
insilmaril@761
|
71 |
widths<<120;
|
insilmaril@761
|
72 |
widths<<600;
|
insilmaril@761
|
73 |
setSizes(widths);
|
insilmaril@726
|
74 |
}
|
insilmaril@726
|
75 |
|
insilmaril@772
|
76 |
VymView::~VymView()
|
insilmaril@772
|
77 |
{
|
insilmaril@772
|
78 |
//cout << "Destructor VymView\n";
|
insilmaril@772
|
79 |
}
|
insilmaril@772
|
80 |
|
insilmaril@772
|
81 |
VymModel* VymView::getModel()
|
insilmaril@772
|
82 |
{
|
insilmaril@772
|
83 |
return model;
|
insilmaril@772
|
84 |
}
|
insilmaril@772
|
85 |
|
insilmaril@772
|
86 |
MapEditor* VymView::getMapEditor()
|
insilmaril@772
|
87 |
{
|
insilmaril@772
|
88 |
return mapEditor;
|
insilmaril@772
|
89 |
}
|
insilmaril@772
|
90 |
|
insilmaril@769
|
91 |
void VymView::initFocus()
|
insilmaril@769
|
92 |
{
|
insilmaril@769
|
93 |
mapEditor->setFocus();
|
insilmaril@769
|
94 |
}
|
insilmaril@769
|
95 |
|
insilmaril@726
|
96 |
QItemSelectionModel* VymView::selectionModel()
|
insilmaril@726
|
97 |
{
|
insilmaril@769
|
98 |
if (treeEditor)
|
insilmaril@728
|
99 |
return selModel;
|
insilmaril@728
|
100 |
else
|
insilmaril@769
|
101 |
std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n";
|
insilmaril@726
|
102 |
return NULL;
|
insilmaril@726
|
103 |
}
|
insilmaril@726
|
104 |
|
insilmaril@746
|
105 |
void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
|
insilmaril@727
|
106 |
{
|
insilmaril@746
|
107 |
// Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
|
insilmaril@746
|
108 |
mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly?
|
insilmaril@775
|
109 |
//showSelection();
|
insilmaril@727
|
110 |
}
|
insilmaril@727
|
111 |
|
insilmaril@763
|
112 |
void VymView::expandAll()
|
insilmaril@763
|
113 |
{
|
insilmaril@769
|
114 |
treeEditor->expandAll();
|
insilmaril@763
|
115 |
}
|
insilmaril@763
|
116 |
|
insilmaril@763
|
117 |
void VymView::showSelection()
|
insilmaril@763
|
118 |
{
|
insilmaril@772
|
119 |
QModelIndex ix=model->getSelectedIndex();
|
insilmaril@772
|
120 |
treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
|
insilmaril@772
|
121 |
mapEditor->scrollTo ( ix);
|
insilmaril@763
|
122 |
}
|
insilmaril@763
|
123 |
|