From 920e6fc8ab40bd369ad54240d7d844973e419a88 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 19 Nov 2021 13:23:35 +0200 Subject: [PATCH] Add text search bar in History window. Closes #153 --- ChangeLog.txt | 1 + src/app/valentina/dialogs/dialoghistory.cpp | 19 ++++++ src/app/valentina/dialogs/dialoghistory.h | 2 + src/app/valentina/dialogs/dialoghistory.ui | 67 +++++++++++++++++++++ 4 files changed, 89 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 113cf9db7..5e1b03fc4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -22,6 +22,7 @@ - Improve storing visibility group items. Don't store duplicate information. - Remove tool from all visibility groups it in. - Option to disable the automatic search for updates. +- [smart-pattern/valentina#153] To add text search bar in History window. # Valentina 0.7.49 July 1, 2021 - Fix crash. diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index f23ce0bcf..66d0338a2 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -40,6 +40,7 @@ #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../xml/vpattern.h" #include "../vmisc/diagnostic.h" +#include "../vmisc/vtablesearch.h" #include #include @@ -72,6 +73,22 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); ShowPoint(); + + m_search = QSharedPointer(new VTableSearch(ui->tableWidget)); + + connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);}); + connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){m_search->FindPrevious();}); + connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){m_search->FindNext();}); + + connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) + { + ui->toolButtonFindPrevious->setEnabled(state); + }); + + connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) + { + ui->toolButtonFindNext->setEnabled(state); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -158,6 +175,8 @@ void DialogHistory::UpdateHistory() { FillTable(); InitialTable(); + + m_search->RefreshList(ui->lineEditFind->text()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialoghistory.h b/src/app/valentina/dialogs/dialoghistory.h index 85e3e999d..a8dedb14d 100644 --- a/src/app/valentina/dialogs/dialoghistory.h +++ b/src/app/valentina/dialogs/dialoghistory.h @@ -34,6 +34,7 @@ #include class VPattern; +class VTableSearch; struct HistoryRecord { @@ -90,6 +91,7 @@ private: /** @brief cursorToolRecordRow save number of row selected record */ qint32 cursorToolRecordRow; + QSharedPointer m_search{}; void FillTable(); HistoryRecord Record(const VToolRecord &tool) const; diff --git a/src/app/valentina/dialogs/dialoghistory.ui b/src/app/valentina/dialogs/dialoghistory.ui index 956aec9fb..dd2d00878 100644 --- a/src/app/valentina/dialogs/dialoghistory.ui +++ b/src/app/valentina/dialogs/dialoghistory.ui @@ -24,6 +24,73 @@ + + + + + + Find: + + + + + + + true + + + <html><head/><body><p>Search measurements by term. </p><p>Prepend &quot;/r/&quot; to the front of the search string to search history records by regex.</p></body></html> + + + Search + + + + + + + false + + + Find Previous + + + ... + + + + ../../tape../../tape + + + Ctrl+Shift+G + + + + + + + false + + + Find Next + + + ... + + + + ../../tape../../tape + + + Ctrl+G + + + false + + + + +