From a92ddc6d0b8c1dcd725d1a95336d16c5f3ced884 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Sun, 27 May 2012 13:19:12 +0200 Subject: [PATCH] Add case sensitivity option to search. --- src/gui/DatabaseWidget.cpp | 18 +++++++++++++- src/gui/DatabaseWidget.h | 1 + src/gui/SearchWidget.ui | 48 ++++++++++++++++++++++---------------- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 38e432a56..c6f99088d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -147,6 +147,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) connect(m_databaseSettingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged())); connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer())); + connect(m_searchUi->caseSensitiveCheckBox, SIGNAL(toggled(bool)), this, SLOT(startSearch())); connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search())); connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch())); connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(updateEntryActions())); @@ -491,7 +492,14 @@ void DatabaseWidget::showSearch() void DatabaseWidget::search() { Group* searchGroup = m_db->rootGroup(); - QList searchResult = searchGroup->search(m_searchUi->searchEdit->text(), Qt::CaseInsensitive); + Qt::CaseSensitivity sensitivity; + if (m_searchUi->caseSensitiveCheckBox->isChecked()) { + sensitivity = Qt::CaseSensitive; + } + else { + sensitivity = Qt::CaseInsensitive; + } + QList searchResult = searchGroup->search(m_searchUi->searchEdit->text(), sensitivity); Group* group = m_groupView->currentGroup(); if (group) { @@ -510,6 +518,14 @@ void DatabaseWidget::startSearchTimer() m_searchTimer->start(100); } +void DatabaseWidget::startSearch() +{ + if (!m_searchTimer->isActive()) { + m_searchTimer->stop(); + } + search(); +} + bool DatabaseWidget::dbHasKey() { return m_db->hasKey(); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index c70f15555..13f26d949 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -100,6 +100,7 @@ private Q_SLOTS: void emitCurrentModeChanged(); void clearLastGroup(Group* group); void search(); + void startSearch(); void startSearchTimer(); void showSearch(); void closeSearch(); diff --git a/src/gui/SearchWidget.ui b/src/gui/SearchWidget.ui index 96a8e3ede..38fa4e427 100644 --- a/src/gui/SearchWidget.ui +++ b/src/gui/SearchWidget.ui @@ -6,34 +6,42 @@ 0 0 - 466 - 53 + 630 + 87 - - - 0 - - - + + + - - - - true + Case sensitive - - - - Find: - - - - + + + + + + + + + + true + + + + + + + Find: + + + + +