29 #include <QTextDocument>
42 int fileno,
unsigned int lineno,
43 bool inside,
const QString& src,
55 setTextAlignment(0, Qt::AlignRight);
56 setTextAlignment(1, Qt::AlignRight);
57 setTextAlignment(2, Qt::AlignRight);
62 setText(0, QString::number(lineno));
65 setText(4, s.replace( QRegExp(
"\t"),
" " ));
73 int fileno,
unsigned int lineno,
85 setTextAlignment(0, Qt::AlignRight);
86 setTextAlignment(1, Qt::AlignRight);
87 setTextAlignment(2, Qt::AlignRight);
93 QString callStr =
" ";
95 callStr += QObject::tr(
"Active call to '%1'")
98 callStr += QObject::tr(
"%n call(s) to '%2'",
"", (
uint64)cc)
112 int fileno,
unsigned int lineno,
124 setTextAlignment(0, Qt::AlignRight);
125 setTextAlignment(1, Qt::AlignRight);
126 setTextAlignment(2, Qt::AlignRight);
139 jStr = QObject::tr(
"Jump %1 of %2 times to %3")
144 jStr = QObject::tr(
"Jump %1 times to %2")
154 if (!_lineCall)
return;
167 if (_lineJump)
return;
178 QString icon =
"edit-undo";
180 KIconLoader* loader = KIconLoader::global();
181 p= loader->loadIcon(icon, KIconLoader::Small, 0,
182 KIconLoader::DefaultState, QStringList(), 0,
true);
185 str = QObject::tr(
"(cycle)");
203 setText(1, QString());
204 setIcon(1, QPixmap());
207 double total = totalCost->
subCost(ct);
208 double pure = 100.0 * _pure / total;
211 setText(1, QString(
"%1")
214 setText(1, _pure.
pretty());
216 setIcon(1,
costPixmap(ct, lineCost, total,
false));
222 setText(2, QString());
223 setIcon(2, QPixmap());
226 double total = totalCost->
subCost(ct2);
227 double pure2 = 100.0 * _pure2 / total;
230 setText(2, QString(
"%1")
233 setText(2, _pure2.
pretty());
235 setIcon(2,
costPixmap(ct2, lineCost, total,
false));
244 int col = treeWidget()->sortColumn();
247 return (si1->_pure < si2->_pure);
250 return (si1->_pure2 < si2->_pure2);
254 if (si1->_fileno < si2->_fileno)
return true;
255 if (si1->_fileno > si2->_fileno)
return false;
258 if (si1->_lineno < si2->_lineno)
return true;
259 if (si1->_lineno > si2->_lineno)
return false;
262 if (!si1->_lineCall && !si1->_lineJump)
return true;
263 if (!si2->_lineCall && !si2->_lineJump)
return false;
266 if (si1->_lineCall && !si2->_lineCall)
return true;
267 if (si2->_lineCall && !si1->_lineCall)
return false;
269 if (si1->_lineCall && si2->_lineCall) {
271 if (si1->_pure < si2->_pure)
return true;
272 if (si1->_pure > si2->_pure)
return false;
285 return QTreeWidgetItem::operator <(other);
305 const QModelIndex &index)
const
307 QSize sz = QItemDelegate::sizeHint(option, index);
309 int c = index.column();
310 if (c != 3)
return sz;
316 return QSize(0, sz.height());
319 return QSize(10 + 6*levels + 2, sz.height());
323 const QStyleOptionViewItem &option,
324 const QModelIndex &index)
const
326 int column = index.column();
330 if ( !item->
inside() || ((column==1) || (column==2)))
331 color = option.palette.color( QPalette::Button );
333 color = option.palette.color( QPalette::Midlight );
340 QItemDelegate::paint(painter, option, index);
344 const QStyleOptionViewItem &option,
345 const QModelIndex &index)
const
351 const QRect& rect = option.rect;
352 int height = rect.height();
355 drawBackground(p, option, index);
356 p->translate(rect.topLeft());
359 int yy = height/2, y1, y2;
362 int start = -1, end = -1;
365 uint lineno = item->
lineno();
369 for(
int i=0; i< item->
jumpCount(); i++) {
371 if (jump == 0)
continue;
379 if (start<0) start = i;
380 if (lineJump == jump) {
387 else if (!lineJump && !lineCall &&
397 p->fillRect( marg + 6*i, y1, 4, y2, c);
398 p->setPen(c.light());
399 p->drawLine( marg + 6*i, y1, marg + 6*i, y2);
401 p->drawLine( marg + 6*i +3, y1, marg + 6*i +3, y2);
405 int x, y = yy-2, w, h = 4;
410 p->fillRect( x, y, w, h, c);
411 p->setPen(c.light());
412 p->drawLine(x, y, x+w-1, y);
413 p->drawLine(x, y, x, y+h-1);
415 p->drawLine(x+w-1, y, x+w-1, y+h-1);
416 p->drawLine(x+1, y+h-1, x+w-1, y+h-1);
424 a.putPoints(0, 8, x,y+h,
425 x,y, x+w-8,y, x+w-8,y-2,
427 x+w-8,y+h+2, x+w-8,y+h,
430 p->drawConvexPolygon(a);
432 p->setPen(c.light());
433 p->drawPolyline(a.constData(), 5);
435 p->drawPolyline(a.constData() + 4, 2);
436 p->setPen(c.light());
437 p->drawPolyline(a.constData() + 5, 2);
439 p->drawPolyline(a.constData() + 6, 2);
446 if (jump == 0)
continue;
453 if (start<0) drawUp =
false;
456 p->fillRect( marg + 6*i +1, 0, 2, yy, c);
458 p->fillRect( marg + 6*i +1, yy, 2, height-yy, c);
463 p->fillRect( marg + 6*i +1, 0, 2, yy, c);
465 p->fillRect( marg + 6*i +1, yy, 2, height-yy, c);
void paintArrows(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const
EventType * eventType2() const
static bool showPercentage()
SubCost subCost(EventType *)
Returns a sub cost.
EventType * eventType() const
SourceItem(SourceView *sv, QTreeWidget *parent, int fileno, unsigned int lineno, bool inside, const QString &src, TraceLine *line=0)
TraceLine * lineTo() const
static QColor functionColor(ProfileContext::Type gt, TraceFunction *)
TraceFunction * function() const
unsigned long long uint64
A call from a line of one function to another function.
virtual void setData(TraceData *d)
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
void setJumpArray(const QVector< TraceLineJump * > &a)
An array of basic cost metrics for a trace item.
TraceLineJump * jump(int i) const
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
virtual TraceData * data()
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
A source line of the program.
virtual QString name() const
Returns dynamic name info (without type)
QVector< TraceLineJump * > _jump
TraceFunctionSource * functionSource() const
TraceLineCall * lineCall() const
SourceItemDelegate(SourceView *parent)
TraceLine * lineFrom() const
static bool showExpanded()
static int percentPrecision()
bool operator<(const QTreeWidgetItem &other) const
Cost event counter, simple wrapper around a 64bit entity.
TraceLineJump * lineJump() const
TraceFunction * called(bool skipCycle=false) const
void addPrettyLocation(QString &, int maxFiles=1) const
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
ProfileContext::Type groupType() const
QPixmap costPixmap(EventType *ct, ProfileCostArray *cost, double total, bool framed)
QPixmap colorPixmap(int w, int h, QColor c)
QString calledName(bool skipCycle=false) const
A jump from one line to another inside of a function.
ProfileCostArray * inclusive()