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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
/* This file is part of KCachegrind.
Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
KCachegrind 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, version 2.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/*
* Configuration Dialog for KCachegrind
*/
#include <tqcombobox.h>
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqlistview.h>
#include <tqdict.h>
#include <tqmessagebox.h>
#include <kcolorbutton.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <knumvalidator.h>
#include "configdlg.h"
#include "tracedata.h"
#include "configuration.h"
ConfigDlg::ConfigDlg(Configuration* c, TraceData* data,
TQWidget* parent, const char* name)
:ConfigDlgBase(parent, name)
{
_config = c;
_data = data;
_objectCS = 0;
_classCS = 0;
_fileCS = 0;
KIntValidator * numValidator = new KIntValidator( this );
maxListEdit->setValidator(numValidator );
symbolCount->setValidator(numValidator );
symbolLength->setValidator(numValidator );
precisionEdit->setValidator(numValidator );
contextEdit->setValidator(numValidator );
#if 0
TQListViewItem *oItem, *fItem, *cItem, *fnItem;
oItem = new(colorList, i18n("ELF Objects"));
fItem = new(colorList, i18n("Source Files"));
cItem = new(colorList, i18n("C++ Classes"));
fnItem = new(colorList, i18n("Function (no Grouping)"));
#endif
connect(objectCombo, TQT_SIGNAL(activated(const TQString &)),
this, TQT_SLOT(objectActivated(const TQString &)));
connect(objectCombo, TQT_SIGNAL(textChanged(const TQString &)),
this, TQT_SLOT(objectActivated(const TQString &)));
connect(objectCheck, TQT_SIGNAL(toggled(bool)),
this, TQT_SLOT(objectCheckChanged(bool)));
connect(objectColor, TQT_SIGNAL(changed(const TQColor &)),
this, TQT_SLOT(objectColorChanged(const TQColor &)));
connect(classCombo, TQT_SIGNAL(activated(const TQString &)),
this, TQT_SLOT(classActivated(const TQString &)));
connect(classCombo, TQT_SIGNAL(textChanged(const TQString &)),
this, TQT_SLOT(classActivated(const TQString &)));
connect(classCheck, TQT_SIGNAL(toggled(bool)),
this, TQT_SLOT(classCheckChanged(bool)));
connect(classColor, TQT_SIGNAL(changed(const TQColor &)),
this, TQT_SLOT(classColorChanged(const TQColor &)));
connect(fileCombo, TQT_SIGNAL(activated(const TQString &)),
this, TQT_SLOT(fileActivated(const TQString &)));
connect(fileCombo, TQT_SIGNAL(textChanged(const TQString &)),
this, TQT_SLOT(fileActivated(const TQString &)));
connect(fileCheck, TQT_SIGNAL(toggled(bool)),
this, TQT_SLOT(fileCheckChanged(bool)));
connect(fileColor, TQT_SIGNAL(changed(const TQColor &)),
this, TQT_SLOT(fileColorChanged(const TQColor &)));
TQString objectPrefix = TraceCost::typeName(TraceCost::Object);
TQString classPrefix = TraceCost::typeName(TraceCost::Class);
TQString filePrefix = TraceCost::typeName(TraceCost::File);
objectCombo->setDuplicatesEnabled(false);
classCombo->setDuplicatesEnabled(false);
fileCombo->setDuplicatesEnabled(false);
objectCombo->setAutoCompletion(true);
classCombo->setAutoCompletion(true);
fileCombo->setAutoCompletion(true);
// first unspecified cost items from data
TraceObjectMap::Iterator oit;
TQStringList oList;
for ( oit = data->objectMap().begin();
oit != data->objectMap().end(); ++oit )
oList.append((*oit).prettyName());
TraceClassMap::Iterator cit;
TQStringList cList;
for ( cit = data->classMap().begin();
cit != data->classMap().end(); ++cit )
cList.append((*cit).prettyName());
TraceFileMap::Iterator fit;
TQStringList fList;
for ( fit = data->fileMap().begin();
fit != data->fileMap().end(); ++fit )
fList.append((*fit).prettyName());
// then already defined colors (have to check for duplicates!)
TQDictIterator<Configuration::ColorSetting> it( c->_colors );
for( ; it.current(); ++it ) {
if ((*it)->automatic) continue;
TQString n = it.currentKey();
if (n.startsWith(objectPrefix)) {
n = n.remove(0, objectPrefix.length()+1);
if (oList.findIndex(n) == -1) oList.append(n);
}
else if (n.startsWith(classPrefix)) {
n = n.remove(0, classPrefix.length()+1);
if (cList.findIndex(n) == -1) cList.append(n);
}
else if (n.startsWith(filePrefix)) {
n = n.remove(0, filePrefix.length()+1);
if (fList.findIndex(n) == -1) fList.append(n);
}
}
oList.sort();
cList.sort();
fList.sort();
objectCombo->insertStringList(oList);
classCombo->insertStringList(cList);
fileCombo->insertStringList(fList);
objectActivated(objectCombo->currentText());
classActivated(classCombo->currentText());
fileActivated(fileCombo->currentText());
maxListEdit->setText(TQString::number(c->_maxListCount));
_dirItem = 0;
TQListViewItem* i = new TQListViewItem(dirList, i18n("(always)"));
i->setOpen(true);
TQStringList::Iterator sit = c->_generalSourceDirs.begin();
for(; sit != c->_generalSourceDirs.end(); ++sit ) {
TQString d = (*sit);
if (d.isEmpty()) d = "/";
new TQListViewItem(i, d);
}
for ( oit = data->objectMap().begin();
oit != data->objectMap().end(); ++oit ) {
TQString n = (*oit).name();
i = new TQListViewItem(dirList, n);
i->setOpen(true);
TQStringList* dirs = c->_objectSourceDirs[n];
if (!dirs) continue;
sit = dirs->begin();
for(; sit != dirs->end(); ++sit ) {
TQString d = (*sit);
if (d.isEmpty()) d = "/";
new TQListViewItem(i, d);
}
}
connect(dirList, TQT_SIGNAL(selectionChanged(TQListViewItem*)),
this, TQT_SLOT(dirsItemChanged(TQListViewItem*)));
connect(addDirButton, TQT_SIGNAL(clicked()),
this, TQT_SLOT(dirsAddPressed()));
connect(deleteDirButton, TQT_SIGNAL(clicked()),
this, TQT_SLOT(dirsDeletePressed()));
dirList->setSelected(dirList->firstChild(), true);
symbolCount->setText(TQString::number(c->_maxSymbolCount));
symbolLength->setText(TQString::number(c->_maxSymbolLength));
precisionEdit->setText(TQString::number(c->_percentPrecision));
contextEdit->setText(TQString::number(c->_context));
}
ConfigDlg::~ConfigDlg()
{
}
bool ConfigDlg::configure(Configuration* c, TraceData* d, TQWidget* p)
{
ConfigDlg dlg(c, d, p);
if (dlg.exec()) {
bool ok;
int newValue = dlg.maxListEdit->text().toUInt(&ok);
if (ok && newValue < 500)
c->_maxListCount = newValue;
else
TQMessageBox::warning(p, i18n("KCachegrind Configuration"),
i18n("The Maximum Number of List Items should be below 500."
"The previous set value (%1) will still be used.")
.arg(TQString::number(c->_maxListCount)),
TQMessageBox::Ok, 0);
c->_maxSymbolCount = dlg.symbolCount->text().toInt();
c->_maxSymbolLength = dlg.symbolLength->text().toInt();
c->_percentPrecision = dlg.precisionEdit->text().toInt();
c->_context = dlg.contextEdit->text().toInt();
return true;
}
return false;
}
void ConfigDlg::objectActivated(const TQString & s)
{
// tqDebug("objectActivated: %s", s.ascii());
if (s.isEmpty()) { _objectCS=0; return; }
TQString n = TraceCost::typeName(TraceCost::Object) + "-" + s;
Configuration* c = Configuration::config();
Configuration::ColorSetting* cs = c->_colors[n];
if (!cs)
cs = Configuration::color(n);
// else
// tqDebug("found color %s", n.ascii());
_objectCS = cs;
objectCheck->setChecked(cs->automatic);
objectColor->setColor(cs->color);
/*
tqDebug("Found Color %s, automatic to %s",
_objectCS->name.ascii(),
_objectCS->automatic ? "true":"false");
*/
}
void ConfigDlg::objectCheckChanged(bool b)
{
if (_objectCS) {
_objectCS->automatic = b;
/*
tqDebug("Set Color %s automatic to %s",
_objectCS->name.ascii(),
_objectCS->automatic ? "true":"false");
*/
}
}
void ConfigDlg::objectColorChanged(const TQColor & c)
{
if (_objectCS) _objectCS->color = c;
}
void ConfigDlg::classActivated(const TQString & s)
{
// tqDebug("classActivated: %s", s.ascii());
if (s.isEmpty()) { _classCS=0; return; }
TQString n = TraceCost::typeName(TraceCost::Class) + "-" + s;
Configuration* c = Configuration::config();
Configuration::ColorSetting* cs = c->_colors[n];
if (!cs)
cs = Configuration::color(n);
_classCS = cs;
classCheck->setChecked(cs->automatic);
classColor->setColor(cs->color);
}
void ConfigDlg::classCheckChanged(bool b)
{
if (_classCS) _classCS->automatic = b;
}
void ConfigDlg::classColorChanged(const TQColor & c)
{
if (_classCS) _classCS->color = c;
}
void ConfigDlg::fileActivated(const TQString & s)
{
// tqDebug("fileActivated: %s", s.ascii());
if (s.isEmpty()) { _fileCS=0; return; }
TQString n = TraceCost::typeName(TraceCost::File) + "-" + s;
Configuration* c = Configuration::config();
Configuration::ColorSetting* cs = c->_colors[n];
if (!cs)
cs = Configuration::color(n);
_fileCS = cs;
fileCheck->setChecked(cs->automatic);
fileColor->setColor(cs->color);
}
void ConfigDlg::fileCheckChanged(bool b)
{
if (_fileCS) _fileCS->automatic = b;
}
void ConfigDlg::fileColorChanged(const TQColor & c)
{
if (_fileCS) _fileCS->color = c;
}
void ConfigDlg::dirsItemChanged(TQListViewItem* i)
{
_dirItem = i;
deleteDirButton->setEnabled(i->depth() == 1);
addDirButton->setEnabled(i->depth() == 0);
}
void ConfigDlg::dirsDeletePressed()
{
if (!_dirItem || (_dirItem->depth() == 0)) return;
TQListViewItem* p = _dirItem->parent();
if (!p) return;
Configuration* c = Configuration::config();
TQString objName = p->text(0);
TQStringList* dirs;
if (objName == i18n("(always)"))
dirs = &(c->_generalSourceDirs);
else
dirs = c->_objectSourceDirs[objName];
if (!dirs) return;
dirs->remove(_dirItem->text(0));
delete _dirItem;
_dirItem = 0;
deleteDirButton->setEnabled(false);
}
void ConfigDlg::dirsAddPressed()
{
if (!_dirItem || (_dirItem->depth() >0)) return;
Configuration* c = Configuration::config();
TQString objName = _dirItem->text(0);
TQStringList* dirs;
if (objName == i18n("(always)"))
dirs = &(c->_generalSourceDirs);
else {
dirs = c->_objectSourceDirs[objName];
if (!dirs) {
dirs = new TQStringList;
c->_objectSourceDirs.insert(objName, dirs);
}
}
TQString newDir;
newDir = KFileDialog::getExistingDirectory(TQString(),
this,
i18n("Choose Source Folder"));
if (newDir.isEmpty()) return;
// even for "/", we strip the tailing slash
if (newDir.endsWith("/"))
newDir = newDir.left(newDir.length()-1);
if (dirs->findIndex(newDir)>=0) return;
dirs->append(newDir);
if (newDir.isEmpty()) newDir = TQString("/");
new TQListViewItem(_dirItem, newDir);
}
#include "configdlg.moc"
|