From 1a99bf1ded6c0da53bcb760e5f286fa5a6ee9830 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 12 Jan 2019 22:03:18 +0100 Subject: [PATCH] Bugfix: Do not perform a search if mouse enters text field. --- src/interface_qt.cpp | 71 +++++++++------ src/whyblocked.ui | 2 +- translations/whyblocked_de.ts | 164 +--------------------------------- translations/whyblocked_en.ts | 164 +--------------------------------- 4 files changed, 53 insertions(+), 348 deletions(-) diff --git a/src/interface_qt.cpp b/src/interface_qt.cpp index 71f394e..92c8ef3 100644 --- a/src/interface_qt.cpp +++ b/src/interface_qt.cpp @@ -283,40 +283,57 @@ void MainWindow::find() bool MainWindow::eventFilter(QObject *obj, QEvent *event) { - if (obj == text_find && - (event->type() == QEvent::KeyRelease || event->type() == QEvent::Enter)) + wstring searchfor; + + if (obj == text_find) { - vector filtered_entries; - if (!_dbdata.empty()) + if (event->type() == QEvent::KeyRelease) { - for (const Database::data &entry : _dbdata) + 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()) { - 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( - text_find->text().toLower().toStdWString()) - != std::string::npos) - { - filtered_entries.push_back(entry); - } + 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); } + populate_tableview(filtered_entries); + return QObject::eventFilter(obj, event); } diff --git a/src/whyblocked.ui b/src/whyblocked.ui index 017f2e9..919ad83 100644 --- a/src/whyblocked.ui +++ b/src/whyblocked.ui @@ -46,7 +46,7 @@ true - true + false diff --git a/translations/whyblocked_de.ts b/translations/whyblocked_de.ts index 8619fdb..2c533ba 100644 --- a/translations/whyblocked_de.ts +++ b/translations/whyblocked_de.ts @@ -74,7 +74,7 @@ Du kannst URLs hier hineinziehen - + Insert receipt here. Beleg hier einfügen. @@ -270,175 +270,19 @@ Bitte wähle einträge aus, die gelöscht werden sollen. - + About Whyblocked Über 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> <p><b>Whyblocked</b> %1</p><p>Erinnert dich, warum du jemanden blockiertest.</p><p>Quelltext: <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>Lizenz GPLv3: <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a>.<br>Für dieses Programm besteht KEINERLEI GARANTIE. Dies ist freie Software, die Sie unter bestimmten Bedingungen weitergeben dürfen.</small></p> - + Receipts: Belege: - - Text - - - Blocked or silenced? - Blockiert oder gedämpft? - - - - Add receipt? [y/n] - Beleg hinzufügen? [j/n] - - - - y - j - - - - Y - J - - - - Receipt - Beleg - - - - Receipt added. - Beleg hinzugefügt. - - - - n - n - - - - N - N - - - - - - - User or instance - Benutzer oder Instanz - - - - Reason - Begründung - - - - added. - hinzugefügt. - - - - A blank line keeps the former value. - Leere Zeile um den alten Wert zu erhalten. - - - - Change user or instance to - Ändere Benutzer oder Instanz zu - - - - Old reason was: - Alte Begründung war: - - - - Change reason to - Ändere Begründung zu - - - - Old receipt was: - Alter Beleg war: - - - - Change receipt to - Ändere beleg zu - - - - Could not remove - Konnte nicht entfernen: - - - - removed. - entfernt. - - - - Blocked: - Blockiert: - - - - Silenced: - Gedämpft: - - - - because: - weil: - - - - is - ist - - - - blocked, because: - blockiert, weil: - - - - silenced, because: - gedämpft, weil: - - - - Receipts: - Belege: - - - - Type add, edit, remove, view or details. Or just the first letter. - Schreibe a für hinzufügen, e für ändern, r für entfernen, v für anschauen oder d für Details. - - - - Type help or h to show this help. Type quit or q to quit the program. - Schreibe hilfe oder h, um die Hilfe anzuzeigen. Schreibe q um das Programm zu beenden. - - - - This is Whyblocked - Dies ist Whyblocked - - - - Response not understood. - Antwort nicht verstanden. - - diff --git a/translations/whyblocked_en.ts b/translations/whyblocked_en.ts index cfa23c4..c260eda 100644 --- a/translations/whyblocked_en.ts +++ b/translations/whyblocked_en.ts @@ -74,7 +74,7 @@ - + Insert receipt here. @@ -270,175 +270,19 @@ - + 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: - - Text - - - Blocked or silenced? - - - - - Add receipt? [y/n] - - - - - y - - - - - Y - - - - - Receipt - - - - - Receipt added. - - - - - n - - - - - N - - - - - - - - User or instance - - - - - Reason - - - - - added. - - - - - A blank line keeps the former value. - - - - - Change user or instance to - - - - - Old reason was: - - - - - Change reason to - - - - - Old receipt was: - - - - - Change receipt to - - - - - Could not remove - - - - - removed. - - - - - Blocked: - - - - - Silenced: - - - - - because: - - - - - is - - - - - blocked, because: - - - - - silenced, because: - - - - - Receipts: - - - - - Type add, edit, remove, view or details. Or just the first letter. - - - - - Type help or h to show this help. Type quit or q to quit the program. - - - - - This is Whyblocked - - - - - Response not understood. - - -