0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +08:00

(GUI) similar blocks highlighting fix;

(EasyDescTreeWidget) tree build fix;
This commit is contained in:
Victor Zarubkin 2016-12-07 22:40:45 +03:00
parent 46c4867b2d
commit 0a4f9b0f43
2 changed files with 10 additions and 5 deletions

View File

@ -57,6 +57,7 @@
#include <QToolBar> #include <QToolBar>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QTimer>
#include <thread> #include <thread>
#include "descriptors_tree_widget.h" #include "descriptors_tree_widget.h"
#include "globals.h" #include "globals.h"
@ -382,7 +383,7 @@ void EasyDescTreeWidget::build()
auto it = p.children.find(desc->line()); auto it = p.children.find(desc->line());
if (it == p.children.end()) if (it == p.children.end())
{ {
auto item = new EasyDescWidgetItem(id, p.item); auto item = new EasyDescWidgetItem(desc->id(), p.item);
item->setText(DESC_COL_FILE_LINE, QString::number(desc->line())); item->setText(DESC_COL_FILE_LINE, QString::number(desc->line()));
item->setData(DESC_COL_FILE_LINE, Qt::UserRole, desc->line()); item->setData(DESC_COL_FILE_LINE, Qt::UserRole, desc->line());
item->setText(DESC_COL_NAME, desc->name()); item->setText(DESC_COL_NAME, desc->name());
@ -403,6 +404,7 @@ void EasyDescTreeWidget::build()
item->setForeground(DESC_COL_STATUS, QColor::fromRgba(statusColor(desc->status()))); item->setForeground(DESC_COL_STATUS, QColor::fromRgba(statusColor(desc->status())));
m_items[id] = item; m_items[id] = item;
p.children.insert(::std::make_pair(desc->line(), item));
} }
else else
{ {
@ -424,6 +426,7 @@ void EasyDescTreeWidget::build()
setSortingEnabled(true); setSortingEnabled(true);
sortByColumn(DESC_COL_FILE_LINE, Qt::AscendingOrder); sortByColumn(DESC_COL_FILE_LINE, Qt::AscendingOrder);
resizeColumnsToContents(); resizeColumnsToContents();
QTimer::singleShot(100, [this](){ onSelectedBlockChange(EASY_GLOBALS.selected_block); });
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -541,7 +544,7 @@ void EasyDescTreeWidget::resizeColumnsToContents()
void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index) void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index)
{ {
if (_block_index == ::profiler_gui::numeric_max(_block_index)) if (::profiler_gui::is_max(_block_index))
return; return;
auto item = m_items[blocksTree(_block_index).node->id()]; auto item = m_items[blocksTree(_block_index).node->id()];

View File

@ -352,7 +352,8 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
_painter->setBrush(brush); _painter->setBrush(brush);
} }
if (EASY_GLOBALS.highlight_blocks_with_same_id && EASY_GLOBALS.selected_block_id == itemDesc.id()) if (EASY_GLOBALS.highlight_blocks_with_same_id && (EASY_GLOBALS.selected_block_id == itemBlock.tree.node->id()
|| (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && EASY_GLOBALS.selected_block_id == itemDesc.id())))
{ {
if (previousPenStyle != Qt::DotLine) if (previousPenStyle != Qt::DotLine)
{ {
@ -409,7 +410,8 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
_painter->setBrush(brush); _painter->setBrush(brush);
} }
if (EASY_GLOBALS.highlight_blocks_with_same_id && EASY_GLOBALS.selected_block_id == itemDesc.id()) if (EASY_GLOBALS.highlight_blocks_with_same_id && (EASY_GLOBALS.selected_block_id == itemBlock.tree.node->id()
|| (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && EASY_GLOBALS.selected_block_id == itemDesc.id())))
{ {
if (previousPenStyle != Qt::DotLine) if (previousPenStyle != Qt::DotLine)
{ {
@ -578,7 +580,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
_painter->setFont(SELECTED_ITEM_FONT); _painter->setFont(SELECTED_ITEM_FONT);
// drawing text // drawing text
auto name = *itemBlock.tree.node->name() != 0 ? itemBlock.tree.node->name() : easyDescriptor(itemBlock.tree.node->id()).name(); auto name = *itemBlock.tree.node->name() != 0 ? itemBlock.tree.node->name() : itemDesc.name();
_painter->drawText(rect, Qt::AlignCenter, ::profiler_gui::toUnicode(name)); _painter->drawText(rect, Qt::AlignCenter, ::profiler_gui::toUnicode(name));
// END Draw text~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // END Draw text~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} }