summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-07-04 14:10:37 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-07-07 10:26:19 +0200
commitcb7963bc18297251bd44480ca9392d16e20e17f8 (patch)
tree52a9f76393bc25a36ed6968fb9ef15ea81cfbc98
parent6a93d4183192a8d89346fc812563877ddb440718 (diff)
downloadqt-creator-cb7963bc18297251bd44480ca9392d16e20e17f8.tar.gz
QmlProfiler: Make events view properly sortable
Add all the missing bits and actually use the filename for sorting. Change-Id: Icc2a07d297fe17423aa23bf58a602dfa0dcf5a87 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r--src/plugins/qmlprofiler/qmlprofilereventview.cpp39
-rw-r--r--src/plugins/qmlprofiler/qmlprofilereventview.h11
2 files changed, 33 insertions, 17 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp
index d4bb588478..b800c57296 100644
--- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp
@@ -92,18 +92,25 @@ public:
virtual bool operator<(const QStandardItem &other) const
{
- if (data().type() == QVariant::String) {
- // first column
- if (column() == 0) {
- return data(FilenameRole).toString() == other.data(FilenameRole).toString() ?
- data(LineRole).toInt() < other.data(LineRole).toInt() :
- data(FilenameRole).toString() < other.data(FilenameRole).toString();
- } else {
- return data().toString().toLower() < other.data().toString().toLower();
- }
+ if (column() == 0) {
+ // first column is special
+ int filenameDiff = QUrl(data(FilenameRole).toString()).fileName().compare(
+ QUrl(other.data(FilenameRole).toString()).fileName(), Qt::CaseInsensitive);
+ if (filenameDiff != 0)
+ return filenameDiff < 0;
+
+ return data(LineRole).toInt() == other.data(LineRole).toInt() ?
+ data(ColumnRole).toInt() < other.data(ColumnRole).toInt() :
+ data(LineRole).toInt() < other.data(LineRole).toInt();
+
+ } else if (data(SortRole).type() == QVariant::String) {
+ // Strings should be case-insensitive compared
+ return data(SortRole).toString().compare(other.data(SortRole).toString(),
+ Qt::CaseInsensitive) < 0;
+ } else {
+ // For everything else the standard comparison should be OK
+ return QStandardItem::operator<(other);
}
-
- return data().toDouble() < other.data().toDouble();
}
};
@@ -395,6 +402,7 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
setSortingEnabled(false);
d->m_model = new QStandardItemModel(this);
+ d->m_model->setSortRole(SortRole);
setModel(d->m_model);
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
@@ -851,7 +859,9 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(QmlProfilerModelMan
Q_UNUSED(modelManager);
setSortingEnabled(false);
d->modelProxy = modelProxy;
- setModel(new QStandardItemModel(this));
+ QStandardItemModel *model = new QStandardItemModel(this);
+ model->setSortRole(SortRole);
+ setModel(model);
setRootIsDecorated(false);
updateHeader();
@@ -905,8 +915,13 @@ void QmlProfilerEventRelativesView::rebuildTree(
type.data);
newRow.at(0)->setData(QVariant(typeIndex), EventTypeIndexRole);
+ newRow.at(0)->setData(QVariant(type.location.filename),FilenameRole);
+ newRow.at(0)->setData(QVariant(type.location.line),LineRole);
+ newRow.at(0)->setData(QVariant(type.location.column),ColumnRole);
+ newRow.at(1)->setData(QVariant(QmlProfilerEventsMainView::nameForType(type.rangeType)));
newRow.at(2)->setData(QVariant(event.duration));
newRow.at(3)->setData(QVariant(event.calls));
+ newRow.at(4)->setData(QVariant(type.data));
if (event.isBindingLoop) {
foreach (QStandardItem *item, newRow) {
diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h
index 95651d9b6d..86ef4400d7 100644
--- a/src/plugins/qmlprofiler/qmlprofilereventview.h
+++ b/src/plugins/qmlprofiler/qmlprofilereventview.h
@@ -48,11 +48,12 @@ class QmlProfilerEventChildrenView;
class QmlProfilerEventRelativesView;
enum ItemRole {
- EventTypeIndexRole = Qt::UserRole+1,
- FilenameRole = Qt::UserRole+2,
- LineRole = Qt::UserRole+3,
- ColumnRole = Qt::UserRole+4,
- EventIdRole = Qt::UserRole+5
+ SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string
+ EventTypeIndexRole,
+ FilenameRole,
+ LineRole,
+ ColumnRole,
+ EventIdRole
};
class QmlProfilerEventsWidget : public QWidget