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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
/***************************************************************************
* Copyright (C) 1999 by Jonas Nordin *
* jonas.nordin@syncom.se *
* Copyright (C) 2000-2001 by Bernd Gehrmann *
* bernd@kdevelop.org *
* *
* This program 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. *
* *
***************************************************************************/
#include "classtooldlg.h"
#include <tqlistbox.h>
#include <tqpushbutton.h>
#include <tqtooltip.h>
#include <kdialog.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include "tdevlanguagesupport.h"
#include "classstore.h"
#include "parsedclass.h"
#include "classviewpart.h"
ClassToolDialog::ClassToolDialog( ClassViewPart *part )
: TQWidget(0, "class tool dialog")
{
currentOperation = ViewNone;
comboAccess = (PIAccess)-1;
currentClass = 0;
m_part = part;
class_combo = new TQComboBox(false, this);
TQPushButton *close_button = new KPushButton(KStdGuiItem::close(), this);
parents_button = new TQToolButton(this);
parents_button->setPixmap( UserIcon("CTparents", TDEIcon::DefaultState, ClassViewFactory::instance()) );
parents_button->setToggleButton(true);
parents_button->setFixedSize(parents_button->sizeHint());
TQToolTip::add(parents_button, i18n("Show parents"));
children_button = new TQToolButton(this);
children_button->setPixmap( UserIcon("CTchildren", TDEIcon::DefaultState, ClassViewFactory::instance()) );
children_button->setToggleButton(true);
children_button->setFixedSize(children_button->sizeHint());
TQToolTip::add(children_button, i18n("Show children"));
clients_button = new TQToolButton(this);
clients_button->setPixmap( UserIcon("CTclients", TDEIcon::DefaultState, ClassViewFactory::instance()) );
clients_button->setToggleButton(true);
clients_button->setFixedSize(clients_button->sizeHint());
TQToolTip::add(clients_button, i18n("Show clients"));
suppliers_button = new TQToolButton(this);
suppliers_button->setPixmap( UserIcon("CTsuppliers", TDEIcon::DefaultState, ClassViewFactory::instance()) );
suppliers_button->setToggleButton(true);
suppliers_button->setFixedSize(suppliers_button->sizeHint());
TQToolTip::add(suppliers_button, i18n("Show suppliers"));
methods_button = new TQToolButton(this);
methods_button->setPixmap( UserIcon("CVpublic_meth", TDEIcon::DefaultState, ClassViewFactory::instance()) );
methods_button->setToggleButton(true);
methods_button->setFixedSize(methods_button->sizeHint());
TQToolTip::add(methods_button, i18n("Show methods"));
attributes_button = new TQToolButton(this);
attributes_button->setPixmap( UserIcon("CVpublic_var", TDEIcon::DefaultState, ClassViewFactory::instance()) );
attributes_button->setToggleButton(true);
attributes_button->setFixedSize(attributes_button->sizeHint());
TQToolTip::add(attributes_button, i18n("Show attributes"));
access_combo = new TQComboBox(false, this, "access combo");
access_combo->setMinimumWidth(100);
access_combo->setSizeLimit(10);
access_combo->insertItem(i18n("member access","All"));
access_combo->insertItem(i18n("member access","Public"));
access_combo->insertItem(i18n("member access","Protected"));
access_combo->insertItem(i18n("member access","Private"));
access_combo->insertItem(i18n("member access","Package"));
class_tree = new ClassToolWidget(part, this);
// classTree->setMinimumSize( 500, 400 );
TQVBoxLayout *layout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
TQHBoxLayout *firstrowLayout = new TQHBoxLayout();
TQHBoxLayout *secondrowLayout = new TQHBoxLayout();
layout->addLayout(firstrowLayout);
layout->addLayout(secondrowLayout);
firstrowLayout->addWidget(class_combo, 1);
firstrowLayout->addWidget(close_button, 0);
secondrowLayout->addWidget(parents_button);
secondrowLayout->addWidget(children_button);
secondrowLayout->addWidget(clients_button);
secondrowLayout->addWidget(suppliers_button);
secondrowLayout->addStretch();
secondrowLayout->addWidget(methods_button);
secondrowLayout->addWidget(attributes_button);
secondrowLayout->addWidget(access_combo);
layout->addWidget(class_tree, 10);
connect( class_combo, TQT_SIGNAL(activated(const TQString&)),
this, TQT_SLOT(slotClassComboChoice(const TQString&)) );
connect( close_button, TQT_SIGNAL(clicked()),
this, TQT_SLOT(slotClose()) );
connect( access_combo, TQT_SIGNAL(activated(const TQString&)),
this, TQT_SLOT(slotAccessComboChoice(const TQString&)) );
connect( parents_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewParents()));
connect( children_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewChildren()));
connect( clients_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewClients()));
connect( suppliers_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewSuppliers()));
connect( methods_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewMethods()));
connect( attributes_button, TQT_SIGNAL(clicked()), TQT_SLOT(viewAttributes()));
connect( part, TQT_SIGNAL(setLanguageSupport(TDevLanguageSupport*)),
this, TQT_SLOT(setLanguageSupport(TDevLanguageSupport*)) );
m_part->registerClassToolDialog(this);
}
ClassToolDialog::~ClassToolDialog()
{
m_part->unregisterClassToolDialog(this);
}
void ClassToolDialog::setLanguageSupport(TDevLanguageSupport *ls)
{
if (ls) {
disconnect(ls, 0, this, 0);
connect(ls, TQT_SIGNAL(updatedSourceInfo()), this, TQT_SLOT(refresh()));
} else
refresh();
currentOperation = ViewNone;
}
void ClassToolDialog::setClassName(const TQString &name)
{
if ( class_combo->count() == 0 ) refresh();
TQListBox *lb = class_combo->listBox();
for (int i=0; i < (int)lb->count(); ++i)
if (lb->text(i) == name) {
class_combo->setCurrentItem(i);
break;
}
if (!name.isEmpty())
currentClass = m_part->classStore()->getClassByName(name);
else
currentClass = 0;
}
void ClassToolDialog::viewNone()
{
currentOperation = ViewNone;
refresh();
}
/** View the parents of the current class. */
void ClassToolDialog::viewParents()
{
currentOperation = ViewParents;
refresh();
}
/** View the children of the current class. */
void ClassToolDialog::viewChildren()
{
currentOperation = ViewChildren;
refresh();
}
/** View all classes that has this class as an attribute. */
void ClassToolDialog::viewClients()
{
currentOperation = ViewClients;
refresh();
}
/** View all classes that this class has as attributes. */
void ClassToolDialog::viewSuppliers()
{
currentOperation = ViewSuppliers;
refresh();
}
/** View methods in this class and parents. */
void ClassToolDialog::viewMethods()
{
currentOperation = ViewMethods;
refresh();
}
/** View attributes in this class and parents. */
void ClassToolDialog::viewAttributes()
{
currentOperation = ViewAttributes;
refresh();
}
void ClassToolDialog::slotAccessComboChoice(const TQString &str)
{
if( str == i18n("member access","All") )
comboAccess = (PIAccess)-1;
else if( str == i18n("member access","Public") )
comboAccess = PIE_PUBLIC;
else if( str == i18n("member access","Protected") )
comboAccess = PIE_PROTECTED;
else if( str == i18n("member access","Private") )
comboAccess = PIE_PRIVATE;
else if( str == i18n("member access","Package") )
comboAccess = PIE_PACKAGE;
// Update the view if the choice affected the data.
if (currentOperation == ViewMethods || currentOperation == ViewAttributes)
buildTree();
}
void ClassToolDialog::slotClose()
{
delete this;
// TQTimer::singleShot(0, this, TQT_SLOT(delayedClose()));
}
void ClassToolDialog::delayedClose()
{
delete this;
}
void ClassToolDialog::slotClassComboChoice(const TQString &str)
{
setClassName(str);
refresh();
}
void ClassToolDialog::refresh()
{
// Clear the combo box and fill it with the new items.
// Try to select the previously selected class
TQString oldName = class_combo->currentText();
class_combo->clear();
TQStringList list = m_part->classStore()->getSortedClassNameList();
class_combo->insertStringList(list);
setClassName(oldName);
// Rebuild the tree and caption/button state
buildTree();
}
/** Change the caption depending on the current operation. */
void ClassToolDialog::updateCaptionAndButtons()
{
TQString caption;
TQToolButton *button;
switch (currentOperation)
{
case ViewParents:
button = parents_button;
caption = i18n("Parents");
break;
case ViewChildren:
button = children_button;
caption = i18n("Children");
break;
case ViewClients:
button = clients_button;
caption = i18n("Clients");
break;
case ViewSuppliers:
button = suppliers_button;
caption = i18n("Suppliers");
break;
case ViewMethods:
button = methods_button;
caption = i18n("%1 Methods").arg(access_combo->currentText());
break;
case ViewAttributes:
button = attributes_button;
caption = i18n("%1 Attributes").arg(access_combo->currentText());
break;
default:
button = 0;
caption = i18n("Class Tool Dialog");
break;
}
parents_button->setOn(false);
children_button->setOn(false);
clients_button->setOn(false);
suppliers_button->setOn(false);
methods_button->setOn(false);
attributes_button->setOn(false);
if (button) {
button->setOn(true);
setCaption(i18n("%1 of Class %2").arg(caption).arg(currentClass->name()));
} else
setCaption(caption);
}
void ClassToolDialog::buildTree()
{
if (!currentClass)
currentOperation = ViewNone;
updateCaptionAndButtons();
class_tree->clear();
switch (currentOperation)
{
case ViewParents:
class_tree->insertClassAndClasses(currentClass, currentClass->parents);
break;
case ViewChildren:
{
TQValueList<ParsedClass*> list = m_part->classStore()->getClassesByParent(currentClass->name());
class_tree->insertClassAndClasses(currentClass, list);
}
break;
case ViewClients:
{
TQValueList<ParsedClass*> list = m_part->classStore()->getClassClients(currentClass->name());
class_tree->insertClassAndClasses(currentClass, list);
}
break;
case ViewSuppliers:
{
TQValueList<ParsedClass*> list = m_part->classStore()->getClassSuppliers(currentClass->name());
class_tree->insertClassAndClasses(currentClass, list);
}
break;
case ViewMethods:
class_tree->insertAllClassMethods(currentClass, comboAccess);
break;
case ViewAttributes:
class_tree->insertAllClassAttributes(currentClass, comboAccess);
break;
default:
break;
}
}
#include "classtooldlg.moc"
|