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

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • qcachegrind
qcgtoplevel.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002 - 2009 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  * QCachegrind top level window
21  */
22 
23 #define TRACE_UPDATES 0
24 
25 #include "qcgtoplevel.h"
26 
27 #include <stdlib.h> // for system()
28 
29 #include <QApplication>
30 #include <QDebug>
31 #include <QDockWidget>
32 #include <QTimer>
33 #include <QByteArray>
34 #include <QLabel>
35 #include <QMenuBar>
36 #include <QProgressBar>
37 #include <QFile>
38 #include <QFileDialog>
39 #include <QEventLoop>
40 #include <QToolBar>
41 #include <QComboBox>
42 #include <QMessageBox>
43 #include <QStatusBar>
44 #include <QWhatsThis>
45 
46 #ifdef QT_DBUS_SUPPORT
47 #include <QtDBus/QDBusConnection>
48 #endif
49 
50 #include "partselection.h"
51 #include "functionselection.h"
52 #include "stackselection.h"
53 #include "stackbrowser.h"
54 #include "tracedata.h"
55 #include "config.h"
56 #include "globalguiconfig.h"
57 #include "multiview.h"
58 #include "callgraphview.h"
59 #include "configdialog.h"
60 
61 QCGTopLevel::QCGTopLevel()
62 {
63 #ifdef QT_DBUS_SUPPORT
64  QDBusConnection con = QDBusConnection::sessionBus();
65  con.registerObject("/QCachegrind", this,
66  QDBusConnection::ExportScriptableSlots);
67 #endif
68 
69  _progressBar = 0;
70  _statusbar = statusBar();
71  _statusLabel = new QLabel(_statusbar);
72  _statusbar->addWidget(_statusLabel, 1);
73 
74  _layoutCount = 1;
75  _layoutCurrent = 0;
76 
77  resetState();
78 
79  GlobalGUIConfig::config()->readOptions();
80 
81  createActions();
82  createDocks();
83  createMenu();
84  createToolbar();
85 
86  _multiView = new MultiView(this, this);
87  _multiView->setObjectName("MultiView");
88  setCentralWidget(_multiView);
89 
90  // restore current state settings (not configuration options)
91  restoreCurrentState(QString::null);
92 
93  // restore docks & toolbars from config
94  QByteArray state, geometry;
95  ConfigGroup* topConfig = ConfigStorage::group("TopWindow");
96  _forcePartDock = topConfig->value("ForcePartDockVisible", false).toBool();
97  state = topConfig->value("State", QByteArray()).toByteArray();
98  geometry = topConfig->value("Geometry", QByteArray()).toByteArray();
99  delete topConfig;
100 
101  if (!geometry.isEmpty())
102  restoreGeometry(geometry);
103  if (!state.isEmpty())
104  restoreState(state);
105 
106  setWindowIcon(QIcon(":/app.png"));
107  setAttribute(Qt::WA_DeleteOnClose);
108 }
109 
110 QCGTopLevel::~QCGTopLevel()
111 {
112  delete _data;
113 }
114 
115 // reset the visualization state, e.g. before loading new data
116 void QCGTopLevel::resetState()
117 {
118  _activeParts.clear();
119  _hiddenParts.clear();
120 
121  _data = 0;
122  _function = 0;
123  _eventType = 0;
124  _eventType2 = 0;
125  _groupType = ProfileContext::InvalidType;
126  _group = 0;
127 
128  // for delayed slots
129  _traceItemDelayed = 0;
130  _eventTypeDelayed = 0;
131  _eventType2Delayed = 0;
132  _groupTypeDelayed = ProfileContext::InvalidType;
133  _groupDelayed = 0;
134  _directionDelayed = TraceItemView::None;
135  _lastSender = 0;
136 }
137 
138 
146 void QCGTopLevel::saveCurrentState(const QString& postfix)
147 {
148  QString eventType, eventType2;
149  if (_eventType) eventType = _eventType->name();
150  if (_eventType2) eventType2 = _eventType2->name();
151 
152  ConfigGroup* stateConfig = ConfigStorage::group(QString("CurrentState") + postfix);
153  stateConfig->setValue("EventType", eventType);
154  stateConfig->setValue("EventType2", eventType2);
155  stateConfig->setValue("GroupType", ProfileContext::typeName(_groupType));
156  delete stateConfig;
157 
158  _partSelection->saveOptions(QString("PartOverview"), postfix);
159  _multiView->saveLayout(QString("MainView"), postfix);
160  _multiView->saveOptions(QString("MainView"), postfix);
161 }
162 
167 void QCGTopLevel::saveTraceSettings()
168 {
169  QString key = traceKey();
170 
171  ConfigGroup* lConfig = ConfigStorage::group("Layouts");
172  lConfig->setValue(QString("Count%1").arg(key), _layoutCount);
173  lConfig->setValue(QString("Current%1").arg(key), _layoutCurrent);
174  delete lConfig;
175 
176  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
177  if (_eventType)
178  pConfig->setValue(QString("EventType%1").arg(key), _eventType->name());
179  if (_eventType2)
180  pConfig->setValue(QString("EventType2%1").arg(key), _eventType2->name());
181  if (_groupType != ProfileContext::InvalidType)
182  pConfig->setValue(QString("GroupType%1").arg(key),
183  ProfileContext::typeName(_groupType));
184 
185  if (_data) {
186  if (_group)
187  pConfig->setValue(QString("Group%1").arg(key), _group->name());
188  saveCurrentState(key);
189  }
190  delete pConfig;
191 }
192 
197 void QCGTopLevel::restoreCurrentState(const QString& postfix)
198 {
199  _partSelection->restoreOptions(QString("PartOverview"), postfix);
200  _multiView->restoreLayout(QString("MainView"), postfix);
201  _multiView->restoreOptions(QString("MainView"), postfix);
202 
203  _splittedToggleAction->setChecked(_multiView->childCount()>1);
204  _splitDirectionToggleAction->setEnabled(_multiView->childCount()>1);
205  _splitDirectionToggleAction->setChecked(_multiView->orientation() ==
206  Qt::Horizontal);
207 }
208 
209 void QCGTopLevel::sidebarMenuAboutToShow()
210 {
211  QAction* action;
212  QMenu *popup = _sidebarMenuAction->menu();
213 
214  popup->clear();
215 
216  action = popup->addAction(tr("Parts Overview"));
217  action->setCheckable(true);
218  action->setChecked(_partDock->isVisible());
219  connect(action, SIGNAL(triggered(bool)), this, SLOT(togglePartDock()));
220 
221  action = popup->addAction(tr("Top Cost Call Stack"));
222  action->setCheckable(true);
223  action->setChecked(_stackDock->isVisible());
224  connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleStackDock()));
225 
226  action = popup->addAction(tr("Flat Profile"));
227  action->setCheckable(true);
228  action->setChecked(_functionDock->isVisible());
229  connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleFunctionDock()));
230 }
231 
232 void QCGTopLevel::recentFilesMenuAboutToShow()
233 {
234  QStringList recentFiles;
235  QMenu *popup = _recentFilesMenuAction->menu();
236 
237  popup->clear();
238 
239  ConfigGroup* generalConfig = ConfigStorage::group("GeneralSettings");
240  recentFiles = generalConfig->value("RecentFiles",
241  QStringList()).toStringList();
242  delete generalConfig;
243 
244  if (recentFiles.count() == 0)
245  popup->addAction(tr("(No recent files)"));
246  else {
247  foreach(const QString& file, recentFiles) {
248  // paths shown to user should use OS-native separators
249  popup->addAction(QDir::toNativeSeparators(file));
250  }
251  }
252 }
253 
254 void QCGTopLevel::recentFilesTriggered(QAction* action)
255 {
256  if (action)
257  load(QStringList(QDir::fromNativeSeparators(action->text())));
258 }
259 
260 void QCGTopLevel::createDocks()
261 {
262  // part visualization/selection side bar
263  _partDock = new QDockWidget(this);
264  _partDock->setObjectName("part-dock");
265  _partDock->setWindowTitle(tr("Parts Overview"));
266  _partSelection = new PartSelection(this, _partDock);
267  _partDock->setWidget(_partSelection);
268 
269  connect(_partSelection, SIGNAL(partsHideSelected()),
270  this, SLOT(partsHideSelectedSlotDelayed()));
271  connect(_partSelection, SIGNAL(partsUnhideAll()),
272  this, SLOT(partsUnhideAllSlotDelayed()));
273 
274  // stack selection side bar
275  _stackDock = new QDockWidget(this);
276  _stackDock->setObjectName("stack-dock");
277  _stackSelection = new StackSelection(_stackDock);
278  _stackDock->setWidget(_stackSelection);
279  _stackDock->setWindowTitle(tr("Top Cost Call Stack"));
280  _stackSelection->setWhatsThis( tr(
281  "<b>The Top Cost Call Stack</b>"
282  "<p>This is a purely fictional 'most probable' call stack. "
283  "It is built up by starting with the current selected "
284  "function and adds the callers/callees with highest cost "
285  "at the top and to bottom.</p>"
286  "<p>The <b>Cost</b> and <b>Calls</b> columns show the "
287  "cost used for all calls from the function in the line "
288  "above.</p>"));
289  connect(_stackSelection, SIGNAL(functionSelected(CostItem*)),
290  this, SLOT(setTraceItemDelayed(CostItem*)));
291  // actions are already created
292  connect(_upAction, SIGNAL(triggered(bool)),
293  _stackSelection, SLOT(browserUp()) );
294  connect(_backAction, SIGNAL(triggered(bool)),
295  _stackSelection, SLOT(browserBack()) );
296  connect(_forwardAction, SIGNAL(triggered(bool)),
297  _stackSelection, SLOT(browserForward()));
298 
299  // flat function profile side bar
300  _functionDock = new QDockWidget(this);
301  _functionDock->setObjectName("function-dock");
302  _functionDock->setWindowTitle(tr("Flat Profile"));
303  _functionSelection = new FunctionSelection(this, _functionDock);
304  _functionDock->setWidget(_functionSelection);
305  // functionDock needs call to updateView() when getting visible
306  connect(_functionDock, SIGNAL(visibilityChanged(bool)),
307  this, SLOT(functionVisibilityChanged(bool)));
308 
309  // defaults (later to be adjusted from stored state in config)
310  addDockWidget(Qt::LeftDockWidgetArea, _partDock );
311  addDockWidget(Qt::LeftDockWidgetArea, _stackDock );
312  addDockWidget(Qt::LeftDockWidgetArea, _functionDock );
313  _stackDock->hide();
314  _partDock->hide();
315 }
316 
317 
318 
319 
320 void QCGTopLevel::createActions()
321 {
322  QString hint;
323  QIcon icon;
324 
325  // file menu actions
326  _newAction = new QAction(tr("&New"), this);
327  _newAction->setShortcuts(QKeySequence::New);
328  _newAction->setStatusTip(tr("Open new empty window"));
329  connect(_newAction, SIGNAL(triggered()), this, SLOT(newWindow()));
330 
331  icon = QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton);
332  _openAction = new QAction(icon, tr("&Open..."), this);
333  _openAction->setShortcuts(QKeySequence::Open);
334  _openAction->setStatusTip(tr("Open profile data file"));
335  connect(_openAction, SIGNAL(triggered()), this, SLOT(load()));
336 
337  _addAction = new QAction(tr( "&Add..." ), this);
338  _addAction->setStatusTip(tr("Add profile data to current window"));
339  connect(_addAction, SIGNAL(triggered(bool)), SLOT(add()));
340 
341  _exportAction = new QAction(tr("Export Graph"), this);
342  _exportAction->setStatusTip(tr("Generate GraphViz file 'callgraph.dot'"));
343  connect(_exportAction, SIGNAL(triggered(bool)), SLOT(exportGraph()));
344 
345  _recentFilesMenuAction = new QAction(tr("Open &Recent"), this);
346  _recentFilesMenuAction->setMenu(new QMenu(this));
347  connect(_recentFilesMenuAction->menu(), SIGNAL(aboutToShow()),
348  this, SLOT(recentFilesMenuAboutToShow()));
349  connect(_recentFilesMenuAction->menu(), SIGNAL(triggered(QAction*)),
350  this, SLOT(recentFilesTriggered(QAction*)));
351 
352  _exitAction = new QAction(tr("E&xit"), this);
353  _exitAction->setShortcut(tr("Ctrl+Q"));
354  _exitAction->setStatusTip(tr("Exit the application"));
355  connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
356 
357  // view menu actions
358  icon = QApplication::style()->standardIcon(QStyle::SP_BrowserReload);
359  _cyclesToggleAction = new QAction(icon, tr("Detect Cycles"), this);
360  _cyclesToggleAction->setCheckable(true);
361  _cyclesToggleAction->setStatusTip(tr("Do Cycle Detection"));
362  hint = tr("<b>Detect recursive cycles</b>"
363  "<p>If this is switched off, the treemap drawing will show "
364  "black areas when a recursive call is made instead of drawing "
365  "the recursion ad infinitum. Note that "
366  "the size of black areas often will be wrong, as inside "
367  "recursive cycles the cost of calls cannot be determined; "
368  "the error is small, "
369  "however, for false cycles (see documentation).</p>"
370  "<p>The correct handling for cycles is to detect them and "
371  "collapse all functions of a cycle into an artificial "
372  "function, which is done when this option is selected. "
373  "Unfortunately, with GUI applications, this often will "
374  "lead to huge false cycles, making the analysis impossible; "
375  "therefore, there is the option to switch this off.</p>");
376  _cyclesToggleAction->setWhatsThis(hint);
377  connect(_cyclesToggleAction, SIGNAL(triggered(bool)),
378  this, SLOT(toggleCycles()));
379  _cyclesToggleAction->setChecked(GlobalConfig::showCycles());
380 
381  _percentageToggleAction = new QAction(QIcon(":/percent.png"),
382  tr("Relative Cost"), this);
383  _percentageToggleAction->setCheckable(true);
384  _percentageToggleAction->setStatusTip(tr("Show Relative Costs"));
385  connect(_percentageToggleAction, SIGNAL(triggered(bool)),
386  this, SLOT(togglePercentage()));
387  _percentageToggleAction->setChecked(GlobalConfig::showPercentage());
388 
389  _hideTemplatesToggleAction = new QAction(QIcon(":/hidetemplates.png"),
390  tr("Shorten Templates"), this);
391  _hideTemplatesToggleAction->setCheckable(true);
392  _hideTemplatesToggleAction->setStatusTip(tr("Hide Template Parameters "
393  "in C++ Symbols"));
394  connect(_hideTemplatesToggleAction, SIGNAL(triggered(bool)),
395  this, SLOT(toggleHideTemplates()));
396  _hideTemplatesToggleAction->setChecked(GlobalConfig::hideTemplates());
397  hint = tr("<b>Hide Template Parameters in C++ Symbols</b>"
398  "<p>If this is switched on, every symbol displayed will have "
399  "any C++ template parameters hidden, just showing &lt;&gt; "
400  "instead of a potentially nested template parameter.</p>"
401  "<p>In this mode, you can hover the mouse pointer over the "
402  "activated symbol label to show a tooltip with the "
403  "unabbreviated symbol.</p>");
404  _hideTemplatesToggleAction->setWhatsThis(hint);
405 
406  _expandedToggleAction = new QAction(QIcon(":/move.png"),
407  tr("Relative to Parent"), this);
408  _expandedToggleAction->setCheckable(true);
409  _expandedToggleAction->setStatusTip(
410  tr("Show Percentage relative to Parent"));
411  hint = tr("<b>Show percentage costs relative to parent</b>"
412  "<p>If this is switched off, percentage costs are always "
413  "shown relative to the total cost of the profile part(s) "
414  "that are currently browsed. By turning on this option, "
415  "percentage cost of shown cost items will be relative "
416  "to the parent cost item.</p>"
417  "<ul><table>"
418  "<tr><td><b>Cost Type</b></td><td><b>Parent Cost</b></td></tr>"
419  "<tr><td>Function Inclusive</td><td>Total</td></tr>"
420  "<tr><td>Function Self</td><td>Function Group (*)/Total</td></tr>"
421  "<tr><td>Call</td><td>Function Inclusive</td></tr>"
422  "<tr><td>Source Line</td><td>Function Inclusive</td></tr>"
423  "</table></ul>"
424  "<p>(*) Only if function grouping is switched on "
425  "(e.g. ELF object grouping).</p>");
426  _expandedToggleAction->setWhatsThis( hint );
427  connect(_expandedToggleAction, SIGNAL(triggered(bool)),
428  this, SLOT(toggleExpanded()));
429  _expandedToggleAction->setChecked(GlobalConfig::showExpanded());
430 
431  _splittedToggleAction = new QAction(tr("Splitted Visualization"), this);
432  _splittedToggleAction->setCheckable(true);
433  _splittedToggleAction->setStatusTip(
434  tr("Show visualization of two cost items"));
435  connect(_splittedToggleAction, SIGNAL(triggered(bool)),
436  this, SLOT(toggleSplitted()));
437 
438  _splitDirectionToggleAction = new QAction(tr("Split Horizontal"), this);
439  _splitDirectionToggleAction->setCheckable(true);
440  _splitDirectionToggleAction->setStatusTip(
441  tr("Split visualization area horizontally"));
442  connect(_splitDirectionToggleAction, SIGNAL(triggered(bool)),
443  this, SLOT(toggleSplitDirection()));
444 
445  _sidebarMenuAction = new QAction(tr("Sidebars"), this);
446  _sidebarMenuAction->setMenu(new QMenu(this));
447  connect( _sidebarMenuAction->menu(), SIGNAL( aboutToShow() ),
448  this, SLOT( sidebarMenuAboutToShow() ));
449 
450  _layoutDup = new QAction(tr("&Duplicate"), this);
451  connect(_layoutDup, SIGNAL(triggered()), SLOT(layoutDuplicate()));
452  _layoutDup->setShortcut(Qt::CTRL + Qt::Key_Plus);
453  _layoutDup->setStatusTip(tr("Duplicate current layout"));
454 
455  _layoutRemove = new QAction(tr("&Remove"), this);
456  connect(_layoutRemove, SIGNAL(triggered()), SLOT(layoutRemove()));
457  _layoutRemove->setStatusTip(tr("Remove current layout"));
458 
459  _layoutNext = new QAction(tr("Go to &Next"), this);
460  connect(_layoutNext, SIGNAL(triggered()), SLOT(layoutNext()));
461  _layoutNext->setShortcut(Qt::CTRL + Qt::Key_Right);
462  _layoutNext->setStatusTip(tr("Switch to next layout"));
463 
464  _layoutPrev = new QAction(tr("Go to &Previous"), this);
465  connect(_layoutPrev, SIGNAL(triggered()), SLOT(layoutPrevious()));
466  _layoutPrev->setShortcut(Qt::CTRL + Qt::Key_Left);
467  _layoutPrev->setStatusTip(tr("Switch to previous layout"));
468 
469  _layoutRestore = new QAction(tr("&Restore to Default"), this);
470  connect(_layoutRestore, SIGNAL(triggered()), SLOT(layoutRestore()));
471  _layoutRestore->setStatusTip(tr("Restore layouts to default"));
472 
473  _layoutSave = new QAction(tr("&Save as Default"), this);
474  connect(_layoutSave, SIGNAL(triggered()), SLOT(layoutSave()));
475  _layoutSave->setStatusTip(tr("Save layouts as default"));
476 
477  // go menu actions
478  icon = QApplication::style()->standardIcon(QStyle::SP_ArrowUp);
479  _upAction = new QAction(icon, tr( "Up" ), this );
480  _upAction->setShortcut( QKeySequence(Qt::ALT+Qt::Key_Up) );
481  _upAction->setStatusTip(tr("Go Up in Call Stack"));
482  _upAction->setMenu(new QMenu(this));
483  connect(_upAction->menu(), SIGNAL(aboutToShow()),
484  this, SLOT(upAboutToShow()) );
485  connect(_upAction->menu(), SIGNAL(triggered(QAction*)),
486  this, SLOT(upTriggered(QAction*)) );
487  hint = tr("Go to last selected caller of current function");
488  _upAction->setToolTip(hint);
489 
490  icon = QApplication::style()->standardIcon(QStyle::SP_ArrowBack);
491  _backAction = new QAction(icon, tr("Back"), this);
492  _backAction->setShortcut( QKeySequence(Qt::ALT+Qt::Key_Left) );
493  _backAction->setStatusTip(tr("Go Back"));
494  _backAction->setMenu(new QMenu(this));
495  connect(_backAction->menu(), SIGNAL(aboutToShow()),
496  this, SLOT(backAboutToShow()) );
497  connect(_backAction->menu(), SIGNAL(triggered(QAction*)),
498  this, SLOT(backTriggered(QAction*)) );
499  hint = tr("Go back in function selection history");
500  _backAction->setToolTip(hint);
501 
502  icon = QApplication::style()->standardIcon(QStyle::SP_ArrowForward);
503  _forwardAction = new QAction(icon, tr("Forward"), this);
504  _forwardAction->setShortcut( QKeySequence(Qt::ALT+Qt::Key_Right) );
505  _forwardAction->setStatusTip(tr("Go Forward"));
506  _forwardAction->setMenu(new QMenu(this));
507  connect(_forwardAction->menu(), SIGNAL(aboutToShow()),
508  this, SLOT(forwardAboutToShow()) );
509  connect(_forwardAction->menu(), SIGNAL(triggered(QAction*)),
510  this, SLOT(forwardTriggered(QAction*)) );
511  hint = tr("Go forward in function selection history");
512  _forwardAction->setToolTip( hint );
513 
514  // settings menu actions
515  _configureAction = new QAction(tr("&Configure..."), this);
516  _configureAction->setStatusTip(tr("Configure QCachegrind"));
517  connect(_configureAction, SIGNAL(triggered()), this, SLOT(configure()));
518 
519  // help menu actions
520  _aboutAction = new QAction(tr("&About QCachegrind..."), this);
521  _aboutAction->setStatusTip(tr("Show the application's About box"));
522  connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
523 
524  _aboutQtAction = new QAction(tr("About Qt..."), this);
525  connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
526 
527  // toolbar actions
528  _eventTypeBox = new QComboBox(this);
529  _eventTypeBox->setMinimumContentsLength(25);
530  hint = tr("Select primary event type of costs");
531  _eventTypeBox->setToolTip( hint );
532  connect( _eventTypeBox, SIGNAL(activated(const QString&)),
533  this, SLOT(eventTypeSelected(const QString&)));
534 }
535 
536 void QCGTopLevel::createMenu()
537 {
538  QMenuBar* mBar = menuBar();
539 
540  QMenu* fileMenu = mBar->addMenu(tr("&File"));
541  fileMenu->addAction(_newAction);
542  fileMenu->addAction(_openAction);
543  fileMenu->addAction(_recentFilesMenuAction);
544  fileMenu->addAction(_addAction);
545  fileMenu->addSeparator();
546  fileMenu->addAction(_exportAction);
547  fileMenu->addSeparator();
548  fileMenu->addAction(_exitAction);
549 
550  QMenu* layoutMenu = new QMenu(tr("&Layout"), this);
551  layoutMenu->addAction(_layoutDup);
552  layoutMenu->addAction(_layoutRemove);
553  layoutMenu->addSeparator();
554  layoutMenu->addAction(_layoutPrev);
555  layoutMenu->addAction(_layoutNext);
556  layoutMenu->addSeparator();
557  layoutMenu->addAction(_layoutSave);
558  layoutMenu->addAction(_layoutRestore);
559 
560  QMenu* viewMenu = mBar->addMenu(tr("&View"));
561  viewMenu->addAction(_cyclesToggleAction);
562  viewMenu->addAction(_percentageToggleAction);
563  viewMenu->addAction(_expandedToggleAction);
564  viewMenu->addAction(_hideTemplatesToggleAction);
565  viewMenu->addSeparator();
566  viewMenu->addAction(_splittedToggleAction);
567  viewMenu->addAction(_splitDirectionToggleAction);
568  viewMenu->addMenu(layoutMenu);
569 
570  QMenu* goMenu = mBar->addMenu(tr("&Go"));
571  goMenu->addAction(_backAction);
572  goMenu->addAction(_forwardAction);
573  goMenu->addAction(_upAction);
574 
575  QMenu* settingsMenu = mBar->addMenu(tr("&Settings"));
576  settingsMenu->addAction(_sidebarMenuAction);
577  settingsMenu->addSeparator();
578  settingsMenu->addAction(_configureAction);
579 
580  QMenu* helpMenu = mBar->addMenu(tr("&Help"));
581  helpMenu->addAction(QWhatsThis::createAction(this));
582  helpMenu->addSeparator();
583  helpMenu->addAction(_aboutAction);
584  helpMenu->addAction(_aboutQtAction);
585 }
586 
587 void QCGTopLevel::createToolbar()
588 {
589  QToolBar* tb = new QToolBar(tr("Main Toolbar"), this);
590  tb->setObjectName("main-toolbar");
591  addToolBar(Qt::TopToolBarArea, tb);
592 
593  tb->addAction(_openAction);
594  tb->addSeparator();
595 
596  tb->addAction(_cyclesToggleAction);
597  tb->addAction(_percentageToggleAction);
598  tb->addAction(_expandedToggleAction);
599  tb->addAction(_hideTemplatesToggleAction);
600  tb->addSeparator();
601 
602  tb->addAction(_backAction);
603  tb->addAction(_forwardAction);
604  tb->addAction(_upAction);
605  tb->addSeparator();
606 
607  tb->addWidget(_eventTypeBox);
608 }
609 
610 
611 void QCGTopLevel::about()
612 {
613  QString text, version;
614  version = QLatin1String("0.7.4kde");
615  text = QString("<h3>QCachegrind %1</h3>").arg(version);
616  text += tr("<p>QCachegrind is a graphical user interface for analysing "
617  "profiling data, which helps in the performance optimization "
618  "phase of developing a computer program. "
619  "QCachegrind is open-source, and it is distributed under the "
620  "terms of the GPL v2. For details and source code, see the "
621  "<a href=\"http://kcachegrind.sf.net\">homepage</a> of the "
622  "KCachegrind project.</p>"
623  "Main author and maintainer: "
624  "<a href=\"mailto:Josef.Weidendorfer@gmx.de\">"
625  "Josef Weidendorfer</a><br>"
626  "(with lots of bug fixes and porting to Qt4 by the KDE team)");
627  QMessageBox::about(this, tr("About QCachegrind"), text);
628 }
629 
630 void QCGTopLevel::configure(QString s)
631 {
632  static QString lastPage = QString::null;
633 
634  // if no specific config item should be focused, use last page
635  if (s.isEmpty()) s = lastPage;
636  ConfigDialog d(_data, this, s);
637 
638  if (d.exec() == QDialog::Accepted) {
639  GlobalConfig::config()->saveOptions();
640  configChanged();
641  }
642  lastPage = d.currentPage();
643 }
644 
645 void QCGTopLevel::togglePartDock()
646 {
647  if (!_partDock->isVisible())
648  _partDock->show();
649  else
650  _partDock->hide();
651 }
652 
653 void QCGTopLevel::toggleStackDock()
654 {
655  if (!_stackDock->isVisible())
656  _stackDock->show();
657  else
658  _stackDock->hide();
659 }
660 
661 void QCGTopLevel::toggleFunctionDock()
662 {
663  if (!_functionDock->isVisible())
664  _functionDock->show();
665  else
666  _functionDock->hide();
667 }
668 
669 void QCGTopLevel::togglePercentage()
670 {
671  setPercentage(_percentageToggleAction->isChecked());
672 }
673 
674 
675 void QCGTopLevel::setAbsoluteCost()
676 {
677  setPercentage(false);
678 }
679 
680 void QCGTopLevel::setRelativeCost()
681 {
682  setPercentage(true);
683 }
684 
685 void QCGTopLevel::setPercentage(bool show)
686 {
687  if (GlobalConfig::showPercentage() == show) return;
688  if (_percentageToggleAction->isChecked() != show)
689  _percentageToggleAction->setChecked(show);
690  _expandedToggleAction->setEnabled(show);
691  GlobalConfig::setShowPercentage(show);
692 
693  _partSelection->notifyChange(TraceItemView::configChanged);
694  _stackSelection->refresh();
695  _functionSelection->notifyChange(TraceItemView::configChanged);
696  _multiView->notifyChange(TraceItemView::configChanged);
697 }
698 
699 void QCGTopLevel::toggleHideTemplates()
700 {
701  bool show = _hideTemplatesToggleAction->isChecked();
702  if (GlobalConfig::hideTemplates() == show) return;
703  GlobalConfig::setHideTemplates(show);
704 
705  _partSelection->notifyChange(TraceItemView::configChanged);
706  _stackSelection->refresh();
707  _functionSelection->notifyChange(TraceItemView::configChanged);
708  _multiView->notifyChange(TraceItemView::configChanged);
709 }
710 
711 void QCGTopLevel::toggleExpanded()
712 {
713  bool show = _expandedToggleAction->isChecked();
714  if (GlobalConfig::showExpanded() == show) return;
715  GlobalConfig::setShowExpanded(show);
716 
717  _partSelection->notifyChange(TraceItemView::configChanged);
718  _stackSelection->refresh();
719  _functionSelection->notifyChange(TraceItemView::configChanged);
720  _multiView->notifyChange(TraceItemView::configChanged);
721 }
722 
723 void QCGTopLevel::toggleCycles()
724 {
725  bool show = _cyclesToggleAction->isChecked();
726  if (GlobalConfig::showCycles() == show) return;
727  GlobalConfig::setShowCycles(show);
728 
729  if (!_data) return;
730 
731  _data->invalidateDynamicCost();
732  _data->updateFunctionCycles();
733 
734  _partSelection->notifyChange(TraceItemView::configChanged);
735  _stackSelection->rebuildStackList();
736  _functionSelection->notifyChange(TraceItemView::configChanged);
737  _multiView->notifyChange(TraceItemView::configChanged);
738 }
739 
740 
741 void QCGTopLevel::functionVisibilityChanged(bool v)
742 {
743  if (v)
744  _functionSelection->updateView();
745 }
746 
747 
748 void QCGTopLevel::newWindow()
749 {
750  QCGTopLevel* t = new QCGTopLevel();
751  t->show();
752 }
753 
754 
755 void QCGTopLevel::load()
756 {
757  QStringList files;
758  files = QFileDialog::getOpenFileNames(this,
759  tr("Open Callgrind Data"),
760  _lastFile,
761  tr("Callgrind Files (callgrind.*);;All Files (*)"));
762  load(files);
763 }
764 
765 void QCGTopLevel::load(QStringList files, bool addToRecentFiles)
766 {
767  if (files.isEmpty()) return;
768  _lastFile = files[0];
769 
770  if (_data && _data->parts().count()>0) {
771 
772  // In new window
773  QCGTopLevel* t = new QCGTopLevel();
774  t->show();
775  t->loadDelayed(files, addToRecentFiles);
776  return;
777  }
778 
779  // this constructor enables progress bar callbacks
780  TraceData* d = new TraceData(this);
781  int filesLoaded = d->load(files);
782  if (filesLoaded >0)
783  setData(d);
784 
785  if (!addToRecentFiles) return;
786 
787  // add to recent file list in config
788  QStringList recentFiles;
789  ConfigGroup* generalConfig = ConfigStorage::group("GeneralSettings");
790  recentFiles = generalConfig->value("RecentFiles",
791  QStringList()).toStringList();
792  foreach(QString file, files) {
793  recentFiles.removeAll(file);
794  if (filesLoaded >0)
795  recentFiles.prepend(file);
796  if (recentFiles.count() >5)
797  recentFiles.removeLast();
798  }
799  generalConfig->setValue("RecentFiles", recentFiles);
800  delete generalConfig;
801 }
802 
803 
804 void QCGTopLevel::add()
805 {
806  QStringList files;
807  files = QFileDialog::getOpenFileNames(this,
808  tr("Add Callgrind Data"),
809  _lastFile,
810  tr("Callgrind Files (callgrind.*);;All Files (*)"));
811  add(files);
812 }
813 
814 
815 void QCGTopLevel::add(QStringList files)
816 {
817  if (files.isEmpty()) return;
818  _lastFile = files[0];
819 
820  if (_data) {
821  _data->load(files);
822 
823  // GUI update for added data
824  configChanged();
825  return;
826  }
827 
828  // this constructor enables progress bar callbacks
829  TraceData* d = new TraceData(this);
830  int filesLoaded = d->load(files);
831  if (filesLoaded >0)
832  setData(d);
833 }
834 
835 void QCGTopLevel::loadDelayed(QString file, bool addToRecentFiles)
836 {
837  _loadFilesDelayed << file;
838 
839  _addToRecentFiles = addToRecentFiles;
840  QTimer::singleShot(0, this, SLOT(loadFilesDelayed()));
841 }
842 
843 void QCGTopLevel::loadDelayed(QStringList files, bool addToRecentFiles)
844 {
845  _loadFilesDelayed << files;
846 
847  _addToRecentFiles = addToRecentFiles;
848  QTimer::singleShot(0, this, SLOT(loadFilesDelayed()));
849 }
850 
851 void QCGTopLevel::loadFilesDelayed()
852 {
853  if (_loadFilesDelayed.isEmpty()) return;
854 
855  load(_loadFilesDelayed, _addToRecentFiles);
856  _loadFilesDelayed.clear();
857 }
858 
859 
860 void QCGTopLevel::exportGraph()
861 {
862  if (!_data || !_function) return;
863 
864  QString n = QString("callgraph.dot");
865  GraphExporter ge(_data, _function, _eventType, _groupType, n);
866  ge.writeDot();
867 
868 #ifdef Q_OS_UNIX
869  // shell commands only work in UNIX
870  QString cmd = QString("(dot %1 -Tps > %2.ps; xdg-open %3.ps)&")
871  .arg(n).arg(n).arg(n);
872  if (::system(QFile::encodeName( cmd ))<0)
873  qDebug() << "QCGTopLevel::exportGraph: can not run " << cmd;
874 #endif
875 }
876 
877 
878 bool QCGTopLevel::setEventType(QString s)
879 {
880  EventType* ct;
881 
882  ct = (_data) ? _data->eventTypes()->type(s) : 0;
883 
884  // if costtype with given name not found, use first available
885  if (!ct && _data) ct = _data->eventTypes()->type(0);
886 
887  return setEventType(ct);
888 }
889 
890 bool QCGTopLevel::setEventType2(QString s)
891 {
892  EventType* ct;
893 
894  // Special type tr("(Hidden)") gives 0
895  ct = (_data) ? _data->eventTypes()->type(s) : 0;
896 
897  return setEventType2(ct);
898 }
899 
900 void QCGTopLevel::eventTypeSelected(const QString& s)
901 {
902  EventType* ct;
903 
904  ct = (_data) ? _data->eventTypes()->typeForLong(s) : 0;
905  setEventType(ct);
906 }
907 
908 void QCGTopLevel::eventType2Selected(const QString& s)
909 {
910  EventType* ct;
911 
912  ct = (_data) ? _data->eventTypes()->typeForLong(s) : 0;
913  setEventType2(ct);
914 }
915 
916 bool QCGTopLevel::setEventType(EventType* ct)
917 {
918  if (_eventType == ct) return false;
919  _eventType = ct;
920 
921  if (ct) {
922  int idx = _eventTypeBox->findText(ct->longName());
923  if (idx >=0) _eventTypeBox->setCurrentIndex(idx);
924  }
925 
926  _partSelection->setEventType(_eventType);
927  _stackSelection->setEventType(_eventType);
928  _functionSelection->setEventType(_eventType);
929  _multiView->setEventType(_eventType);
930 
931  updateStatusBar();
932 
933  return true;
934 }
935 
936 bool QCGTopLevel::setEventType2(EventType* ct)
937 {
938  if (_eventType2 == ct) return false;
939  _eventType2 = ct;
940 
941  QString longName = ct ? ct->longName() : tr("(Hidden)");
942 
943  _partSelection->setEventType2(_eventType2);
944  _stackSelection->setEventType2(_eventType2);
945  _functionSelection->setEventType2(_eventType2);
946  _multiView->setEventType2(_eventType2);
947 
948  updateStatusBar();
949 
950  return true;
951 }
952 
953 
954 void QCGTopLevel::groupTypeSelected(int cg)
955 {
956  switch(cg) {
957  case 0: setGroupType( ProfileContext::Function ); break;
958  case 1: setGroupType( ProfileContext::Object ); break;
959  case 2: setGroupType( ProfileContext::File ); break;
960  case 3: setGroupType( ProfileContext::Class ); break;
961  case 4: setGroupType( ProfileContext::FunctionCycle ); break;
962  default: break;
963  }
964 }
965 
966 bool QCGTopLevel::setGroupType(QString s)
967 {
968  ProfileContext::Type gt;
969 
970  gt = ProfileContext::type(s);
971  // only allow Function/Object/File/Class as grouptype
972  switch(gt) {
973  case ProfileContext::Object:
974  case ProfileContext::File:
975  case ProfileContext::Class:
976  case ProfileContext::FunctionCycle:
977  break;
978  default:
979  gt = ProfileContext::Function;
980  }
981 
982  return setGroupType(gt);
983 }
984 
985 bool QCGTopLevel::setGroupType(ProfileContext::Type gt)
986 {
987  if (_groupType == gt) return false;
988  _groupType = gt;
989 
990  int idx = -1;
991  switch(gt) {
992  case ProfileContext::Function: idx = 0; break;
993  case ProfileContext::Object: idx = 1; break;
994  case ProfileContext::File: idx = 2; break;
995  case ProfileContext::Class: idx = 3; break;
996  case ProfileContext::FunctionCycle: idx = 4; break;
997  default:
998  break;
999  }
1000 
1001  if (idx==-1) return false;
1002 
1003 #if 0
1004  if (saGroup->currentItem() != idx)
1005  saGroup->setCurrentItem(idx);
1006 #endif
1007 
1008  _stackSelection->setGroupType(_groupType);
1009 
1010  _partSelection->set(_groupType);
1011  _functionSelection->set(_groupType);
1012  _multiView->set(_groupType);
1013 
1014  updateStatusBar();
1015 
1016  return true;
1017 }
1018 
1019 bool QCGTopLevel::setGroup(QString s)
1020 {
1021  TraceCostItem* ci = _functionSelection->group(s);
1022  if (!ci)
1023  return false;
1024 
1025  return setGroup(ci);
1026 }
1027 
1028 
1029 bool QCGTopLevel::setGroup(TraceCostItem* g)
1030 {
1031  if (_group == g) return false;
1032  _group = g;
1033 
1034  _functionSelection->setGroup(g);
1035  updateStatusBar();
1036 
1037  return true;
1038 }
1039 
1040 bool QCGTopLevel::setFunction(QString s)
1041 {
1042  if (!_data) return false;
1043 
1044  ProfileCostArray* f = _data->search(ProfileContext::Function, s, _eventType);
1045  if (!f) return false;
1046 
1047  return setFunction((TraceFunction*)f);
1048 }
1049 
1050 bool QCGTopLevel::setFunction(TraceFunction* f)
1051 {
1052  if (_function == f) return false;
1053  _function = f;
1054 
1055  _multiView->activate(f);
1056  _functionSelection->activate(f);
1057  _partSelection->activate(f);
1058  _stackSelection->setFunction(_function);
1059 
1060  StackBrowser* b = _stackSelection->browser();
1061  if (b) {
1062  // do not disable up: a press forces stack-up extending...
1063  _forwardAction->setEnabled(b->canGoForward());
1064  _backAction->setEnabled(b->canGoBack());
1065  }
1066 
1067 #if TRACE_UPDATES
1068  qDebug("QCGTopLevel::setFunction(%s), lastSender %s",
1069  f ? f->prettyName().toAscii() : "0",
1070  _lastSender ? _lastSender->name() :"0" );
1071 #endif
1072 
1073  return true;
1074 }
1075 
1076 
1084 void QCGTopLevel::setEventTypeDelayed(EventType* ct)
1085 {
1086  _eventTypeDelayed = ct;
1087  QTimer::singleShot (0, this, SLOT(setEventTypeDelayed()));
1088 }
1089 
1090 void QCGTopLevel::setEventType2Delayed(EventType* ct)
1091 {
1092  _eventType2Delayed = ct;
1093  QTimer::singleShot (0, this, SLOT(setEventType2Delayed()));
1094 }
1095 
1096 void QCGTopLevel::setEventTypeDelayed()
1097 {
1098  setEventType(_eventTypeDelayed);
1099 }
1100 
1101 void QCGTopLevel::setEventType2Delayed()
1102 {
1103  setEventType2(_eventType2Delayed);
1104 }
1105 
1106 void QCGTopLevel::setGroupTypeDelayed(ProfileContext::Type gt)
1107 {
1108  _groupTypeDelayed = gt;
1109  QTimer::singleShot (0, this, SLOT(setGroupTypeDelayed()));
1110 }
1111 
1112 void QCGTopLevel::setGroupTypeDelayed()
1113 {
1114  setGroupType(_groupTypeDelayed);
1115 }
1116 
1117 void QCGTopLevel::setGroupDelayed(TraceCostItem* g)
1118 {
1119 #if TRACE_UPDATES
1120  qDebug("QCGTopLevel::setGroupDelayed(%s), sender %s",
1121  g ? g->prettyName().toAscii() : "0",
1122  _lastSender ? _lastSender->name() :"0" );
1123 #endif
1124 
1125  _groupDelayed = g;
1126  QTimer::singleShot (0, this, SLOT(setGroupDelayed()));
1127 }
1128 
1129 void QCGTopLevel::setGroupDelayed()
1130 {
1131  setGroup(_groupDelayed);
1132 }
1133 
1134 void QCGTopLevel::setDirectionDelayed(TraceItemView::Direction d)
1135 {
1136  _directionDelayed = d;
1137  QTimer::singleShot (0, this, SLOT(setDirectionDelayed()));
1138 }
1139 
1140 void QCGTopLevel::setDirectionDelayed()
1141 {
1142  switch(_directionDelayed) {
1143  case TraceItemView::Back:
1144  _stackSelection->browserBack();
1145  break;
1146 
1147  case TraceItemView::Forward:
1148  _stackSelection->browserForward();
1149  break;
1150 
1151  case TraceItemView::Up:
1152  {
1153  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1154  HistoryItem* hi = b ? b->current() : 0;
1155  TraceFunction* f = hi ? hi->function() : 0;
1156 
1157  if (!f) break;
1158  f = hi->stack()->caller(f, false);
1159  if (f) setFunction(f);
1160  }
1161  break;
1162 
1163  default: break;
1164  }
1165 
1166  _directionDelayed = TraceItemView::None;
1167 }
1168 
1169 
1170 void QCGTopLevel::setTraceItemDelayed(CostItem* i)
1171 {
1172  // no need to select same item a 2nd time...
1173  if (_traceItemDelayed == i) return;
1174  _traceItemDelayed = i;
1175  _lastSender = sender();
1176 
1177  qDebug() << "Selected " << (i ? i->fullName() : "(none)");
1178 
1179 #if TRACE_UPDATES
1180  qDebug("QCGTopLevel::setTraceItemDelayed(%s), sender %s",
1181  i ? i->prettyName().toAscii() : "0",
1182  _lastSender ? _lastSender->name() :"0" );
1183 #endif
1184 
1185  QTimer::singleShot (0, this, SLOT(setTraceItemDelayed()));
1186 }
1187 
1188 void QCGTopLevel::setTraceItemDelayed()
1189 {
1190  if (!_traceItemDelayed) return;
1191 
1192  switch(_traceItemDelayed->type()) {
1193  case ProfileContext::Function:
1194  case ProfileContext::FunctionCycle:
1195  setFunction((TraceFunction*)_traceItemDelayed);
1196  break;
1197 
1198  case ProfileContext::Object:
1199  case ProfileContext::File:
1200  case ProfileContext::Class:
1201  _multiView->activate(_traceItemDelayed);
1202  break;
1203 
1204 #if 0
1205  // this conflicts with the selection policy of InstrView ?!?
1206  case ProfileContext::Instr:
1207  case ProfileContext::Line:
1208  // only for multiview
1209  _multiView->activate(_traceItemDelayed);
1210  break;
1211 #endif
1212 
1213  default: break;
1214  }
1215 
1216  _traceItemDelayed = 0;
1217  _lastSender = 0;
1218 }
1219 
1226 void QCGTopLevel::setData(TraceData* data)
1227 {
1228  if (data == _data) return;
1229 
1230  _lastSender = 0;
1231 
1232  saveTraceSettings();
1233 
1234  if (_data) {
1235  _partSelection->setData(0);
1236  _stackSelection->setData(0);
1237  _functionSelection->setData(0);
1238  _multiView->setData(0);
1239  _multiView->updateView(true);
1240 
1241  // we are the owner...
1242  delete _data;
1243  }
1244 
1245  // reset members
1246  resetState();
1247 
1248  _data = data;
1249 
1250  // fill cost type list
1251  QStringList types;
1252 
1253  if (_data) {
1254  /* add all supported virtual types */
1255  EventTypeSet* m = _data->eventTypes();
1256  m->addKnownDerivedTypes();
1257 
1258  /* first, fill selection list with available cost types */
1259  for (int i=0;i<m->realCount();i++)
1260  types << m->realType(i)->longName();
1261  for (int i=0;i<m->derivedCount();i++)
1262  types << m->derivedType(i)->longName();
1263  }
1264  _eventTypes = types;
1265  _eventTypeBox->addItems(types);
1266 
1267  _stackSelection->setData(_data);
1268  _partSelection->setData(_data);
1269  _functionSelection->setData(_data);
1270  _multiView->setData(_data);
1271  // Force update of _data in all children of _multiView
1272  // This is needed to make restoring of activeItem work!
1273  _multiView->updateView(true);
1274 
1275  /* this is needed to let the other widgets know the types */
1276  restoreTraceTypes();
1277 
1278  restoreTraceSettings();
1279 
1280  QString caption;
1281  if (_data) {
1282  caption = QDir::toNativeSeparators(_data->traceName());
1283  if (!_data->command().isEmpty())
1284  caption += " [" + _data->command() + ']';
1285  }
1286  setWindowTitle(caption);
1287 
1288  if (!_data || (!_forcePartDock && _data->parts().count()<2))
1289  _partDock->hide();
1290  else
1291  _partDock->show();
1292 
1293  updateStatusBar();
1294 }
1295 
1296 void QCGTopLevel::addEventTypeMenu(QMenu* popup, bool withCost2)
1297 {
1298  if (_data) {
1299  QMenu *popup1, *popup2 = 0;
1300  QAction* action;
1301 
1302  popup1 = popup->addMenu(tr("Primary Event Type"));
1303  connect(popup1, SIGNAL(triggered(QAction*)),
1304  this, SLOT(setEventType(QAction*)));
1305 
1306  if (withCost2) {
1307  popup2 = popup->addMenu(tr("Secondary Event Type"));
1308  connect(popup2, SIGNAL(triggered(QAction*)),
1309  this, SLOT(setEventType2(QAction*)));
1310 
1311  if (_eventType2) {
1312  action = popup2->addAction(tr("Hide"));
1313  action->setData(199);
1314  popup2->addSeparator();
1315  }
1316  }
1317 
1318  EventTypeSet* m = _data->eventTypes();
1319  EventType* ct;
1320  for (int i=0;i<m->realCount();i++) {
1321  ct = m->realType(i);
1322 
1323  action = popup1->addAction(ct->longName());
1324  action->setCheckable(true);
1325  action->setData(100+i);
1326  if (_eventType == ct) action->setChecked(true);
1327 
1328  if (popup2) {
1329  action = popup2->addAction(ct->longName());
1330  action->setCheckable(true);
1331  action->setData(100+i);
1332  if (_eventType2 == ct) action->setChecked(true);
1333  }
1334  }
1335 
1336  for (int i=0;i<m->derivedCount();i++) {
1337  ct = m->derivedType(i);
1338 
1339  action = popup1->addAction(ct->longName());
1340  action->setCheckable(true);
1341  action->setData(200+i);
1342  if (_eventType == ct) action->setChecked(true);
1343 
1344  if (popup2) {
1345  action = popup2->addAction(ct->longName());
1346  action->setCheckable(true);
1347  action->setData(200+i);
1348  if (_eventType2 == ct) action->setChecked(true);
1349  }
1350  }
1351  }
1352 
1353  if (GlobalConfig::showPercentage())
1354  popup->addAction(tr("Show Absolute Cost"),
1355  this, SLOT(setAbsoluteCost()));
1356  else
1357  popup->addAction(tr("Show Relative Cost"),
1358  this, SLOT(setRelativeCost()));
1359 }
1360 
1361 bool QCGTopLevel::setEventType(QAction* action)
1362 {
1363  if (!_data) return false;
1364  int id = action->data().toInt(0);
1365 
1366  EventTypeSet* m = _data->eventTypes();
1367  EventType* ct=0;
1368  if (id >=100 && id<199) ct = m->realType(id-100);
1369  if (id >=200 && id<299) ct = m->derivedType(id-200);
1370 
1371  return ct ? setEventType(ct) : false;
1372 }
1373 
1374 bool QCGTopLevel::setEventType2(QAction* action)
1375 {
1376  if (!_data) return false;
1377  int id = action->data().toInt(0);
1378 
1379  EventTypeSet* m = _data->eventTypes();
1380  EventType* ct=0;
1381  if (id >=100 && id<199) ct = m->realType(id-100);
1382  if (id >=200 && id<299) ct = m->derivedType(id-200);
1383 
1384  return setEventType2(ct);
1385 }
1386 
1387 void QCGTopLevel::addGoMenu(QMenu* popup)
1388 {
1389  StackBrowser* b = _stackSelection->browser();
1390  if (b) {
1391  if (b->canGoBack())
1392  popup->addAction(tr("Go Back"), this, SLOT(goBack()));
1393  if (b->canGoForward())
1394  popup->addAction(tr("Go Forward"), this, SLOT(goForward()));
1395  }
1396  // do not disable up: a press forces stack-up extending...
1397  popup->addAction(tr("Go Up"), this, SLOT(goUp()));
1398 }
1399 
1400 void QCGTopLevel::goBack()
1401 {
1402  setDirectionDelayed(TraceItemView::Back);
1403 }
1404 
1405 void QCGTopLevel::goForward()
1406 {
1407  setDirectionDelayed(TraceItemView::Forward);
1408 }
1409 
1410 void QCGTopLevel::goUp()
1411 {
1412  setDirectionDelayed(TraceItemView::Up);
1413 }
1414 
1415 QString QCGTopLevel::traceKey()
1416 {
1417  if (!_data || _data->command().isEmpty()) return QString();
1418 
1419  QString name = _data->command();
1420  QString key;
1421  for (int l=0;l<name.length();l++)
1422  if (name[l].isLetterOrNumber()) key += name[l];
1423 
1424  return QString("-") + key;
1425 }
1426 
1427 
1428 void QCGTopLevel::restoreTraceTypes()
1429 {
1430  QString key = traceKey();
1431  QString groupType, eventType, eventType2;
1432 
1433  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
1434  groupType = pConfig->value(QString("GroupType%1").arg(key),QString()).toString();
1435  eventType = pConfig->value(QString("EventType%1").arg(key),QString()).toString();
1436  eventType2 = pConfig->value(QString("EventType2%1").arg(key),QString()).toString();
1437  delete pConfig;
1438 
1439  ConfigGroup* cConfig = ConfigStorage::group("CurrentState");
1440  if (groupType.isEmpty())
1441  groupType = cConfig->value("GroupType",QString()).toString();
1442  if (eventType.isEmpty())
1443  eventType = cConfig->value("EventType",QString()).toString();
1444  if (eventType2.isEmpty())
1445  eventType2 = cConfig->value("EventType2",QString()).toString();
1446  delete cConfig;
1447 
1448  setGroupType(groupType);
1449  setEventType(eventType);
1450  setEventType2(eventType2);
1451 
1452  // if still no event type set, use first available
1453  if (!_eventType && !_eventTypes.isEmpty())
1454  eventTypeSelected(_eventTypes.first());
1455 
1456  ConfigGroup* aConfig = ConfigStorage::group("Layouts");
1457  _layoutCount = aConfig->value(QString("Count%1").arg(key), 0).toInt();
1458  _layoutCurrent = aConfig->value(QString("Current%1").arg(key), 0).toInt();
1459  delete aConfig;
1460 
1461  if (_layoutCount == 0) layoutRestore();
1462  updateLayoutActions();
1463 }
1464 
1465 
1471 void QCGTopLevel::restoreTraceSettings()
1472 {
1473  if (!_data) return;
1474 
1475  QString key = traceKey();
1476 
1477  restoreCurrentState(key);
1478 
1479  ConfigGroup* pConfig = ConfigStorage::group("TracePositions");
1480  QString group = pConfig->value(QString("Group%1").arg(key),QString()).toString();
1481  delete pConfig;
1482  if (!group.isEmpty()) setGroup(group);
1483 
1484  // restoreCurrentState() usually leads to a call to setTraceItemDelayed()
1485  // to restore last active item...
1486  if (!_traceItemDelayed) {
1487  // function not available any more.. try with "main"
1488  if (!setFunction("main")) {
1489 #if 1
1490  _functionSelection->selectTopFunction();
1491 #else
1492  HighestCostList hc;
1493  hc.clear(50);
1494  TraceFunctionMap::Iterator it;
1495  for ( it = _data->functionMap().begin();
1496  it != _data->functionMap().end(); ++it )
1497  hc.addCost(&(*it), (*it).inclusive()->subCost(_eventType));
1498 
1499  setFunction( (TraceFunction*) hc[0]);
1500 #endif
1501  }
1502  }
1503 }
1504 
1505 
1506 /* Layout */
1507 
1508 void QCGTopLevel::layoutDuplicate()
1509 {
1510  // save current and allocate a new slot
1511  _multiView->saveLayout(QString("Layout%1-MainView").arg(_layoutCurrent),
1512  traceKey());
1513  _layoutCurrent = _layoutCount;
1514  _layoutCount++;
1515 
1516  updateLayoutActions();
1517 
1518  qDebug() << "QCGTopLevel::layoutDuplicate: count " << _layoutCount;
1519 }
1520 
1521 void QCGTopLevel::layoutRemove()
1522 {
1523  if (_layoutCount <2) return;
1524 
1525  int from = _layoutCount-1;
1526  if (_layoutCurrent == from) { _layoutCurrent--; from--; }
1527 
1528  // restore from last and decrement count
1529  _multiView->restoreLayout(QString("Layout%1-MainView").arg(from),
1530  traceKey());
1531  _layoutCount--;
1532 
1533  updateLayoutActions();
1534 
1535  qDebug() << "QCGTopLevel::layoutRemove: count " << _layoutCount;
1536 }
1537 
1538 void QCGTopLevel::layoutNext()
1539 {
1540  if (_layoutCount <2) return;
1541 
1542  QString key = traceKey();
1543  QString layoutPrefix = QString("Layout%1-MainView");
1544 
1545  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1546  _layoutCurrent++;
1547  if (_layoutCurrent == _layoutCount) _layoutCurrent = 0;
1548  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1549 
1550  qDebug() << "QCGTopLevel::layoutNext: current " << _layoutCurrent;
1551 }
1552 
1553 void QCGTopLevel::layoutPrevious()
1554 {
1555  if (_layoutCount <2) return;
1556 
1557  QString key = traceKey();
1558  QString layoutPrefix = QString("Layout%1-MainView");
1559 
1560  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1561  _layoutCurrent--;
1562  if (_layoutCurrent <0) _layoutCurrent = _layoutCount-1;
1563  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1564 
1565  qDebug() << "QCGTopLevel::layoutPrevious: current " << _layoutCurrent;
1566 }
1567 
1568 void QCGTopLevel::layoutSave()
1569 {
1570  QString key = traceKey();
1571  QString layoutPrefix = QString("Layout%1-MainView");
1572 
1573  _multiView->saveLayout(layoutPrefix.arg(_layoutCurrent), key);
1574 
1575  // save all layouts as defaults (ie. without any group name postfix)
1576  for(int i=0;i<_layoutCount;i++) {
1577  _multiView->restoreLayout(layoutPrefix.arg(i), key);
1578  _multiView->saveLayout(layoutPrefix.arg(i), QString());
1579  }
1580  // restore the previously saved current layout
1581  _multiView->restoreLayout(layoutPrefix.arg(_layoutCurrent), key);
1582 
1583  ConfigGroup* layoutConfig = ConfigStorage::group("Layouts");
1584  layoutConfig->setValue("DefaultCount", _layoutCount);
1585  layoutConfig->setValue("DefaultCurrent", _layoutCurrent);
1586  delete layoutConfig;
1587 }
1588 
1589 void QCGTopLevel::layoutRestore()
1590 {
1591  ConfigGroup* layoutConfig = ConfigStorage::group("Layouts");
1592  _layoutCount = layoutConfig->value("DefaultCount", 0).toInt();
1593  _layoutCurrent = layoutConfig->value("DefaultCurrent", 0).toInt();
1594  delete layoutConfig;
1595 
1596  if (_layoutCount == 0) {
1597  _layoutCount++;
1598  return;
1599  }
1600 
1601  QString layoutPrefix = QString("Layout%1-MainView");
1602  _multiView->restoreLayout( layoutPrefix.arg(_layoutCurrent), traceKey());
1603 
1604  updateLayoutActions();
1605 }
1606 
1607 
1608 void QCGTopLevel::updateLayoutActions()
1609 {
1610  if (_layoutNext)
1611  _layoutNext->setEnabled(_layoutCount>1);
1612 
1613  if (_layoutPrev)
1614  _layoutPrev->setEnabled(_layoutCount>1);
1615 
1616  if (_layoutRemove)
1617  _layoutRemove->setEnabled(_layoutCount>1);
1618 
1619  if (_statusbar)
1620  _statusbar->showMessage(tr("Layout Count: %1").arg(_layoutCount),
1621  1000);
1622 }
1623 
1624 
1625 void QCGTopLevel::updateStatusBar()
1626 {
1627  if (!_data || _data->parts().count()==0) {
1628  _statusLabel->setText(tr("No profile data file loaded."));
1629  return;
1630  }
1631 
1632  QString status = QString("%1 [%2] - ")
1633  .arg(_data->shortTraceName())
1634  .arg(_data->activePartRange());
1635 
1636  if (_eventType) {
1637  status += tr("Total %1 Cost: %2")
1638  .arg(_eventType->longName())
1639  .arg(_data->prettySubCost(_eventType));
1640 
1641  /* this gets too long...
1642  if (_eventType2 && (_eventType2 != _eventType))
1643  status += tr(", %1 Cost: %2")
1644  .arg(_eventType2->longName())
1645  .arg(_data->prettySubCost(_eventType2));
1646  */
1647  }
1648  else
1649  status += tr("No event type selected");
1650 
1651  /* Not working... should give group of selected function
1652 
1653  if (_groupType != ProfileContext::Function) {
1654  status += QString(" - %1 '%2'")
1655  .arg(ProfileContext::trTypeName(_groupType))
1656  .arg(_group ? _group->prettyName() : tr("(None)"));
1657  }
1658  */
1659 
1660  _statusLabel->setText(status);
1661 }
1662 
1663 
1664 void QCGTopLevel::closeEvent(QCloseEvent* event)
1665 {
1666  GlobalConfig::config()->saveOptions();
1667 
1668  saveTraceSettings();
1669  saveCurrentState(QString::null);
1670 
1671  // if part dock was chosen visible even for only 1 part loaded,
1672  // keep this choice...
1673  _forcePartDock = false;
1674  if (_data && (_data->parts().count()<2) && _partDock->isVisible())
1675  _forcePartDock=true;
1676 
1677  ConfigGroup* topConfig = ConfigStorage::group("TopWindow");
1678  topConfig->setValue("ForcePartDockVisible", _forcePartDock, false);
1679  topConfig->setValue("State", saveState());
1680  topConfig->setValue("Geometry", saveGeometry());
1681  delete topConfig;
1682 
1683  event->accept();
1684 }
1685 
1686 
1687 void QCGTopLevel::toggleSplitted()
1688 {
1689  int count = _multiView->childCount();
1690  if (count<1) count = 1;
1691  if (count>2) count = 2;
1692  count = 3-count;
1693  _multiView->setChildCount(count);
1694 
1695  _splittedToggleAction->setChecked(count>1);
1696  _splitDirectionToggleAction->setEnabled(count>1);
1697  _splitDirectionToggleAction->setChecked(_multiView->orientation() ==
1698  Qt::Horizontal);
1699 }
1700 
1701 void QCGTopLevel::toggleSplitDirection()
1702 {
1703  _multiView->setOrientation( _splitDirectionToggleAction->isChecked() ?
1704  Qt::Horizontal : Qt::Vertical );
1705 }
1706 
1707 
1708 
1709 // this is called after a config change in the dialog
1710 void QCGTopLevel::configChanged()
1711 {
1712  // invalidate found/cached dirs of source files
1713  if (_data)
1714  _data->resetSourceDirs();
1715 
1716  _partSelection->notifyChange(TraceItemView::configChanged);
1717  _stackSelection->refresh();
1718  _functionSelection->notifyChange(TraceItemView::configChanged);
1719  _multiView->notifyChange(TraceItemView::configChanged);
1720 }
1721 
1722 
1723 
1724 void QCGTopLevel::activePartsChangedSlot(const TracePartList& list)
1725 {
1726  if (!_data) return;
1727 
1728  if (!_data->activateParts(list)) {
1729 // qDebug("QCGTopLevel::activePartsChangedSlot: No Change!");
1730  return;
1731  }
1732  _activeParts = list;
1733 
1734  _partSelection->set(list);
1735  _stackSelection->refresh();
1736  _functionSelection->set(list);
1737  _multiView->set(list);
1738 
1739  updateStatusBar();
1740 }
1741 
1742 void QCGTopLevel::partsHideSelectedSlotDelayed()
1743 {
1744  QTimer::singleShot( 0, this, SLOT(partsHideSelectedSlot()) );
1745 }
1746 
1747 // this puts selected parts into hidden list,
1748 // deselects them and makes the remaining parts selected
1749 void QCGTopLevel::partsHideSelectedSlot()
1750 {
1751  if (!_data) return;
1752 
1753  TracePartList newHidden, newActive;
1754  foreach(TracePart* part, _data->parts()) {
1755  if (_activeParts.contains(part) ||
1756  _hiddenParts.contains(part))
1757  newHidden.append(part);
1758  else
1759  newActive.append(part);
1760  }
1761 
1762  _hiddenParts = newHidden;
1763  _partSelection->hiddenPartsChangedSlot(_hiddenParts);
1764 
1765 #if 0
1766  _mainWidget1->hiddenPartsChangedSlot(_hiddenParts);
1767  _mainWidget2->hiddenPartsChangedSlot(_hiddenParts);
1768 #endif
1769 
1770  activePartsChangedSlot(newActive);
1771 }
1772 
1773 void QCGTopLevel::partsUnhideAllSlotDelayed()
1774 {
1775  QTimer::singleShot( 0, this, SLOT(partsUnhideAllSlot()) );
1776 }
1777 
1778 // this unhides all hidden parts. Does NOT change selection
1779 void QCGTopLevel::partsUnhideAllSlot()
1780 {
1781  if (!_data) return;
1782 
1783  _hiddenParts.clear();
1784  _partSelection->hiddenPartsChangedSlot(_hiddenParts);
1785 
1786 #if 0
1787  _mainWidget1->hiddenPartsChangedSlot(_hiddenParts);
1788  _mainWidget2->hiddenPartsChangedSlot(_hiddenParts);
1789 #endif
1790 }
1791 
1792 void QCGTopLevel::forwardAboutToShow()
1793 {
1794  QMenu *popup = _forwardAction->menu();
1795 
1796  popup->clear();
1797  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1798  HistoryItem* hi = b ? b->current() : 0;
1799  TraceFunction* f;
1800  QAction* action;
1801 
1802  if (!hi) {
1803  popup->addAction(tr("(No Stack)"));
1804  return;
1805  }
1806 
1807  hi = hi->next();
1808  if (!hi) {
1809  popup->addAction(tr("(No next function)"));
1810  return;
1811  }
1812 
1813  int count = 1;
1814  while (count<GlobalConfig::maxSymbolCount() && hi) {
1815  f = hi->function();
1816  if (!f) break;
1817 
1818  QString name = GlobalConfig::shortenSymbol(f->prettyName());
1819 
1820  //qDebug("forward: Adding %s", name.toAscii());
1821  action = popup->addAction(name);
1822  action->setData(count);
1823 
1824  hi = hi->next();
1825  count++;
1826  }
1827 }
1828 
1829 void QCGTopLevel::backAboutToShow()
1830 {
1831  QMenu *popup = _backAction->menu();
1832 
1833  popup->clear();
1834  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1835  HistoryItem* hi = b ? b->current() : 0;
1836  TraceFunction* f;
1837  QAction* action;
1838 
1839  if (!hi) {
1840  popup->addAction(tr("(No Stack)"));
1841  return;
1842  }
1843 
1844  hi = hi->last();
1845  if (!hi) {
1846  popup->addAction(tr("(No previous function)"));
1847  return;
1848  }
1849 
1850  int count = 1;
1851  while (count<GlobalConfig::maxSymbolCount() && hi) {
1852  f = hi->function();
1853  if (!f) break;
1854 
1855  QString name = GlobalConfig::shortenSymbol(f->prettyName());
1856 
1857  //qDebug("back: Adding %s", name.toAscii());
1858  action = popup->addAction(name);
1859  action->setData(count);
1860 
1861  hi = hi->last();
1862  count++;
1863  }
1864 }
1865 
1866 void QCGTopLevel::upAboutToShow()
1867 {
1868  QMenu *popup = _upAction->menu();
1869 
1870  popup->clear();
1871  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1872  HistoryItem* hi = b ? b->current() : 0;
1873  TraceFunction* f = hi ? hi->function() : 0;
1874  QAction* action;
1875 
1876  if (!f) {
1877  popup->addAction(tr("(No Stack)"));
1878  return;
1879  }
1880  f = hi->stack()->caller(f, false);
1881  if (!f) {
1882  popup->addAction(tr("(No Function Up)"));
1883  return;
1884  }
1885 
1886  int count = 1;
1887  while (count<GlobalConfig::maxSymbolCount() && f) {
1888  QString name = GlobalConfig::shortenSymbol(f->prettyName());
1889 
1890  action = popup->addAction(name);
1891  action->setData(count);
1892 
1893  f = hi->stack()->caller(f, false);
1894  count++;
1895  }
1896 }
1897 
1898 void QCGTopLevel::forwardTriggered(QAction* action)
1899 {
1900  int count = action->data().toInt(0);
1901  //qDebug("forwardTriggered: %d", count);
1902  if( count <= 0)
1903  return;
1904 
1905  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1906  if (!b) return;
1907 
1908  while (count>1) {
1909  b->goForward();
1910  count--;
1911  }
1912  _stackSelection->browserForward();
1913 }
1914 
1915 void QCGTopLevel::backTriggered(QAction* action)
1916 {
1917  int count = action->data().toInt(0);
1918  //qDebug("backTriggered: %d", count);
1919  if( count <= 0)
1920  return;
1921 
1922  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1923  if (!b) return;
1924 
1925  while (count>1) {
1926  b->goBack();
1927  count--;
1928  }
1929  _stackSelection->browserBack();
1930 }
1931 
1932 void QCGTopLevel::upTriggered(QAction* action)
1933 {
1934  int count = action->data().toInt(0);
1935  //qDebug("upTriggered: %d", count);
1936  if( count <= 0)
1937  return;
1938 
1939  StackBrowser* b = _stackSelection ? _stackSelection->browser() : 0;
1940  HistoryItem* hi = b ? b->current() : 0;
1941  if (!hi) return;
1942 
1943  TraceFunction* f = hi->function();
1944 
1945  while (count>0 && f) {
1946  f = hi->stack()->caller(f, false);
1947  count--;
1948  }
1949 
1950  //qDebug("upActivated: %s", f ? f->prettyName().toAscii() : "??" );
1951  if (f)
1952  setFunction(f);
1953 }
1954 
1955 void QCGTopLevel::showMessage(const QString& msg, int ms)
1956 {
1957  if (_statusbar)
1958  _statusbar->showMessage(msg, ms);
1959 }
1960 
1961 void QCGTopLevel::showStatus(const QString& msg, int progress)
1962 {
1963  static bool msgUpdateNeeded = true;
1964 
1965  if (!_statusbar) return;
1966 
1967  if (msg.isEmpty()) {
1968  //reset status
1969  if (_progressBar) {
1970  _statusbar->removeWidget(_progressBar);
1971  delete _progressBar;
1972  _progressBar = 0;
1973  }
1974  _statusbar->clearMessage();
1975  _progressMsg = msg;
1976  return;
1977  }
1978 
1979  if (_progressMsg.isEmpty())
1980  _progressStart.start();
1981 
1982  if (msg != _progressMsg) {
1983  _progressMsg = msg;
1984  msgUpdateNeeded = true;
1985  }
1986 
1987  // do nothing if last change was less than 0.5 seconds ago
1988  if (_progressStart.elapsed() < 500)
1989  return;
1990 
1991  if (!_progressBar) {
1992  _progressBar = new QProgressBar(_statusbar);
1993  _progressBar->setMaximumSize(200, _statusbar->height()-4);
1994  _statusbar->addPermanentWidget(_progressBar, 1);
1995  _progressBar->show();
1996  msgUpdateNeeded = true;
1997  }
1998 
1999  _progressStart.restart();
2000 
2001  if (msgUpdateNeeded) {
2002  _statusbar->showMessage(msg);
2003  msgUpdateNeeded = false;
2004  }
2005  _progressBar->setValue(progress);
2006 
2007  // let the progress bar update itself
2008  qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
2009 }
2010 
2011 void QCGTopLevel::loadStart(const QString& filename)
2012 {
2013  showStatus(QString("Loading %1").arg(filename), 0);
2014  Logger::_filename = filename;
2015 }
2016 
2017 void QCGTopLevel::loadFinished(const QString& msg)
2018 {
2019  showStatus(QString::null, 0);
2020  if (!msg.isEmpty())
2021  showMessage(QString("Error loading %1: %2").arg(_filename).arg(msg),
2022  2000);
2023 }
2024 
2025 void QCGTopLevel::loadProgress(int progress)
2026 {
2027  showStatus(QString("Loading %1").arg(_filename), progress);
2028 }
2029 
2030 void QCGTopLevel::loadError(int line, const QString& msg)
2031 {
2032  qCritical() << "Loading" << _filename
2033  << ":" << line << ": " << msg;
2034 }
2035 
2036 void QCGTopLevel::loadWarning(int line, const QString& msg)
2037 {
2038  qWarning() << "Loading" << _filename
2039  << ":" << line << ": " << msg;
2040 }
2041 
2042 #include "qcgtoplevel.moc"
StackSelection::browser
StackBrowser * browser() const
Definition: stackselection.h:48
StackSelection::setEventType2
void setEventType2(EventType *)
Definition: stackselection.cpp:246
QCGTopLevel::updateStatusBar
void updateStatusBar()
Definition: qcgtoplevel.cpp:1625
QCGTopLevel::QCGTopLevel
QCGTopLevel()
Definition: qcgtoplevel.cpp:61
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
QCGTopLevel::eventType2
EventType * eventType2()
Definition: qcgtoplevel.h:72
HistoryItem::function
TraceFunction * function()
Definition: stackbrowser.h:71
GlobalConfig::showPercentage
static bool showPercentage()
Definition: globalconfig.cpp:328
PartSelection
Definition: partselection.h:38
QCGTopLevel::eventType
EventType * eventType()
Definition: qcgtoplevel.h:71
ProfileContext::Line
Definition: context.h:39
QCGTopLevel::layoutDuplicate
void layoutDuplicate()
Definition: qcgtoplevel.cpp:1508
QCGTopLevel::about
void about()
Definition: qcgtoplevel.cpp:611
QCGTopLevel::~QCGTopLevel
~QCGTopLevel()
Definition: qcgtoplevel.cpp:110
ProfileContext::FunctionCycle
Definition: context.h:46
QCGTopLevel::toggleHideTemplates
void toggleHideTemplates()
Definition: qcgtoplevel.cpp:699
MultiView::saveLayout
void saveLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:202
QCGTopLevel::loadProgress
virtual void loadProgress(int progress)
Definition: qcgtoplevel.cpp:2025
QCGTopLevel::createToolbar
void createToolbar()
Definition: qcgtoplevel.cpp:587
StackSelection::rebuildStackList
void rebuildStackList()
Definition: stackselection.cpp:109
QCGTopLevel::recentFilesMenuAboutToShow
void recentFilesMenuAboutToShow()
Definition: qcgtoplevel.cpp:232
TraceItemView::set
void set(ProfileContext::Type g)
Definition: traceitemview.h:115
QCGTopLevel::layoutRemove
void layoutRemove()
Definition: qcgtoplevel.cpp:1521
StackBrowser::goBack
HistoryItem * goBack()
Definition: stackbrowser.cpp:339
QCGTopLevel::setEventType2
bool setEventType2(EventType *)
Definition: qcgtoplevel.cpp:936
TraceItemView::setEventType2
void setEventType2(EventType *t)
Definition: traceitemview.h:114
ProfileContext::File
Definition: context.h:48
ProfileContext::typeName
static QString typeName(Type)
Definition: context.cpp:62
QCGTopLevel::togglePartDock
void togglePartDock()
Definition: qcgtoplevel.cpp:645
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
ConfigDialog::currentPage
QString currentPage()
Definition: configdialog.cpp:142
stackbrowser.h
CostItem::type
ProfileContext::Type type() const
Definition: costitem.h:45
StackSelection::setFunction
void setFunction(TraceFunction *)
Definition: stackselection.cpp:92
TraceData::command
QString command() const
Definition: tracedata.h:1448
QCGTopLevel::setGroupType
bool setGroupType(ProfileContext::Type)
Definition: qcgtoplevel.cpp:985
TraceItemView::configChanged
Definition: traceitemview.h:88
QCGTopLevel::createDocks
void createDocks()
Definition: qcgtoplevel.cpp:260
StackBrowser
Definition: stackbrowser.h:85
QCGTopLevel::groupTypeSelected
void groupTypeSelected(int)
Definition: qcgtoplevel.cpp:954
QCGTopLevel::closeEvent
void closeEvent(QCloseEvent *)
Definition: qcgtoplevel.cpp:1664
ProfileCostArray::prettySubCost
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
Definition: costitem.cpp:601
TraceItemView::setEventType
void setEventType(EventType *t)
Definition: traceitemview.h:113
TraceFunction
A traced function.
Definition: tracedata.h:1122
TraceCostItem
Definition: tracedata.h:980
QCGTopLevel::configure
void configure(QString page=QString::null)
Definition: qcgtoplevel.cpp:630
QCGTopLevel::toggleStackDock
void toggleStackDock()
Definition: qcgtoplevel.cpp:653
HighestCostList::clear
void clear(int maxSize)
Definition: subcost.cpp:75
QCGTopLevel::partsUnhideAllSlotDelayed
void partsUnhideAllSlotDelayed()
Definition: qcgtoplevel.cpp:1773
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
GraphExporter
GraphExporter.
Definition: callgraphview.h:298
CostItem
Base class for cost items.
Definition: costitem.h:37
FunctionSelection::setGroup
void setGroup(TraceCostItem *)
Definition: functionselection.cpp:548
config.h
QCGTopLevel::activePartsChangedSlot
void activePartsChangedSlot(const TracePartList &list)
Definition: qcgtoplevel.cpp:1724
QCGTopLevel::createActions
void createActions()
Definition: qcgtoplevel.cpp:320
GlobalConfig::config
static GlobalConfig * config()
Definition: globalconfig.cpp:145
TraceItemView::updateView
void updateView(bool force=false)
Definition: traceitemview.cpp:185
ProfileContext::Instr
Definition: context.h:38
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
QCGTopLevel::eventType2Selected
void eventType2Selected(const QString &)
Definition: qcgtoplevel.cpp:908
TraceData::activePartRange
QString activePartRange()
Definition: tracedata.cpp:3280
FunctionSelection::group
TraceCostItem * group()
Definition: functionselection.h:53
QCGTopLevel::layoutSave
void layoutSave()
Definition: qcgtoplevel.cpp:1568
Stack::caller
TraceFunction * caller(TraceFunction *, bool extend)
Definition: stackbrowser.cpp:134
StackBrowser::goForward
HistoryItem * goForward()
Definition: stackbrowser.cpp:347
QCGTopLevel::newWindow
void newWindow()
Definition: qcgtoplevel.cpp:748
stackselection.h
configdialog.h
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
QCGTopLevel::setTraceItemDelayed
void setTraceItemDelayed()
Definition: qcgtoplevel.cpp:1188
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
QCGTopLevel::partsUnhideAllSlot
void partsUnhideAllSlot()
Definition: qcgtoplevel.cpp:1779
QCGTopLevel::add
void add()
Definition: qcgtoplevel.cpp:804
QCGTopLevel
Definition: qcgtoplevel.h:51
PartSelection::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: partselection.cpp:483
QCGTopLevel::forwardAboutToShow
void forwardAboutToShow()
Definition: qcgtoplevel.cpp:1792
QCGTopLevel::toggleCycles
void toggleCycles()
Definition: qcgtoplevel.cpp:723
TraceData::parts
TracePartList parts() const
Definition: tracedata.h:1397
QCGTopLevel::loadFinished
virtual void loadFinished(const QString &msg)
Definition: qcgtoplevel.cpp:2017
QCGTopLevel::setAbsoluteCost
void setAbsoluteCost()
Definition: qcgtoplevel.cpp:675
tracedata.h
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
QCGTopLevel::backTriggered
void backTriggered(QAction *)
Definition: qcgtoplevel.cpp:1915
QCGTopLevel::setEventTypeDelayed
void setEventTypeDelayed()
Definition: qcgtoplevel.cpp:1096
GlobalConfig::setShowCycles
static void setShowCycles(bool)
Definition: globalconfig.cpp:364
MultiView::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:224
QCGTopLevel::setGroup
bool setGroup(TraceCostItem *)
Definition: qcgtoplevel.cpp:1029
QCGTopLevel::load
void load()
Definition: qcgtoplevel.cpp:755
MultiView
Definition: multiview.h:36
StackSelection::refresh
void refresh()
Definition: stackselection.cpp:209
QCGTopLevel::toggleSplitted
void toggleSplitted()
Definition: qcgtoplevel.cpp:1687
QCGTopLevel::goUp
void goUp()
Definition: qcgtoplevel.cpp:1410
MultiView::setData
void setData(TraceData *)
Definition: multiview.cpp:49
TraceData::updateFunctionCycles
void updateFunctionCycles()
Definition: tracedata.cpp:3675
HighestCostList
A class to calculate the ProfileCostArray items with highest cost.
Definition: subcost.h:78
QCGTopLevel::configChanged
void configChanged()
Definition: qcgtoplevel.cpp:1710
StackBrowser::canGoBack
bool canGoBack()
Definition: stackbrowser.cpp:377
StackSelection
Definition: stackselection.h:38
QCGTopLevel::exportGraph
void exportGraph()
Definition: qcgtoplevel.cpp:860
QCGTopLevel::goForward
void goForward()
Definition: qcgtoplevel.cpp:1405
TraceData::load
int load(QStringList files)
Loads profile data files.
Definition: tracedata.cpp:3130
StackSelection::browserForward
void browserForward()
Definition: stackselection.cpp:185
QCGTopLevel::toggleExpanded
void toggleExpanded()
Definition: qcgtoplevel.cpp:711
ConfigDialog
Definition: configdialog.h:40
QCGTopLevel::addEventTypeMenu
void addEventTypeMenu(QMenu *, bool)
Definition: qcgtoplevel.cpp:1296
CostItem::fullName
QString fullName() const
Returns type name + dynamic name.
Definition: costitem.cpp:76
GlobalConfig::showCycles
static bool showCycles()
Definition: globalconfig.cpp:338
QCGTopLevel::upAboutToShow
void upAboutToShow()
Definition: qcgtoplevel.cpp:1866
QCGTopLevel::eventTypeSelected
void eventTypeSelected(const QString &)
Definition: qcgtoplevel.cpp:900
QCGTopLevel::goBack
void goBack()
Definition: qcgtoplevel.cpp:1400
QCGTopLevel::setGroupTypeDelayed
void setGroupTypeDelayed()
Definition: qcgtoplevel.cpp:1112
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
QCGTopLevel::loadError
virtual void loadError(int line, const QString &msg)
Definition: qcgtoplevel.cpp:2030
StackSelection::setEventType
void setEventType(EventType *)
Definition: stackselection.cpp:235
QCGTopLevel::functionVisibilityChanged
void functionVisibilityChanged(bool)
Definition: qcgtoplevel.cpp:741
TraceItemView::activate
bool activate(CostItem *i)
Definition: traceitemview.cpp:110
EventTypeSet::derivedCount
int derivedCount()
Definition: eventtype.h:134
QCGTopLevel::updateLayoutActions
void updateLayoutActions()
Definition: qcgtoplevel.cpp:1608
FunctionSelection
Definition: functionselection.h:46
globalguiconfig.h
QCGTopLevel::loadWarning
virtual void loadWarning(int line, const QString &msg)
Definition: qcgtoplevel.cpp:2036
GlobalConfig::shortenSymbol
static QString shortenSymbol(const QString &)
Definition: globalconfig.cpp:395
ConfigGroup
A group of configuration settings.
Definition: config.h:35
TraceItemView::notifyChange
void notifyChange(int changeType)
Definition: traceitemview.h:120
Logger::_filename
QString _filename
Definition: logger.h:45
QCGTopLevel::setFunction
bool setFunction(TraceFunction *)
Definition: qcgtoplevel.cpp:1050
QCGTopLevel::addGoMenu
void addGoMenu(QMenu *)
Definition: qcgtoplevel.cpp:1387
HistoryItem::next
HistoryItem * next()
Definition: stackbrowser.h:73
GlobalGUIConfig::config
static GlobalGUIConfig * config()
Definition: globalguiconfig.cpp:88
TraceItemView::Forward
Definition: traceitemview.h:90
QCGTopLevel::showStatus
void showStatus(const QString &msg, int progress)
Definition: qcgtoplevel.cpp:1961
QCGTopLevel::loadDelayed
void loadDelayed(QString file, bool addToRecentFiles=true)
Definition: qcgtoplevel.cpp:835
QCGTopLevel::setEventType2Delayed
void setEventType2Delayed()
Definition: qcgtoplevel.cpp:1101
PartSelection::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: partselection.cpp:525
FunctionSelection::setData
void setData(TraceData *)
Definition: functionselection.cpp:232
QCGTopLevel::upTriggered
void upTriggered(QAction *)
Definition: qcgtoplevel.cpp:1932
HighestCostList::addCost
void addCost(ProfileCostArray *, SubCost)
Definition: subcost.cpp:83
QCGTopLevel::setEventType
bool setEventType(EventType *)
Definition: qcgtoplevel.cpp:916
EventTypeSet::realType
EventType * realType(int)
Definition: eventtype.cpp:462
QCGTopLevel::setRelativeCost
void setRelativeCost()
Definition: qcgtoplevel.cpp:680
HistoryItem::last
HistoryItem * last()
Definition: stackbrowser.h:72
TracePart
A Trace Part: All data read from a trace file, containing all costs that happened in a specified time...
Definition: tracedata.h:655
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
QCGTopLevel::createMenu
void createMenu()
Definition: qcgtoplevel.cpp:536
QCGTopLevel::backAboutToShow
void backAboutToShow()
Definition: qcgtoplevel.cpp:1829
TraceData::shortTraceName
QString shortTraceName() const
Definition: tracedata.cpp:3093
TraceItemView::Direction
Direction
Definition: traceitemview.h:90
qcgtoplevel.h
ProfileContext::Type
Type
Definition: context.h:36
QCGTopLevel::data
TraceData * data()
Definition: qcgtoplevel.h:60
MultiView::restoreLayout
void restoreLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:169
GlobalConfig::hideTemplates
static bool hideTemplates()
Definition: globalconfig.cpp:343
TraceData::resetSourceDirs
void resetSourceDirs()
Definition: tracedata.cpp:3498
QCGTopLevel::setPercentage
void setPercentage(bool)
Definition: qcgtoplevel.cpp:685
QCGTopLevel::layoutRestore
void layoutRestore()
Definition: qcgtoplevel.cpp:1589
QCGTopLevel::setDirectionDelayed
void setDirectionDelayed()
Definition: qcgtoplevel.cpp:1140
QCGTopLevel::recentFilesTriggered
void recentFilesTriggered(QAction *)
Definition: qcgtoplevel.cpp:254
EventType::longName
const QString & longName()
Definition: eventtype.h:66
TracePartList
QList< TracePart * > TracePartList
Definition: tracedata.h:176
EventTypeSet
A class for managing a set of event types.
Definition: eventtype.h:117
QCGTopLevel::toggleFunctionDock
void toggleFunctionDock()
Definition: qcgtoplevel.cpp:661
QCGTopLevel::groupType
ProfileContext::Type groupType()
Definition: qcgtoplevel.h:70
QCGTopLevel::partsHideSelectedSlotDelayed
void partsHideSelectedSlotDelayed()
Definition: qcgtoplevel.cpp:1742
MultiView::setChildCount
void setChildCount(int)
Definition: multiview.cpp:57
GlobalConfig::saveOptions
virtual void saveOptions()
Definition: globalconfig.cpp:154
HistoryItem
Definition: stackbrowser.h:64
TraceData::functionMap
TraceFunctionMap & functionMap()
Definition: tracedata.h:1441
QCGTopLevel::sidebarMenuAboutToShow
void sidebarMenuAboutToShow()
Definition: qcgtoplevel.cpp:209
ProfileContext::Object
Definition: context.h:49
QCGTopLevel::loadFilesDelayed
void loadFilesDelayed()
Definition: qcgtoplevel.cpp:851
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
QCGTopLevel::layoutPrevious
void layoutPrevious()
Definition: qcgtoplevel.cpp:1553
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
QCGTopLevel::toggleSplitDirection
void toggleSplitDirection()
Definition: qcgtoplevel.cpp:1701
EventTypeSet::derivedType
EventType * derivedType(int)
Definition: eventtype.cpp:468
MultiView::childCount
int childCount()
Definition: multiview.h:50
QCGTopLevel::setData
void setData(TraceData *)
A TraceData object cannot be viewed many times in different toplevel windows.
Definition: qcgtoplevel.cpp:1226
callgraphview.h
GlobalConfig::setShowExpanded
static void setShowExpanded(bool)
Definition: globalconfig.cpp:356
QCGTopLevel::loadStart
virtual void loadStart(const QString &filename)
Definition: qcgtoplevel.cpp:2011
QCGTopLevel::setGroupDelayed
void setGroupDelayed()
Definition: qcgtoplevel.cpp:1129
MultiView::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:231
QCGTopLevel::forwardTriggered
void forwardTriggered(QAction *)
Definition: qcgtoplevel.cpp:1898
QCGTopLevel::togglePercentage
void togglePercentage()
Definition: qcgtoplevel.cpp:669
StackBrowser::canGoForward
bool canGoForward()
Definition: stackbrowser.cpp:382
GlobalConfig::maxSymbolCount
static int maxSymbolCount()
Definition: globalconfig.cpp:407
TraceData::traceName
QString traceName() const
Definition: tracedata.h:1401
partselection.h
QCGTopLevel::partsHideSelectedSlot
void partsHideSelectedSlot()
Definition: qcgtoplevel.cpp:1749
EventType::name
const QString & name()
Definition: eventtype.h:65
ProfileContext::Function
Definition: context.h:46
PartSelection::setData
void setData(TraceData *)
Definition: partselection.cpp:130
QCGTopLevel::layoutNext
void layoutNext()
Definition: qcgtoplevel.cpp:1538
ProfileContext::InvalidType
Definition: context.h:37
ConfigGroup::value
virtual QVariant value(const QString &key, const QVariant &defaultValue) const
Definition: config.cpp:60
QCGTopLevel::showMessage
void showMessage(const QString &, int msec)
Definition: qcgtoplevel.cpp:1955
TraceData::invalidateDynamicCost
void invalidateDynamicCost()
Definition: tracedata.cpp:3306
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:27 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
  • okteta
  • 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