• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.14
  • kdesdk
  • kcachegrind
  • kcachegrind
toplevel.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 /*
20  * KCachegrind top level window
21  */
22 
23 #define TRACE_UPDATES 0
24 #define ENABLE_DUMPDOCK 0
25 
26 #include "toplevel.h"
27 
28 #include <stdlib.h> // for system()
29 
30 #include <QDockWidget>
31 #include <QTimer>
32 #include <QLabel>
33 #include <QLineEdit>
34 #include <QProgressBar>
35 #include <QFile>
36 #include <QEventLoop>
37 #include <QProcess>
38 #include <QtDBus/QDBusConnection>
39 
40 #include <ktoggleaction.h>
41 #include <ktoolbarpopupaction.h>
42 #include <kactioncollection.h>
43 #include <kselectaction.h>
44 #include <krecentfilesaction.h>
45 #include <ktoolbar.h>
46 #include <kstandardguiitem.h>
47 #include <klocale.h>
48 #include <kglobal.h>
49 #include <kstatusbar.h>
50 #include <kstandardshortcut.h>
51 #include <kstandardaction.h>
52 #include <kaction.h>
53 #include <kurl.h>
54 #include <kfiledialog.h>
55 #include <kio/netaccess.h>
56 #include <kedittoolbar.h>
57 #include <kshortcutsdialog.h>
58 #include <ktip.h>
59 #include <kmenu.h>
60 #include <kmessagebox.h>
61 #include <kdebug.h>
62 #include <kicon.h>
63 #include <kconfiggroup.h>
64 #include <kfilterdev.h>
65 #include <kmimetype.h>
66 
67 #if ENABLE_DUMPDOCK
68 #include "dumpselection.h"
69 #endif
70 
71 #include "partselection.h"
72 #include "functionselection.h"
73 #include "stackselection.h"
74 #include "stackbrowser.h"
75 #include "tracedata.h"
76 #include "globalguiconfig.h"
77 #include "config.h"
78 #include "configdlg.h"
79 #include "multiview.h"
80 #include "callgraphview.h"
81 
82 TopLevel::TopLevel()
83  : KXmlGuiWindow(0)
84 {
85  QDBusConnection::sessionBus().registerObject("/KCachegrind", this, QDBusConnection::ExportScriptableSlots);
86 
87  _progressBar = 0;
88  _statusbar = statusBar();
89  _statusLabel = new QLabel(_statusbar);
90  _statusbar->addWidget(_statusLabel, 1);
91  _ccProcess = 0;
92 
93  _layoutCount = 1;
94  _layoutCurrent = 0;
95 
96  resetState();
97 
98  KConfig *kconfig = KGlobal::config().data();
99  GlobalGUIConfig::config()->readOptions();
100 
101  createDocks();
102 
103  _multiView = new MultiView(this, this );
104  _multiView->setObjectName("MultiView");
105  setCentralWidget(_multiView);
106 
107  createActions();
108 
109  _partDockShown->setChecked(!_partDock->isHidden());
110  _stackDockShown->setChecked(!_stackDock->isHidden());
111  _functionDockShown->setChecked(!_functionDock->isHidden());
112 
113  connect(_partDock, SIGNAL(visibilityChanged(bool)),
114  this, SLOT(partVisibilityChanged(bool)));
115  connect(_stackDock, SIGNAL(visibilityChanged(bool)),
116  this, SLOT(stackVisibilityChanged(bool)));
117  connect(_functionDock, SIGNAL(visibilityChanged(bool)),
118  this, SLOT(functionVisibilityChanged(bool)));
119 
120 #if ENABLE_DUMPDOCK
121  _dumpDockShown->setChecked(!_dumpDock->isHidden());
122  connect(_dumpDock, SIGNAL(visibilityChanged(bool)),
123  this, SLOT(dumpVisibilityChanged(bool)));
124 #endif
125 
126 
127  // set toggle after reading configuration
128  _showPercentage = GlobalConfig::showPercentage();
129  _showExpanded = GlobalConfig::showExpanded();
130  _showCycles = GlobalConfig::showCycles();
131  _hideTemplates = GlobalConfig::hideTemplates();
132  _taPercentage->setChecked(_showPercentage);
133  _taExpanded->setChecked(_showExpanded);
134  _taCycles->setChecked(_showCycles);
135  _taHideTemplates->setChecked(_hideTemplates);
136 
137  setupPartSelection(_partSelection);
138 
139  // KCachegrind for KDE 3.0.x does not allow to hide toolbars...
140  setStandardToolBarMenuEnabled(true);
141  _openRecent->loadEntries( KConfigGroup( kconfig, "" ) );
142 
143  // QT dock windows are created before (using QT position restoring)
144  createGUI();
145 
146  setAutoSaveSettings();
147 
148  // restore current state settings (not configuration options)
149  restoreCurrentState(QString::null); //krazy:exclude=nullstrassign for old broken gcc
150 
151  // if this is the first toplevel, show tip of day
152  if (memberList().count() == 1)
153  QTimer::singleShot( 200, this, SLOT(slotShowTipOnStart()) );
154 }
155 
156 void TopLevel::resetState()
157 {
158  _activeParts.clear();
159  _hiddenParts.clear();
160 
161  _data = 0;
162  _function = 0;
163  _eventType = 0;
164  _eventType2 = 0;
165  _groupType = ProfileContext::InvalidType;
166  _group = 0;
167 
168  // for delayed slots
169  _traceItemDelayed = 0;
170  _eventTypeDelayed = 0;
171  _eventType2Delayed = 0;
172  _groupTypeDelayed = ProfileContext::InvalidType;
173  _groupDelayed = 0;
174  _directionDelayed = TraceItemView::None;
175  _lastSender = 0;
176 }
177 
178 
183 void TopLevel::setupPartSelection(PartSelection* ps)
184 {
185  // setup connections from the part selection widget
186 
187  connect(ps, SIGNAL(partsHideSelected()),
188  this, SLOT(partsHideSelectedSlotDelayed()));
189  connect(ps, SIGNAL(partsUnhideAll()),
190  this, SLOT(partsUnhideAllSlotDelayed()));
191 }
192 
200 void TopLevel::saveCurrentState(const QString& postfix)
201 {
202  QString eventType = _eventType ? _eventType->name() : QString("?");
203  QString eventType2 = _eventType2 ? _eventType2->name() : QString("?");
204 
205  ConfigGroup* stateConfig = ConfigStorage::group(QString("CurrentState") + postfix);
206  stateConfig->setValue("EventType", eventType);
207  stateConfig->setValue("EventType2", eventType2);
208  stateConfig->setValue("GroupType", ProfileContext::typeName(_groupType));
209  delete stateConfig;
210 
211  _partSelection->saveOptions(QString("PartOverview"), postfix);
212  _multiView->saveLayout(QString("MainView"), postfix);
213  _multiView->saveOptions(QString("MainView"), postfix);
214 }
215 
220 void TopLevel::saveTraceSettings()
221 {
222  QString key = traceKey();
223 
224  ConfigGroup* lConfig = ConfigStorage::group("Layouts");
225  lConfig->setValue(QString("Count%1").arg(key), _layoutCount);
226  lConfig->setValue(QString("Current%1").arg(key), _layoutCurrent);
227  delete lConfig;
228 
229  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
230  if (_eventType)
231  pConfig->setValue(QString("EventType%1").arg(key), _eventType->name());
232  if (_eventType2)
233  pConfig->setValue(QString("EventType2%1").arg(key), _eventType2->name());
234  if (_groupType != ProfileContext::InvalidType)
235  pConfig->setValue(QString("GroupType%1").arg(key),
236  ProfileContext::typeName(_groupType));
237 
238  if (_data) {
239  if (_group)
240  pConfig->setValue(QString("Group%1").arg(key), _group->name());
241  saveCurrentState(key);
242  }
243  delete pConfig;
244 }
245 
253 void TopLevel::restoreCurrentState(const QString& postfix)
254 {
255  _partSelection->restoreOptions(QString("PartOverview"), postfix);
256  _multiView->restoreLayout(QString("MainView"), postfix);
257  _multiView->restoreOptions(QString("MainView"), postfix);
258 
259  _taSplit->setChecked(_multiView->childCount()>1);
260  _taSplitDir->setEnabled(_multiView->childCount()>1);
261  _taSplitDir->setChecked(_multiView->orientation() == Qt::Horizontal);
262 }
263 
264 
265 void TopLevel::createDocks()
266 {
267  _partDock = new QDockWidget(this);
268  _partDock->setObjectName("part dock");
269  _partDock->setWindowTitle(i18n("Parts Overview"));
270  _partSelection = new PartSelection(this, _partDock);
271  _partDock->setWidget(_partSelection);
272 
273  _stackDock = new QDockWidget(this);
274  _stackDock->setObjectName("stack dock");
275  // Why is the caption only correct with a close button?
276  _stackSelection = new StackSelection(_stackDock);
277  _stackDock->setWidget(_stackSelection);
278  _stackDock->setWindowTitle(i18n("Top Cost Call Stack"));
279  _stackSelection->setWhatsThis( i18n(
280  "<b>The Top Cost Call Stack</b>"
281  "<p>This is a purely fictional 'most probable' call stack. "
282  "It is built up by starting with the current selected "
283  "function and adds the callers/callees with highest cost "
284  "at the top and to bottom.</p>"
285  "<p>The <b>Cost</b> and <b>Calls</b> columns show the "
286  "cost used for all calls from the function in the line "
287  "above.</p>"));
288 
289  connect(_stackSelection, SIGNAL(functionSelected(CostItem*)),
290  this, SLOT(setTraceItemDelayed(CostItem*)));
291 
292  _functionDock = new QDockWidget(this);
293  _functionDock->setObjectName("function dock");
294  _functionDock->setWindowTitle(i18n("Flat Profile"));
295  _functionSelection = new FunctionSelection(this, _functionDock);
296  _functionDock->setWidget(_functionSelection);
297 
298 #if ENABLE_DUMPDOCK
299  _dumpDock = new QDockWidget(this);
300  _dumpDock->setWindowTitle(i18n("Profile Dumps"));
301  _dumpSelection = new DumpSelection(this, _dumpDock,
302  "dumpSelection");
303  _dumpSelection->setTopLevel(this);
304 
305  _dumpDock->setWidget(_dumpSelection);
306  _dumpSelection->setWhatsThis( i18n(
307  "<b>Profile Dumps</b>"
308  "<p>This dockable shows in the top part the list of "
309  "loadable profile dumps in all subdirectories of: "
310  "<ul><li>current working directory of KCachegrind, "
311  "i.e. where it was started from, and </li>"
312  "<li>the default profile dump directory given in the "
313  "configuration.</li></ul> "
314  "The list is sorted according to the target command "
315  "profiled in the corresponding dump.</p>"
316  "<p>On selecting a profile dump, information for it "
317  "is shown in the bottom area of the dockable: "
318  "<ul><li><b>Options</b> allows you to view the profiled "
319  "command and profile options of this dump. By changing "
320  "any item, a new (yet unexisting) profile template "
321  "is created. Press <b>Run Profile</b> to start a "
322  "profile run with these options in the background. </li>"
323  "<li><b>Info</b> gives detailed info on the selected "
324  "dump like event cost summary and properties of the "
325  "simulated cache. </li>"
326  "<li><b>State</b> is only available for current happening "
327  "profiles runs. Press <b>Update</b> to see different "
328  "counters of the run, and a stack trace of the current "
329  "position in the program profiled. Check the <b>Every</b> "
330  "option to let KCachegrind regularly poll these data. "
331  "Check the <b>Sync</b> option to let the dockable activate "
332  "the top function in the current loaded dump.</li></ul></p>"));
333 #endif
334 
335  // default positions, will be adjusted automatically by stored state in config
336  addDockWidget(Qt::LeftDockWidgetArea, _partDock );
337  addDockWidget(Qt::LeftDockWidgetArea, _stackDock );
338  addDockWidget(Qt::LeftDockWidgetArea, _functionDock );
339  _stackDock->hide();
340  _partDock->hide();
341 
342 #if ENABLE_DUMPDOCK
343  addDockWidget( Qt::LeftDockWidgetArea, _dumpDock );
344  _dumpDock->hide();
345 #endif
346 
347  KConfigGroup dockConfig(KGlobal::config(), "Docks");
348  _forcePartDock = dockConfig.readEntry("ForcePartDockVisible", false);
349 }
350 
351 
352 TopLevel::~TopLevel()
353 {
354  delete _data;
355 }
356 
357 
358 void TopLevel::saveProperties(KConfigGroup & c)
359 {
360  if ( _data )
361  c.writeEntry("TraceName", _data->traceName());
362 }
363 
364 void TopLevel::readProperties(const KConfigGroup &c)
365 {
366  QString traceName = c.readEntry("TraceName");
367  if (!traceName.isEmpty()) {
368  openDataFile(traceName);
369  }
370 }
371 
372 void TopLevel::createLayoutActions()
373 {
374  QString hint;
375  KAction* action;
376 
377  action = actionCollection()->addAction( "layout_duplicate" );
378  action->setText( i18n( "&Duplicate" ) );
379  connect(action, SIGNAL(triggered(bool)), SLOT(layoutDuplicate()));
380  action->setShortcuts(KShortcut(Qt::CTRL+Qt::Key_Plus));
381  hint = i18n("<b>Duplicate Current Layout</b>"
382  "<p>Make a copy of the current layout.</p>");
383  action->setWhatsThis( hint );
384 
385  action = actionCollection()->addAction( "layout_remove" );
386  action->setText( i18n( "&Remove" ) );
387  connect(action, SIGNAL(triggered(bool) ), SLOT(layoutRemove()));
388  hint = i18n("<b>Remove Current Layout</b>"
389  "<p>Delete current layout and make the previous active.</p>");
390  action->setWhatsThis( hint );
391 
392  action = actionCollection()->addAction( "layout_next" );
393  action->setText( i18n( "&Go to Next" ) );
394  connect(action, SIGNAL(triggered(bool)), SLOT(layoutNext()));
395  action->setShortcuts(KShortcut(Qt::CTRL+Qt::Key_Right));
396  hint = i18n("Go to Next Layout");
397  action->setWhatsThis( hint );
398 
399  action = actionCollection()->addAction( "layout_previous" );
400  action->setText( i18n( "&Go to Previous" ) );
401  connect(action, SIGNAL(triggered(bool)), SLOT(layoutPrevious()));
402  action->setShortcuts(KShortcut(Qt::CTRL+Qt::Key_Left));
403  hint = i18n("Go to Previous Layout");
404  action->setWhatsThis( hint );
405 
406  action = actionCollection()->addAction( "layout_restore" );
407  action->setText( i18n( "&Restore to Default" ) );
408  connect(action, SIGNAL(triggered(bool) ), SLOT(layoutRestore()));
409  hint = i18n("Restore Layouts to Default");
410  action->setWhatsThis( hint );
411 
412  action = actionCollection()->addAction( "layout_save" );
413  action->setText( i18n( "&Save as Default" ) );
414  connect(action, SIGNAL(triggered(bool) ), SLOT(layoutSave()));
415  hint = i18n("Save Layouts as Default");
416  action->setWhatsThis( hint );
417 }
418 
419 // TODO: split this up...
420 void TopLevel::createMiscActions()
421 {
422  QString hint;
423  KAction* action;
424 
425  action = KStandardAction::openNew(this, SLOT(newWindow()), actionCollection());
426  hint = i18n("<b>New</b><p>Open new empty KCachegrind window.</p>");
427  action->setWhatsThis( hint );
428 
429  action = actionCollection()->addAction( "file_add" );
430  action->setText( i18n( "&Add..." ) );
431  connect(action, SIGNAL(triggered(bool) ), SLOT(add()));
432  hint = i18n("<b>Add Profile Data</b>"
433  "<p>This opens an additional profile data file in the current window.</p>");
434  action->setWhatsThis( hint );
435 
436  action = actionCollection()->addAction( "reload" );
437  action->setIcon( KIcon("view-refresh") );
438  action->setText( i18nc("Reload a document", "&Reload" ) );
439  connect(action, SIGNAL(triggered(bool) ), SLOT( reload() ));
440  action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Reload));
441  hint = i18n("<b>Reload Profile Data</b>"
442  "<p>This loads any new created parts, too.</p>");
443  action->setWhatsThis( hint );
444 
445  action = actionCollection()->addAction( "export" );
446  action->setText( i18n( "&Export Graph" ) );
447  connect(action, SIGNAL(triggered(bool) ), SLOT(exportGraph()));
448 
449  hint = i18n("<b>Export Call Graph</b>"
450  "<p>Generates a file with extension .dot for the tools "
451  "of the GraphViz package.</p>");
452  action->setWhatsThis( hint );
453 
454 
455  _taDump = actionCollection()->add<KToggleAction>( "dump" );
456  _taDump->setIcon( KIcon("edit-redo") );
457  _taDump->setText( i18n( "&Force Dump" ) );
458  connect(_taDump, SIGNAL(triggered(bool) ), SLOT( forceTrace() ));
459  _taDump->setShortcut(KStandardShortcut::shortcut(KStandardShortcut::Redo));
460  hint = i18n("<b>Force Dump</b>"
461  "<p>This forces a dump for a Callgrind profile run "
462  "in the current directory. This action is checked while "
463  "KCachegrind looks for the dump. If the dump is "
464  "finished, it automatically reloads the current trace. "
465  "If this is the one from the running Callgrind, the new "
466  "created trace part will be loaded, too.</p>"
467  "<p>Force dump creates a file 'callgrind.cmd', and "
468  "checks every second for its existence. A running "
469  "Callgrind will detect this file, dump a trace part, "
470  "and delete 'callgrind.cmd'. "
471  "The deletion is detected by KCachegrind, "
472  "and it does a Reload. If there is <em>no</em> Callgrind "
473  "running, press 'Force Dump' again to cancel the dump "
474  "request. This deletes 'callgrind.cmd' itself and "
475  "stops polling for a new dump.</p>"
476  "<p>Note: A Callgrind run <em>only</em> detects "
477  "existence of 'callgrind.cmd' when actively running "
478  "a few milliseconds, i.e. "
479  "<em>not</em> sleeping. Tip: For a profiled GUI program, "
480  "you can awake Callgrind e.g. by resizing a window "
481  "of the program.</p>");
482  _taDump->setWhatsThis( hint );
483 
484  action = KStandardAction::open(this, SLOT(load()), actionCollection());
485  hint = i18n("<b>Open Profile Data</b>"
486  "<p>This opens a profile data file, with possible multiple parts</p>");
487  action->setToolTip( hint );
488  action->setWhatsThis( hint );
489 
490  _openRecent = KStandardAction::openRecent(this, SLOT(load(const KUrl&)),
491  actionCollection());
492 
493  KStandardAction::showStatusbar(this,
494  SLOT(toggleStatusBar()), actionCollection());
495 
496  _partDockShown = actionCollection()->add<KToggleAction>("settings_show_partdock");
497  _partDockShown->setText(i18n("Parts Overview"));
498  connect(_partDockShown, SIGNAL(triggered(bool) ), SLOT(togglePartDock()));
499 
500  hint = i18n("Show/Hide the Parts Overview Dockable");
501  _partDockShown->setToolTip( hint );
502  _partDockShown->setWhatsThis( hint );
503 
504  _stackDockShown = actionCollection()->add<KToggleAction>("settings_show_stackdock");
505  _stackDockShown->setText(i18n("Call Stack"));
506  connect(_stackDockShown, SIGNAL(triggered(bool) ), SLOT(toggleStackDock()));
507 
508  hint = i18n("Show/Hide the Call Stack Dockable");
509  _stackDockShown->setToolTip( hint );
510  _stackDockShown->setWhatsThis( hint );
511 
512  _functionDockShown = actionCollection()->add<KToggleAction>("settings_show_profiledock");
513  _functionDockShown->setText(i18n("Function Profile"));
514  connect(_functionDockShown, SIGNAL(triggered(bool) ), SLOT(toggleFunctionDock()));
515 
516  hint = i18n("Show/Hide the Function Profile Dockable");
517  _functionDockShown->setToolTip( hint );
518  _functionDockShown->setWhatsThis( hint );
519 
520 #if ENABLE_DUMPDOCK
521  _dumpDockShown = actionCollection()->add<KToggleAction>("settings_show_dumpdock",
522  this, SLOT(toggleDumpDock()));
523  _dumpDockShown->setText(i18n("Profile Dumps"));
524  hint = i18n("Show/Hide the Profile Dumps Dockable");
525  _dumpDockShown->setToolTip( hint );
526  _dumpDockShown->setWhatsThis( hint );
527 #endif
528 
529  _taPercentage = actionCollection()->add<KToggleAction>("view_percentage");
530  _taPercentage->setIcon(KIcon("percent"));
531  _taPercentage->setText(i18n("Relative"));
532  connect(_taPercentage, SIGNAL(triggered(bool) ), SLOT(togglePercentage()));
533  hint = i18n("Show relative instead of absolute costs");
534  _taPercentage->setToolTip( hint );
535  _taPercentage->setWhatsThis( hint );
536 
537  _taExpanded = actionCollection()->add<KToggleAction>("view_expanded");
538  _taExpanded->setIcon(KIcon("move"));
539  _taExpanded->setText(i18n("Relative to Parent"));
540  connect(_taExpanded, SIGNAL(triggered(bool) ), SLOT(toggleExpanded()));
541 
542  hint = i18n("Show percentage costs relative to parent");
543  _taExpanded->setToolTip( hint );
544  _taExpanded->setWhatsThis( hint );
545 
546  hint = i18n("<b>Show percentage costs relative to parent</b>"
547  "<p>If this is switched off, percentage costs are always shown "
548  "relative to the total cost of the profile part(s) that are "
549  "currently browsed. By turning on this option, percentage cost "
550  "of shown cost items will be relative to the parent cost item.</p>"
551  "<ul><table>"
552  "<tr><td><b>Cost Type</b></td><td><b>Parent Cost</b></td></tr>"
553  "<tr><td>Function Cumulative</td><td>Total</td></tr>"
554  "<tr><td>Function Self</td><td>Function Group (*) / Total</td></tr>"
555  "<tr><td>Call</td><td>Function Inclusive</td></tr>"
556  "<tr><td>Source Line</td><td>Function Inclusive</td></tr>"
557  "</table></ul>"
558  "<p>(*) Only if function grouping is switched on (e.g. ELF object grouping).</p>");
559  _taExpanded->setWhatsThis( hint );
560 
561  _taCycles = actionCollection()->add<KToggleAction>("view_cycles");
562  _taCycles->setIcon(KIcon("edit-undo"));
563  _taCycles->setText(i18n( "Cycle Detection" ));
564  connect(_taCycles, SIGNAL(triggered(bool) ), SLOT( toggleCycles() ));
565 
566  hint = i18n("<b>Detect recursive cycles</b>"
567  "<p>If this is switched off, the treemap drawing will show "
568  "black areas when a recursive call is made instead of drawing the "
569  "recursion ad infinitum. Note that "
570  "the size of black areas often will be wrong, as inside recursive "
571  "cycles the cost of calls cannot be determined; the error is small, "
572  "however, for false cycles (see documentation).</p>"
573  "<p>The correct handling for cycles is to detect them and collapse all "
574  "functions of a cycle into an artificial function, which is done when this "
575  "option is selected. Unfortunately, with GUI applications, this often will "
576  "lead to huge false cycles, making the analysis impossible; therefore, there "
577  "is the option to switch this off.</p>");
578  _taCycles->setWhatsThis( hint );
579 
580  _taHideTemplates = actionCollection()->add<KToggleAction>("hide_templates");
581  _taHideTemplates->setIcon(KIcon("hidetemplates"));
582  _taHideTemplates->setText(i18n( "Shorten Templates" ));
583  connect(_taHideTemplates, SIGNAL(triggered(bool) ), SLOT( toggleHideTemplates() ));
584  _taHideTemplates->setToolTip(i18n( "Hide Template Parameters in C++ Symbols" ));
585  hint = i18n("<b>Hide Template Parameters in C++ Symbols</b>"
586  "<p>If this is switched on, every symbol displayed will have "
587  "any C++ template parameters hidden, just showing &lt;&gt; "
588  "instead of a potentially nested template parameter.</p>"
589  "<p>In this mode, you can hover the mouse pointer over the "
590  "activated symbol label to show a tooltip with the "
591  "unabbreviated symbol.</p>");
592  _taHideTemplates->setWhatsThis(hint);
593 
594  KStandardAction::quit(this, SLOT(close()), actionCollection());
595  KStandardAction::preferences(this, SLOT(configure()), actionCollection());
596  KStandardAction::keyBindings(this, SLOT(configureKeys()), actionCollection());
597  KStandardAction::configureToolbars(this,SLOT(configureToolbars()),
598  actionCollection());
599 #if 0
600  action = KStandardAction::back(_stackSelection, SLOT(browserBack()),
601  actionCollection());
602  hint = i18n("Go back in function selection history");
603  action->setToolTip( hint );
604  action->setWhatsThis( hint );
605 
606  action = KStandardAction::forward(_stackSelection, SLOT(browserForward()),
607  actionCollection());
608  hint = i18n("Go forward in function selection history");
609  action->setToolTip( hint );
610  action->setWhatsThis( hint );
611 
612  action = KStandardAction::up(_stackSelection, SLOT(browserUp()),
613  actionCollection());
614  hint = i18n("<b>Go Up</b>"
615  "<p>Go to last selected caller of current function. "
616  "If no caller was visited, use that with highest cost.</p>");
617  action->setToolTip( hint );
618  action->setWhatsThis( hint );
619 #else
620  _paUp = new KToolBarPopupAction( KIcon( "go-up" ), i18n( "&Up" ), this );
621  _paUp->setShortcuts( KShortcut(Qt::ALT+Qt::Key_Up) );
622  connect( _paUp, SIGNAL( triggered( bool ) ), _stackSelection, SLOT( browserUp() ) );
623  actionCollection()->addAction( "go_up", _paUp );
624  connect( _paUp->menu(), SIGNAL( aboutToShow() ),
625  this, SLOT( upAboutToShow() ) );
626  connect( _paUp->menu(), SIGNAL( triggered( QAction* ) ),
627  this, SLOT( upTriggered( QAction* ) ) );
628  hint = i18n("<b>Go Up</b>"
629  "<p>Go to last selected caller of current function. "
630  "If no caller was visited, use that with highest cost.</p>");
631  _paUp->setToolTip( hint );
632  _paUp->setWhatsThis( hint );
633 
634  QPair< KGuiItem, KGuiItem > backForward = KStandardGuiItem::backAndForward();
635  _paBack = new KToolBarPopupAction( backForward.first.icon(), backForward.first.text(), this );
636  _paBack->setShortcuts( KShortcut(Qt::ALT+Qt::Key_Left) );
637  connect( _paBack, SIGNAL( triggered( bool ) ), _stackSelection, SLOT( browserBack() ) );
638  actionCollection()->addAction( "go_back", _paBack );
639  connect( _paBack->menu(), SIGNAL( aboutToShow() ),
640  this, SLOT( backAboutToShow() ) );
641  connect( _paBack->menu(), SIGNAL( triggered( QAction* ) ),
642  this, SLOT( backTriggered( QAction* ) ) );
643  hint = i18n("Go back in function selection history");
644  _paBack->setToolTip( hint );
645  _paBack->setWhatsThis( hint );
646 
647  _paForward = new KToolBarPopupAction( backForward.second.icon(), backForward.second.text(), this );
648  _paForward->setShortcuts( KShortcut(Qt::ALT+Qt::Key_Right) );
649  connect( _paForward, SIGNAL( triggered( bool ) ), _stackSelection, SLOT( browserForward() ) );
650  actionCollection()->addAction( "go_forward", _paForward );
651  connect( _paForward->menu(), SIGNAL( aboutToShow() ),
652  this, SLOT( forwardAboutToShow() ) );
653  connect( _paForward->menu(), SIGNAL( triggered( QAction* ) ),
654  this, SLOT( forwardTriggered( QAction* ) ) );
655  hint = i18n("Go forward in function selection history");
656  _paForward->setToolTip( hint );
657  _paForward->setWhatsThis( hint );
658 #endif
659 
660  _saCost = actionCollection()->add<KSelectAction>("view_cost_type");
661  _saCost->setText(i18n("Primary Event Type"));
662  hint = i18n("Select primary event type of costs");
663  _saCost->setComboWidth(300);
664  _saCost->setToolTip( hint );
665  _saCost->setWhatsThis( hint );
666 
667  // This is needed because for KDE4, "_saCost->setComboWidth(300);" seems to
668  // have no effect. Instead, list box entry widths are used to determine the
669  // combobox width. However, at KCachegrind startup, we do not have yet
670  // a list of event types, as this depends on the profile data.
671  // In KDE 4.2, we used a translatable string, which did not really work as
672  // the semantic is not known to translators. Instead, we use a
673  // nontranslatable string now...
674  QStringList dummyItems;
675  dummyItems << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
676  _saCost->setItems(dummyItems);
677 
678  // cost types are dependent on loaded data, thus KSelectAction
679  // is filled in setData()
680  connect( _saCost, SIGNAL(triggered(const QString&)),
681  this, SLOT(eventTypeSelected(const QString&)));
682 
683  _saCost2 = actionCollection()->add<KSelectAction>("view_cost_type2");
684  _saCost2->setText(i18n("Secondary Event Type"));
685  hint = i18n("Select secondary event type for cost e.g. shown in annotations");
686  _saCost2->setComboWidth(300);
687  _saCost2->setToolTip( hint );
688  _saCost2->setWhatsThis( hint );
689  _saCost2->setItems(dummyItems);
690 
691  connect( _saCost2, SIGNAL(triggered(const QString&)),
692  this, SLOT(eventType2Selected(const QString&)));
693 
694  saGroup = actionCollection()->add<KSelectAction>("view_group_type");
695  saGroup->setText(i18n("Grouping"));
696 
697  hint = i18n("Select how functions are grouped into higher level cost items");
698  saGroup->setToolTip( hint );
699  saGroup->setWhatsThis( hint );
700 
701  QStringList args;
702 
703  args << i18n("(No Grouping)")
704  << ProfileContext::i18nTypeName(ProfileContext::Object)
705  << ProfileContext::i18nTypeName(ProfileContext::File)
706  << ProfileContext::i18nTypeName(ProfileContext::Class)
707  << ProfileContext::i18nTypeName(ProfileContext::FunctionCycle);
708 
709  saGroup->setItems(args);
710  connect( saGroup, SIGNAL(triggered(int)),
711  this, SLOT(groupTypeSelected(int)));
712 
713  _taSplit = actionCollection()->add<KToggleAction>("view_split");
714  _taSplit->setIcon(KIcon("view-split-left-right"));
715  _taSplit->setText(i18n("Split"));
716  connect(_taSplit, SIGNAL(triggered(bool) ), SLOT(splitSlot()));
717 
718  hint = i18n("Show two information panels");
719  _taSplit->setToolTip( hint );
720  _taSplit->setWhatsThis( hint );
721 
722  _taSplitDir = actionCollection()->add<KToggleAction>("view_split_dir");
723  _taSplitDir->setIcon(KIcon("view-split-left-right"));
724  _taSplitDir->setText(i18n("Split Horizontal"));
725  connect(_taSplitDir, SIGNAL(triggered(bool) ), SLOT(splitDirSlot()));
726 
727  hint = i18n("Change Split Orientation when main window is split.");
728  _taSplitDir->setToolTip( hint );
729  _taSplitDir->setWhatsThis( hint );
730 
731  // copied from KMail...
732  KStandardAction::tipOfDay( this, SLOT( slotShowTip() ), actionCollection() );
733 }
734 
735 void TopLevel::createActions()
736 {
737  createMiscActions();
738  createLayoutActions();
739 }
740 
741 void TopLevel::toggleStatusBar()
742 {
743  if (statusBar()->isVisible())
744  statusBar()->hide();
745  else
746  statusBar()->show();
747 }
748 
749 void TopLevel::togglePartDock()
750 {
751  if (!_partDock->isVisible())
752  _partDock->show();
753  else
754  _partDock->hide();
755 }
756 
757 void TopLevel::toggleStackDock()
758 {
759  if (!_stackDock->isVisible())
760  _stackDock->show();
761  else
762  _stackDock->hide();
763 }
764 
765 void TopLevel::toggleDumpDock()
766 {
767 #if ENABLE_DUMPDOCK
768  if (!_dumpDock->isVisible())
769  _dumpDock->show();
770  else
771  _dumpDock->hide();
772 #endif
773 }
774 
775 void TopLevel::toggleFunctionDock()
776 {
777  if (!_functionDock->isVisible())
778  _functionDock->show();
779  else
780  _functionDock->hide();
781 }
782 
783 void TopLevel::togglePercentage()
784 {
785  setPercentage(_taPercentage->isChecked());
786 }
787 
788 void TopLevel::setAbsoluteCost()
789 {
790  setPercentage(false);
791 }
792 
793 void TopLevel::setRelativeCost()
794 {
795  setPercentage(true);
796 }
797 
798 void TopLevel::updateViewsOnChange(int change)
799 {
800  _partSelection->notifyChange(change);
801  _functionSelection->notifyChange(change);
802  _multiView->notifyChange(change);
803 }
804 
805 void TopLevel::setPercentage(bool show)
806 {
807  if (_showPercentage == show) return;
808  _showPercentage = show;
809  if (_taPercentage->isChecked() != show)
810  _taPercentage->setChecked(show);
811 
812  GlobalConfig::setShowPercentage(_showPercentage);
813 
814  _stackSelection->refresh();
815 
816  updateViewsOnChange(TraceItemView::configChanged);
817 }
818 
819 void TopLevel::toggleExpanded()
820 {
821  bool show = _taExpanded->isChecked();
822  if (_showExpanded == show) return;
823  _showExpanded = show;
824 
825  GlobalConfig::setShowExpanded(_showExpanded);
826 
827  _stackSelection->refresh();
828 
829  updateViewsOnChange(TraceItemView::configChanged);
830 }
831 
832 void TopLevel::toggleCycles()
833 {
834  bool show = _taCycles->isChecked();
835  if (_showCycles == show) return;
836  _showCycles = show;
837 
838  GlobalConfig::setShowCycles(_showCycles);
839 
840  if (!_data) return;
841 
842  _data->invalidateDynamicCost();
843  _data->updateFunctionCycles();
844 
845  _stackSelection->rebuildStackList();
846 
847  updateViewsOnChange(TraceItemView::configChanged);
848 }
849 
850 void TopLevel::toggleHideTemplates()
851 {
852  bool b = _taHideTemplates->isChecked();
853  if (_hideTemplates == b) return;
854  _hideTemplates = b;
855 
856  GlobalConfig::setHideTemplates(_hideTemplates);
857 
858  _stackSelection->refresh();
859 
860  updateViewsOnChange(TraceItemView::configChanged);
861 }
862 
863 void TopLevel::partVisibilityChanged(bool v)
864 {
865  _partDockShown->setChecked(v);
866 }
867 
868 void TopLevel::stackVisibilityChanged(bool v)
869 {
870  _stackDockShown->setChecked(v);
871 }
872 
873 #if ENABLE_DUMPDOCK
874 void TopLevel::dumpVisibilityChanged(bool v)
875 #else
876 void TopLevel::dumpVisibilityChanged(bool)
877 #endif
878 {
879 #if ENABLE_DUMPDOCK
880  _dumpDockShown->setChecked(v);
881 #endif
882 }
883 
884 void TopLevel::functionVisibilityChanged(bool v)
885 {
886  _functionDockShown->setChecked(v);
887  if (v)
888  _functionSelection->updateView();
889 }
890 
891 
892 void TopLevel::querySlot()
893 {
894  _functionSelection->query(queryLineEdit->text());
895 }
896 
897 void TopLevel::configureKeys()
898 {
899  KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this);
900 }
901 
902 
903 void TopLevel::configureToolbars()
904 {
905  KEditToolBar *dlg = new KEditToolBar(guiFactory(), this);
906 
907  if (dlg->exec())
908  createGUI();
909 
910  delete dlg;
911 }
912 
913 
914 void TopLevel::newWindow()
915 {
916  TopLevel* t = new TopLevel();
917  t->show();
918 }
919 
920 
921 void TopLevel::load()
922 {
923  KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///"),
924  i18n("cachegrind.out* callgrind.out*|Callgrind Profile Data\n*|All Files"),
925  this,
926  i18n("Select Callgrind Profile Data"));
927  load(url);
928 }
929 
930 void TopLevel::load(const KUrl& url)
931 {
932  if (url.isEmpty()) return;
933 
934  // network transparency
935  QString tmpFile;
936  // for KDE 3.2: KIO::NetAccess::download with 2 args is deprecated
937  if(KIO::NetAccess::download( url, tmpFile, this )) {
938  _openRecent->addUrl(url);
939  _openRecent->saveEntries( KConfigGroup( KGlobal::config(), QString() ) );
940 
941  load(tmpFile);
942  KIO::NetAccess::removeTempFile( tmpFile );
943  } else {
944  KMessageBox::error(this, i18n("Could not open the file \"%1\". "
945  "Check it exists and you have enough "
946  "permissions to read it.", url.prettyUrl()));
947  }
948 }
949 
950 /* if file name is ".": load first file found in current directory, but do
951  * not show an error message if nothing could be loaded
952  */
953 void TopLevel::load(QString file)
954 {
955  if (file.isEmpty()) return;
956 
957  bool showError = true;
958  if (file == QString("."))
959  showError = false;
960 
961  if (_data && _data->parts().count()>0) {
962 
963  // In new window
964  TopLevel* t = new TopLevel();
965  t->show();
966  t->loadDelayed(file);
967  return;
968  }
969 
970  bool loaded = openDataFile(file);
971  if (!loaded && showError)
972  KMessageBox::error(this, i18n("Could not open the file \"%1\". "
973  "Check it exists and you have enough "
974  "permissions to read it.", file));
975 }
976 
977 
978 void TopLevel::add()
979 {
980  KUrl url = KFileDialog::getOpenUrl(KUrl(),
981  i18n("cachegrind.out* callgrind.out*|Callgrind Profile Data\n*|All Files"),
982  this,
983  i18n("Add Callgrind Profile Data"));
984  add(url);
985 }
986 
987 void TopLevel::add(const KUrl& url)
988 {
989  if (url.isEmpty()) return;
990 
991  // network transparency
992  QString tmpFile;
993  if(KIO::NetAccess::download( url, tmpFile, this )) {
994  _openRecent->addUrl(url);
995  _openRecent->saveEntries( KGlobal::config()->group( QString() ) );
996 
997  add(tmpFile);
998  KIO::NetAccess::removeTempFile( tmpFile );
999  }
1000 }
1001 
1002 void TopLevel::add(QString file)
1003 {
1004  if (file.isEmpty()) return;
1005 
1006  if (_data) {
1007  _data->load(file);
1008 
1009  // GUI update for added data
1010  configChanged();
1011  return;
1012  }
1013 
1014  openDataFile(file);
1015 }
1016 
1017 
1018 
1019 void TopLevel::loadDelayed(QString file)
1020 {
1021  _loadFilesDelayed << file;
1022  QTimer::singleShot(0, this, SLOT(loadTraceDelayed()));
1023 }
1024 
1025 void TopLevel::loadDelayed(QStringList files)
1026 {
1027  _loadFilesDelayed << files;
1028  QTimer::singleShot(0, this, SLOT(loadTraceDelayed()));
1029 }
1030 
1031 void TopLevel::loadTraceDelayed()
1032 {
1033  if (_loadFilesDelayed.isEmpty()) return;
1034 
1035  if (_loadFilesDelayed.count()>1) {
1036  // FIXME: we expect all files to be local and existing
1037  TraceData* d = new TraceData(this);
1038  d->load(_loadFilesDelayed);
1039  setData(d);
1040  }
1041  else {
1042  QString file = _loadFilesDelayed[0];
1043 
1044  // if URL scheme is missing (URL is relative), this is a local file
1045  if (KUrl::isRelativeUrl(file))
1046  load(file);
1047  else
1048  load(KUrl(file));
1049  }
1050  _loadFilesDelayed.clear();
1051 }
1052 
1053 
1054 void TopLevel::reload()
1055 {
1056  QString trace;
1057  if (!_data || _data->parts().count()==0)
1058  trace = "."; // open first trace found in dir
1059  else
1060  trace = _data->traceName();
1061 
1062  // this also keeps sure we have the same browsing position...
1063  openDataFile(trace);
1064 }
1065 
1066 void TopLevel::exportGraph()
1067 {
1068  if (!_data || !_function) return;
1069 
1070  QString n = QString("callgraph.dot");
1071  GraphExporter ge(_data, _function, _eventType, _groupType, n);
1072  ge.writeDot();
1073 
1074 #ifdef Q_OS_UNIX
1075  // shell commands only work in UNIX
1076  QString cmd = QString("(dot %1 -Tps > %2.ps; xdg-open %3.ps)&")
1077  .arg(n).arg(n).arg(n);
1078  if (::system(QFile::encodeName( cmd ))<0)
1079  qDebug() << "TopLevel::exportGraph: can not run " << cmd;
1080 #endif
1081 }
1082 
1083 
1084 bool TopLevel::setEventType(QString s)
1085 {
1086  EventType* ct;
1087 
1088  ct = (_data) ? _data->eventTypes()->type(s) : 0;
1089 
1090  // if costtype with given name not found, use first available
1091  if (!ct && _data) ct = _data->eventTypes()->type(0);
1092 
1093  return setEventType(ct);
1094 }
1095 
1096 bool TopLevel::setEventType2(QString s)
1097 {
1098  EventType* ct;
1099 
1100  // Special type i18n("(Hidden)") gives 0
1101  ct = (_data) ? _data->eventTypes()->type(s) : 0;
1102 
1103  return setEventType2(ct);
1104 }
1105 
1106 void TopLevel::eventTypeSelected(const QString& s)
1107 {
1108  EventType* ct;
1109 
1110  ct = (_data) ? _data->eventTypes()->typeForLong(s) : 0;
1111  setEventType(ct);
1112 }
1113 
1114 void TopLevel::eventType2Selected(const QString& s)
1115 {
1116  EventType* ct;
1117 
1118  ct = (_data) ? _data->eventTypes()->typeForLong(s) : 0;
1119  setEventType2(ct);
1120 }
1121 
1122 bool TopLevel::setEventType(EventType* ct)
1123 {
1124  if (_eventType == ct) return false;
1125  _eventType = ct;
1126 
1127  if (ct) {
1128  QStringList l = _saCost->items();
1129  int idx = l.indexOf(ct->longName());
1130  if (idx >= 0)
1131  _saCost->setCurrentItem(idx);
1132  }
1133 
1134  _partSelection->setEventType(_eventType);
1135  _stackSelection->setEventType(_eventType);
1136  _functionSelection->setEventType(_eventType);
1137  _multiView->setEventType(_eventType);
1138 
1139  updateStatusBar();
1140 
1141  return true;
1142 }
1143 
1144 bool TopLevel::setEventType2(EventType* ct)
1145 {
1146  if (_eventType2 == ct) return false;
1147  _eventType2 = ct;
1148 
1149  QString longName = ct ? ct->longName() : i18n("(Hidden)");
1150  QStringList l = _saCost2->items();
1151  int idx = l.indexOf(longName);
1152  if (idx >= 0)
1153  _saCost2->setCurrentItem(idx);
1154 
1155  _partSelection->setEventType2(_eventType2);
1156  _stackSelection->setEventType2(_eventType2);
1157  _functionSelection->setEventType2(_eventType2);
1158  _multiView->setEventType2(_eventType2);
1159 
1160  updateStatusBar();
1161 
1162  return true;
1163 }
1164 
1165 
1166 void TopLevel::groupTypeSelected(int cg)
1167 {
1168  switch(cg) {
1169  case 0: setGroupType( ProfileContext::Function ); break;
1170  case 1: setGroupType( ProfileContext::Object ); break;
1171  case 2: setGroupType( ProfileContext::File ); break;
1172  case 3: setGroupType( ProfileContext::Class ); break;
1173  case 4: setGroupType( ProfileContext::FunctionCycle ); break;
1174  default: break;
1175  }
1176 }
1177 
1178 bool TopLevel::setGroupType(QString s)
1179 {
1180  ProfileContext::Type gt;
1181 
1182  gt = ProfileContext::type(s);
1183  // only allow Function/Object/File/Class as grouptype
1184  switch(gt) {
1185  case ProfileContext::Object:
1186  case ProfileContext::File:
1187  case ProfileContext::Class:
1188  case ProfileContext::FunctionCycle:
1189  break;
1190  default:
1191  gt = ProfileContext::Function;
1192  }
1193 
1194  return setGroupType(gt);
1195 }
1196 
1197 bool TopLevel::setGroupType(ProfileContext::Type gt)
1198 {
1199  if (_groupType == gt) return false;
1200  _groupType = gt;
1201 
1202  int idx = -1;
1203  switch(gt) {
1204  case ProfileContext::Function: idx = 0; break;
1205  case ProfileContext::Object: idx = 1; break;
1206  case ProfileContext::File: idx = 2; break;
1207  case ProfileContext::Class: idx = 3; break;
1208  case ProfileContext::FunctionCycle: idx = 4; break;
1209  default:
1210  break;
1211  }
1212 
1213  if (idx==-1) return false;
1214 
1215  if (saGroup->currentItem() != idx)
1216  saGroup->setCurrentItem(idx);
1217 
1218  _stackSelection->setGroupType(_groupType);
1219  _partSelection->set(_groupType);
1220  _functionSelection->set(_groupType);
1221  _multiView->set(_groupType);
1222 
1223  updateStatusBar();
1224 
1225  return true;
1226 }
1227 
1228 bool TopLevel::setGroup(QString s)
1229 {
1230  TraceCostItem* ci = _functionSelection->group(s);
1231  if (!ci)
1232  return false;
1233 
1234  return setGroup(ci);
1235 }
1236 
1237 
1238 bool TopLevel::setGroup(TraceCostItem* g)
1239 {
1240  if (_group == g) return false;
1241  _group = g;
1242 
1243  _functionSelection->setGroup(g);
1244  updateStatusBar();
1245 
1246  return true;
1247 }
1248 
1249 bool TopLevel::setFunction(QString s)
1250 {
1251  if (!_data) return false;
1252 
1253  ProfileCostArray* f = _data->search(ProfileContext::Function, s, _eventType);
1254  if (!f) return false;
1255 
1256  return setFunction((TraceFunction*)f);
1257 }
1258 
1259 bool TopLevel::setFunction(TraceFunction* f)
1260 {
1261  if (_function == f) return false;
1262  _function = f;
1263 
1264  _multiView->activate(f);
1265  _functionSelection->activate(f);
1266  _partSelection->activate(f);
1267  _stackSelection->setFunction(_function);
1268 
1269  StackBrowser* b = _stackSelection->browser();
1270  if (b) {
1271  // do not disable up: a press forces stack-up extending...
1272  _paForward->setEnabled(b->canGoForward());
1273  _paBack->setEnabled(b->canGoBack());
1274  }
1275 
1276 #if TRACE_UPDATES
1277  qDebug("TopLevel::setFunction(%s), lastSender %s",
1278  f ? f->prettyName().ascii() : "0",
1279  _lastSender ? _lastSender->name() :"0" );
1280 #endif
1281 
1282  return true;
1283 }
1284 
1285 
1293 void TopLevel::setEventTypeDelayed(EventType* ct)
1294 {
1295  _eventTypeDelayed = ct;
1296  QTimer::singleShot (0, this, SLOT(setEventTypeDelayed()));
1297 }
1298 
1299 void TopLevel::setEventType2Delayed(EventType* ct)
1300 {
1301  _eventType2Delayed = ct;
1302  QTimer::singleShot (0, this, SLOT(setEventType2Delayed()));
1303 }
1304 
1305 void TopLevel::setEventTypeDelayed()
1306 {
1307  setEventType(_eventTypeDelayed);
1308 }
1309 
1310 void TopLevel::setEventType2Delayed()
1311 {
1312  setEventType2(_eventType2Delayed);
1313 }
1314 
1315 void TopLevel::setGroupTypeDelayed(ProfileContext::Type gt)
1316 {
1317  _groupTypeDelayed = gt;
1318  QTimer::singleShot (0, this, SLOT(setGroupTypeDelayed()));
1319 }
1320 
1321 void TopLevel::setGroupTypeDelayed()
1322 {
1323  setGroupType(_groupTypeDelayed);
1324 }
1325 
1326 void TopLevel::setGroupDelayed(TraceCostItem* g)
1327 {
1328 #if TRACE_UPDATES
1329  qDebug("TopLevel::setGroupDelayed(%s), sender %s",
1330  g ? g->prettyName().ascii() : "0",
1331  _lastSender ? _lastSender->name() :"0" );
1332 #endif
1333 
1334  _groupDelayed = g;
1335  QTimer::singleShot (0, this, SLOT(setGroupDelayed()));
1336 }
1337 
1338 void TopLevel::setGroupDelayed()
1339 {
1340  setGroup(_groupDelayed);
1341 }
1342 
1343 void TopLevel::setDirectionDelayed(TraceItemView::Direction d)
1344 {
1345  _directionDelayed = d;
1346  QTimer::singleShot (0, this, SLOT(setDirectionDelayed()));
1347 }
1348 
1349 void TopLevel::setDirectionDelayed()
1350 {
1351  switch(_directionDelayed) {
1352  case TraceItemView::Back:
1353  _stackSelection->browserBack();
1354  break;
1355 
1356  case TraceItemView::Forward:
1357  _stackSelection->browserForward();
1358  break;
1359 
1360  case TraceItemView::Up:
1361  {
1362  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1363  HistoryItem* hi = b ? b->current() : 0;
1364  TraceFunction* f = hi ? hi->function() : 0;
1365 
1366  if (!f) break;
1367  f = hi->stack()->caller(f, false);
1368  if (f) setFunction(f);
1369  }
1370  break;
1371 
1372  default: break;
1373  }
1374 
1375  _directionDelayed = TraceItemView::None;
1376 }
1377 
1378 
1379 void TopLevel::setTraceItemDelayed(CostItem* i)
1380 {
1381  // no need to select same item a 2nd time...
1382  if (_traceItemDelayed == i) return;
1383  _traceItemDelayed = i;
1384  _lastSender = sender();
1385 
1386  kDebug() << "Selected " << (i ? i->prettyName() : "(none)");
1387 
1388 #if TRACE_UPDATES
1389  qDebug("TopLevel::setTraceItemDelayed(%s), sender %s",
1390  i ? i->prettyName().ascii() : "0",
1391  _lastSender ? _lastSender->name() :"0" );
1392 #endif
1393 
1394  QTimer::singleShot (0, this, SLOT(setTraceItemDelayed()));
1395 }
1396 
1397 void TopLevel::setTraceItemDelayed()
1398 {
1399  if (!_traceItemDelayed) return;
1400 
1401  switch(_traceItemDelayed->type()) {
1402  case ProfileContext::Function:
1403  case ProfileContext::FunctionCycle:
1404  setFunction((TraceFunction*)_traceItemDelayed);
1405  break;
1406 
1407  case ProfileContext::Object:
1408  case ProfileContext::File:
1409  case ProfileContext::Class:
1410  _multiView->activate(_traceItemDelayed);
1411  break;
1412 
1413 #if 0
1414  // this conflicts with the selection policy of InstrView ?!?
1415  case ProfileContext::Instr:
1416  case ProfileContext::Line:
1417  // only for multiview
1418  _multiView->activate(_traceItemDelayed);
1419  break;
1420 #endif
1421 
1422  default: break;
1423  }
1424 
1425  _traceItemDelayed = 0;
1426  _lastSender = 0;
1427 }
1428 
1435 void TopLevel::setData(TraceData* data)
1436 {
1437  if (data == _data) return;
1438 
1439  _lastSender = 0;
1440 
1441  saveTraceSettings();
1442 
1443  if (_data) {
1444  _partSelection->setData(0);
1445  _stackSelection->setData(0);
1446  _functionSelection->setData(0);
1447  _multiView->setData(0);
1448  _multiView->updateView(true);
1449 
1450  // we are the owner...
1451  delete _data;
1452  }
1453 
1454  // reset members
1455  resetState();
1456 
1457  _data = data;
1458 
1459  // fill cost type list
1460  QStringList types;
1461 
1462  if (_data) {
1463  /* add all supported virtual types */
1464  EventTypeSet* m = _data->eventTypes();
1465  m->addKnownDerivedTypes();
1466 
1467  /* first, fill selection list with available cost types */
1468  for (int i=0;i<m->realCount();i++)
1469  types << m->realType(i)->longName();
1470  for (int i=0;i<m->derivedCount();i++)
1471  types << m->derivedType(i)->longName();
1472  }
1473  _saCost->setItems(types);
1474  _saCost->setComboWidth(300);
1475 
1476  if (types.count()>0) {
1477  // second type list gets an additional "(Hidden)"
1478  types.prepend(i18n("(Hidden)"));
1479  }
1480  _saCost2->setItems(types);
1481  _saCost2->setComboWidth(300);
1482  // default is hidden
1483  if (types.count()>0)
1484  _saCost2->setCurrentItem(0);
1485 
1486  _partSelection->setData(_data);
1487  _stackSelection->setData(_data);
1488  _functionSelection->setData(_data);
1489  _multiView->setData(_data);
1490  // Force update of _data in all children of _multiView
1491  // This is needed to make restoring of activeItem work!
1492  _multiView->updateView(true);
1493 
1494  /* this is needed to let the other widgets know the types */
1495  restoreTraceTypes();
1496 
1497  restoreTraceSettings();
1498 
1499  QString caption;
1500  if (_data) {
1501  caption = _data->traceName();
1502  if (!_data->command().isEmpty())
1503  caption += " [" + _data->command() + ']';
1504  }
1505  setWindowTitle(caption);
1506 
1507  if (!_data || (!_forcePartDock && _data->parts().count()<2)) {
1508  _partDock->hide();
1509  _partDockShown->setChecked(false);
1510  }
1511  else {
1512  _partDock->show();
1513  _partDockShown->setChecked(true);
1514  }
1515 
1516  updateStatusBar();
1517 }
1518 
1519 void TopLevel::addEventTypeMenu(QMenu* popup, bool withCost2)
1520 {
1521  if (_data) {
1522  QMenu *popup1, *popup2 = 0;
1523  QAction* action;
1524 
1525  popup1 = popup->addMenu(i18n("Primary Event Type"));
1526  connect(popup1, SIGNAL(triggered(QAction*)),
1527  this, SLOT(setEventType(QAction*)));
1528 
1529  if (withCost2) {
1530  popup2 = popup->addMenu(i18n("Secondary Event Type"));
1531  connect(popup2, SIGNAL(triggered(QAction*)),
1532  this, SLOT(setEventType2(QAction*)));
1533 
1534  if (_eventType2) {
1535  action = popup2->addAction(i18n("Hide"));
1536  action->setData(199);
1537  popup2->addSeparator();
1538  }
1539  }
1540 
1541  EventTypeSet* m = _data->eventTypes();
1542  EventType* ct;
1543  for (int i=0;i<m->realCount();i++) {
1544  ct = m->realType(i);
1545 
1546  action = popup1->addAction(ct->longName());
1547  action->setCheckable(true);
1548  action->setData(100+i);
1549  if (_eventType == ct) action->setChecked(true);
1550 
1551  if (popup2) {
1552  action = popup2->addAction(ct->longName());
1553  action->setCheckable(true);
1554  action->setData(100+i);
1555  if (_eventType2 == ct) action->setChecked(true);
1556  }
1557  }
1558 
1559  for (int i=0;i<m->derivedCount();i++) {
1560  ct = m->derivedType(i);
1561 
1562  action = popup1->addAction(ct->longName());
1563  action->setCheckable(true);
1564  action->setData(200+i);
1565  if (_eventType == ct) action->setChecked(true);
1566 
1567  if (popup2) {
1568  action = popup2->addAction(ct->longName());
1569  action->setCheckable(true);
1570  action->setData(200+i);
1571  if (_eventType2 == ct) action->setChecked(true);
1572  }
1573  }
1574  }
1575 
1576  if (_showPercentage)
1577  popup->addAction(i18n("Show Absolute Cost"),
1578  this, SLOT(setAbsoluteCost()));
1579  else
1580  popup->addAction(i18n("Show Relative Cost"),
1581  this, SLOT(setRelativeCost()));
1582 }
1583 
1584 bool TopLevel::setEventType(QAction* action)
1585 {
1586  if (!_data) return false;
1587  int id = action->data().toInt(0);
1588 
1589  EventTypeSet* m = _data->eventTypes();
1590  EventType* ct=0;
1591  if (id >=100 && id<199) ct = m->realType(id-100);
1592  if (id >=200 && id<299) ct = m->derivedType(id-200);
1593 
1594  return ct ? setEventType(ct) : false;
1595 }
1596 
1597 bool TopLevel::setEventType2(QAction* action)
1598 {
1599  if (!_data) return false;
1600  int id = action->data().toInt(0);
1601 
1602  EventTypeSet* m = _data->eventTypes();
1603  EventType* ct=0;
1604  if (id >=100 && id<199) ct = m->realType(id-100);
1605  if (id >=200 && id<299) ct = m->derivedType(id-200);
1606 
1607  return setEventType2(ct);
1608 }
1609 
1610 void TopLevel::addGoMenu(QMenu* popup)
1611 {
1612  popup->addAction(i18n("Go Back"), this, SLOT(goBack()));
1613  popup->addAction(i18n("Go Forward"), this, SLOT(goForward()));
1614  popup->addAction(i18n("Go Up"), this, SLOT(goUp()));
1615 }
1616 
1617 void TopLevel::goBack()
1618 {
1619  setDirectionDelayed(TraceItemView::Back);
1620 }
1621 
1622 void TopLevel::goForward()
1623 {
1624  setDirectionDelayed(TraceItemView::Forward);
1625 }
1626 
1627 void TopLevel::goUp()
1628 {
1629  setDirectionDelayed(TraceItemView::Up);
1630 }
1631 
1632 QString TopLevel::traceKey()
1633 {
1634  if (!_data || _data->command().isEmpty()) return QString();
1635 
1636  QString name = _data->command();
1637  QString key;
1638  for (int l=0;l<name.length();l++)
1639  if (name[l].isLetterOrNumber()) key += name[l];
1640 
1641  return QString("-") + key;
1642 }
1643 
1644 
1645 void TopLevel::restoreTraceTypes()
1646 {
1647  QString key = traceKey();
1648  QString groupType, eventType, eventType2;
1649 
1650  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
1651  groupType = pConfig->value(QString("GroupType%1").arg(key),QString()).toString();
1652  eventType = pConfig->value(QString("EventType%1").arg(key),QString()).toString();
1653  eventType2 = pConfig->value(QString("EventType2%1").arg(key),QString()).toString();
1654  delete pConfig;
1655 
1656  ConfigGroup* cConfig = ConfigStorage::group("CurrentState");
1657  if (groupType.isEmpty())
1658  groupType = cConfig->value("GroupType",QString()).toString();
1659  if (eventType.isEmpty())
1660  eventType = cConfig->value("EventType",QString()).toString();
1661  if (eventType2.isEmpty())
1662  eventType2 = cConfig->value("EventType2",QString()).toString();
1663  delete cConfig;
1664 
1665  setGroupType(groupType);
1666  setEventType(eventType);
1667  setEventType2(eventType2);
1668 
1669  // if still no cost type set, use first available
1670  if (!_eventType && !_saCost->items().isEmpty())
1671  eventTypeSelected(_saCost->items().first());
1672 
1673  ConfigGroup* aConfig = ConfigStorage::group("Layouts");
1674  _layoutCount = aConfig->value(QString("Count%1").arg(key), 0).toInt();
1675  _layoutCurrent = aConfig->value(QString("Current%1").arg(key), 0).toInt();
1676  delete aConfig;
1677 
1678  if (_layoutCount == 0) layoutRestore();
1679  updateLayoutActions();
1680 }
1681 
1682 
1688 void TopLevel::restoreTraceSettings()
1689 {
1690  if (!_data) return;
1691 
1692  QString key = traceKey();
1693 
1694  restoreCurrentState(key);
1695 
1696  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
1697  QString group = pConfig->value(QString("Group%1").arg(key),QString()).toString();
1698  delete pConfig;
1699  if (!group.isEmpty()) setGroup(group);
1700 
1701 
1702  // restoreCurrentState() usually leads to a call to setTraceItemDelayed()
1703  // to restore last active item...
1704  if (!_traceItemDelayed) {
1705  // function not available any more.. try with "main"
1706  if (!setFunction("main"))
1707  _functionSelection->selectTopFunction();
1708  }
1709 }
1710 
1711 
1712 /* Layout */
1713 
1714 void TopLevel::layoutDuplicate()
1715 {
1716  // save current and allocate a new slot
1717  _multiView->saveLayout(QString("Layout%1-MainView").arg(_layoutCurrent),
1718  traceKey());
1719  _layoutCurrent = _layoutCount;
1720  _layoutCount++;
1721 
1722  updateLayoutActions();
1723 
1724  if (0) kDebug() << "TopLevel::layoutDuplicate: count " << _layoutCount;
1725 }
1726 
1727 void TopLevel::layoutRemove()
1728 {
1729  if (_layoutCount <2) return;
1730 
1731  int from = _layoutCount-1;
1732  if (_layoutCurrent == from) { _layoutCurrent--; from--; }
1733 
1734  // restore from last and decrement count
1735  _multiView->restoreLayout(QString("Layout%1-MainView").arg(from),
1736  traceKey());
1737  _layoutCount--;
1738 
1739  updateLayoutActions();
1740 }
1741 
1742 void TopLevel::layoutNext()
1743 {
1744  if (_layoutCount <2) return;
1745 
1746  QString key = traceKey();
1747  QString layoutPrefix = QString("Layout%1-MainView");
1748 
1749  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1750  _layoutCurrent++;
1751  if (_layoutCurrent == _layoutCount) _layoutCurrent = 0;
1752  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1753 
1754  if (0) kDebug() << "TopLevel::layoutNext: current "
1755  << _layoutCurrent << endl;
1756 }
1757 
1758 void TopLevel::layoutPrevious()
1759 {
1760  if (_layoutCount <2) return;
1761 
1762  QString key = traceKey();
1763  QString layoutPrefix = QString("Layout%1-MainView");
1764 
1765  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1766  _layoutCurrent--;
1767  if (_layoutCurrent <0) _layoutCurrent = _layoutCount-1;
1768  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1769 
1770  if (0) kDebug() << "TopLevel::layoutPrevious: current "
1771  << _layoutCurrent << endl;
1772 }
1773 
1774 void TopLevel::layoutSave()
1775 {
1776  QString key = traceKey();
1777  QString layoutPrefix = QString("Layout%1-MainView");
1778 
1779  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1780 
1781  // save all layouts as defaults (ie. without any group name postfix)
1782  for(int i=0;i<_layoutCount;i++) {
1783  _multiView->restoreLayout(layoutPrefix.arg(i), key);
1784  _multiView->saveLayout(layoutPrefix.arg(i), QString());
1785  }
1786  // restore the previously saved current layout
1787  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1788 
1789  ConfigGroup* layoutConfig = ConfigStorage::group("Layouts");
1790  layoutConfig->setValue("DefaultCount", _layoutCount);
1791  layoutConfig->setValue("DefaultCurrent", _layoutCurrent);
1792  delete layoutConfig;
1793 }
1794 
1795 void TopLevel::layoutRestore()
1796 {
1797  KConfig *config = KGlobal::config().data();
1798  KConfigGroup aConfig(config, "Layouts");
1799  _layoutCount = aConfig.readEntry("DefaultCount", 0);
1800  _layoutCurrent = aConfig.readEntry("DefaultCurrent", 0);
1801  if (_layoutCount == 0) {
1802  _layoutCount++;
1803  return;
1804  }
1805 
1806  QString layoutPrefix = QString("Layout%1-MainView");
1807  _multiView->restoreLayout( layoutPrefix.arg(_layoutCurrent), traceKey());
1808 
1809  updateLayoutActions();
1810 }
1811 
1812 
1813 void TopLevel::updateLayoutActions()
1814 {
1815  QAction* ka;
1816 
1817  ka = actionCollection()->action("layout_next");
1818  if (ka) ka->setEnabled(_layoutCount>1);
1819 
1820  ka = actionCollection()->action("layout_previous");
1821  if (ka) ka->setEnabled(_layoutCount>1);
1822 
1823  ka = actionCollection()->action("layout_remove");
1824  if (ka) ka->setEnabled(_layoutCount>1);
1825 
1826  _statusbar->showMessage(i18n("Layout Count: %1", _layoutCount), 1000);
1827 }
1828 
1829 
1830 void TopLevel::updateStatusBar()
1831 {
1832  if (!_data || _data->parts().count()==0) {
1833  _statusLabel->setText(i18n("No profile data file loaded."));
1834  return;
1835  }
1836 
1837  QString status = QString("%1 [%2] - ")
1838  .arg(_data->shortTraceName())
1839  .arg(_data->activePartRange());
1840 
1841  if (_eventType) {
1842  status += i18n("Total %1 Cost: %2",
1843  _eventType->longName(),
1844  _data->prettySubCost(_eventType));
1845 
1846  /* this gets too long...
1847  if (_eventType2 && (_eventType2 != _eventType))
1848  status += i18n(", %1 Cost: %2")
1849  .arg(_eventType2->longName())
1850  .arg(_data->prettySubCost(_eventType2));
1851  */
1852  }
1853  else
1854  status += i18n("No event type selected");
1855 
1856  /* Not working... should give group of selected function
1857 
1858  if (_groupType != ProfileContext::Function) {
1859  status += QString(" - %1 '%2'")
1860  .arg(ProfileContext::i18nTypeName(_groupType))
1861  .arg(_group ? _group->prettyName() : i18n("(None)"));
1862  }
1863  */
1864 
1865  _statusLabel->setText(status);
1866 }
1867 
1868 void TopLevel::configure()
1869 {
1870  if (ConfigDlg::configure( GlobalGUIConfig::config(),
1871  _data, this)) {
1872  GlobalGUIConfig::config()->saveOptions();
1873 
1874  configChanged();
1875  }
1876  else
1877  GlobalGUIConfig::config()->readOptions();
1878 }
1879 
1880 bool TopLevel::queryClose()
1881 {
1882  saveTraceSettings();
1883 
1884  // save current toplevel options as defaults...
1885  GlobalConfig::setShowPercentage(_showPercentage);
1886  GlobalConfig::setShowExpanded(_showExpanded);
1887  GlobalConfig::setShowCycles(_showCycles);
1888  GlobalConfig::setHideTemplates(_hideTemplates);
1889  GlobalGUIConfig::config()->saveOptions();
1890 
1891  saveCurrentState(QString());
1892 
1893  // toolbar and dock positions are automatically stored
1894 
1895  // if part dock was chosen visible even for only 1 part loaded,
1896  // keep this choice...
1897  _forcePartDock = false;
1898  if (_data && (_data->parts().count()<2) && _partDock->isVisible())
1899  _forcePartDock=true;
1900  KConfigGroup dockConfig(KGlobal::config(), "Docks");
1901  dockConfig.writeEntry("ForcePartDockVisible", _forcePartDock);
1902 
1903  return true;
1904 }
1905 
1906 
1907 void TopLevel::splitSlot()
1908 {
1909  int count = _multiView->childCount();
1910  if (count<1) count = 1;
1911  if (count>2) count = 2;
1912  count = 3-count;
1913  _multiView->setChildCount(count);
1914 
1915  _taSplit->setChecked(count>1);
1916  _taSplitDir->setEnabled(count>1);
1917  _taSplitDir->setChecked(_multiView->orientation() == Qt::Horizontal);
1918 }
1919 
1920 void TopLevel::splitDirSlot()
1921 {
1922  _multiView->setOrientation( _taSplitDir->isChecked() ?
1923  Qt::Horizontal : Qt::Vertical );
1924 }
1925 
1926 
1927 
1928 // this is called after a config change in the dialog
1929 void TopLevel::configChanged()
1930 {
1931  // Invalidate found/cached dirs of source files if we have TraceData loaded.
1932  if (_data) {
1933  _data->resetSourceDirs();
1934  }
1935 
1936  _stackSelection->refresh();
1937 
1938  updateViewsOnChange(TraceItemView::configChanged);
1939 }
1940 
1941 void TopLevel::slotShowTipOnStart() {
1942  KTipDialog::showTip(this);
1943 }
1944 
1945 void TopLevel::slotShowTip() {
1946  KTipDialog::showTip( this, QString(), true );
1947 }
1948 
1949 void TopLevel::dummySlot()
1950 {
1951 }
1952 
1953 void TopLevel::activePartsChangedSlot(const TracePartList& list)
1954 {
1955  if (!_data) return;
1956 
1957  if (!_data->activateParts(list)) {
1958 // qDebug("TopLevel::activePartsChangedSlot: No Change!");
1959  return;
1960  }
1961  _activeParts = list;
1962 
1963  _partSelection->set(list);
1964  _multiView->set(list);
1965  _functionSelection->set(list);
1966  _stackSelection->refresh();
1967 
1968  updateStatusBar();
1969 }
1970 
1971 void TopLevel::partsHideSelectedSlotDelayed()
1972 {
1973  QTimer::singleShot( 0, this, SLOT(partsHideSelectedSlot()) );
1974 }
1975 
1976 // this puts selected parts into hidden list,
1977 // deselects them and makes the remaining parts selected
1978 void TopLevel::partsHideSelectedSlot()
1979 {
1980  if (!_data) return;
1981 
1982  TracePartList newHidden, newActive;
1983  foreach(TracePart* part, _data->parts()) {
1984  if (_activeParts.contains(part) ||
1985  _hiddenParts.contains(part))
1986  newHidden.append(part);
1987  else
1988  newActive.append(part);
1989  }
1990 
1991  _hiddenParts = newHidden;
1992  _partSelection->hiddenPartsChangedSlot(_hiddenParts);
1993 
1994 #if 0
1995  _mainWidget1->hiddenPartsChangedSlot(_hiddenParts);
1996  _mainWidget2->hiddenPartsChangedSlot(_hiddenParts);
1997 #endif
1998 
1999  activePartsChangedSlot(newActive);
2000 }
2001 
2002 void TopLevel::partsUnhideAllSlotDelayed()
2003 {
2004  QTimer::singleShot( 0, this, SLOT(partsUnhideAllSlot()) );
2005 }
2006 
2007 // this unhides all hidden parts. Does NOT change selection
2008 void TopLevel::partsUnhideAllSlot()
2009 {
2010  if (!_data) return;
2011 
2012  _hiddenParts.clear();
2013  _partSelection->hiddenPartsChangedSlot(_hiddenParts);
2014 #if 0
2015  _mainWidget1->hiddenPartsChangedSlot(_hiddenParts);
2016  _mainWidget2->hiddenPartsChangedSlot(_hiddenParts);
2017 #endif
2018 }
2019 
2020 void TopLevel::forceTrace()
2021 {
2022  if (_ccProcess) {
2023  // callgrind_control still running, cancel request
2024  qDebug("TopLevel::forceTrace: killing old callgrind_control");
2025  _ccProcess->kill();
2026  delete _ccProcess;
2027  _ccProcess = 0;
2028  _ccOutput = QString();
2029  }
2030  if (!_taDump->isChecked()) return;
2031 
2032  // get PID of first loaded part
2033  int pid = 0;
2034  TracePart* p = 0;
2035  TracePartList pl;
2036  if (_data) pl = _data->parts();
2037  if (!pl.isEmpty()) p = pl.first();
2038  if (p) pid = p->processID();
2039  if (pid == 0) {
2040  showMessage(i18n("Cannot determine receiver PID for dump request"),
2041  5000);
2042  _taDump->setChecked(false);
2043  return;
2044  }
2045 
2046  qDebug("TopLevel::forceTrace: run 'callgrind_control -d %d'", pid);
2047 
2048  _ccProcess = new QProcess(this);
2049  connect(_ccProcess, SIGNAL(readyReadStandardOutput()),
2050  SLOT(ccReadOutput()));
2051  connect(_ccProcess, SIGNAL(error(QProcess::ProcessError)),
2052  SLOT(ccError(QProcess::ProcessError)));
2053  connect(_ccProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
2054  SLOT(ccExit(int,QProcess::ExitStatus)));
2055  _ccProcess->start(QString("callgrind_control -d %1").arg(pid),
2056  QIODevice::ReadOnly);
2057 }
2058 
2059 void TopLevel::ccReadOutput()
2060 {
2061  QProcess* p = qobject_cast<QProcess*>(sender());
2062  qDebug("TopLevel::ccReadOutput: QProcess %p", p);
2063 
2064  // signal from old/uninteresting process?
2065  if (!_ccProcess) return;
2066  if (p != _ccProcess) return;
2067 
2068  _ccOutput.append(_ccProcess->readAllStandardOutput());
2069 }
2070 
2071 void TopLevel::ccError(QProcess::ProcessError e)
2072 {
2073  QProcess* p = qobject_cast<QProcess*>(sender());
2074  qDebug("TopLevel::ccError: Got %d from QProcess %p",
2075  e, p);
2076 
2077  // signal from old/uninteresting process?
2078  if (!_ccProcess) return;
2079  if (p != _ccProcess) return;
2080 
2081  showMessage(i18n("Error running callgrind_control"), 5000);
2082 
2083  _ccProcess->deleteLater();
2084  _ccProcess = 0;
2085 }
2086 
2087 void TopLevel::ccExit(int exitCode, QProcess::ExitStatus s)
2088 {
2089  QProcess* p = qobject_cast<QProcess*>(sender());
2090  qDebug("TopLevel::ccExit: QProcess %p, exitCode %d",
2091  p, exitCode);
2092 
2093  // signal from old/uninteresting process?
2094  if (!_ccProcess) return;
2095  if (p != _ccProcess) return;
2096  _ccProcess->deleteLater();
2097  _ccProcess = 0;
2098  _taDump->setChecked(false);
2099 
2100  // if not successful no need to reload
2101  if ((s == QProcess::CrashExit) || (exitCode != 0))
2102  return;
2103 
2104  // FIXME: Are we sure that file is completely
2105  // dumped after waiting one second?
2106  QTimer::singleShot( 1000, this, SLOT(reload()) );
2107 }
2108 
2109 void TopLevel::forwardAboutToShow()
2110 {
2111  QMenu *popup = _paForward->menu();
2112 
2113  popup->clear();
2114  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2115  HistoryItem* hi = b ? b->current() : 0;
2116  TraceFunction* f;
2117  QAction* action;
2118 
2119  if (!hi) {
2120  popup->addAction(i18n("(No Stack)"));
2121  return;
2122  }
2123 
2124  hi = hi->next();
2125  if (!hi) {
2126  popup->addAction(i18n("(No next function)"));
2127  return;
2128  }
2129 
2130  int count = 1;
2131  while (count<GlobalConfig::maxSymbolCount() && hi) {
2132  f = hi->function();
2133  if (!f) break;
2134 
2135  QString name = GlobalConfig::shortenSymbol(f->prettyName());
2136 
2137  //qDebug("forward: Adding %s", name.ascii());
2138  action = popup->addAction(name);
2139  action->setData(count);
2140 
2141  hi = hi->next();
2142  count++;
2143  }
2144 }
2145 
2146 void TopLevel::backAboutToShow()
2147 {
2148  QMenu *popup = _paBack->menu();
2149 
2150  popup->clear();
2151  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2152  HistoryItem* hi = b ? b->current() : 0;
2153  TraceFunction* f;
2154  QAction* action;
2155 
2156  if (!hi) {
2157  popup->addAction(i18n("(No Stack)"));
2158  return;
2159  }
2160 
2161  hi = hi->last();
2162  if (!hi) {
2163  popup->addAction(i18n("(No previous function)"));
2164  return;
2165  }
2166 
2167  int count = 1;
2168  while (count<GlobalConfig::maxSymbolCount() && hi) {
2169  f = hi->function();
2170  if (!f) break;
2171 
2172  QString name = GlobalConfig::shortenSymbol(f->prettyName());
2173 
2174  //qDebug("back: Adding %s", name.ascii());
2175  action = popup->addAction(name);
2176  action->setData(count);
2177 
2178  hi = hi->last();
2179  count++;
2180  }
2181 }
2182 
2183 void TopLevel::upAboutToShow()
2184 {
2185  QMenu *popup = _paUp->menu();
2186 
2187  popup->clear();
2188  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2189  HistoryItem* hi = b ? b->current() : 0;
2190  TraceFunction* f = hi ? hi->function() : 0;
2191  QAction* action;
2192 
2193  if (!f) {
2194  popup->addAction(i18n("(No Stack)"));
2195  return;
2196  }
2197  f = hi->stack()->caller(f, false);
2198  if (!f) {
2199  popup->addAction(i18n("(No Function Up)"));
2200  return;
2201  }
2202 
2203  int count = 1;
2204  while (count<GlobalConfig::maxSymbolCount() && f) {
2205  QString name = GlobalConfig::shortenSymbol(f->prettyName());
2206 
2207  action = popup->addAction(name);
2208  action->setData(count);
2209 
2210  f = hi->stack()->caller(f, false);
2211  count++;
2212  }
2213 
2214 }
2215 
2216 void TopLevel::forwardTriggered(QAction* action)
2217 {
2218  int count = action->data().toInt(0);
2219  //qDebug("forwardTriggered: %d", count);
2220  if( count <= 0)
2221  return;
2222 
2223  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2224  if (!b) return;
2225 
2226  while (count>1) {
2227  b->goForward();
2228  count--;
2229  }
2230  _stackSelection->browserForward();
2231 }
2232 
2233 void TopLevel::backTriggered(QAction* action)
2234 {
2235  int count = action->data().toInt(0);
2236  //qDebug("backTriggered: %d", count);
2237  if( count <= 0)
2238  return;
2239 
2240  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2241  if (!b) return;
2242 
2243  while (count>1) {
2244  b->goBack();
2245  count--;
2246  }
2247  _stackSelection->browserBack();
2248 }
2249 
2250 void TopLevel::upTriggered(QAction* action)
2251 {
2252  int count = action->data().toInt(0);
2253  //qDebug("upTriggered: %d", count);
2254  if( count <= 0)
2255  return;
2256 
2257  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
2258  HistoryItem* hi = b ? b->current() : 0;
2259  if (!hi) return;
2260 
2261  TraceFunction* f = hi->function();
2262 
2263  while (count>0 && f) {
2264  f = hi->stack()->caller(f, false);
2265  count--;
2266  }
2267 
2268  //qDebug("upActivated: %s", f ? f->prettyName().ascii() : "??" );
2269  if (f)
2270  setFunction(f);
2271 }
2272 
2273 void TopLevel::showMessage(const QString& msg, int ms)
2274 {
2275  if (_statusbar)
2276  _statusbar->showMessage(msg, ms);
2277 }
2278 
2279 void TopLevel::showStatus(const QString& msg, int progress)
2280 {
2281  static bool msgUpdateNeeded = true;
2282 
2283  if (!_statusbar) return;
2284 
2285  if (msg.isEmpty()) {
2286  //reset status
2287  if (_progressBar) {
2288  _statusbar->removeWidget(_progressBar);
2289  delete _progressBar;
2290  _progressBar = 0;
2291  }
2292  _statusbar->clearMessage();
2293  _progressMsg = msg;
2294  return;
2295  }
2296 
2297  if (_progressMsg.isEmpty())
2298  _progressStart.start();
2299 
2300  if (msg != _progressMsg) {
2301  _progressMsg = msg;
2302  msgUpdateNeeded = true;
2303  }
2304 
2305  // do nothing if last change was less than 0.5 seconds ago
2306  if (_progressStart.elapsed() < 500)
2307  return;
2308 
2309  if (!_progressBar) {
2310  _progressBar = new QProgressBar(_statusbar);
2311  _progressBar->setMaximumSize(200, _statusbar->height()-4);
2312  _statusbar->addPermanentWidget(_progressBar, 1);
2313  _progressBar->show();
2314  msgUpdateNeeded = true;
2315  }
2316 
2317  _progressStart.restart();
2318 
2319  if (msgUpdateNeeded) {
2320  _statusbar->showMessage(msg);
2321  msgUpdateNeeded = false;
2322  }
2323  _progressBar->setValue(progress);
2324 
2325  // let the progress bar update itself
2326  qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
2327 }
2328 
2329 void TopLevel::loadStart(const QString& filename)
2330 {
2331  showStatus(i18n("Loading %1").arg(filename), 0);
2332  Logger::_filename = filename;
2333 }
2334 
2335 void TopLevel::loadFinished(const QString& msg)
2336 {
2337  showStatus(QString(), 0);
2338  if (!msg.isEmpty())
2339  showMessage(i18n("Error loading %1: %2").arg(_filename).arg(msg),
2340  2000);
2341 }
2342 
2343 void TopLevel::loadProgress(int progress)
2344 {
2345  showStatus(i18n("Loading %1").arg(_filename), progress);
2346 }
2347 
2348 void TopLevel::loadError(int line, const QString& msg)
2349 {
2350  kError() << "Loading" << _filename << ":" << line << ": " << msg;
2351 }
2352 
2353 void TopLevel::loadWarning(int line, const QString& msg)
2354 {
2355  kWarning() << "Loading" << _filename << ":" << line << ": " << msg;
2356 }
2357 
2358 bool TopLevel::openDataFile(const QString& file)
2359 {
2360  TraceData* d = new TraceData(this);
2361  int filesLoaded;
2362 
2363  // see whether this file is compressed, than take the direct route
2364  QString mimeType = KMimeType::findByFileContent(file)->name ();
2365  QIODevice* compressed = KFilterDev::deviceForFile (file, mimeType, true);
2366  if (compressed) {
2367  filesLoaded = d->load(compressed, file);
2368  } else {
2369  // else fallback to string based method that can also find multi-part callgrind data.
2370  filesLoaded = d->load(file);
2371  }
2372  if (filesLoaded > 0) {
2373  setData(d);
2374  return true;
2375  } else {
2376  return false;
2377  }
2378 }
2379 
2380 
2381 #include "toplevel.moc"
QIODevice
StackSelection::browser
StackBrowser * browser() const
Definition: stackselection.h:48
StackSelection::setEventType2
void setEventType2(EventType *)
Definition: stackselection.cpp:246
TopLevel::configureKeys
void configureKeys()
Definition: toplevel.cpp:897
TopLevel::setDirectionDelayed
void setDirectionDelayed()
Definition: toplevel.cpp:1349
TopLevel::saveProperties
virtual void saveProperties(KConfigGroup &)
Definition: toplevel.cpp:358
QProgressBar
QList::clear
void clear()
ProfileContext::type
ProfileContext::Type type()
Definition: context.h:55
EventTypeSet::realCount
int realCount()
Definition: eventtype.h:133
GlobalConfig::setShowPercentage
static void setShowPercentage(bool)
Definition: globalconfig.cpp:348
HistoryItem::function
TraceFunction * function()
Definition: stackbrowser.h:71
TopLevel::~TopLevel
~TopLevel()
Definition: toplevel.cpp:352
TopLevel::exportGraph
void exportGraph()
Definition: toplevel.cpp:1066
GlobalConfig::showPercentage
static bool showPercentage()
Definition: globalconfig.cpp:328
QString::append
QString & append(QChar ch)
TopLevel::eventType2
EventType * eventType2()
Definition: toplevel.h:77
TopLevel::setRelativeCost
void setRelativeCost()
Definition: toplevel.cpp:793
TopLevel::backAboutToShow
void backAboutToShow()
Definition: toplevel.cpp:2146
PartSelection
Definition: partselection.h:38
QString::ascii
const char * ascii() const
QProcess::kill
void kill()
QWidget::isHidden
bool isHidden() const
TracePart::processID
int processID() const
Definition: tracedata.h:674
TopLevel::load
void load()
Definition: toplevel.cpp:921
ProfileContext::Line
Definition: context.h:39
TopLevel::toggleHideTemplates
void toggleHideTemplates()
Definition: toplevel.cpp:850
ProfileContext::FunctionCycle
Definition: context.h:46
TopLevel::goUp
void goUp()
Definition: toplevel.cpp:1627
MultiView::saveLayout
void saveLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:202
StackSelection::rebuildStackList
void rebuildStackList()
Definition: stackselection.cpp:109
TraceItemView::set
void set(ProfileContext::Type g)
Definition: traceitemview.h:115
StackBrowser::goBack
HistoryItem * goBack()
Definition: stackbrowser.cpp:339
TopLevel::setEventType2Delayed
void setEventType2Delayed()
Definition: toplevel.cpp:1310
TraceItemView::setEventType2
void setEventType2(EventType *t)
Definition: traceitemview.h:114
QDockWidget
QLineEdit::text
text
ProfileContext::File
Definition: context.h:48
ProfileContext::typeName
static QString typeName(Type)
Definition: context.cpp:62
TopLevel::toggleFunctionDock
void toggleFunctionDock()
Definition: toplevel.cpp:775
TraceData::search
ProfileCostArray * search(ProfileContext::Type, QString, EventType *ct=0, ProfileCostArray *parent=0)
Search for item with given name and highest subcost of given cost type.
Definition: tracedata.cpp:3522
QAction::setChecked
void setChecked(bool)
TopLevel::goForward
void goForward()
Definition: toplevel.cpp:1622
stackbrowser.h
CostItem::type
ProfileContext::Type type() const
Definition: costitem.h:45
QAction::data
QVariant data() const
TopLevel::add
void add()
Definition: toplevel.cpp:978
StackSelection::setFunction
void setFunction(TraceFunction *)
Definition: stackselection.cpp:92
TraceData::command
QString command() const
Definition: tracedata.h:1448
dumpselection.h
TopLevel::setGroupDelayed
void setGroupDelayed()
Definition: toplevel.cpp:1338
TraceItemView::configChanged
Definition: traceitemview.h:88
StackBrowser
Definition: stackbrowser.h:85
TopLevel::queryClose
bool queryClose()
Definition: toplevel.cpp:1880
ProfileCostArray::prettySubCost
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
Definition: costitem.cpp:601
TopLevel::forwardTriggered
void forwardTriggered(QAction *)
Definition: toplevel.cpp:2216
TraceItemView::setEventType
void setEventType(EventType *t)
Definition: traceitemview.h:113
TopLevel::slotShowTipOnStart
void slotShowTipOnStart()
Definition: toplevel.cpp:1941
TraceFunction
A traced function.
Definition: tracedata.h:1122
TraceCostItem
Definition: tracedata.h:980
QMenu::addAction
void addAction(QAction *action)
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
TopLevel::loadError
virtual void loadError(int line, const QString &msg)
Definition: toplevel.cpp:2348
QWidget::isVisible
bool isVisible() const
ConfigGroup::setValue
virtual void setValue(const QString &key, const QVariant &value, const QVariant &defaultValue=QVariant())
Definition: config.cpp:57
FunctionSelection::selectTopFunction
bool selectTopFunction()
Definition: functionselection.cpp:846
functionselection.h
TopLevel::ccReadOutput
void ccReadOutput()
Definition: toplevel.cpp:2059
GraphExporter
GraphExporter.
Definition: callgraphview.h:298
CostItem
Base class for cost items.
Definition: costitem.h:37
TopLevel::setEventType2
bool setEventType2(EventType *)
Definition: toplevel.cpp:1144
FunctionSelection::setGroup
void setGroup(TraceCostItem *)
Definition: functionselection.cpp:548
config.h
QDBusConnection::sessionBus
QDBusConnection sessionBus()
TopLevel::activePartsChangedSlot
void activePartsChangedSlot(const TracePartList &list)
Definition: toplevel.cpp:1953
TopLevel::partVisibilityChanged
void partVisibilityChanged(bool)
Definition: toplevel.cpp:863
TraceItemView::updateView
void updateView(bool force=false)
Definition: traceitemview.cpp:189
ProfileContext::Instr
Definition: context.h:38
TopLevel::showMessage
void showMessage(const QString &, int msec)
Definition: toplevel.cpp:2273
TraceItemView::Back
Definition: traceitemview.h:90
EventTypeSet::addKnownDerivedTypes
int addKnownDerivedTypes()
Adds all known derived event types that can be parsed.
Definition: eventtype.cpp:536
EventTypeSet::type
EventType * type(int)
Definition: eventtype.cpp:475
TraceData::eventTypes
EventTypeSet * eventTypes()
Definition: tracedata.h:1407
TraceData::activePartRange
QString activePartRange()
Definition: tracedata.cpp:3280
TopLevel::querySlot
void querySlot()
Definition: toplevel.cpp:892
FunctionSelection::group
TraceCostItem * group()
Definition: functionselection.h:53
Stack::caller
TraceFunction * caller(TraceFunction *, bool extend)
Definition: stackbrowser.cpp:134
TopLevel::toggleStatusBar
void toggleStatusBar()
Definition: toplevel.cpp:741
QProgressBar::setValue
void setValue(int value)
StackBrowser::goForward
HistoryItem * goForward()
Definition: stackbrowser.cpp:347
stackselection.h
TopLevel::loadProgress
virtual void loadProgress(int progress)
Definition: toplevel.cpp:2343
TopLevel::dummySlot
void dummySlot()
Definition: toplevel.cpp:1949
TopLevel
Definition: toplevel.h:58
TopLevel::backTriggered
void backTriggered(QAction *)
Definition: toplevel.cpp:2233
EventType
A cost type, e.g.
Definition: eventtype.h:43
ProfileContext::Class
Definition: context.h:47
TraceData::activateParts
bool activateParts(const TracePartList &)
returns true if something changed.
Definition: tracedata.cpp:3213
StackSelection::setData
void setData(TraceData *)
Definition: stackselection.cpp:79
PartSelection::hiddenPartsChangedSlot
void hiddenPartsChangedSlot(const TracePartList &list)
Definition: partselection.cpp:478
StackSelection::browserBack
void browserBack()
Definition: stackselection.cpp:177
TopLevel::stackVisibilityChanged
void stackVisibilityChanged(bool)
Definition: toplevel.cpp:868
TopLevel::functionVisibilityChanged
void functionVisibilityChanged(bool)
Definition: toplevel.cpp:884
DumpSelection
Definition: dumpselection.h:34
EventTypeSet::typeForLong
EventType * typeForLong(const QString &)
Definition: eventtype.cpp:500
ConfigStorage::group
static ConfigGroup * group(const QString &group, const QString &optSuffix=QString())
Definition: config.cpp:80
QSplitter::orientation
orientation
TopLevel::data
TraceData * data()
Definition: toplevel.h:66
PartSelection::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: partselection.cpp:483
TopLevel::configure
void configure()
Definition: toplevel.cpp:1868
TraceData::parts
TracePartList parts() const
Definition: tracedata.h:1397
TopLevel::loadWarning
virtual void loadWarning(int line, const QString &msg)
Definition: toplevel.cpp:2353
QMenu::clear
void clear()
QObject::name
const char * name() const
TopLevel::newWindow
void newWindow()
Definition: toplevel.cpp:914
TopLevel::upTriggered
void upTriggered(QAction *)
Definition: toplevel.cpp:2250
QTime::elapsed
int elapsed() const
tracedata.h
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
QList::count
int count(const T &value) const
GlobalConfig::setShowCycles
static void setShowCycles(bool)
Definition: globalconfig.cpp:364
MultiView::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:224
TopLevel::setFunction
bool setFunction(TraceFunction *)
Definition: toplevel.cpp:1259
TopLevel::setTraceItemDelayed
void setTraceItemDelayed()
Definition: toplevel.cpp:1397
QList::append
void append(const T &value)
MultiView
Definition: multiview.h:36
StackSelection::refresh
void refresh()
Definition: stackselection.cpp:209
KXmlGuiWindow
QVariant::toInt
int toInt(bool *ok) const
TopLevel::togglePartDock
void togglePartDock()
Definition: toplevel.cpp:749
MultiView::setData
void setData(TraceData *)
Definition: multiview.cpp:49
TopLevel::addEventTypeMenu
void addEventTypeMenu(QMenu *, bool)
Definition: toplevel.cpp:1519
TraceData::updateFunctionCycles
void updateFunctionCycles()
Definition: tracedata.cpp:3675
QProcess
StackBrowser::canGoBack
bool canGoBack()
Definition: stackbrowser.cpp:377
StackSelection
Definition: stackselection.h:38
TopLevel::setGroupTypeDelayed
void setGroupTypeDelayed()
Definition: toplevel.cpp:1321
TraceData::load
int load(QStringList files)
Loads profile data files.
Definition: tracedata.cpp:3130
TopLevel::configChanged
void configChanged()
Definition: toplevel.cpp:1929
ProfileContext::i18nTypeName
static QString i18nTypeName(Type)
Definition: context.cpp:118
StackSelection::browserForward
void browserForward()
Definition: stackselection.cpp:185
QList::isEmpty
bool isEmpty() const
QObject::setObjectName
void setObjectName(const QString &name)
TopLevel::updateLayoutActions
void updateLayoutActions()
Definition: toplevel.cpp:1813
TopLevel::partsUnhideAllSlotDelayed
void partsUnhideAllSlotDelayed()
Definition: toplevel.cpp:2002
QString::isEmpty
bool isEmpty() const
GlobalConfig::showCycles
static bool showCycles()
Definition: globalconfig.cpp:338
TopLevel::eventTypeSelected
void eventTypeSelected(const QString &)
Definition: toplevel.cpp:1106
HistoryItem::stack
Stack * stack()
Definition: stackbrowser.h:70
TraceItemView::None
Definition: traceitemview.h:90
GlobalGUIConfig::readOptions
void readOptions()
Definition: globalguiconfig.cpp:125
TraceCostItem::name
virtual QString name() const
Returns dynamic name info (without type)
Definition: tracedata.h:986
TraceItemView::Up
Definition: traceitemview.h:90
TraceFunction::prettyName
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
Definition: tracedata.cpp:1889
QTime::restart
int restart()
TopLevel::layoutDuplicate
void layoutDuplicate()
Definition: toplevel.cpp:1714
StackSelection::setEventType
void setEventType(EventType *)
Definition: stackselection.cpp:235
QObject::deleteLater
void deleteLater()
QList::first
T & first()
QLabel::setText
void setText(const QString &)
TraceItemView::activate
bool activate(CostItem *i)
Definition: traceitemview.cpp:111
QMenu::addSeparator
QAction * addSeparator()
EventTypeSet::derivedCount
int derivedCount()
Definition: eventtype.h:134
TopLevel::updateStatusBar
void updateStatusBar()
Definition: toplevel.cpp:1830
QString
QList< TracePart * >
QWidget::hide
void hide()
TopLevel::addGoMenu
void addGoMenu(QMenu *)
Definition: toplevel.cpp:1610
TopLevel::togglePercentage
void togglePercentage()
Definition: toplevel.cpp:783
FunctionSelection
Definition: functionselection.h:46
globalguiconfig.h
TopLevel::toggleCycles
void toggleCycles()
Definition: toplevel.cpp:832
GlobalConfig::shortenSymbol
static QString shortenSymbol(const QString &)
Definition: globalconfig.cpp:395
ConfigGroup
A group of configuration settings.
Definition: config.h:35
FunctionSelection::query
void query(QString)
Definition: functionselection.cpp:777
TraceItemView::notifyChange
void notifyChange(int changeType)
Definition: traceitemview.h:120
Logger::_filename
QString _filename
Definition: logger.h:45
QStringList
TopLevel::toggleDumpDock
void toggleDumpDock()
Definition: toplevel.cpp:765
TopLevel::createDocks
void createDocks()
Definition: toplevel.cpp:265
TopLevel::layoutRemove
void layoutRemove()
Definition: toplevel.cpp:1727
QPair
HistoryItem::next
HistoryItem * next()
Definition: stackbrowser.h:73
TopLevel::partsHideSelectedSlotDelayed
void partsHideSelectedSlotDelayed()
Definition: toplevel.cpp:1971
GlobalGUIConfig::config
static GlobalGUIConfig * config()
Definition: globalguiconfig.cpp:88
QAction::setData
void setData(const QVariant &userData)
TraceItemView::Forward
Definition: traceitemview.h:90
QMenu
PartSelection::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: partselection.cpp:525
TopLevel::setAbsoluteCost
void setAbsoluteCost()
Definition: toplevel.cpp:788
TopLevel::splitSlot
void splitSlot()
Definition: toplevel.cpp:1907
TopLevel::forwardAboutToShow
void forwardAboutToShow()
Definition: toplevel.cpp:2109
TopLevel::layoutNext
void layoutNext()
Definition: toplevel.cpp:1742
TopLevel::partsHideSelectedSlot
void partsHideSelectedSlot()
Definition: toplevel.cpp:1978
TopLevel::showStatus
void showStatus(const QString &msg, int progress)
Definition: toplevel.cpp:2279
FunctionSelection::setData
void setData(TraceData *)
Definition: functionselection.cpp:232
QList::contains
bool contains(const T &value) const
QAction::setCheckable
void setCheckable(bool)
toplevel.h
QWidget::setMaximumSize
void setMaximumSize(const QSize &)
QDockWidget::setWidget
void setWidget(QWidget *widget)
TopLevel::goBack
void goBack()
Definition: toplevel.cpp:1617
TopLevel::groupTypeSelected
void groupTypeSelected(int)
Definition: toplevel.cpp:1166
TopLevel::ccError
void ccError(QProcess::ProcessError)
Definition: toplevel.cpp:2071
EventTypeSet::realType
EventType * realType(int)
Definition: eventtype.cpp:462
TopLevel::slotShowTip
void slotShowTip()
Definition: toplevel.cpp:1945
HistoryItem::last
HistoryItem * last()
Definition: stackbrowser.h:72
TopLevel::layoutPrevious
void layoutPrevious()
Definition: toplevel.cpp:1758
TracePart
A Trace Part: All data read from a trace file, containing all costs that happened in a specified time...
Definition: tracedata.h:655
QWidget::setWhatsThis
void setWhatsThis(const QString &)
GraphExporter::writeDot
void writeDot(QIODevice *=0)
Definition: callgraphview.cpp:661
GlobalConfig::setHideTemplates
static void setHideTemplates(bool)
Definition: globalconfig.cpp:372
GlobalConfig::showExpanded
static bool showExpanded()
Definition: globalconfig.cpp:333
TopLevel::createActions
void createActions()
Definition: toplevel.cpp:735
TopLevel::partsUnhideAllSlot
void partsUnhideAllSlot()
Definition: toplevel.cpp:2008
TraceData::shortTraceName
QString shortTraceName() const
Definition: tracedata.cpp:3093
TraceItemView::Direction
Direction
Definition: traceitemview.h:90
ProfileContext::Type
Type
Definition: context.h:36
MultiView::restoreLayout
void restoreLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:169
GlobalConfig::hideTemplates
static bool hideTemplates()
Definition: globalconfig.cpp:343
QMenu::addMenu
QAction * addMenu(QMenu *menu)
QWidget::setWindowTitle
void setWindowTitle(const QString &)
QAction
GlobalGUIConfig::saveOptions
void saveOptions()
Definition: globalguiconfig.cpp:105
TopLevel::layoutSave
void layoutSave()
Definition: toplevel.cpp:1774
TraceData::resetSourceDirs
void resetSourceDirs()
Definition: tracedata.cpp:3498
TopLevel::eventType
EventType * eventType()
Definition: toplevel.h:76
TopLevel::eventType2Selected
void eventType2Selected(const QString &)
Definition: toplevel.cpp:1114
TopLevel::loadFinished
virtual void loadFinished(const QString &msg)
Definition: toplevel.cpp:2335
TopLevel::ccExit
void ccExit(int, QProcess::ExitStatus)
Definition: toplevel.cpp:2087
TopLevel::groupType
ProfileContext::Type groupType()
Definition: toplevel.h:75
QString::length
int length() const
EventType::longName
const QString & longName()
Definition: eventtype.h:66
TopLevel::configureToolbars
void configureToolbars()
Definition: toplevel.cpp:903
TopLevel::toggleExpanded
void toggleExpanded()
Definition: toplevel.cpp:819
EventTypeSet
A class for managing a set of event types.
Definition: eventtype.h:117
TraceItemView::setTopLevel
void setTopLevel(TopLevelBase *t)
Definition: traceitemview.h:160
TopLevel::upAboutToShow
void upAboutToShow()
Definition: toplevel.cpp:2183
TopLevel::reload
void reload()
Definition: toplevel.cpp:1054
QTime::start
void start()
QStringList::indexOf
int indexOf(const QRegExp &rx, int from) const
QList::prepend
void prepend(const T &value)
TopLevel::loadDelayed
void loadDelayed(QString)
Definition: toplevel.cpp:1019
TopLevel::setEventTypeDelayed
void setEventTypeDelayed()
Definition: toplevel.cpp:1305
ConfigDlg::configure
static bool configure(GlobalGUIConfig *, TraceData *, QWidget *)
Definition: configdlg.cpp:189
TopLevel::setEventType
bool setEventType(EventType *)
Definition: toplevel.cpp:1122
QWidget::show
void show()
MultiView::setChildCount
void setChildCount(int)
Definition: multiview.cpp:57
TopLevel::loadTraceDelayed
void loadTraceDelayed()
Definition: toplevel.cpp:1031
HistoryItem
Definition: stackbrowser.h:64
configdlg.h
TopLevel::setPercentage
void setPercentage(bool)
Definition: toplevel.cpp:805
TopLevel::setData
void setData(TraceData *)
A TraceData object cannot be viewed many times in different toplevel windows.
Definition: toplevel.cpp:1435
ProfileContext::Object
Definition: context.h:49
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
StackSelection::setGroupType
void setGroupType(ProfileContext::Type)
Definition: stackselection.cpp:257
multiview.h
StackBrowser::current
HistoryItem * current()
Definition: stackbrowser.h:94
CostItem::prettyName
virtual QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
Definition: costitem.cpp:65
EventTypeSet::derivedType
EventType * derivedType(int)
Definition: eventtype.cpp:468
TopLevel::layoutRestore
void layoutRestore()
Definition: toplevel.cpp:1795
TopLevel::setGroupType
bool setGroupType(ProfileContext::Type)
Definition: toplevel.cpp:1197
TopLevel::toggleStackDock
void toggleStackDock()
Definition: toplevel.cpp:757
MultiView::childCount
int childCount()
Definition: multiview.h:50
QLabel
callgraphview.h
GlobalConfig::setShowExpanded
static void setShowExpanded(bool)
Definition: globalconfig.cpp:356
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QVariant::toString
QString toString() const
TopLevel::forceTrace
void forceTrace()
Definition: toplevel.cpp:2020
MultiView::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:231
QProcess::readAllStandardOutput
QByteArray readAllStandardOutput()
TopLevel::setGroup
bool setGroup(TraceCostItem *)
Definition: toplevel.cpp:1238
StackBrowser::canGoForward
bool canGoForward()
Definition: stackbrowser.cpp:382
QProcess::start
void start(const QString &program, const QStringList &arguments, QFlags< QIODevice::OpenModeFlag > mode)
GlobalConfig::maxSymbolCount
static int maxSymbolCount()
Definition: globalconfig.cpp:407
QAction::setEnabled
void setEnabled(bool)
TraceData::traceName
QString traceName() const
Definition: tracedata.h:1401
partselection.h
TopLevel::splitDirSlot
void splitDirSlot()
Definition: toplevel.cpp:1920
QFile::encodeName
QByteArray encodeName(const QString &fileName)
TopLevel::TopLevel
TopLevel()
Definition: toplevel.cpp:82
EventType::name
const QString & name()
Definition: eventtype.h:65
ProfileContext::Function
Definition: context.h:46
TopLevel::readProperties
virtual void readProperties(const KConfigGroup &)
Definition: toplevel.cpp:364
PartSelection::setData
void setData(TraceData *)
Definition: partselection.cpp:130
ProfileContext::InvalidType
Definition: context.h:37
TopLevel::dumpVisibilityChanged
void dumpVisibilityChanged(bool)
Definition: toplevel.cpp:876
ConfigGroup::value
virtual QVariant value(const QString &key, const QVariant &defaultValue) const
Definition: config.cpp:60
QTimer::singleShot
singleShot
TraceData::invalidateDynamicCost
void invalidateDynamicCost()
Definition: tracedata.cpp:3306
TopLevel::loadStart
virtual void loadStart(const QString &filename)
Definition: toplevel.cpp:2329
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal