mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
#0 [Gui] TreeView style fixes
This commit is contained in:
parent
e3f1dfad10
commit
b6b988e274
@ -50,8 +50,6 @@ if (Qt5Widgets_FOUND)
|
|||||||
tree_widget_item.cpp
|
tree_widget_item.cpp
|
||||||
tree_widget_loader.h
|
tree_widget_loader.h
|
||||||
tree_widget_loader.cpp
|
tree_widget_loader.cpp
|
||||||
treeview_first_column_delegate.h
|
|
||||||
treeview_first_column_delegate.cpp
|
|
||||||
resources.qrc
|
resources.qrc
|
||||||
resources.rc
|
resources.rc
|
||||||
)
|
)
|
||||||
|
@ -75,7 +75,6 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "arbitrary_value_inspector.h"
|
#include "arbitrary_value_inspector.h"
|
||||||
#include "treeview_first_column_delegate.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "easy_complexity_calculator.h"
|
#include "easy_complexity_calculator.h"
|
||||||
|
|
||||||
@ -1744,7 +1743,6 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent)
|
|||||||
//m_treeWidget->setSortingEnabled(false);
|
//m_treeWidget->setSortingEnabled(false);
|
||||||
m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count));
|
m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count));
|
||||||
m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
m_treeWidget->setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(m_treeWidget));
|
|
||||||
|
|
||||||
auto headerItem = new QTreeWidgetItem();
|
auto headerItem = new QTreeWidgetItem();
|
||||||
headerItem->setText(int_cast(ArbitraryColumns::Type), "Type");
|
headerItem->setText(int_cast(ArbitraryColumns::Type), "Type");
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include "descriptors_tree_widget.h"
|
#include "descriptors_tree_widget.h"
|
||||||
#include "arbitrary_value_inspector.h"
|
#include "arbitrary_value_inspector.h"
|
||||||
#include "treeview_first_column_delegate.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -276,8 +275,6 @@ DescriptorsTreeWidget::DescriptorsTreeWidget(QWidget* _parent)
|
|||||||
connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
|
connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorsTreeWidget::~DescriptorsTreeWidget()
|
DescriptorsTreeWidget::~DescriptorsTreeWidget()
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
<file alias="arrow-down">images/default/arrow-down.svg</file>
|
<file alias="arrow-down">images/default/arrow-down.svg</file>
|
||||||
<file alias="arrow-down-hover">images/default/arrow-down-hover.svg</file>
|
<file alias="arrow-down-hover">images/default/arrow-down-hover.svg</file>
|
||||||
<file alias="arrow-down-disabled">images/default/arrow-down-disabled.svg</file>
|
<file alias="arrow-down-disabled">images/default/arrow-down-disabled.svg</file>
|
||||||
|
<file alias="arrow-right">images/default/arrow-right.svg</file>
|
||||||
<file alias="yx-chart">images/default/yx.svg</file>
|
<file alias="yx-chart">images/default/yx.svg</file>
|
||||||
<file alias="big-o-chart">images/default/big-o.svg</file>
|
<file alias="big-o-chart">images/default/big-o.svg</file>
|
||||||
<file alias="csv">images/default/csv.svg</file>
|
<file alias="csv">images/default/csv.svg</file>
|
||||||
|
@ -143,6 +143,23 @@ QListView, QTableView, QTreeView {
|
|||||||
selection-background-color: rgba(152, 222, 152, 0.8);
|
selection-background-color: rgba(152, 222, 152, 0.8);
|
||||||
selection-color: #504040; }
|
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 {
|
QListView::item, QTableView::item, QTreeView::item {
|
||||||
height: 26px;
|
height: 26px;
|
||||||
border-bottom: 1px solid #cccccc; }
|
border-bottom: 1px solid #cccccc; }
|
||||||
|
@ -160,6 +160,27 @@ QListView, QTableView, QTreeView {
|
|||||||
selection-color: $TextColor;
|
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 {
|
QListView::item, QTableView::item, QTreeView::item {
|
||||||
height: $DefaultHeight + 2px;
|
height: $DefaultHeight + 2px;
|
||||||
border-bottom: 1px solid $BorderColor;
|
border-bottom: 1px solid $BorderColor;
|
||||||
|
@ -350,57 +350,23 @@ TreeWidgetItemDelegate::~TreeWidgetItemDelegate()
|
|||||||
|
|
||||||
void TreeWidgetItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
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);
|
auto brushData = m_treeWidget->model()->data(index, BlockColorRole);
|
||||||
if (brushData.isNull())
|
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
|
// Draw item as usual
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto colorBlockSize = option.rect.height() >> 1;
|
||||||
const auto currentTreeIndex = m_treeWidget->currentIndex();
|
const auto currentTreeIndex = m_treeWidget->currentIndex();
|
||||||
if (index.parent() == currentTreeIndex.parent() && index.row() == currentTreeIndex.row())
|
if (index.parent() == currentTreeIndex.parent() && index.row() == currentTreeIndex.row())
|
||||||
{
|
{
|
||||||
// Draw selection background for selected row
|
// Draw selection background for selected row
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->setBrush(QColor::fromRgba(0xCC98DE98));
|
painter->setBrush(QColor::fromRgba(0xCC98DE98));
|
||||||
painter->setPen(Qt::NoPen);
|
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()));
|
painter->drawRect(QRect(option.rect.left(), option.rect.top(), colorBlockSize, option.rect.height()));
|
||||||
#endif
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,11 +390,8 @@ void TreeWidgetItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem
|
|||||||
|
|
||||||
// Draw line under tree indicator
|
// Draw line under tree indicator
|
||||||
const auto bottomLeft = opt.rect.bottomLeft();
|
const auto bottomLeft = opt.rect.bottomLeft();
|
||||||
if (bottomLeft.x() > 0)
|
painter->setBrush(Qt::NoBrush);
|
||||||
{
|
painter->drawLine(QPoint(bottomLeft.x() - colorBlockSize, bottomLeft.y()), bottomLeft);
|
||||||
painter->setBrush(Qt::NoBrush);
|
|
||||||
painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QTreeWidget>
|
|
||||||
#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<const QTreeWidget*>(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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H
|
|
||||||
#define EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H
|
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
|
||||||
|
|
||||||
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
|
|
Loading…
x
Reference in New Issue
Block a user