forked from werneazc/gsysc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gsysHierarchyTree.cc
166 lines (147 loc) · 5.27 KB
/
gsysHierarchyTree.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
** This file is part of gSysC.
**
** gSysC is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** gSysC is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with gSysC with the file ``LICENSE''; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gsysHierarchyTree.moc"
#include "gsysHierarchyTree.h"
#include "gsysHierarchy.h"
#include "gsysHierarchyWindow.h"
#include "gsysMain.h"
#include "gsysMainGUI.h"
/*
* constructor of this class
*/
gsysHierarchyTree::gsysHierarchyTree( QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl ) : QDialog( parent, fl )
{
windowOpen.clear();
allHierarchies.clear();
allConnections.clear();
setModal(modal);
if ( !name ) setObjectName("gsysHierarchyTree");
gsysHierarchyTreeLayout = new QVBoxLayout( this );
gsysHierarchyTreeLayout->setObjectName("gsysHierarchyTreeLayout");
gsysHierarchyTreeLayout->setSpacing(6);
gsysHierarchyTreeLayout->setMargin(11);
tree = new Q3ListView(this,"tree");
tree->setRootIsDecorated(true);
tree->addColumn(tr("Module"));
tree->addColumn(tr("Type"));
tree->addColumn(tr("Address"));
gsysHierarchyTreeLayout->addWidget( tree );
openMod = new QPushButton("openMod", this );
gsysHierarchyTreeLayout->addWidget( openMod );
languageChanged();
resize( QSize(260, 250).expandedTo(minimumSizeHint()) );
// signals and slots connections
connect( openMod, SIGNAL( clicked() ), this, SLOT( openMod_clicked() ) );
}
/*
* destructor
*/
gsysHierarchyTree::~gsysHierarchyTree()
{
this->hide();
windowOpen.clear();
allHierarchies.clear();
allConnections.clear();
// Qt components get deleted by Qt
}
/*
* method to test, whether the module that hier points to is open
*/
gsysHierarchyWindow* gsysHierarchyTree::isOpen(gsysHierarchy* hier)
{
for (int i=0; i<windowOpen.size(); i++)
{
if (hier==0)
{
if (windowOpen[i]->getOwnHier() != 0) std::cout << "i: " << i << "; OwnerHier: " << windowOpen[i]->getOwnHier()->getName() << "; Parameter: 0" << std::endl;
else std::cout << "i: " << i << "; OwnerHier: Root(NULL); Parameter: 0" << std::endl;
}
else
if (windowOpen[i]->getOwnHier() != 0) std::cout << "i: " << i << "; OwnerHier: " << windowOpen[i]->getOwnHier()->getName() << "; Parameter: " << hier->getName() << std::endl;
else std::cout << "i: " << i << "; OwnerHier: Root(NULL); Parameter: " << hier->getName() << std::endl;
if (windowOpen[i]->getOwnHier() == hier)
return windowOpen[i];
}
return 0;
}
/*
* method to open the hierarchy window of the module that 'hierarchy' points to
*/
void gsysHierarchyTree::openWindow(gsysHierarchy *hierarchy)
{
#ifdef DEBUG_GSYSC
cout<<"HierarchyTree called with parameter "<<hierarchy;
if(hierarchy!=0) cout << ", also "<<hierarchy->getName();
cout<<endl;
#endif
gsysHierarchyWindow* hierWdw = isOpen(hierarchy);
bool isRoot = (hierarchy == 0);
if (isRoot || hierarchy->getChildren().size()>0)
if (hierWdw == 0)
{
// Initialisieren und Zeichnen der Hierarchie-Ebene
hierWdw = new gsysHierarchyWindow(this);
#ifdef DEBUG_GSYSC
if (isRoot) std::cout << "Node is /: " << isRoot << "; Name of module: Root" << std::endl;
else std::cout << "Node is /: " << isRoot << "; Name of module: " << hierarchy->getName() << std::endl;
#endif
hierWdw->setCaption(isRoot?"Root":hierarchy->getName());
if (!isRoot) hierWdw->initializeWdw(hierarchy,allHierarchies,allConnections,false);
else hierWdw->initializeWdw(0,allHierarchies,allConnections,false);
// signalizing the end of creation
windowOpen.push_back(hierWdw);
hierWdw->move((new gsysMain())->getMainWindow()->width()+8,0);
hierWdw->show();
hierWdw->setFocus(); // **** won't bring the window on top (unfortunately!)
}
else
{
hierWdw->show();
hierWdw->setFocus(); // **** won't bring the window on top (unfortunately!)
}
hierWdw = 0;
}
/*
* eventHandler for button click of openModule-Button
*/
void gsysHierarchyTree::openMod_clicked()
{
Q3ListViewItem* lvi = tree->currentItem();
if (lvi != 0)
{
int addr = lvi->text(2).toInt();
openWindow((gsysHierarchy*) addr);
}
lvi = 0;
}
/*
* method to adjust the used language to the language of the environment
*/
void gsysHierarchyTree::languageChanged()
{
setCaption("HierarchyTree");
openMod->setText( tr("&Open module") );
}
/*
* method to transfer the lists of hierarchies and connections from the gsysRegister-object to this class
*/
void gsysHierarchyTree::setInfoVectors(vector<gsysHierarchy*> hier, vector<gsysConnection*> conn)
{
allHierarchies = hier;
allConnections = conn;
}