diff --git a/CMakeLists.txt b/CMakeLists.txt index b44f9fd..cde8c4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.2) project (whyblocked - VERSION 0.14.1 + VERSION 0.14.2 LANGUAGES CXX ) diff --git a/src/qt/mainwindow.cpp b/src/qt/mainwindow.cpp index c6b924c..777c2a5 100644 --- a/src/qt/mainwindow.cpp +++ b/src/qt/mainwindow.cpp @@ -103,7 +103,6 @@ MainWindow::MainWindow(QMainWindow *parent) } widget_find->hide(); - text_find->installEventFilter(this); reload(); @@ -258,62 +257,6 @@ void MainWindow::dropEvent(QDropEvent *event) dialog->show(); } -bool MainWindow::eventFilter(QObject *obj, QEvent *event) -{ - wstring searchfor; - - if (obj == text_find) - { - if (event->type() == QEvent::KeyRelease) - { - searchfor = text_find->text().toLower().toStdWString(); - } - else if (event->type() == QEvent::Drop) - { - QDropEvent *drop = static_cast(event); - searchfor = drop->mimeData()->text().toLower().toStdWString(); - } - else - { - return QObject::eventFilter(obj, event); - } - } - else - { - return QObject::eventFilter(obj, event); - } - - vector filtered_entries; - if (!_dbdata.empty()) - { - for (const Database::data &entry : _dbdata) - { - wstring searchstring; - - std::wstring_convert> convert; - - if (check_user->isChecked()) - { - searchstring += convert.from_bytes(entry.user); - } - if (check_reason->isChecked()) - { - searchstring += convert.from_bytes(entry.reason); - } - std::transform(searchstring.begin(), searchstring.end(), - searchstring.begin(), ::towlower); - if (searchstring.find(searchfor) != std::string::npos) - { - filtered_entries.push_back(entry); - } - } - } - - populate_tableview(filtered_entries); - - return QObject::eventFilter(obj, event); -} - void MainWindow::add() { DialogAdd *dialog = new DialogAdd(_database, this); @@ -414,3 +357,40 @@ void MainWindow::find() text_find->setFocus(); } } + +void MainWindow::update_search(const QString &text) +{ + const wstring searchfor = text.toLower().toStdWString(); + + vector filtered_entries; + if (!_dbdata.empty()) + { + for (const Database::data &entry : _dbdata) + { + wstring searchstring; + std::wstring_convert> convert; + + if (check_user->isChecked()) + { + searchstring += convert.from_bytes(entry.user); + } + if (check_reason->isChecked()) + { + searchstring += convert.from_bytes(entry.reason); + } + std::transform(searchstring.begin(), searchstring.end(), + searchstring.begin(), ::towlower); + if (searchstring.find(searchfor) != std::string::npos) + { + filtered_entries.push_back(entry); + } + } + } + + populate_tableview(filtered_entries); +} + +void MainWindow::update_search() +{ + update_search(text_find->text()); +} diff --git a/src/qt/mainwindow.hpp b/src/qt/mainwindow.hpp index 2ff375b..29dd12d 100644 --- a/src/qt/mainwindow.hpp +++ b/src/qt/mainwindow.hpp @@ -49,7 +49,6 @@ private: const string urls_to_hyperlinks(const string &text); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); - bool eventFilter(QObject *obj, QEvent *event); QStandardItemModel *_model; xdgcfg _config; @@ -65,6 +64,8 @@ private slots: void populate_tableview(const vector &entries); void reload(); void find(); + void update_search(const QString &text); + void update_search(); }; diff --git a/src/qt/whyblocked.ui b/src/qt/whyblocked.ui index 919ad83..0a2a568 100644 --- a/src/qt/whyblocked.ui +++ b/src/qt/whyblocked.ui @@ -46,7 +46,7 @@ true - false + true @@ -453,6 +453,54 @@ + + text_find + textChanged(QString) + MainWindow + update_search(QString) + + + 201 + 83 + + + 299 + 299 + + + + + check_user + clicked() + MainWindow + update_search() + + + 455 + 82 + + + 299 + 299 + + + + + check_reason + clicked() + MainWindow + update_search() + + + 553 + 82 + + + 299 + 299 + + + add() @@ -463,5 +511,9 @@ edit() find() reload() + check_user_changed(int) + check_reason_changed(int) + update_search(QString) + update_search() diff --git a/translations/whyblocked_de.ts b/translations/whyblocked_de.ts index 1f4fc09..ce24203 100644 --- a/translations/whyblocked_de.ts +++ b/translations/whyblocked_de.ts @@ -93,7 +93,7 @@ - + User/Instance @@ -104,7 +104,7 @@ - + Reason @@ -210,7 +210,7 @@ - + Edit entry @@ -230,57 +230,57 @@ - + Try dragging an account from your webbrowser into this window. - + blocked - + silenced - + Nothing selected - + Please select entries to remove. - + Invalid selection - + Please select only 1 entry to edit. - + About Whyblocked - + <p><b>Whyblocked</b> %1</p><p>Reminds you why you blocked someone.</p><p>Sourcecode: <a href="https://schlomp.space/tastytea/whyblocked">https://schlomp.space/tastytea/whyblocked</a></p><p><small>Copyright © 2018 <a href="mailto:tastytea@tastytea.de">tastytea</a>.<br>Licence GPLv3: <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a>.<br>This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.</small></p> - + Receipts: - + Blocked/Silenced diff --git a/translations/whyblocked_en.ts b/translations/whyblocked_en.ts index 970fe8b..d91f0c4 100644 --- a/translations/whyblocked_en.ts +++ b/translations/whyblocked_en.ts @@ -198,7 +198,7 @@ - + Edit entry @@ -219,68 +219,68 @@ - + User/Instance - + Blocked/Silenced - + Reason - + Try dragging an account from your webbrowser into this window. - + blocked - + silenced - + Invalid selection - + Please select only 1 entry to edit. - + Nothing selected - + Please select entries to remove. - + About Whyblocked - + <p><b>Whyblocked</b> %1</p><p>Reminds you why you blocked someone.</p><p>Sourcecode: <a href="https://schlomp.space/tastytea/whyblocked">https://schlomp.space/tastytea/whyblocked</a></p><p><small>Copyright © 2018 <a href="mailto:tastytea@tastytea.de">tastytea</a>.<br>Licence GPLv3: <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a>.<br>This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.</small></p> - + Receipts: