From 01b946f396b2df403d7924920bb402df0a6630bb Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Sun, 2 Oct 2016 17:52:42 +0300 Subject: [PATCH] Thread names change --- profiler_gui/easy_graphics_item.cpp | 14 +++++++++- profiler_gui/tree_widget_loader.cpp | 40 +++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/profiler_gui/easy_graphics_item.cpp b/profiler_gui/easy_graphics_item.cpp index 71128a1..ef6917c 100644 --- a/profiler_gui/easy_graphics_item.cpp +++ b/profiler_gui/easy_graphics_item.cpp @@ -73,10 +73,22 @@ const auto SELECTED_ITEM_FONT = ::profiler_gui::EFont("Helvetica", 10, QFont::Bo EasyGraphicsItem::EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root) : QGraphicsItem(nullptr) - , m_threadName(_root.got_name() ? QString("%1 Thread %2").arg(_root.name()).arg(_root.thread_id) : QString("Thread %1").arg(_root.thread_id)) , m_pRoot(&_root) , m_index(_index) { + const auto u_thread = ::profiler_gui::toUnicode("thread"); + if (_root.got_name()) + { + QString rootname(::profiler_gui::toUnicode(_root.name())); + if (rootname.contains(u_thread, Qt::CaseInsensitive)) + m_threadName = ::std::move(QString("%1 %2").arg(rootname).arg(_root.thread_id)); + else + m_threadName = ::std::move(QString("%1 Thread %2").arg(rootname).arg(_root.thread_id)); + } + else + { + m_threadName = ::std::move(QString("Thread %1").arg(_root.thread_id)); + } } EasyGraphicsItem::~EasyGraphicsItem() diff --git a/profiler_gui/tree_widget_loader.cpp b/profiler_gui/tree_widget_loader.cpp index f258999..39af6c4 100644 --- a/profiler_gui/tree_widget_loader.cpp +++ b/profiler_gui/tree_widget_loader.cpp @@ -168,6 +168,7 @@ void FillTreeClass::setTreeInternal1(T& _safelocker, Items& _items, ThreadedI } //const QSignalBlocker b(this); + const auto u_thread = ::profiler_gui::toUnicode("thread"); int i = 0; const int total = static_cast(_blocksTree.size()); for (const auto& threadTree : _blocksTree) @@ -178,10 +179,21 @@ void FillTreeClass::setTreeInternal1(T& _safelocker, Items& _items, ThreadedI const auto& root = threadTree.second; auto item = new EasyTreeWidgetItem(); - if (root.got_name()) - item->setText(COL_NAME, QString("%1 Thread %2").arg(root.name()).arg(root.thread_id)); - else - item->setText(COL_NAME, QString("Thread %1").arg(root.thread_id)); + QString threadName; + if (root.got_name()) + { + QString rootname(::profiler_gui::toUnicode(root.name())); + if (rootname.contains(u_thread, Qt::CaseInsensitive)) + threadName = ::std::move(QString("%1 %2").arg(rootname).arg(root.thread_id)); + else + threadName = ::std::move(QString("%1 Thread %2").arg(rootname).arg(root.thread_id)); + } + else + { + threadName = ::std::move(QString("Thread %1").arg(root.thread_id)); + } + + item->setText(COL_NAME, threadName); ::profiler::timestamp_t duration = 0; if (!root.children.empty()) @@ -239,6 +251,7 @@ void FillTreeClass::setTreeInternal2(T& _safelocker, Items& _items, ThreadedI RootsMap threadsMap; + const auto u_thread = ::profiler_gui::toUnicode("thread"); int i = 0, total = static_cast(_blocks.size()); //const QSignalBlocker b(this); for (const auto& block : _blocks) @@ -266,10 +279,21 @@ void FillTreeClass::setTreeInternal2(T& _safelocker, Items& _items, ThreadedI { thread_item = new EasyTreeWidgetItem(); - if (block.root->got_name()) - thread_item->setText(COL_NAME, QString("%1 Thread %2").arg(block.root->name()).arg(block.root->thread_id)); - else - thread_item->setText(COL_NAME, QString("Thread %1").arg(block.root->thread_id)); + QString threadName; + if (block.root->got_name()) + { + QString rootname(::profiler_gui::toUnicode(block.root->name())); + if (rootname.contains(u_thread, Qt::CaseInsensitive)) + threadName = ::std::move(QString("%1 %2").arg(rootname).arg(block.root->thread_id)); + else + threadName = ::std::move(QString("%1 Thread %2").arg(rootname).arg(block.root->thread_id)); + } + else + { + threadName = ::std::move(QString("Thread %1").arg(block.root->thread_id)); + } + + thread_item->setText(COL_NAME, threadName); if (!block.root->children.empty()) duration = blocksTree(block.root->children.back()).node->end() - blocksTree(block.root->children.front()).node->begin();