42 #define DEFAULT_SPLITMODE "Rows"
43 #define DEFAULT_DRAWNAME true
44 #define DEFAULT_DRAWCOST true
45 #define DEFAULT_DRAWLOCATION false
46 #define DEFAULT_DRAWCALLS false
47 #define DEFAULT_FORCESTRINGS false
48 #define DEFAULT_ROTATION true
49 #define DEFAULT_SHADING true
50 #define DEFAULT_STOPNAME ""
51 #define DEFAULT_MAXDEPTH -1
52 #define DEFAULT_MAXAREA 100
56 QWidget* parent,
const char* name)
100 QString s = _showCallers ?
101 tr(
"<b>Caller Map</b>"
102 "<p>This graph shows the nested hierarchy of "
103 "all callers of the current activated function. "
104 "Each colored rectangle represents a function; "
105 "its size tries to be proportional to the cost spent "
106 "therein while the active function is running "
107 "(however, there are drawing constraints).</p>") :
109 "<p>This graph shows the nested hierarchy of "
110 "all callees of the current activated function. "
111 "Each colored rectangle represents a function; "
112 "its size tries to be proportional to the cost spent "
113 "therein while the active function is running "
114 "(however, there are drawing constraints).</p>");
116 s += tr(
"<p>Appearance options can be found in the "
117 "in the context menu. To get exact size proportions, "
118 "choose 'Hide incorrect borders'. As this mode can be "
119 "<em>very</em> time consuming, you may want to limit "
120 "the maximum drawn nesting level before. "
121 "'Best' determinates the split direction for children "
122 "from the aspect ratio of the parent. "
123 "'Always Best' decides on remaining space for each "
125 "'Ignore Proportions' takes space for function name "
126 "drawing <em>before</em> drawing children. Note that "
127 "size proportions can get <em>heavily</em> wrong.</p>"
129 "<p>This is a <em>TreeMap</em> widget. "
130 "Keyboard navigation is available with the left/right arrow "
131 "keys for traversing siblings, and up/down arrow keys "
132 "to go a nesting level up/down. "
133 "<em>Return</em> activates the current item.</p>");
145 void CallMapView::addItemListMenu(QMenu* menu,
TreeMapItem* item)
149 QMenu* m = menu->addMenu(tr(
"Go To"));
152 QString name = item->
text(0);
154 a->setData(QVariant::fromValue( (
void*)item ));
158 connect(m, SIGNAL(triggered(QAction*)),
159 this, SLOT(mapItemTriggered(QAction*)) );
162 void CallMapView::mapItemTriggered(QAction* a)
164 activatedSlot( (
TreeMapItem*) a->data().value<
void*>() );
167 QAction* CallMapView::addDrawingDepthAction(QMenu* m,
168 const QString& s,
int d)
170 QAction* a = m->addAction(s);
172 a->setCheckable(
true);
177 void CallMapView::addDrawingDepthMenu(QMenu* menu,
180 QMenu* m = menu->addMenu(tr(
"Stop at Depth"));
181 addDrawingDepthAction(m, tr(
"No Depth Limit"), -1);
183 addDrawingDepthAction(m, tr(
"Depth 10"), 10);
184 addDrawingDepthAction(m, tr(
"Depth 15"), 15);
185 addDrawingDepthAction(m, tr(
"Depth 20"), 20);
188 addDrawingDepthAction(m, tr(
"Depth of '%1' (%2)")
189 .arg(name).arg(i->
depth()),
195 addDrawingDepthAction(m, tr(
"Decrement Depth (to %1)").arg(maxDepth-1),
197 addDrawingDepthAction(m, tr(
"Increment Depth (to %1)").arg(maxDepth+1),
201 connect(m, SIGNAL(triggered(QAction*)),
202 this, SLOT(drawingDepthTriggered(QAction*)) );
205 void CallMapView::drawingDepthTriggered(QAction* a)
210 QAction* CallMapView::addStopFunctionAction(QMenu* m,
214 QAction* a = m->addAction(s);
216 a->setCheckable(
true);
221 void CallMapView::addStopFunctionMenu(QMenu* menu,
TreeMapItem* item)
223 QMenu* m = menu->addMenu(tr(
"Stop at Function"));
224 addStopFunctionAction(m, tr(
"No Function Limit"), QString());
226 bool foundStopName =
false;
233 a = addStopFunctionAction(m, name, item->
text(0));
234 if (a->isChecked()) foundStopName =
true;
239 if (!foundStopName && !
fieldStop(0).isEmpty()) {
242 addStopFunctionAction(m, name,
fieldStop(0));
245 connect(m, SIGNAL(triggered(QAction*)),
246 this, SLOT(stopFunctionTriggered(QAction*)) );
249 void CallMapView::stopFunctionTriggered(QAction* a)
254 QAction* CallMapView::addAreaLimitAction(QMenu* m,
255 const QString& s,
int v)
257 QAction* a = m->addAction(s);
259 a->setCheckable(
true);
264 void CallMapView::addAreaLimitMenu(QMenu* menu,
TreeMapItem* i,
267 QMenu* m = menu->addMenu(tr(
"Stop at Area"));
268 addAreaLimitAction(m, tr(
"No Area Limit"), -1);
270 addAreaLimitAction(m, tr(
"100 Pixels"), 100);
271 addAreaLimitAction(m, tr(
"200 Pixels"), 200);
272 addAreaLimitAction(m, tr(
"500 Pixels"), 500);
273 addAreaLimitAction(m, tr(
"1000 Pixels"), 1000);
279 addAreaLimitAction(m, tr(
"Area of '%1' (%2)")
280 .arg(name).arg(currentArea), currentArea);
285 addAreaLimitAction(m, tr(
"Double Area Limit (to %1)")
286 .arg(mArea*2), mArea*2);
287 addAreaLimitAction(m, tr(
"Half Area Limit (to %1)")
288 .arg(mArea/2), mArea/2);
291 connect(m, SIGNAL(triggered(QAction*)),
292 this, SLOT(areaLimitTriggered(QAction*)) );
295 void CallMapView::areaLimitTriggered(QAction* a)
300 QAction* CallMapView::addBorderWidthAction(QMenu* m,
const QString& s,
int v)
302 QAction* a = m->addAction(s);
304 a->setCheckable(
true);
309 void CallMapView::borderWidthTriggered(QAction* a)
314 void CallMapView::context(
TreeMapItem* i,
const QPoint & p)
321 QString shortCurrentName;
327 addItemListMenu(&popup, i);
328 popup.addSeparator();
331 popup.addSeparator();
332 addDrawingDepthMenu(&popup, i, shortCurrentName);
333 addStopFunctionMenu(&popup, i);
334 addAreaLimitMenu(&popup, i, shortCurrentName);
335 popup.addSeparator();
337 QMenu* vpopup = popup.addMenu(tr(
"Visualization"));
338 QMenu* spopup = vpopup->addMenu(tr(
"Split Direction"));
341 QAction* skipBorderAction = vpopup->addAction(tr(
"Skip Incorrect Borders"));
342 skipBorderAction->setEnabled(!_showCallers);
343 skipBorderAction->setCheckable(
true);
346 QMenu* bpopup = vpopup->addMenu(tr(
"Border Width"));
347 a = addBorderWidthAction(bpopup, tr(
"Border 0"), 0);
348 a->setEnabled(!_showCallers);
349 addBorderWidthAction(bpopup, tr(
"Border 1"), 1);
350 addBorderWidthAction(bpopup, tr(
"Border 2"), 2);
351 addBorderWidthAction(bpopup, tr(
"Border 3"), 3);
352 connect(bpopup, SIGNAL(triggered(QAction*)),
353 this, SLOT(borderWidthTriggered(QAction*)) );
354 vpopup->addSeparator();
356 QAction* drawNamesAction = vpopup->addAction(tr(
"Draw Symbol Names"));
357 drawNamesAction->setCheckable(
true);
358 QAction* drawCostAction = vpopup->addAction(tr(
"Draw Cost"));
359 drawCostAction->setCheckable(
true);
360 QAction* drawLocationAction = vpopup->addAction(tr(
"Draw Location"));
361 drawLocationAction->setCheckable(
true);
362 QAction* drawCallsAction = vpopup->addAction(tr(
"Draw Calls"));
363 drawCallsAction->setCheckable(
true);
364 vpopup->addSeparator();
366 QAction* ignorePropAction = vpopup->addAction(tr(
"Ignore Proportions"));
367 ignorePropAction->setCheckable(
true);
368 QAction* allowRotationAction = vpopup->addAction(tr(
"Allow Rotation"));
369 allowRotationAction->setCheckable(
true);
374 ignorePropAction->setEnabled(
false);
375 allowRotationAction->setEnabled(
false);
386 QAction* drawShadingAction = vpopup->addAction(tr(
"Shading"));
387 drawShadingAction->setCheckable(
true);
390 a = popup.exec(mapToGlobal(p));
391 if (a == drawNamesAction)
393 else if (a == drawCostAction)
395 else if (a == drawLocationAction)
397 else if (a == drawCallsAction)
399 else if (a == ignorePropAction) {
406 else if (a == allowRotationAction)
408 else if (a == drawShadingAction)
410 else if (a == skipBorderAction)
418 if (item->
rtti() == 1) {
422 else if (item->
rtti() == 2) {
426 else if (item->
rtti() == 3) {
432 void CallMapView::selectedSlot(
TreeMapItem* item,
bool kbd)
435 if (item->
text(0).isEmpty())
return;
438 QString msg = tr(
"Call Map: Current is '%1'").arg(item->
text(0));
445 if (item->
rtti() == 1) {
449 else if (item->
rtti() == 2) {
453 else if (item->
rtti() == 3) {
478 void CallMapView::doUpdate(
int changeType,
bool)
497 if (changeType == selectedItemChanged) {
526 else if ((changeType & partsChanged) ||
541 return palette().color( QPalette::Button );
549 QString tip, itemTip;
558 if (!i->
text(1).isEmpty())
559 itemTip +=
" (" + i->
text(1) +
')';
561 if (!tip.isEmpty()) tip +=
'\n';
604 return QObject::tr(
"(no function)");
609 if (!_f)
return QString();
613 if (textNo != 1)
return QString();
625 return QString(
"%1 %")
633 if ((i != 1) || !_f)
return QPixmap();
676 if (0) qDebug(
"Create Function %s (%s)",
678 qPrintable(
text(0)));
684 if (call->
inCycle()>0)
continue;
695 if (call->
inCycle()>0)
continue;
731 _recursive = !setFunction(_c->
called());
740 return QObject::tr(
"(no call)");
747 if (textNo != 1)
return QString();
757 return QString(
"%1 %")
765 if (i != 1)
return QPixmap();
780 return _factor * _c->
subCost(ct);
797 if (0) qDebug(
"Create Calling subitems (%s)",
798 qPrintable(
path(0).join(
"/")));
807 qDebug(
"Warning: CallingItem subVal %u > Sum %u (%s)",
811 double newFactor = _factor * v / s;
814 qDebug(
"CallingItem: Subitems of %s => %s, factor %f * %d/%d => %f",
817 _factor, v, s, newFactor);
822 if (call->
inCycle()>0)
continue;
855 return QObject::tr(
"(no call)");
862 if (textNo != 1)
return QString();
871 return QString(
"%1 %")
880 if (i != 1)
return QPixmap();
895 return (
double) _c->
subCost(ct);
914 double newFactor = _factor * v / s;
918 qDebug(
"CallerItem: Subitems of %s => %s, factor %f * %d/%d => %f",
921 _factor, v, s, newFactor);
927 if (call->
inCycle()>0)
continue;
993 #include "callmapview.moc"
void setData(TraceData *)
static bool showPercentage()
SubCost subCost(EventType *)
Returns a sub cost.
EventType * eventType() const
const TraceCallList & callings(bool skipCycle=false) const
TraceFunction * caller(bool skipCycle=false) const
ProfileContext::Type type() const
static QColor functionColor(ProfileContext::Type gt, TraceFunction *)
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
ProfileCostArray * totalCost()
virtual void setValue(const QString &key, const QVariant &value, const QVariant &defaultValue=QVariant())
Base class for cost items.
QPixmap pixmap(int) const
CallMapView(bool showCallers, TraceItemView *parentView, QWidget *parent=0, const char *name=0)
ProfileContext::Type _groupType
TraceCallList callers(bool skipCycle=false) const
static ConfigGroup * group(const QString &group, const QString &optSuffix=QString())
Abstract Base Class for KCachegrind Views.
virtual void setData(TraceData *d)
TreeMapItemList * children()
QString callerName(bool skipCycle=false) const
TreeMapItem * parent() const
Parent Item.
An array of basic cost metrics for a trace item.
QString whatsThis() const
QString tipString(TreeMapItem *) const
Return tooltip string to show for a item (can be rich text) Default implementation gives lines with "...
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
virtual TraceData * data()
TreeMapItemList * children()
#define DEFAULT_SPLITMODE
static QString shortenSymbol(const QString &)
A group of configuration settings.
CallMapCallingItem(double factor, TraceCall *c)
virtual void selected(TraceItemView *sender, CostItem *)
Notification from child views.
virtual void activated(TraceItemView *sender, CostItem *)
TraceFunction * function()
#define DEFAULT_DRAWLOCATION
void restoreOptions(const QString &prefix, const QString &postfix)
TraceFunction * function()
QPixmap pixmap(int) const
static bool showExpanded()
int depth() const
Depth of this item.
QColor groupColor(TraceFunction *) const
TreeMapItemList * _children
static int percentPrecision()
Cost event counter, simple wrapper around a 64bit entity.
TraceFunction * called(bool skipCycle=false) const
QStringList path(int) const
Returns a list of text strings of specified text number, from root up to this item.
void setSorting(int textNo, bool ascending=true)
Set the sorting for child drawing.
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
virtual void showMessage(const QString &, int msec)=0
void saveOptions(const QString &prefix, const QString &postfix)
TreeMapItemList * children()
TraceFunction * function()
QString prettyLocation(int maxFiles=0) const
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
#define DEFAULT_FORCESTRINGS
A call from one to another function.
Base class of items in TreeMap.
void addItem(TreeMapItem *)
Adds an item to a parent.
TreeMapWidget * widget() const
TreeMap widget this item is put in.
QPixmap costPixmap(EventType *ct, ProfileCostArray *cost, double total, bool framed)
#define DEFAULT_DRAWCALLS
QString calledName(bool skipCycle=false) const
QPixmap pixmap(int) const
void setFunction(TraceFunction *f)
static int maxSymbolCount()
CallMapCallerItem(double factor, TraceCall *c)
ProfileCostArray * inclusive()
virtual QVariant value(const QString &key, const QVariant &defaultValue) const