• 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
callitem.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  * Items for caller/callee view.
21  */
22 
23 #include "callitem.h"
24 
25 #include <QPixmap>
26 
27 #include "globalguiconfig.h"
28 #include "listutils.h"
29 #include "callview.h"
30 
31 
32 // CallItem
33 
34 
35 CallItem::CallItem(CallView* view, QTreeWidget* parent, TraceCall* c)
36  : QTreeWidgetItem(parent)
37 {
38  for (int i = 0 ; i < 5; ++i)
39  setTextAlignment(i, Qt::AlignRight);
40 
41  _call = c;
42  _view = view;
43 
44  _active = _view->activeFunction();
45  bool baseIsCycle = (_active && (_active == _active->cycle()));
46 
47  QString fName;
48  if (_view->showCallers()) {
49  _shown = _call->caller(true);
50  fName = c->callerName(!baseIsCycle);
51  }
52  else {
53  _shown = _call->called(true);
54  fName = c->calledName(!baseIsCycle);
55  }
56 
57  _shown->addPrettyLocation(fName);
58 
59  setText(5, fName);
60  updateGroup();
61  updateCost();
62 }
63 
64 void CallItem::updateGroup()
65 {
66  QColor c = GlobalGUIConfig::functionColor(_view->groupType(), _shown);
67  setIcon(5, colorPixmap(10, 10, c));
68 }
69 
70 void CallItem::updateCost()
71 {
72  bool sameCycle = _shown->cycle() && (_active->cycle() == _shown->cycle());
73  bool shownIsCycle = (_shown == _shown->cycle());
74  bool selectedIsCycle = (_active == _active->cycle());
75  if (_call->isRecursion()) sameCycle=true;
76 
77  QString cStr;
78  if ((selectedIsCycle || shownIsCycle) && sameCycle)
79  cStr = "-";
80  else {
81  _cc = _call->callCount();
82  if (_cc == 0)
83  cStr = QObject::tr("(active)");
84  else
85  cStr = _call->prettyCallCount();
86  }
87  setText(4, cStr);
88 
89  ProfileCostArray* totalCost;
90  if (GlobalConfig::showExpanded()) {
91  if (_active->cycle())
92  totalCost = _active->cycle()->inclusive();
93  else
94  totalCost = _active->inclusive();
95  }
96  else
97  totalCost = _active->data();
98 
99  EventType* ct = _view->eventType();
100  _sum = _call->subCost(ct);
101  double total = totalCost->subCost(ct);
102 
103  if (total == 0.0) {
104  QString str = "-";
105 
106  setText(0, str);
107  setIcon(0, QPixmap());
108  }
109  else {
110  double sum = 100.0 * _sum / total;
111 
112  if (GlobalConfig::showPercentage())
113  setText(0, QString("%1")
114  .arg(sum, 0, 'f', GlobalConfig::percentPrecision()));
115  else {
116  setText(0, _call->prettySubCost(ct));
117  }
118  setIcon(0, costPixmap(ct, _call, total, false));
119  setText(1, _call->prettySubCostPerCall(ct, _cc));
120  }
121 
122  // Cost Type 2
123  EventType* ct2 = _view->eventType2();
124  if (ct2) {
125  _sum2 = _call->subCost(ct2);
126  double total = totalCost->subCost(ct2);
127 
128  if (total == 0.0) {
129  QString str = "-";
130 
131  setText(2, str);
132  setIcon(2, QPixmap());
133  }
134  else {
135  double sum = 100.0 * _sum2 / total;
136 
137  if (GlobalConfig::showPercentage())
138  setText(2, QString("%1")
139  .arg(sum, 0, 'f', GlobalConfig::percentPrecision()));
140  else {
141  setText(2, _call->prettySubCost(ct2));
142  }
143  setIcon(2, costPixmap(ct2, _call, total, false));
144  setText(3, _call->prettySubCostPerCall(ct, _cc));
145  }
146  }
147 
148  QPixmap p;
149  if (sameCycle && !selectedIsCycle && !shownIsCycle) {
150 
151  QString icon = "edit-undo";
152 #if 0 // TODO
153  KIconLoader* loader = KIconLoader::global();
154  p= loader->loadIcon(icon, KIconLoader::Small, 0,
155  KIconLoader::DefaultState, QStringList(), 0, true);
156 #endif
157  }
158  setIcon(4, p);
159 }
160 
161 
162 bool CallItem::operator<(const QTreeWidgetItem& other) const
163 {
164  int col = treeWidget()->sortColumn();
165  const CallItem* ci1 = this;
166  const CallItem* ci2 = (CallItem*) &other;
167 
168  if (col==0)
169  return ci1->_sum < ci2->_sum;
170 
171  if (col==1)
172  return ci1->_sum2 < ci2->_sum2;
173 
174  if (col==2)
175  return ci1->_cc < ci2->_cc;
176 
177  return QTreeWidgetItem::operator <(other);
178 }
179 
CallView
Definition: callview.h:30
callitem.h
TraceCall::isRecursion
bool isRecursion()
Definition: tracedata.h:844
TraceItemView::eventType2
EventType * eventType2() const
Definition: traceitemview.h:152
GlobalConfig::showPercentage
static bool showPercentage()
Definition: globalconfig.cpp:328
ProfileCostArray::subCost
SubCost subCost(EventType *)
Returns a sub cost.
Definition: costitem.cpp:591
TraceItemView::eventType
EventType * eventType() const
Definition: traceitemview.h:151
QTreeWidget
TraceCall::caller
TraceFunction * caller(bool skipCycle=false) const
Definition: tracedata.cpp:1230
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
TraceCallCost::callCount
SubCost callCount()
Definition: tracedata.cpp:125
TraceFunction::cycle
TraceFunctionCycle * cycle()
Definition: tracedata.h:1200
CallItem::updateGroup
void updateGroup()
Definition: callitem.cpp:64
TraceItemView::activeFunction
TraceFunction * activeFunction()
Definition: traceitemview.cpp:121
EventType
A cost type, e.g.
Definition: eventtype.h:43
TraceCall::callerName
QString callerName(bool skipCycle=false) const
Definition: tracedata.cpp:1248
CallItem::view
CallView * view()
Definition: callitem.h:38
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
listutils.h
CallItem::operator<
bool operator<(const QTreeWidgetItem &other) const
Definition: callitem.cpp:162
TraceCallCost::prettyCallCount
QString prettyCallCount()
Definition: tracedata.cpp:114
CostItem::data
virtual TraceData * data()
Definition: costitem.cpp:111
globalguiconfig.h
ProfileCostArray::prettySubCostPerCall
QString prettySubCostPerCall(EventType *t, int calls)
Definition: costitem.cpp:606
QTreeWidgetItem
CallItem
Definition: callitem.h:31
CallView::showCallers
bool showCallers() const
Definition: callview.h:40
GlobalConfig::showExpanded
static bool showExpanded()
Definition: globalconfig.cpp:333
GlobalConfig::percentPrecision
static int percentPrecision()
Definition: globalconfig.cpp:385
CallItem::updateCost
void updateCost()
Definition: callitem.cpp:70
TraceCall::called
TraceFunction * called(bool skipCycle=false) const
Definition: tracedata.cpp:1235
callview.h
TraceFunction::addPrettyLocation
void addPrettyLocation(QString &, int maxFiles=1) const
Definition: tracedata.cpp:2055
CallItem::CallItem
CallItem(CallView *, QTreeWidget *, TraceCall *c)
Definition: callitem.cpp:35
TraceCall
A call from one to another function.
Definition: tracedata.h:835
TraceItemView::groupType
ProfileContext::Type groupType() const
Definition: traceitemview.h:153
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
TraceCall::calledName
QString calledName(bool skipCycle=false) const
Definition: tracedata.cpp:1264
TraceInclusiveCost::inclusive
ProfileCostArray * inclusive()
Definition: tracedata.cpp:163
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:26 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