• 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
  • libviews
stackitem.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 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  * Items of stack dockable.
21  */
22 
23 #include "stackitem.h"
24 
25 #include <QPixmap>
26 
27 #include "globalguiconfig.h"
28 #include "listutils.h"
29 #include "stackselection.h"
30 
31 
32 // StackItem
33 
34 StackItem::StackItem(StackSelection* ss,
35  QTreeWidget* parent, TraceFunction* f)
36  :QTreeWidgetItem(parent)
37 {
38  _view = ss;
39  _function = f;
40  _call = 0;
41 
42  setTextAlignment(0, Qt::AlignRight);
43  setTextAlignment(1, Qt::AlignRight);
44  setTextAlignment(2, Qt::AlignRight);
45 
46  updateGroup();
47  updateCost();
48 
49  setText(2, QString("-- "));
50  setText(3, f->prettyName());
51 }
52 
53 StackItem::StackItem(StackSelection* ss,
54  QTreeWidget* parent, TraceCall* call)
55  :QTreeWidgetItem(parent)
56 {
57  _view = ss;
58  _call = call;
59  _function = call->called();
60 
61  setTextAlignment(0, Qt::AlignRight);
62  setTextAlignment(1, Qt::AlignRight);
63  setTextAlignment(2, Qt::AlignRight);
64 
65  updateGroup();
66  updateCost();
67 
68  setText(3, _function->prettyName());
69 }
70 
71 
72 void StackItem::updateGroup()
73 {
74  QColor c = GlobalGUIConfig::functionColor(_view->groupType(),
75  _function);
76  setIcon(3, colorPixmap(10, 10, c));
77 }
78 
79 void StackItem::updateCost()
80 {
81  if (!_call) return;
82 
83  setText(2, _call->prettyCallCount());
84 
85  EventType* ct = _view->eventType();
86  _sum = _call->subCost(ct);
87  double total = _call->called()->data()->subCost(ct);
88  if (total == 0.0) {
89  setText(0, "-");
90  setIcon(0, QPixmap());
91  }
92  else {
93  double sum = 100.0 * _sum / total;
94 
95  if (GlobalConfig::showPercentage())
96  setText(0, QString("%1")
97  .arg(sum, 0, 'f', GlobalConfig::percentPrecision()));
98  else
99  setText(0, _call->prettySubCost(ct));
100 
101  setIcon(0, costPixmap(ct, _call, total, false));
102  }
103 
104  // if _eventType2 is 0, column1 is hidden, no change needed
105  EventType* ct2 = _view->eventType2();
106  if (!ct2) return;
107 
108  _sum = _call->subCost(ct2);
109  total = _call->called()->data()->subCost(ct2);
110  if (total == 0.0) {
111  setText(1, "-");
112  setIcon(1, QPixmap());
113  }
114  else {
115  double sum = 100.0 * _sum / total;
116 
117  if (GlobalConfig::showPercentage())
118  setText(1, QString("%1")
119  .arg(sum, 0, 'f', GlobalConfig::percentPrecision()));
120  else
121  setText(1, _call->prettySubCost(ct2));
122 
123  setIcon(1, costPixmap(ct2, _call, total, false));
124  }
125 }
StackSelection::eventType2
EventType * eventType2()
Definition: stackselection.h:50
StackItem::StackItem
StackItem(StackSelection *ss, QTreeWidget *parent, TraceFunction *f)
Definition: stackitem.cpp:34
GlobalConfig::showPercentage
static bool showPercentage()
Definition: globalconfig.cpp:328
ProfileCostArray::subCost
SubCost subCost(EventType *)
Returns a sub cost.
Definition: costitem.cpp:591
QTreeWidget
GlobalGUIConfig::functionColor
static QColor functionColor(ProfileContext::Type gt, TraceFunction *)
Definition: globalguiconfig.cpp:205
ProfileCostArray::prettySubCost
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
Definition: costitem.cpp:601
TraceFunction
A traced function.
Definition: tracedata.h:1122
StackSelection::groupType
ProfileContext::Type groupType()
Definition: stackselection.h:51
stackselection.h
EventType
A cost type, e.g.
Definition: eventtype.h:43
StackSelection
Definition: stackselection.h:38
listutils.h
StackItem::call
TraceCall * call()
Definition: stackitem.h:43
TraceCallCost::prettyCallCount
QString prettyCallCount()
Definition: tracedata.cpp:114
TraceFunction::prettyName
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
Definition: tracedata.cpp:1889
CostItem::data
virtual TraceData * data()
Definition: costitem.cpp:111
globalguiconfig.h
QTreeWidgetItem
stackitem.h
GlobalConfig::percentPrecision
static int percentPrecision()
Definition: globalconfig.cpp:385
TraceCall::called
TraceFunction * called(bool skipCycle=false) const
Definition: tracedata.cpp:1235
StackItem::updateGroup
void updateGroup()
Definition: stackitem.cpp:72
TraceCall
A call from one to another function.
Definition: tracedata.h:835
StackItem::updateCost
void updateCost()
Definition: stackitem.cpp:79
costPixmap
QPixmap costPixmap(EventType *ct, ProfileCostArray *cost, double total, bool framed)
Definition: listutils.cpp:217
colorPixmap
QPixmap colorPixmap(int w, int h, QColor c)
Definition: listutils.cpp:32
StackSelection::eventType
EventType * eventType()
Definition: stackselection.h:49
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