mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 08:37:55 +08:00
#0 [UI] Adjusted search boxes in Hierarchy widget and Blocks Descriptors Widget
This commit is contained in:
parent
212502578f
commit
e8d667e083
@ -1088,7 +1088,7 @@ void BlocksTreeWidget::saveSettings()
|
|||||||
HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
|
HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
|
||||||
, m_tree(new BlocksTreeWidget(this))
|
, m_tree(new BlocksTreeWidget(this))
|
||||||
, m_searchBox(new QLineEdit(this))
|
, m_searchBox(new QLineEdit(this))
|
||||||
, m_foundNumber(new QLabel("Found 0 matches", this))
|
, m_foundNumber(new QLabel("0 matches", this))
|
||||||
, m_searchButton(nullptr)
|
, m_searchButton(nullptr)
|
||||||
, m_bCaseSensitiveSearch(false)
|
, m_bCaseSensitiveSearch(false)
|
||||||
{
|
{
|
||||||
@ -1096,6 +1096,8 @@ HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
|
|||||||
|
|
||||||
m_searchBox->setFixedWidth(300);
|
m_searchBox->setFixedWidth(300);
|
||||||
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
||||||
|
m_searchBox->setClearButtonEnabled(true);
|
||||||
|
m_searchBox->setPlaceholderText("Search by name");
|
||||||
|
|
||||||
auto menu = new QMenu(this);
|
auto menu = new QMenu(this);
|
||||||
m_searchButton = menu->menuAction();
|
m_searchButton = menu->menuAction();
|
||||||
@ -1133,8 +1135,9 @@ HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
|
|||||||
auto searchbox = new QHBoxLayout();
|
auto searchbox = new QHBoxLayout();
|
||||||
searchbox->setContentsMargins(0, 0, 5, 0);
|
searchbox->setContentsMargins(0, 0, 5, 0);
|
||||||
searchbox->addWidget(tb);
|
searchbox->addWidget(tb);
|
||||||
|
searchbox->addSpacing(5);
|
||||||
|
searchbox->addWidget(m_foundNumber);
|
||||||
searchbox->addStretch(100);
|
searchbox->addStretch(100);
|
||||||
searchbox->addWidget(m_foundNumber, Qt::AlignRight);
|
|
||||||
|
|
||||||
auto lay = new QVBoxLayout(this);
|
auto lay = new QVBoxLayout(this);
|
||||||
lay->setContentsMargins(1, 1, 1, 1);
|
lay->setContentsMargins(1, 1, 1, 1);
|
||||||
@ -1142,9 +1145,13 @@ HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
|
|||||||
lay->addWidget(m_tree);
|
lay->addWidget(m_tree);
|
||||||
|
|
||||||
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
|
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
|
||||||
|
connect(m_searchBox, &QLineEdit::textChanged, this, &This::onSearchBoxTextChanged);
|
||||||
|
|
||||||
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, [this] {
|
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, [this] {
|
||||||
clear(true);
|
clear(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_foundNumber->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
HierarchyWidget::~HierarchyWidget()
|
HierarchyWidget::~HierarchyWidget()
|
||||||
@ -1202,7 +1209,8 @@ BlocksTreeWidget* HierarchyWidget::tree()
|
|||||||
void HierarchyWidget::clear(bool _global)
|
void HierarchyWidget::clear(bool _global)
|
||||||
{
|
{
|
||||||
m_tree->clearSilent(_global);
|
m_tree->clearSilent(_global);
|
||||||
m_foundNumber->setText(QString("Found 0 matches"));
|
m_foundNumber->setText(QString("0 matches"));
|
||||||
|
m_foundNumber->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchyWidget::onSeachBoxReturnPressed()
|
void HierarchyWidget::onSeachBoxReturnPressed()
|
||||||
@ -1213,24 +1221,52 @@ void HierarchyWidget::onSeachBoxReturnPressed()
|
|||||||
findPrev(true);
|
findPrev(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HierarchyWidget::onSearchBoxTextChanged(const QString& _text)
|
||||||
|
{
|
||||||
|
if (_text.isEmpty())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void HierarchyWidget::findNext(bool)
|
void HierarchyWidget::findNext(bool)
|
||||||
{
|
{
|
||||||
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
auto text = m_searchBox->text();
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
if (m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto matches = m_tree->findNext(text, m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||||
|
|
||||||
if (matches == 1)
|
if (matches == 1)
|
||||||
m_foundNumber->setText(QString("Found 1 match"));
|
m_foundNumber->setText(QString("1 match"));
|
||||||
else
|
else
|
||||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
m_foundNumber->setText(QString("%1 matches").arg(matches));
|
||||||
|
|
||||||
|
if (!m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchyWidget::findPrev(bool)
|
void HierarchyWidget::findPrev(bool)
|
||||||
{
|
{
|
||||||
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
auto text = m_searchBox->text();
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
if (m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto matches = m_tree->findPrev(text, m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||||
|
|
||||||
if (matches == 1)
|
if (matches == 1)
|
||||||
m_foundNumber->setText(QString("Found 1 match"));
|
m_foundNumber->setText(QString("1 match"));
|
||||||
else
|
else
|
||||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
m_foundNumber->setText(QString("%1 matches").arg(matches));
|
||||||
|
|
||||||
|
if (!m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchyWidget::findNextFromMenu(bool _checked)
|
void HierarchyWidget::findNextFromMenu(bool _checked)
|
||||||
|
@ -202,6 +202,7 @@ private slots:
|
|||||||
// Private slots
|
// Private slots
|
||||||
|
|
||||||
void onSeachBoxReturnPressed();
|
void onSeachBoxReturnPressed();
|
||||||
|
void onSearchBoxTextChanged(const QString& _text);
|
||||||
void findNext(bool);
|
void findNext(bool);
|
||||||
void findPrev(bool);
|
void findPrev(bool);
|
||||||
void findNextFromMenu(bool);
|
void findNextFromMenu(bool);
|
||||||
|
@ -284,6 +284,7 @@ DescriptorsTreeWidget::~DescriptorsTreeWidget()
|
|||||||
void DescriptorsTreeWidget::setSearchColumn(int column)
|
void DescriptorsTreeWidget::setSearchColumn(int column)
|
||||||
{
|
{
|
||||||
m_searchColumn = column;
|
m_searchColumn = column;
|
||||||
|
emit searchColumnChanged(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DescriptorsTreeWidget::searchColumn() const
|
int DescriptorsTreeWidget::searchColumn() const
|
||||||
@ -754,7 +755,7 @@ BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_paren
|
|||||||
, m_tree(new DescriptorsTreeWidget(this))
|
, m_tree(new DescriptorsTreeWidget(this))
|
||||||
, m_values(new ArbitraryValuesWidget(this))
|
, m_values(new ArbitraryValuesWidget(this))
|
||||||
, m_searchBox(new QLineEdit(this))
|
, m_searchBox(new QLineEdit(this))
|
||||||
, m_foundNumber(new QLabel("Found 0 matches", this))
|
, m_foundNumber(new QLabel("0 matches", this))
|
||||||
, m_searchButton(nullptr)
|
, m_searchButton(nullptr)
|
||||||
, m_bCaseSensitiveSearch(false)
|
, m_bCaseSensitiveSearch(false)
|
||||||
{
|
{
|
||||||
@ -767,6 +768,8 @@ BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_paren
|
|||||||
|
|
||||||
m_searchBox->setFixedWidth(300);
|
m_searchBox->setFixedWidth(300);
|
||||||
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
||||||
|
m_searchBox->setClearButtonEnabled(true);
|
||||||
|
m_searchBox->setPlaceholderText("Search");
|
||||||
|
|
||||||
auto tb = new QToolBar(this);
|
auto tb = new QToolBar(this);
|
||||||
tb->setIconSize(applicationIconsSize());
|
tb->setIconSize(applicationIconsSize());
|
||||||
@ -831,8 +834,9 @@ BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_paren
|
|||||||
auto searchbox = new QHBoxLayout();
|
auto searchbox = new QHBoxLayout();
|
||||||
searchbox->setContentsMargins(0, 0, 5, 0);
|
searchbox->setContentsMargins(0, 0, 5, 0);
|
||||||
searchbox->addWidget(tb);
|
searchbox->addWidget(tb);
|
||||||
|
searchbox->addSpacing(5);
|
||||||
|
searchbox->addWidget(m_foundNumber);
|
||||||
searchbox->addStretch(100);
|
searchbox->addStretch(100);
|
||||||
searchbox->addWidget(m_foundNumber, Qt::AlignRight);
|
|
||||||
|
|
||||||
auto lay = new QVBoxLayout(this);
|
auto lay = new QVBoxLayout(this);
|
||||||
lay->setContentsMargins(1, 1, 1, 1);
|
lay->setContentsMargins(1, 1, 1, 1);
|
||||||
@ -840,12 +844,19 @@ BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_paren
|
|||||||
lay->addWidget(m_splitter);
|
lay->addWidget(m_splitter);
|
||||||
|
|
||||||
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
|
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
|
||||||
|
connect(m_searchBox, &QLineEdit::textChanged, this, &This::onSearchBoxTextChanged);
|
||||||
|
|
||||||
|
connect(m_tree, &DescriptorsTreeWidget::searchColumnChanged, this, &This::onSearchColumnChanged);
|
||||||
|
|
||||||
connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled);
|
connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled);
|
||||||
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, this, &This::clear);
|
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, this, &This::clear);
|
||||||
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::fileOpened, this, &This::build);
|
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::fileOpened, this, &This::build);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
caseSensitiveSwitch->setChecked(m_bCaseSensitiveSearch);
|
caseSensitiveSwitch->setChecked(m_bCaseSensitiveSearch);
|
||||||
|
|
||||||
|
onSearchColumnChanged(m_tree->searchColumn());
|
||||||
|
m_foundNumber->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockDescriptorsWidget::~BlockDescriptorsWidget()
|
BlockDescriptorsWidget::~BlockDescriptorsWidget()
|
||||||
@ -904,7 +915,8 @@ void BlockDescriptorsWidget::contextMenuEvent(QContextMenuEvent* _event)
|
|||||||
void BlockDescriptorsWidget::build()
|
void BlockDescriptorsWidget::build()
|
||||||
{
|
{
|
||||||
m_tree->clearSilent(false);
|
m_tree->clearSilent(false);
|
||||||
m_foundNumber->setText(QString("Found 0 matches"));
|
m_foundNumber->setText(QString("0 matches"));
|
||||||
|
m_foundNumber->hide();
|
||||||
m_tree->build();
|
m_tree->build();
|
||||||
m_values->rebuild();
|
m_values->rebuild();
|
||||||
}
|
}
|
||||||
@ -912,7 +924,8 @@ void BlockDescriptorsWidget::build()
|
|||||||
void BlockDescriptorsWidget::clear()
|
void BlockDescriptorsWidget::clear()
|
||||||
{
|
{
|
||||||
m_tree->clearSilent(true);
|
m_tree->clearSilent(true);
|
||||||
m_foundNumber->setText(QString("Found 0 matches"));
|
m_foundNumber->setText(QString("0 matches"));
|
||||||
|
m_foundNumber->hide();
|
||||||
m_values->clear();
|
m_values->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,6 +942,32 @@ void BlockDescriptorsWidget::onSeachBoxReturnPressed()
|
|||||||
findPrev(true);
|
findPrev(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlockDescriptorsWidget::onSearchBoxTextChanged(const QString& _text)
|
||||||
|
{
|
||||||
|
if (_text.isEmpty())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlockDescriptorsWidget::onSearchColumnChanged(int column)
|
||||||
|
{
|
||||||
|
switch (column)
|
||||||
|
{
|
||||||
|
case DESC_COL_NAME:
|
||||||
|
m_searchBox->setPlaceholderText("Search by name");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DESC_COL_FILE_LINE:
|
||||||
|
m_searchBox->setPlaceholderText("Search by filename");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_searchBox->setPlaceholderText("Search");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSeachBoxReturnPressed();
|
||||||
|
}
|
||||||
|
|
||||||
void BlockDescriptorsWidget::onSearchColumnChange(bool)
|
void BlockDescriptorsWidget::onSearchColumnChange(bool)
|
||||||
{
|
{
|
||||||
auto action = qobject_cast<QAction*>(sender());
|
auto action = qobject_cast<QAction*>(sender());
|
||||||
@ -938,22 +977,44 @@ void BlockDescriptorsWidget::onSearchColumnChange(bool)
|
|||||||
|
|
||||||
void BlockDescriptorsWidget::findNext(bool)
|
void BlockDescriptorsWidget::findNext(bool)
|
||||||
{
|
{
|
||||||
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
auto text = m_searchBox->text();
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
if (m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto matches = m_tree->findNext(text, m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||||
|
|
||||||
if (matches == 1)
|
if (matches == 1)
|
||||||
m_foundNumber->setText(QString("Found 1 match"));
|
m_foundNumber->setText(QString("1 match"));
|
||||||
else
|
else
|
||||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
m_foundNumber->setText(QString("%1 matches").arg(matches));
|
||||||
|
|
||||||
|
if (!m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockDescriptorsWidget::findPrev(bool)
|
void BlockDescriptorsWidget::findPrev(bool)
|
||||||
{
|
{
|
||||||
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
auto text = m_searchBox->text();
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
if (m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto matches = m_tree->findPrev(text, m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||||
|
|
||||||
if (matches == 1)
|
if (matches == 1)
|
||||||
m_foundNumber->setText(QString("Found 1 match"));
|
m_foundNumber->setText(QString("1 match"));
|
||||||
else
|
else
|
||||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
m_foundNumber->setText(QString("%1 matches").arg(matches));
|
||||||
|
|
||||||
|
if (!m_foundNumber->isVisible())
|
||||||
|
m_foundNumber->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockDescriptorsWidget::findNextFromMenu(bool _checked)
|
void BlockDescriptorsWidget::findNextFromMenu(bool _checked)
|
||||||
|
@ -152,6 +152,10 @@ public:
|
|||||||
void setSearchColumn(int column);
|
void setSearchColumn(int column);
|
||||||
int searchColumn() const;
|
int searchColumn() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void searchColumnChanged(int column);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void clearSilent(bool _global = false);
|
void clearSilent(bool _global = false);
|
||||||
@ -221,6 +225,8 @@ private slots:
|
|||||||
void findNextFromMenu(bool);
|
void findNextFromMenu(bool);
|
||||||
void findPrevFromMenu(bool);
|
void findPrevFromMenu(bool);
|
||||||
void onSearchColumnChange(bool);
|
void onSearchColumnChange(bool);
|
||||||
|
void onSearchBoxTextChanged(const QString& _text);
|
||||||
|
void onSearchColumnChanged(int column);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user