From 4436a1c7f264df4961057d0ccf24dc0ea4a04e80 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 May 2016 17:38:45 +0200 Subject: [PATCH] QmlProfiler: Add some more consistency to flame graph model model.parent(someFirstLevelItem) should return the invisible root item. Methods with default parameter in the base class should also have a default parameter in the derived class. As rowCount() is Q_INVOKABLE columnCount() should also be. Change-Id: I62a0ec6f91d01581fd47a43c97af63c58cdd13fa Reviewed-by: Christian Kandeler --- src/plugins/qmlprofiler/flamegraphmodel.cpp | 3 ++- src/plugins/qmlprofiler/flamegraphmodel.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index f5664dc5df0..f9d0f365f47 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -222,7 +222,8 @@ QModelIndex FlameGraphModel::parent(const QModelIndex &child) const { if (child.isValid()) { FlameGraphData *childData = static_cast(child.internalPointer()); - return createIndex(0, 0, childData->parent); + return childData->parent == &m_stackBottom ? QModelIndex() : + createIndex(0, 0, childData->parent); } else { return QModelIndex(); } diff --git a/src/plugins/qmlprofiler/flamegraphmodel.h b/src/plugins/qmlprofiler/flamegraphmodel.h index 0b42aa39468..3b130faaa1c 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.h +++ b/src/plugins/qmlprofiler/flamegraphmodel.h @@ -74,10 +74,11 @@ public: FlameGraphModel(QmlProfilerModelManager *modelManager, QObject *parent = 0); - QModelIndex index(int row, int column, const QModelIndex &parent) const override; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &child) const override; Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; + Q_INVOKABLE int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role) const override; QHash roleNames() const override; QmlProfilerModelManager *modelManager() const;