From f03fa50dd5567a858cebf87d6174f0dc55a183b1 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Tue, 5 Dec 2017 21:53:14 +0300 Subject: [PATCH] #0 [GUI] Appearance --- profiler_gui/blocks_tree_widget.cpp | 1 - profiler_gui/descriptors_tree_widget.cpp | 62 +++++++++++++++--------- profiler_gui/descriptors_tree_widget.h | 4 +- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/profiler_gui/blocks_tree_widget.cpp b/profiler_gui/blocks_tree_widget.cpp index 836f3c3..232d93f 100644 --- a/profiler_gui/blocks_tree_widget.cpp +++ b/profiler_gui/blocks_tree_widget.cpp @@ -1180,7 +1180,6 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent) connect(a, &QAction::triggered, this, &This::findPrevFromMenu); menu->addAction(a); - menu->addSeparator(); a = menu->addAction("Case sensitive"); a->setCheckable(true); a->setChecked(m_bCaseSensitiveSearch); diff --git a/profiler_gui/descriptors_tree_widget.cpp b/profiler_gui/descriptors_tree_widget.cpp index 5123cf9..f037eee 100644 --- a/profiler_gui/descriptors_tree_widget.cpp +++ b/profiler_gui/descriptors_tree_widget.cpp @@ -289,6 +289,18 @@ EasyDescTreeWidget::~EasyDescTreeWidget() ////////////////////////////////////////////////////////////////////////// +void EasyDescTreeWidget::setSearchColumn(int column) +{ + m_searchColumn = column; +} + +int EasyDescTreeWidget::searchColumn() const +{ + return m_searchColumn; +} + +////////////////////////////////////////////////////////////////////////// + void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event) { _event->accept(); @@ -303,22 +315,6 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event) action->setIcon(QIcon(imagePath("collapse"))); connect(action, &QAction::triggered, this, &This::collapseAll); - menu.addSeparator(); - auto submenu = menu.addMenu("Search by"); - auto header_item = headerItem(); - for (int i = 0; i < DESC_COL_STATUS; ++i) - { - if (i == DESC_COL_TYPE) - continue; - - action = submenu->addAction(header_item->text(i)); - action->setData(i); - action->setCheckable(true); - if (i == m_searchColumn) - action->setChecked(true); - connect(action, &QAction::triggered, this, &This::onSearchColumnChange); - } - auto item = currentItem(); if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE) { @@ -352,13 +348,6 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event) menu.exec(QCursor::pos()); } -void EasyDescTreeWidget::onSearchColumnChange(bool) -{ - auto action = qobject_cast(sender()); - if (action != nullptr) - m_searchColumn = action->data().toInt(); -} - ////////////////////////////////////////////////////////////////////////// void EasyDescTreeWidget::clearSilent(bool _global) @@ -801,13 +790,31 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent) connect(a, &QAction::triggered, this, &This::findPrevFromMenu); menu->addAction(a); - menu->addSeparator(); a = menu->addAction("Case sensitive"); a->setCheckable(true); a->setChecked(m_bCaseSensitiveSearch); connect(a, &QAction::triggered, [this](bool _checked){ m_bCaseSensitiveSearch = _checked; }); menu->addAction(a); + menu->addSeparator(); + auto headerItem = m_tree->headerItem(); + actionGroup = new QActionGroup(this); + actionGroup->setExclusive(true); + for (int i = 0; i < DESC_COL_STATUS; ++i) + { + if (i == DESC_COL_TYPE) + continue; + + a = new QAction(QStringLiteral("Search by ") + headerItem->text(i), actionGroup); + a->setData(i); + a->setCheckable(true); + if (i == m_tree->searchColumn()) + a->setChecked(true); + connect(a, &QAction::triggered, this, &This::onSearchColumnChange); + + menu->addAction(a); + } + tb->addSeparator(); tb->addAction(m_searchButton); tb->addWidget(m_searchBox); @@ -891,6 +898,13 @@ void EasyDescWidget::onSeachBoxReturnPressed() findPrev(true); } +void EasyDescWidget::onSearchColumnChange(bool) +{ + auto action = qobject_cast(sender()); + if (action != nullptr) + m_tree->setSearchColumn(action->data().toInt()); +} + void EasyDescWidget::findNext(bool) { auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); diff --git a/profiler_gui/descriptors_tree_widget.h b/profiler_gui/descriptors_tree_widget.h index 0dccd18..34ee88d 100644 --- a/profiler_gui/descriptors_tree_widget.h +++ b/profiler_gui/descriptors_tree_widget.h @@ -162,6 +162,8 @@ public: int findNext(const QString& _str, Qt::MatchFlags _flags); int findPrev(const QString& _str, Qt::MatchFlags _flags); + void setSearchColumn(int column); + int searchColumn() const; public slots: @@ -170,7 +172,6 @@ public slots: private slots: - void onSearchColumnChange(bool); void onBlockStatusChangeClicked(bool); void onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev); void onItemExpand(QTreeWidgetItem* _item); @@ -229,6 +230,7 @@ private slots: void findPrev(bool); void findNextFromMenu(bool); void findPrevFromMenu(bool); + void onSearchColumnChange(bool); private: