forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -92,18 +92,25 @@ public:
|
|||||||
|
|
||||||
virtual bool operator<(const QStandardItem &other) const
|
virtual bool operator<(const QStandardItem &other) const
|
||||||
{
|
{
|
||||||
if (data().type() == QVariant::String) {
|
|
||||||
// first column
|
|
||||||
if (column() == 0) {
|
if (column() == 0) {
|
||||||
return data(FilenameRole).toString() == other.data(FilenameRole).toString() ?
|
// first column is special
|
||||||
data(LineRole).toInt() < other.data(LineRole).toInt() :
|
int filenameDiff = QUrl(data(FilenameRole).toString()).fileName().compare(
|
||||||
data(FilenameRole).toString() < other.data(FilenameRole).toString();
|
QUrl(other.data(FilenameRole).toString()).fileName(), Qt::CaseInsensitive);
|
||||||
} else {
|
if (filenameDiff != 0)
|
||||||
return data().toString().toLower() < other.data().toString().toLower();
|
return filenameDiff < 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data().toDouble() < other.data().toDouble();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -395,6 +402,7 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
|
|||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
|
|
||||||
d->m_model = new QStandardItemModel(this);
|
d->m_model = new QStandardItemModel(this);
|
||||||
|
d->m_model->setSortRole(SortRole);
|
||||||
setModel(d->m_model);
|
setModel(d->m_model);
|
||||||
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
|
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
|
||||||
|
|
||||||
@@ -851,7 +859,9 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(QmlProfilerModelMan
|
|||||||
Q_UNUSED(modelManager);
|
Q_UNUSED(modelManager);
|
||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
d->modelProxy = modelProxy;
|
d->modelProxy = modelProxy;
|
||||||
setModel(new QStandardItemModel(this));
|
QStandardItemModel *model = new QStandardItemModel(this);
|
||||||
|
model->setSortRole(SortRole);
|
||||||
|
setModel(model);
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
updateHeader();
|
updateHeader();
|
||||||
|
|
||||||
@@ -905,8 +915,13 @@ void QmlProfilerEventRelativesView::rebuildTree(
|
|||||||
type.data);
|
type.data);
|
||||||
|
|
||||||
newRow.at(0)->setData(QVariant(typeIndex), EventTypeIndexRole);
|
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(2)->setData(QVariant(event.duration));
|
||||||
newRow.at(3)->setData(QVariant(event.calls));
|
newRow.at(3)->setData(QVariant(event.calls));
|
||||||
|
newRow.at(4)->setData(QVariant(type.data));
|
||||||
|
|
||||||
if (event.isBindingLoop) {
|
if (event.isBindingLoop) {
|
||||||
foreach (QStandardItem *item, newRow) {
|
foreach (QStandardItem *item, newRow) {
|
||||||
|
|||||||
@@ -48,11 +48,12 @@ class QmlProfilerEventChildrenView;
|
|||||||
class QmlProfilerEventRelativesView;
|
class QmlProfilerEventRelativesView;
|
||||||
|
|
||||||
enum ItemRole {
|
enum ItemRole {
|
||||||
EventTypeIndexRole = Qt::UserRole+1,
|
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
||||||
FilenameRole = Qt::UserRole+2,
|
EventTypeIndexRole,
|
||||||
LineRole = Qt::UserRole+3,
|
FilenameRole,
|
||||||
ColumnRole = Qt::UserRole+4,
|
LineRole,
|
||||||
EventIdRole = Qt::UserRole+5
|
ColumnRole,
|
||||||
|
EventIdRole
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlProfilerEventsWidget : public QWidget
|
class QmlProfilerEventsWidget : public QWidget
|
||||||
|
|||||||
Reference in New Issue
Block a user