29 _sortOrder = Qt::DescendingOrder;
38 _max0 = _max1 = _max2 = 0;
46 return (parent.isValid()) ? 0 : 5;
51 if (parent.isValid())
return 0;
55 if (_topList.count() < _filteredList.count()) rowCount++;
61 if (!index.isValid())
return 0;
68 if (!index.isValid())
return QVariant();
71 if ( (_topList.count() < _filteredList.count()) &&
72 (index.row() == _topList.count()) ) {
73 if( (role != Qt::DisplayRole) || (index.column() != 3))
76 return tr(
"(%1 function(s) skipped)").arg(_filteredList.count() - _topList.count());
82 case Qt::TextAlignmentRole:
83 return (index.column()<3) ? Qt::AlignRight : Qt::AlignLeft;
85 case Qt::DecorationRole:
86 switch (index.column()) {
88 return getInclPixmap(f);
90 return getSelfPixmap(f);
92 return getNamePixmap(f);
99 switch (index.column()) {
101 return getInclCost(f);
103 return getSelfCost(f);
105 return getCallCount(f);
109 return getLocation(f);
122 if (!index.isValid())
125 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
131 if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole))
134 return _headerData.value(section);
138 const QModelIndex &parent)
const
140 if (!hasIndex(row, column, parent))
return QModelIndex();
143 if ( (_topList.count() < _list.count()) && (row == _topList.count()) )
144 return createIndex(row, column);
146 return createIndex(row, column, (
void*)_topList[row]);
151 if (!f)
return QModelIndex();
153 int row = _topList.indexOf(f);
157 !_filteredList.contains(f) )
return QModelIndex();
162 insertPos = qLowerBound(_topList.begin(), _topList.end(),
164 row = insertPos - _topList.begin();
165 beginInsertRows(QModelIndex(), row, row);
166 _topList.insert(row, f);
170 return createIndex(row, 0, (
void*)f);
176 return QModelIndex();
181 _sortColumn = column;
188 if (_filterString == filterString)
return;
189 _filterString = filterString;
191 _filter = QRegExp(_filterString, Qt::CaseInsensitive, QRegExp::Wildcard);
192 computeFilteredList();
200 computeFilteredList();
206 if (_maxCount == c)
return;
215 _eventType = eventType;
221 TraceFunctionMap::iterator i = data->
functionMap().begin();
223 _list.append(&(i.value()));
231 _groupType = group->
type();
271 _filterString = filterString;
272 _filter = QRegExp(_filterString, Qt::CaseInsensitive, QRegExp::Wildcard);
274 computeFilteredList();
278 void FunctionListModel::computeFilteredList()
280 FunctionLessThan lessThan0(0, Qt::AscendingOrder, _eventType);
281 FunctionLessThan lessThan1(1, Qt::AscendingOrder, _eventType);
282 FunctionLessThan lessThan2(2, Qt::AscendingOrder, _eventType);
289 _filteredList.clear();
292 if (!_filterString.isEmpty())
293 if (_filter.indexIn(f->
name()) == -1)
continue;
295 _filteredList.append(f);
296 if (!_max0 || lessThan0(_max0, f)) { _max0 = f; }
297 if (!_max1 || lessThan1(_max1, f)) { _max1 = f; }
298 if (!_max2 || lessThan2(_max2, f)) { _max2 = f; }
303 void FunctionListModel::computeTopList()
307 if (_filteredList.isEmpty()) {
312 FunctionLessThan lessThan(_sortColumn, _sortOrder, _eventType);
313 qStableSort(_filteredList.begin(), _filteredList.end(), lessThan);
317 if (_topList.count() >= _maxCount)
break;
322 if (_max0 && !_topList.contains(_max0)) maxList.append(_max0);
323 if (_max1 && !_topList.contains(_max1)) maxList.append(_max1);
324 if (_max2 && !_topList.contains(_max2)) maxList.append(_max2);
325 qSort(maxList.begin(), maxList.end(), lessThan);
326 _topList.append(maxList);
336 QPixmap FunctionListModel::getNamePixmap(
TraceFunction *f)
const
342 QString FunctionListModel::getLocation(
TraceFunction *f)
const
347 QString FunctionListModel::getSelfCost(
TraceFunction *f)
const
358 double selfTotal = selfCost->
subCost(_eventType);
359 if (selfTotal == 0.0)
364 double self = 100.0 * pure / selfTotal;
372 QPixmap FunctionListModel::getSelfPixmap(
TraceFunction *f)
const
383 double selfTotal = selfCost->
subCost(_eventType);
384 if (selfTotal == 0.0)
387 return costPixmap(_eventType, f, selfTotal,
false);
390 QString FunctionListModel::getInclCost(
TraceFunction *f)
const
393 if (inclTotal == 0.0)
397 double incl = 100.0 * sum / inclTotal;
405 QPixmap FunctionListModel::getInclPixmap(
TraceFunction *f)
const
408 if (inclTotal == 0.0)
415 QString FunctionListModel::getCallCount(
TraceFunction *f)
const
424 str = QString(
"(0)");
439 if (_order == Qt::DescendingOrder) {
457 return pure1 < pure2;
474 #include "functionlistmodel.moc"
void setFilter(QString filter)
Qt::ItemFlags flags(const QModelIndex &) const
A source file containing function definitions.
static bool showPercentage()
SubCost subCost(EventType *)
Returns a sub cost.
const TraceFunctionList & functions() const
TraceFunction * function(const QModelIndex &index)
const TraceFunctionList & functions() const
A cycle of recursive calling functions.
ProfileContext::Type type() const
static QColor functionColor(ProfileContext::Type gt, TraceFunction *)
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
TraceObject * object() const
void setEventType(EventType *)
QModelIndex parent(const QModelIndex &index) const
TraceFunctionCycle * cycle()
A object containing a text segment (shared lib/executable) with defined functions.
An array of basic cost metrics for a trace item.
void sort(int column, Qt::SortOrder order)
QModelIndex indexForFunction(TraceFunction *f, bool add=false)
bool operator()(TraceFunction *left, TraceFunction *right)
const TraceFunctionCycleList & functionCycles()
const TraceFunctionList & members() const
virtual QString name() const
Returns dynamic name info (without type)
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
virtual TraceData * data()
QVariant data(const QModelIndex &, int) const
static bool showExpanded()
const TraceFunctionList & functions() const
static int percentPrecision()
int columnCount(const QModelIndex &parent=QModelIndex()) const
Cost event counter, simple wrapper around a 64bit entity.
void resetModelData(TraceData *data, TraceCostItem *group, QString filter, EventType *eventType)
TraceFunctionMap & functionMap()
QString prettyLocation(int maxFiles=0) const
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
QString prettyCalledCount()
QPixmap costPixmap(EventType *ct, ProfileCostArray *cost, double total, bool framed)
QPixmap colorPixmap(int w, int h, QColor c)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
ProfileCostArray * inclusive()