diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-08-19 13:04:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-27 13:41:48 +0200 |
commit | 070719e228957ea6a10f3545bf2ddc0288c236ae (patch) | |
tree | 31525bf560c2316e6a3b31dad1a457a16f74a3bf | |
parent | 6e5f3e008fb0a7ae6e26b6e492ae90d80e0824c9 (diff) | |
download | qttools-070719e228957ea6a10f3545bf2ddc0288c236ae.tar.gz |
fix search occasionally skipping messages
the bizarre persistence of m_foundWhere would make us skip a hit in a
directly subsequent message if the match was in a field that is searched
before the field the last hit was in.
Task-number: QTBUG-32196
Change-Id: I5007d435cfc3a96bb2b61875a5fc40ac6a23c548
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r-- | src/linguist/linguist/mainwindow.cpp | 42 | ||||
-rw-r--r-- | src/linguist/linguist/mainwindow.h | 3 |
2 files changed, 16 insertions, 29 deletions
diff --git a/src/linguist/linguist/mainwindow.cpp b/src/linguist/linguist/mainwindow.cpp index a2aac7e1e..79abaa475 100644 --- a/src/linguist/linguist/mainwindow.cpp +++ b/src/linguist/linguist/mainwindow.cpp @@ -268,7 +268,6 @@ MainWindow::MainWindow() m_findMatchCase(Qt::CaseInsensitive), m_findIgnoreAccelerators(true), m_findWhere(DataModel::NoLocation), - m_foundWhere(DataModel::NoLocation), m_translationSettingsDialog(0), m_settingCurrentMessage(false), m_fileActiveModel(-1), @@ -964,9 +963,9 @@ void MainWindow::print() } } -bool MainWindow::searchItem(const QString &searchWhat) +bool MainWindow::searchItem(DataModel::FindLocation where, const QString &searchWhat) { - if ((m_findWhere & m_foundWhere) == 0) + if ((m_findWhere & where) == 0) return false; QString text = searchWhat; @@ -993,41 +992,31 @@ void MainWindow::findAgain() bool hadMessage = false; for (int i = 0; i < m_dataModel->modelCount(); ++i) { if (MessageItem *m = m_dataModel->messageItem(dataIndex, i)) { + bool found = true; // Note: we do not look into plurals on grounds of them not // containing anything much different from the singular. if (hadMessage) { - m_foundWhere = DataModel::Translations; - if (!searchItem(m->translation())) - m_foundWhere = DataModel::NoLocation; + if (!searchItem(DataModel::Translations, m->translation())) + found = false; } else { - switch (m_foundWhere) { - case 0: - m_foundWhere = DataModel::SourceText; - // fall-through to search source text - case DataModel::SourceText: - if (searchItem(m->text())) + do { + if (searchItem(DataModel::SourceText, m->text())) break; - if (searchItem(m->pluralText())) + if (searchItem(DataModel::SourceText, m->pluralText())) break; - m_foundWhere = DataModel::Translations; - // fall-through to search translation - case DataModel::Translations: - if (searchItem(m->translation())) + if (searchItem(DataModel::Translations, m->translation())) break; - m_foundWhere = DataModel::Comments; - // fall-through to search comment - case DataModel::Comments: - if (searchItem(m->comment())) + if (searchItem(DataModel::Comments, m->comment())) break; - if (searchItem(m->extraComment())) + if (searchItem(DataModel::Comments, m->extraComment())) break; - if (searchItem(m->translatorComment())) + if (searchItem(DataModel::Comments, m->translatorComment())) break; - m_foundWhere = DataModel::NoLocation; + found = false; // did not find the search string in this message - } + } while (0); } - if (m_foundWhere != DataModel::NoLocation) { + if (found) { setCurrentMessage(realIndex, i); // determine whether the search wrapped @@ -1056,7 +1045,6 @@ void MainWindow::findAgain() qApp->beep(); QMessageBox::warning(m_findDialog, tr("Qt Linguist"), tr("Cannot find the string '%1'.").arg(m_findText)); - m_foundWhere = DataModel::NoLocation; } void MainWindow::showBatchTranslateDialog() diff --git a/src/linguist/linguist/mainwindow.h b/src/linguist/linguist/mainwindow.h index 8b94808ff..0220c05bb 100644 --- a/src/linguist/linguist/mainwindow.h +++ b/src/linguist/linguist/mainwindow.h @@ -205,7 +205,7 @@ private: // FIXME: move to DataModel void updateDanger(const MultiDataIndex &index, bool verbose); - bool searchItem(const QString &searchWhat); + bool searchItem(DataModel::FindLocation where, const QString &searchWhat); QProcess *m_assistantProcess; QTreeView *m_contextView; @@ -235,7 +235,6 @@ private: Qt::CaseSensitivity m_findMatchCase; bool m_findIgnoreAccelerators; DataModel::FindLocation m_findWhere; - DataModel::FindLocation m_foundWhere; TranslateDialog *m_translateDialog; QString m_latestFindText; |