mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 00:31:02 +08:00
(GUI) Added possibility to do case sensitive search into blocks descriptions list and hierarchy window
This commit is contained in:
parent
92b2b27a3b
commit
f1017c3ed4
@ -374,13 +374,13 @@ void EasyTreeWidget::clearSilent(bool _global)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int EasyTreeWidget::findNext(const QString& _str)
|
||||
int EasyTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
|
||||
{
|
||||
if (m_bLocked || _str.isEmpty())
|
||||
return 0;
|
||||
|
||||
const bool isNewSearch = (m_lastSearch != _str);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive, COL_NAME);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive | _flags, COL_NAME);
|
||||
|
||||
if (!isNewSearch)
|
||||
{
|
||||
@ -424,13 +424,13 @@ int EasyTreeWidget::findNext(const QString& _str)
|
||||
return itemsList.size();
|
||||
}
|
||||
|
||||
int EasyTreeWidget::findPrev(const QString& _str)
|
||||
int EasyTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
|
||||
{
|
||||
if (m_bLocked || _str.isEmpty())
|
||||
return 0;
|
||||
|
||||
const bool isNewSearch = (m_lastSearch != _str);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive, COL_NAME);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive | _flags, COL_NAME);
|
||||
|
||||
if (!isNewSearch)
|
||||
{
|
||||
@ -922,11 +922,14 @@ void EasyTreeWidget::saveSettings()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
|
||||
, m_tree(new EasyTreeWidget(this))
|
||||
, m_searchBox(new QLineEdit(this))
|
||||
, m_foundNumber(new QLabel("Found 0 matches", this))
|
||||
, m_searchButton(nullptr)
|
||||
, m_tree(new EasyTreeWidget(this))
|
||||
, m_searchBox(new QLineEdit(this))
|
||||
, m_foundNumber(new QLabel("Found 0 matches", this))
|
||||
, m_searchButton(nullptr)
|
||||
, m_bCaseSensitiveSearch(false)
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
m_searchBox->setFixedWidth(200);
|
||||
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
||||
|
||||
@ -951,7 +954,15 @@ 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);
|
||||
connect(a, &QAction::triggered, [this](bool _checked){ m_bCaseSensitiveSearch = _checked; });
|
||||
menu->addAction(a);
|
||||
|
||||
auto tb = new QToolBar(this);
|
||||
tb->setContentsMargins(0, 0, 0, 0);
|
||||
tb->addAction(m_searchButton);
|
||||
tb->addWidget(m_searchBox);
|
||||
|
||||
@ -971,7 +982,27 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
|
||||
|
||||
EasyHierarchyWidget::~EasyHierarchyWidget()
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void EasyHierarchyWidget::loadSettings()
|
||||
{
|
||||
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
|
||||
settings.beginGroup("EasyHierarchyWidget");
|
||||
|
||||
auto val = settings.value("case_sensitive");
|
||||
if (!val.isNull())
|
||||
m_bCaseSensitiveSearch = val.toBool();
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void EasyHierarchyWidget::saveSettings()
|
||||
{
|
||||
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
|
||||
settings.beginGroup("EasyHierarchyWidget");
|
||||
settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void EasyHierarchyWidget::keyPressEvent(QKeyEvent* _event)
|
||||
@ -1000,17 +1031,15 @@ void EasyHierarchyWidget::clear(bool _global)
|
||||
|
||||
void EasyHierarchyWidget::onSeachBoxReturnPressed()
|
||||
{
|
||||
auto matches = m_tree->findNext(m_searchBox->text());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
if (m_searchButton->data().toBool() == true)
|
||||
findNext(true);
|
||||
else
|
||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
||||
findPrev(true);
|
||||
}
|
||||
|
||||
void EasyHierarchyWidget::findNext(bool)
|
||||
{
|
||||
auto matches = m_tree->findNext(m_searchBox->text());
|
||||
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
@ -1020,7 +1049,7 @@ void EasyHierarchyWidget::findNext(bool)
|
||||
|
||||
void EasyHierarchyWidget::findPrev(bool)
|
||||
{
|
||||
auto matches = m_tree->findPrev(m_searchBox->text());
|
||||
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
|
@ -88,8 +88,8 @@ public:
|
||||
virtual ~EasyTreeWidget();
|
||||
|
||||
void clearSilent(bool _global = false);
|
||||
int findNext(const QString& _str);
|
||||
int findPrev(const QString& _str);
|
||||
int findNext(const QString& _str, Qt::MatchFlags _flags);
|
||||
int findPrev(const QString& _str, Qt::MatchFlags _flags);
|
||||
|
||||
public slots:
|
||||
|
||||
@ -152,10 +152,11 @@ class EasyHierarchyWidget : public QWidget
|
||||
|
||||
private:
|
||||
|
||||
EasyTreeWidget* m_tree;
|
||||
class QLineEdit* m_searchBox;
|
||||
class QLabel* m_foundNumber;
|
||||
class QAction* m_searchButton;
|
||||
EasyTreeWidget* m_tree;
|
||||
class QLineEdit* m_searchBox;
|
||||
class QLabel* m_foundNumber;
|
||||
class QAction* m_searchButton;
|
||||
bool m_bCaseSensitiveSearch;
|
||||
|
||||
public:
|
||||
|
||||
@ -174,12 +175,21 @@ public:
|
||||
|
||||
private slots:
|
||||
|
||||
// Private slots
|
||||
|
||||
void onSeachBoxReturnPressed();
|
||||
void findNext(bool);
|
||||
void findPrev(bool);
|
||||
void findNextFromMenu(bool);
|
||||
void findPrevFromMenu(bool);
|
||||
|
||||
private:
|
||||
|
||||
// Private non-virtual methods
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
}; // END of class EasyHierarchyWidget.
|
||||
|
||||
|
||||
|
@ -303,23 +303,6 @@ void EasyDescTreeWidget::onSearchColumnChange(bool)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EasyDescTreeWidget::keyPressEvent(QKeyEvent* _event)
|
||||
{
|
||||
Parent::keyPressEvent(_event);
|
||||
|
||||
if (_event->key() == Qt::Key_F3)
|
||||
{
|
||||
if (_event->modifiers() & Qt::ShiftModifier)
|
||||
findPrev(m_lastSearch);
|
||||
else
|
||||
findNext(m_lastSearch);
|
||||
}
|
||||
|
||||
_event->accept();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EasyDescTreeWidget::clearSilent(bool _global)
|
||||
{
|
||||
const QSignalBlocker b(this);
|
||||
@ -574,7 +557,7 @@ void EasyDescTreeWidget::saveSettings()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int EasyDescTreeWidget::findNext(const QString& _str)
|
||||
int EasyDescTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
|
||||
{
|
||||
if (_str.isEmpty())
|
||||
{
|
||||
@ -588,7 +571,7 @@ int EasyDescTreeWidget::findNext(const QString& _str)
|
||||
}
|
||||
|
||||
const bool isNewSearch = (m_lastSearch != _str);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive, m_searchColumn);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive | _flags, m_searchColumn);
|
||||
|
||||
if (!isNewSearch)
|
||||
{
|
||||
@ -644,7 +627,7 @@ int EasyDescTreeWidget::findNext(const QString& _str)
|
||||
return itemsList.size();
|
||||
}
|
||||
|
||||
int EasyDescTreeWidget::findPrev(const QString& _str)
|
||||
int EasyDescTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
|
||||
{
|
||||
if (_str.isEmpty())
|
||||
{
|
||||
@ -658,7 +641,7 @@ int EasyDescTreeWidget::findPrev(const QString& _str)
|
||||
}
|
||||
|
||||
const bool isNewSearch = (m_lastSearch != _str);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive, m_searchColumn);
|
||||
auto itemsList = findItems(_str, Qt::MatchContains | Qt::MatchRecursive | _flags, m_searchColumn);
|
||||
|
||||
if (!isNewSearch)
|
||||
{
|
||||
@ -717,7 +700,10 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
|
||||
, m_searchBox(new QLineEdit(this))
|
||||
, m_foundNumber(new QLabel("Found 0 matches", this))
|
||||
, m_searchButton(nullptr)
|
||||
, m_bCaseSensitiveSearch(false)
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
m_searchBox->setFixedWidth(200);
|
||||
m_searchBox->setContentsMargins(5, 0, 0, 0);
|
||||
|
||||
@ -750,6 +736,13 @@ 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);
|
||||
|
||||
tb->addSeparator();
|
||||
tb->addAction(m_searchButton);
|
||||
tb->addWidget(m_searchBox);
|
||||
@ -771,7 +764,27 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
|
||||
|
||||
EasyDescWidget::~EasyDescWidget()
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void EasyDescWidget::loadSettings()
|
||||
{
|
||||
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
|
||||
settings.beginGroup("EasyDescWidget");
|
||||
|
||||
auto val = settings.value("case_sensitive");
|
||||
if (!val.isNull())
|
||||
m_bCaseSensitiveSearch = val.toBool();
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void EasyDescWidget::saveSettings()
|
||||
{
|
||||
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
|
||||
settings.beginGroup("EasyDescWidget");
|
||||
settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void EasyDescWidget::keyPressEvent(QKeyEvent* _event)
|
||||
@ -802,17 +815,15 @@ void EasyDescWidget::clear()
|
||||
|
||||
void EasyDescWidget::onSeachBoxReturnPressed()
|
||||
{
|
||||
auto matches = m_tree->findNext(m_searchBox->text());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
if (m_searchButton->data().toBool() == true)
|
||||
findNext(true);
|
||||
else
|
||||
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
|
||||
findPrev(true);
|
||||
}
|
||||
|
||||
void EasyDescWidget::findNext(bool)
|
||||
{
|
||||
auto matches = m_tree->findNext(m_searchBox->text());
|
||||
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
@ -822,7 +833,7 @@ void EasyDescWidget::findNext(bool)
|
||||
|
||||
void EasyDescWidget::findPrev(bool)
|
||||
{
|
||||
auto matches = m_tree->findPrev(m_searchBox->text());
|
||||
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
|
||||
|
||||
if (matches == 1)
|
||||
m_foundNumber->setText(QString("Found 1 match"));
|
||||
|
@ -107,14 +107,13 @@ public:
|
||||
explicit EasyDescTreeWidget(QWidget* _parent = nullptr);
|
||||
virtual ~EasyDescTreeWidget();
|
||||
void contextMenuEvent(QContextMenuEvent* _event) override;
|
||||
void keyPressEvent(QKeyEvent* _event) override;
|
||||
|
||||
public:
|
||||
|
||||
// Public non-virtual methods
|
||||
|
||||
int findNext(const QString& _str);
|
||||
int findPrev(const QString& _str);
|
||||
int findNext(const QString& _str, Qt::MatchFlags _flags);
|
||||
int findPrev(const QString& _str, Qt::MatchFlags _flags);
|
||||
|
||||
public slots:
|
||||
|
||||
@ -156,6 +155,7 @@ private:
|
||||
class QLineEdit* m_searchBox;
|
||||
class QLabel* m_foundNumber;
|
||||
class QAction* m_searchButton;
|
||||
bool m_bCaseSensitiveSearch;
|
||||
|
||||
public:
|
||||
|
||||
@ -180,6 +180,13 @@ private slots:
|
||||
void findNextFromMenu(bool);
|
||||
void findPrevFromMenu(bool);
|
||||
|
||||
private:
|
||||
|
||||
// Private non-virtual slots
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
}; // END of class EasyDescWidget.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user