• 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
costlistitem.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002-2011 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 #include "costlistitem.h"
20 
21 #include <math.h>
22 
23 #include <QPixmap>
24 
25 #include "listutils.h"
26 #include "coverage.h"
27 #include "globalguiconfig.h"
28 
29 
30 // CostListItem
31 
32 
33 CostListItem::CostListItem(QTreeWidget* parent, TraceCostItem* costItem,
34  EventType* et, int size)
35  :QTreeWidgetItem(parent)
36 {
37  _groupSize = size;
38  _skipped = 0;
39  _costItem = costItem;
40  setEventType(et);
41 
42  setTextAlignment(0, Qt::AlignRight);
43 
44  if (costItem) {
45  updateName();
46  setIcon(1, colorPixmap(10, 10,
47  GlobalGUIConfig::groupColor(_costItem)));
48  }
49 }
50 
51 CostListItem::CostListItem(QTreeWidget* parent, int skipped,
52  TraceCostItem* costItem, EventType* et)
53  :QTreeWidgetItem(parent)
54 {
55  _skipped = skipped;
56  _costItem = costItem;
57  setEventType(et);
58 
59  setTextAlignment(0, Qt::AlignRight);
60 
61  setText(1, QObject::tr("(%n item(s) skipped)", "", _skipped));
62 }
63 
64 void CostListItem::setEventType(EventType* et)
65 {
66  _eventType = et;
67  update();
68 }
69 
70 void CostListItem::updateName()
71 {
72  if (!_costItem) return;
73 
74  QString n = _costItem->prettyName();
75  if (_groupSize>=0) n += QString(" (%1)").arg(_groupSize);
76 
77  setText(1, n);
78 }
79 
80 void CostListItem::setSize(int s)
81 {
82  _groupSize = s;
83  updateName();
84 }
85 
86 void CostListItem::update()
87 {
88  if (!_costItem) return;
89  TraceData* d = _costItem->data();
90 
91  double total = d->subCost(_eventType);
92  if (total == 0.0) {
93  setText(0, QString("---"));
94  setIcon(0, QPixmap());
95  return;
96  }
97 
98  _pure = _costItem->subCost(_eventType);
99  double pure = 100.0 * _pure / total;
100  QString str;
101  if (GlobalConfig::showPercentage())
102  str = QString("%1").arg(pure, 0, 'f', GlobalConfig::percentPrecision());
103  else
104  str = _costItem->prettySubCost(_eventType);
105 
106  if (_skipped) {
107  // special handling for skip entries...
108  setText(0, QString("< %1").arg(str));
109  return;
110  }
111 
112  setText(0, str);
113  setIcon(0, costPixmap(_eventType, _costItem, total, false));
114 }
115 
116 bool CostListItem::operator< ( const QTreeWidgetItem & other ) const
117 {
118  const CostListItem* fi1 = this;
119  const CostListItem* fi2 = (CostListItem*) &other;
120  int col = treeWidget()->sortColumn();
121 
122  // a skip entry is always sorted last
123  if (fi1->_skipped) return true;
124  if (fi2->_skipped) return false;
125 
126  if (col==0)
127  return (fi1->_pure < fi2->_pure);
128 
129  return QTreeWidgetItem::operator <(other);
130 }
GlobalConfig::showPercentage
static bool showPercentage()
Definition: globalconfig.cpp:328
CostListItem::setSize
void setSize(int s)
Definition: costlistitem.cpp:80
CostListItem::setEventType
void setEventType(EventType *et)
Definition: costlistitem.cpp:64
ProfileCostArray::subCost
SubCost subCost(EventType *)
Returns a sub cost.
Definition: costitem.cpp:591
QTreeWidget
ProfileCostArray::prettySubCost
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
Definition: costitem.cpp:601
TraceCostItem
Definition: tracedata.h:980
CostListItem::costItem
TraceCostItem * costItem()
Definition: costlistitem.h:36
CostListItem::CostListItem
CostListItem(QTreeWidget *parent, TraceCostItem *cost, EventType *et, int size=-1)
Definition: costlistitem.cpp:33
EventType
A cost type, e.g.
Definition: eventtype.h:43
GlobalGUIConfig::groupColor
static QColor groupColor(CostItem *)
Definition: globalguiconfig.cpp:188
CostListItem::operator<
bool operator<(const QTreeWidgetItem &other) const
Definition: costlistitem.cpp:116
listutils.h
coverage.h
CostItem::data
virtual TraceData * data()
Definition: costitem.cpp:111
globalguiconfig.h
QTreeWidgetItem
CostListItem
Definition: costlistitem.h:26
GlobalConfig::percentPrecision
static int percentPrecision()
Definition: globalconfig.cpp:385
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
CostItem::prettyName
virtual QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
Definition: costitem.cpp:65
CostListItem::update
void update()
Definition: costlistitem.cpp:86
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
costlistitem.h
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