diff --git a/profiler_gui/CMakeLists.txt b/profiler_gui/CMakeLists.txt index c931d8a..688152c 100644 --- a/profiler_gui/CMakeLists.txt +++ b/profiler_gui/CMakeLists.txt @@ -50,8 +50,6 @@ if (Qt5Widgets_FOUND) tree_widget_item.cpp tree_widget_loader.h tree_widget_loader.cpp - treeview_first_column_delegate.h - treeview_first_column_delegate.cpp resources.qrc resources.rc ) diff --git a/profiler_gui/arbitrary_value_inspector.cpp b/profiler_gui/arbitrary_value_inspector.cpp index a2e90e2..e870e5c 100644 --- a/profiler_gui/arbitrary_value_inspector.cpp +++ b/profiler_gui/arbitrary_value_inspector.cpp @@ -75,7 +75,6 @@ #include #include #include "arbitrary_value_inspector.h" -#include "treeview_first_column_delegate.h" #include "globals.h" #include "easy_complexity_calculator.h" @@ -1744,7 +1743,6 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent) //m_treeWidget->setSortingEnabled(false); m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count)); m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - m_treeWidget->setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(m_treeWidget)); auto headerItem = new QTreeWidgetItem(); headerItem->setText(int_cast(ArbitraryColumns::Type), "Type"); diff --git a/profiler_gui/descriptors_tree_widget.cpp b/profiler_gui/descriptors_tree_widget.cpp index db2449a..926a52f 100644 --- a/profiler_gui/descriptors_tree_widget.cpp +++ b/profiler_gui/descriptors_tree_widget.cpp @@ -73,7 +73,6 @@ #include #include "descriptors_tree_widget.h" #include "arbitrary_value_inspector.h" -#include "treeview_first_column_delegate.h" #include "globals.h" #ifdef _WIN32 @@ -276,8 +275,6 @@ DescriptorsTreeWidget::DescriptorsTreeWidget(QWidget* _parent) connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange); loadSettings(); - - setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this)); } DescriptorsTreeWidget::~DescriptorsTreeWidget() diff --git a/profiler_gui/resources.qrc b/profiler_gui/resources.qrc index f9f49dc..641e5de 100644 --- a/profiler_gui/resources.qrc +++ b/profiler_gui/resources.qrc @@ -46,6 +46,7 @@ images/default/arrow-down.svg images/default/arrow-down-hover.svg images/default/arrow-down-disabled.svg + images/default/arrow-right.svg images/default/yx.svg images/default/big-o.svg images/default/csv.svg diff --git a/profiler_gui/themes/default.css b/profiler_gui/themes/default.css index 8e21911..52fc8a8 100644 --- a/profiler_gui/themes/default.css +++ b/profiler_gui/themes/default.css @@ -143,6 +143,23 @@ QListView, QTableView, QTreeView { selection-background-color: rgba(152, 222, 152, 0.8); selection-color: #504040; } +QTreeView::branch { + selection-background-color: rgba(152, 222, 152, 0.8); + border-bottom: 1px solid #cccccc; } + +QTreeView::branch:selected { + background-color: transparent; } + +QTreeView::branch:open:has-children { + padding: 9px 0 9px 0; + border-image: none; + image: url(":/images/default/arrow-down"); } + +QTreeView::branch:closed:has-children { + padding: 9px 0 9px 0; + border-image: none; + image: url(":/images/default/arrow-right"); } + QListView::item, QTableView::item, QTreeView::item { height: 26px; border-bottom: 1px solid #cccccc; } diff --git a/profiler_gui/themes/default.scss b/profiler_gui/themes/default.scss index 5dd4088..f001411 100644 --- a/profiler_gui/themes/default.scss +++ b/profiler_gui/themes/default.scss @@ -160,6 +160,27 @@ QListView, QTableView, QTreeView { selection-color: $TextColor; } +QTreeView::branch { + selection-background-color: rgb_a(#98DE98, 0.8); + border-bottom: 1px solid $BorderColor; +} + +QTreeView::branch:selected { + background-color: transparent; +} + +QTreeView::branch:open:has-children { + padding: 9px 0 9px 0; + border-image: none; + image: url(":/images/default/arrow-down"); +} + +QTreeView::branch:closed:has-children { + padding: 9px 0 9px 0; + border-image: none; + image: url(":/images/default/arrow-right"); +} + QListView::item, QTableView::item, QTreeView::item { height: $DefaultHeight + 2px; border-bottom: 1px solid $BorderColor; diff --git a/profiler_gui/tree_widget_item.cpp b/profiler_gui/tree_widget_item.cpp index 0d3fb92..3174ba9 100644 --- a/profiler_gui/tree_widget_item.cpp +++ b/profiler_gui/tree_widget_item.cpp @@ -350,57 +350,23 @@ TreeWidgetItemDelegate::~TreeWidgetItemDelegate() void TreeWidgetItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - const auto colorBlockSize = option.rect.height() >> 1; - auto brushData = m_treeWidget->model()->data(index, BlockColorRole); if (brushData.isNull()) { -#ifdef _WIN32 - const auto currentTreeIndex = m_treeWidget->currentIndex(); - if (index.parent() == currentTreeIndex.parent() && index.row() == currentTreeIndex.row()) - { - // Draw selection background for selected row - painter->save(); - painter->setBrush(QColor::fromRgba(0xCC98DE98)); - painter->setPen(Qt::NoPen); - painter->drawRect(QRect(0, option.rect.top(), option.rect.left() + colorBlockSize, option.rect.height())); - painter->restore(); - } -#endif - // Draw item as usual QStyledItemDelegate::paint(painter, option, index); - - // Draw line under tree indicator - const auto bottomLeft = option.rect.bottomLeft(); - if (bottomLeft.x() > 0) - { - painter->save(); - painter->setBrush(Qt::NoBrush); - painter->setPen(profiler_gui::SYSTEM_BORDER_COLOR); - painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft); - painter->restore(); - } - return; } + const auto colorBlockSize = option.rect.height() >> 1; const auto currentTreeIndex = m_treeWidget->currentIndex(); if (index.parent() == currentTreeIndex.parent() && index.row() == currentTreeIndex.row()) { // Draw selection background for selected row - painter->save(); - painter->setBrush(QColor::fromRgba(0xCC98DE98)); painter->setPen(Qt::NoPen); - -#ifdef _WIN32 - painter->drawRect(QRect(0, option.rect.top(), option.rect.left() + colorBlockSize, option.rect.height())); -#else painter->drawRect(QRect(option.rect.left(), option.rect.top(), colorBlockSize, option.rect.height())); -#endif - painter->restore(); } @@ -424,11 +390,8 @@ void TreeWidgetItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem // Draw line under tree indicator const auto bottomLeft = opt.rect.bottomLeft(); - if (bottomLeft.x() > 0) - { - painter->setBrush(Qt::NoBrush); - painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft); - } + painter->setBrush(Qt::NoBrush); + painter->drawLine(QPoint(bottomLeft.x() - colorBlockSize, bottomLeft.y()), bottomLeft); painter->restore(); } diff --git a/profiler_gui/treeview_first_column_delegate.cpp b/profiler_gui/treeview_first_column_delegate.cpp deleted file mode 100644 index fdbc8ed..0000000 --- a/profiler_gui/treeview_first_column_delegate.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -#include -#include -#include -#include "treeview_first_column_delegate.h" -#include "globals.h" - -TreeViewFirstColumnItemDelegate::TreeViewFirstColumnItemDelegate(QTreeWidget* parent) : QStyledItemDelegate(parent) -{ - -} - -TreeViewFirstColumnItemDelegate::~TreeViewFirstColumnItemDelegate() -{ - -} - -void TreeViewFirstColumnItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - // Draw item as usual - QStyledItemDelegate::paint(painter, option, index); - - // Draw line under tree indicator - const auto bottomLeft = option.rect.bottomLeft(); - if (bottomLeft.x() > 0) - { - painter->save(); - - if (static_cast(parent())->currentIndex() == index) - { - // Draw selection background for current item - painter->setBrush(QColor::fromRgba(0xCC98DE98)); - painter->setPen(Qt::NoPen); - painter->drawRect(QRectF(0, option.rect.top(), bottomLeft.x(), option.rect.height())); - } - - painter->setBrush(Qt::NoBrush); - painter->setPen(::profiler_gui::SYSTEM_BORDER_COLOR); - painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft); - - painter->restore(); - } -} \ No newline at end of file diff --git a/profiler_gui/treeview_first_column_delegate.h b/profiler_gui/treeview_first_column_delegate.h deleted file mode 100644 index 10e1001..0000000 --- a/profiler_gui/treeview_first_column_delegate.h +++ /dev/null @@ -1,23 +0,0 @@ - - - - - -#ifndef EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H -#define EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H - -#include - -class TreeViewFirstColumnItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - - explicit TreeViewFirstColumnItemDelegate(class QTreeWidget* parent = nullptr); - ~TreeViewFirstColumnItemDelegate() override; - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - -}; // END of class TreeViewFirstColumnItemDelegate. - -#endif // EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H