diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-09-11 11:20:52 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2014-09-15 09:15:52 +0200 |
commit | 2b362de064c3a1573feacfc0edd39f711aa35c4a (patch) | |
tree | 64256cedcdfd69f43055c56bf5148dc6cc03e76a /src/plugins/qmlprofiler | |
parent | 5799901bccd6017b82202612e08b1b3a16927124 (diff) | |
download | qt-creator-2b362de064c3a1573feacfc0edd39f711aa35c4a.tar.gz |
QmlProfiler: introduce properties for empty, hidden and displayName
Like this we can properly refer to them from QML.
Change-Id: I98378d543d307f78909191225e72c9d0404dfa1d
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/qmlprofiler')
8 files changed, 58 insertions, 5 deletions
diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp index 1124d5958a..acfdc65883 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp @@ -42,6 +42,7 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd, d->modelId = 0; d->modelManager = 0; d->expanded = false; + d->hidden = false; d->displayName = displayName; d->message = message; d->rangeType = rangeType; @@ -98,7 +99,7 @@ int AbstractTimelineModel::rowOffset(int rowNumber) const void AbstractTimelineModel::setRowHeight(int rowNumber, int height) { Q_D(AbstractTimelineModel); - if (!expanded()) + if (d->hidden || !d->expanded) return; if (height < DefaultRowHeight) height = DefaultRowHeight; @@ -120,7 +121,7 @@ int AbstractTimelineModel::height() const { Q_D(const AbstractTimelineModel); int depth = rowCount(); - if (!expanded() || d->rowOffsets.empty()) + if (d->hidden || !d->expanded || d->rowOffsets.empty()) return depth * DefaultRowHeight; return d->rowOffsets.last() + (depth - d->rowOffsets.size()) * DefaultRowHeight; @@ -192,6 +193,7 @@ int AbstractTimelineModel::rowMaxValue(int rowNumber) const void AbstractTimelineModel::dataChanged() { Q_D(AbstractTimelineModel); + bool wasEmpty = isEmpty(); switch (d->modelManager->state()) { case QmlProfilerDataState::ProcessingData: loadData(); @@ -202,6 +204,8 @@ void AbstractTimelineModel::dataChanged() default: break; } + if (wasEmpty != isEmpty()) + emit emptyChanged(); } bool AbstractTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const @@ -225,6 +229,21 @@ void AbstractTimelineModel::setExpanded(bool expanded) } } +bool AbstractTimelineModel::hidden() const +{ + Q_D(const AbstractTimelineModel); + return d->hidden; +} + +void AbstractTimelineModel::setHidden(bool hidden) +{ + Q_D(AbstractTimelineModel); + if (hidden != d->hidden) { + d->hidden = hidden; + emit hiddenChanged(); + } +} + QString AbstractTimelineModel::displayName() const { Q_D(const AbstractTimelineModel); @@ -234,6 +253,8 @@ QString AbstractTimelineModel::displayName() const int AbstractTimelineModel::rowCount() const { Q_D(const AbstractTimelineModel); + if (d->hidden) + return 0; if (isEmpty()) return d->modelManager->isEmpty() ? 1 : 0; return d->expanded ? d->expandedRowCount : d->collapsedRowCount; @@ -244,14 +265,18 @@ void AbstractTimelineModel::clear() Q_D(AbstractTimelineModel); d->collapsedRowCount = d->expandedRowCount = 1; bool wasExpanded = d->expanded; + bool wasHidden = d->hidden; bool hadRowHeights = !d->rowOffsets.empty(); d->rowOffsets.clear(); d->expanded = false; + d->hidden = false; SortedTimelineModel::clear(); if (hadRowHeights) emit rowHeightChanged(); if (wasExpanded) emit expandedChanged(); + if (wasHidden) + emit hiddenChanged(); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); } diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.h b/src/plugins/qmlprofiler/abstracttimelinemodel.h index 415eb54429..9ade6f031b 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.h @@ -43,6 +43,9 @@ namespace QmlProfiler { class QMLPROFILER_EXPORT AbstractTimelineModel : public SortedTimelineModel { Q_OBJECT + Q_PROPERTY(QString displayName READ displayName CONSTANT) + Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged) + Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged) public: class AbstractTimelineModelPrivate; @@ -63,7 +66,9 @@ public: qint64 traceDuration() const; bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; bool expanded() const; + bool hidden() const; void setExpanded(bool expanded); + void setHidden(bool hidden); QString displayName() const; int rowCount() const; @@ -87,7 +92,9 @@ public: signals: void expandedChanged(); + void hiddenChanged(); void rowHeightChanged(); + void emptyChanged(); protected: static const int DefaultRowHeight = 30; diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel_p.h b/src/plugins/qmlprofiler/abstracttimelinemodel_p.h index 9696b17b28..46b7a7ca5f 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel_p.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel_p.h @@ -40,6 +40,7 @@ public: QmlProfilerModelManager *modelManager; int modelId; bool expanded; + bool hidden; int expandedRowCount; int collapsedRowCount; QString displayName; diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index 910b4760d0..8a76767de8 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -210,7 +210,7 @@ QVariantList PaintEventsModelProxy::labels() const Q_D(const PaintEventsModelProxy); QVariantList result; - if (d->maxGuiThreadAnimations > 0) { + if (!d->hidden && d->maxGuiThreadAnimations > 0) { QVariantMap element; element.insert(QLatin1String("displayName"), QVariant(tr("Animations"))); element.insert(QLatin1String("description"), QVariant(tr("GUI Thread"))); @@ -218,7 +218,7 @@ QVariantList PaintEventsModelProxy::labels() const result << element; } - if (d->maxRenderThreadAnimations > 0) { + if (!d->hidden && d->maxRenderThreadAnimations > 0) { QVariantMap element; element.insert(QLatin1String("displayName"), QVariant(tr("Animations"))); element.insert(QLatin1String("description"), QVariant(tr("Render Thread"))); diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp index 32a15c9dc5..3ecf3bac34 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp @@ -246,7 +246,7 @@ QVariantList RangeTimelineModel::labels() const Q_D(const RangeTimelineModel); QVariantList result; - if (d->expanded) { + if (d->expanded && !d->hidden) { const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = d->modelManager->qmlModel()->getEventTypes(); for (int i = 1; i < d->expandedRowCount; i++) { // Ignore the -1 for the first row diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp index 5158b4cde4..aefa41da00 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -91,6 +91,7 @@ void TimelineModelAggregator::addModel(AbstractTimelineModel *m) { d->modelList << m; connect(m,SIGNAL(expandedChanged()),this,SIGNAL(expandedChanged())); + connect(m,SIGNAL(hiddenChanged()),this,SIGNAL(hiddenChanged())); connect(m,SIGNAL(rowHeightChanged()),this,SIGNAL(rowHeightChanged())); emit modelsChanged(d->modelList.length(), d->modelList.length()); } @@ -154,6 +155,16 @@ void TimelineModelAggregator::setExpanded(int modelIndex, bool expanded) d->modelList[modelIndex]->setExpanded(expanded); } +bool TimelineModelAggregator::hidden(int modelIndex) const +{ + return d->modelList[modelIndex]->hidden(); +} + +void TimelineModelAggregator::setHidden(int modelIndex, bool hidden) +{ + d->modelList[modelIndex]->setHidden(hidden); +} + int TimelineModelAggregator::rowCount(int modelIndex) const { return d->modelList[modelIndex]->rowCount(); diff --git a/src/plugins/qmlprofiler/timelinemodelaggregator.h b/src/plugins/qmlprofiler/timelinemodelaggregator.h index b345cd03a1..6cffaf5bbe 100644 --- a/src/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/src/plugins/qmlprofiler/timelinemodelaggregator.h @@ -65,6 +65,10 @@ public: Q_INVOKABLE bool expanded(int modelIndex) const; Q_INVOKABLE void setExpanded(int modelIndex, bool expanded); + + Q_INVOKABLE bool hidden(int modelIndex) const; + Q_INVOKABLE void setHidden(int modelIndex, bool hidden); + Q_INVOKABLE int rowCount(int modelIndex) const; Q_INVOKABLE QString displayName(int modelIndex) const; Q_INVOKABLE int rowMinValue(int modelIndex, int row) const; @@ -98,6 +102,7 @@ signals: void dataAvailable(); void stateChanged(); void expandedChanged(); + void hiddenChanged(); void rowHeightChanged(); void modelsChanged(int modelIndex1, int modelIndex2); diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp index d03e623671..50f536290b 100644 --- a/src/plugins/qmlprofiler/timelinerenderer.cpp +++ b/src/plugins/qmlprofiler/timelinerenderer.cpp @@ -55,6 +55,7 @@ void TimelineRenderer::setProfilerModelProxy(QObject *profilerModelProxy) { if (m_profilerModelProxy) { disconnect(m_profilerModelProxy, SIGNAL(expandedChanged()), this, SLOT(requestPaint())); + disconnect(m_profilerModelProxy, SIGNAL(hiddenChanged()), this, SLOT(requestPaint())); disconnect(m_profilerModelProxy, SIGNAL(rowHeightChanged()), this, SLOT(requestPaint())); disconnect(m_profilerModelProxy, SIGNAL(modelsChanged(int,int)), this, SLOT(swapSelections(int,int))); @@ -63,6 +64,7 @@ void TimelineRenderer::setProfilerModelProxy(QObject *profilerModelProxy) if (m_profilerModelProxy) { connect(m_profilerModelProxy, SIGNAL(expandedChanged()), this, SLOT(requestPaint())); + connect(m_profilerModelProxy, SIGNAL(hiddenChanged()), this, SLOT(requestPaint())); connect(m_profilerModelProxy, SIGNAL(rowHeightChanged()), this, SLOT(requestPaint())); connect(m_profilerModelProxy, SIGNAL(modelsChanged(int,int)), this, SLOT(swapSelections(int,int))); @@ -141,6 +143,8 @@ void TimelineRenderer::paint(QPainter *p) p->setPen(Qt::transparent); for (int modelIndex = 0; modelIndex < m_profilerModelProxy->modelCount(); modelIndex++) { + if (m_profilerModelProxy->hidden(modelIndex)) + continue; int lastIndex = m_profilerModelProxy->lastIndex(modelIndex, m_endTime); if (lastIndex >= 0 && lastIndex < m_profilerModelProxy->count(modelIndex)) { int firstIndex = m_profilerModelProxy->firstIndex(modelIndex, m_startTime); |