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

#0 [GUI] Appearance

This commit is contained in:
Victor Zarubkin 2017-12-05 21:53:14 +03:00
parent b11c68e71f
commit f03fa50dd5
3 changed files with 41 additions and 26 deletions

View File

@ -1180,7 +1180,6 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
connect(a, &QAction::triggered, this, &This::findPrevFromMenu); connect(a, &QAction::triggered, this, &This::findPrevFromMenu);
menu->addAction(a); menu->addAction(a);
menu->addSeparator();
a = menu->addAction("Case sensitive"); a = menu->addAction("Case sensitive");
a->setCheckable(true); a->setCheckable(true);
a->setChecked(m_bCaseSensitiveSearch); a->setChecked(m_bCaseSensitiveSearch);

View File

@ -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) void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
_event->accept(); _event->accept();
@ -303,22 +315,6 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
action->setIcon(QIcon(imagePath("collapse"))); action->setIcon(QIcon(imagePath("collapse")));
connect(action, &QAction::triggered, this, &This::collapseAll); 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(); auto item = currentItem();
if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE) if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE)
{ {
@ -352,13 +348,6 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
menu.exec(QCursor::pos()); menu.exec(QCursor::pos());
} }
void EasyDescTreeWidget::onSearchColumnChange(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action != nullptr)
m_searchColumn = action->data().toInt();
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::clearSilent(bool _global) void EasyDescTreeWidget::clearSilent(bool _global)
@ -801,13 +790,31 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
connect(a, &QAction::triggered, this, &This::findPrevFromMenu); connect(a, &QAction::triggered, this, &This::findPrevFromMenu);
menu->addAction(a); menu->addAction(a);
menu->addSeparator();
a = menu->addAction("Case sensitive"); a = menu->addAction("Case sensitive");
a->setCheckable(true); a->setCheckable(true);
a->setChecked(m_bCaseSensitiveSearch); a->setChecked(m_bCaseSensitiveSearch);
connect(a, &QAction::triggered, [this](bool _checked){ m_bCaseSensitiveSearch = _checked; }); connect(a, &QAction::triggered, [this](bool _checked){ m_bCaseSensitiveSearch = _checked; });
menu->addAction(a); 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->addSeparator();
tb->addAction(m_searchButton); tb->addAction(m_searchButton);
tb->addWidget(m_searchBox); tb->addWidget(m_searchBox);
@ -891,6 +898,13 @@ void EasyDescWidget::onSeachBoxReturnPressed()
findPrev(true); findPrev(true);
} }
void EasyDescWidget::onSearchColumnChange(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action != nullptr)
m_tree->setSearchColumn(action->data().toInt());
}
void EasyDescWidget::findNext(bool) void EasyDescWidget::findNext(bool)
{ {
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());

View File

@ -162,6 +162,8 @@ public:
int findNext(const QString& _str, Qt::MatchFlags _flags); int findNext(const QString& _str, Qt::MatchFlags _flags);
int findPrev(const QString& _str, Qt::MatchFlags _flags); int findPrev(const QString& _str, Qt::MatchFlags _flags);
void setSearchColumn(int column);
int searchColumn() const;
public slots: public slots:
@ -170,7 +172,6 @@ public slots:
private slots: private slots:
void onSearchColumnChange(bool);
void onBlockStatusChangeClicked(bool); void onBlockStatusChangeClicked(bool);
void onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev); void onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev);
void onItemExpand(QTreeWidgetItem* _item); void onItemExpand(QTreeWidgetItem* _item);
@ -229,6 +230,7 @@ private slots:
void findPrev(bool); void findPrev(bool);
void findNextFromMenu(bool); void findNextFromMenu(bool);
void findPrevFromMenu(bool); void findPrevFromMenu(bool);
void onSearchColumnChange(bool);
private: private: