aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/ctfvisualizer/ctftracemanager.cpp
diff options
context:
space:
mode:
authorTim Henning <[email protected]>2019-10-17 13:36:37 +0200
committerTim Henning <[email protected]>2019-10-24 08:47:39 +0000
commitb90200cb195d0fc30aba6782b9bb921ae6e91d17 (patch)
tree4a7cdb1d5724d113267c9a809428a8bc4e80b38e /src/plugins/ctfvisualizer/ctftracemanager.cpp
parentee7aad571946ae2ce70d0465fdd46be48e294314 (diff)
Tracing: CtfVisualizer: Add menu to restrict view to certain threads
Add a new dropdown menu to select which threads should be displayed. If no threads are selected, all are shown (this is why the word 'restriction' was chosen). At the moment this only affects the timeline view, see the follow up for the statistics view. Change-Id: Ib3b08ea895e852189156e23feb8dea5f843cceb3 Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'src/plugins/ctfvisualizer/ctftracemanager.cpp')
-rw-r--r--src/plugins/ctfvisualizer/ctftracemanager.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/plugins/ctfvisualizer/ctftracemanager.cpp b/src/plugins/ctfvisualizer/ctftracemanager.cpp
index 855f8341288..493fbff7402 100644
--- a/src/plugins/ctfvisualizer/ctftracemanager.cpp
+++ b/src/plugins/ctfvisualizer/ctftracemanager.cpp
@@ -192,6 +192,7 @@ void CtfTraceManager::finalize()
}
}
m_threadModels.remove(tid);
+ m_threadRestrictions.remove(tid);
}
}
for (CtfTimelineModel *model: m_threadModels) {
@@ -216,25 +217,51 @@ int CtfTraceManager::getSelectionId(const std::string &name)
return *it;
}
+QList<CtfTimelineModel *> CtfTraceManager::getSortedThreads() const
+{
+ QList<CtfTimelineModel *> models = m_threadModels.values();
+ std::sort(models.begin(), models.end(), [](const CtfTimelineModel *a, const CtfTimelineModel *b) -> bool {
+ return (a->m_processId != b->m_processId) ? (a->m_processId < b->m_processId)
+ : (std::abs(a->m_threadId) < std::abs(b->m_threadId));
+ });
+ return models;
+}
+
+void CtfTraceManager::setThreadRestriction(int tid, bool restrictToThisThread)
+{
+ if (m_threadRestrictions.value(tid) == restrictToThisThread)
+ return;
+
+ m_threadRestrictions[tid] = restrictToThisThread;
+ addModelsToAggregator();
+}
+
+bool CtfTraceManager::isRestrictedTo(int tid) const
+{
+ return m_threadRestrictions.value(tid);
+}
+
void CtfTraceManager::addModelForThread(int threadId, int processId)
{
CtfTimelineModel *model = new CtfTimelineModel(m_modelAggregator, this, threadId, processId);
m_threadModels.insert(threadId, model);
+ m_threadRestrictions.insert(threadId, false);
connect(model, &CtfTimelineModel::detailsRequested, this,
&CtfTraceManager::detailsRequested);
}
void CtfTraceManager::addModelsToAggregator()
{
- QList<CtfTimelineModel *> models = m_threadModels.values();
- std::sort(models.begin(), models.end(), [](const CtfTimelineModel *a, const CtfTimelineModel *b) -> bool {
- return (a->m_processId != b->m_processId) ? (a->m_processId < b->m_processId)
- : (std::abs(a->m_threadId) < std::abs(b->m_threadId));
+ const QList<CtfTimelineModel *> models = getSortedThreads();
+
+ const bool showAll = std::none_of(m_threadRestrictions.begin(), m_threadRestrictions.end(), [](bool value) {
+ return value;
});
QVariantList modelsToAdd;
for (CtfTimelineModel *model: models) {
- modelsToAdd.append(QVariant::fromValue(model));
+ if (showAll || isRestrictedTo(model->tid()))
+ modelsToAdd.append(QVariant::fromValue(model));
}
m_modelAggregator->setModels(modelsToAdd);
}