Linguist: Add "Skip obsolete" option to Find dialog.
authorTakumi Asaki <asaki@sra.co.jp>
Tue, 20 Aug 2013 05:26:46 +0000 (14:26 +0900)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 22 Nov 2013 12:54:36 +0000 (13:54 +0100)
When "Skip obsolete" option in Find dialog is checked,
linguist searches only no-obsoleted messages.

Change-Id: I0bee0bcc3a8e651bb2a5d1167f25f35d262da347
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/linguist/finddialog.cpp
src/linguist/linguist/finddialog.h
src/linguist/linguist/finddialog.ui
src/linguist/linguist/mainwindow.cpp
src/linguist/linguist/mainwindow.h

index cc2bfd4..7e0f645 100644 (file)
@@ -78,7 +78,7 @@ void FindDialog::emitFindNext()
                 (comments->isChecked() ? DataModel::Comments : 0));
     else
         where = DataModel::Translations;
-    emit findNext(led->text(), where, matchCase->isChecked(), ignoreAccelerators->isChecked());
+    emit findNext(led->text(), where, matchCase->isChecked(), ignoreAccelerators->isChecked(), skipObsolete->isChecked());
     led->selectAll();
 }
 
index 75270de..07f2367 100644 (file)
@@ -56,7 +56,8 @@ public:
     FindDialog(QWidget *parent = 0);
 
 signals:
-    void findNext(const QString& text, DataModel::FindLocation where, bool matchCase, bool ignoreAccelerators);
+    void findNext(const QString& text, DataModel::FindLocation where,
+                  bool matchCase, bool ignoreAccelerators, bool skipObsolete);
 
 private slots:
     void emitFindNext();
index 44a93a3..5825e98 100644 (file)
           </property>
          </widget>
         </item>
+        <item row="2" column="1">
+         <widget class="QCheckBox" name="skipObsolete">
+          <property name="whatsThis">
+           <string>Obsoleted messages are skipped when checked.</string>
+          </property>
+          <property name="text">
+           <string>Skip &amp;obsolete</string>
+          </property>
+         </widget>
+        </item>
        </layout>
       </widget>
      </item>
index 509406e..bb9f83a 100644 (file)
@@ -267,6 +267,7 @@ MainWindow::MainWindow()
       m_printer(0),
       m_findMatchCase(Qt::CaseInsensitive),
       m_findIgnoreAccelerators(true),
+      m_findSkipObsolete(false),
       m_findWhere(DataModel::NoLocation),
       m_translationSettingsDialog(0),
       m_settingCurrentMessage(false),
@@ -473,8 +474,8 @@ MainWindow::MainWindow()
             this, SLOT(updateTranslation(QStringList)));
     connect(m_messageEditor, SIGNAL(translatorCommentChanged(QString)),
             this, SLOT(updateTranslatorComment(QString)));
-    connect(m_findDialog, SIGNAL(findNext(QString,DataModel::FindLocation,bool,bool)),
-            this, SLOT(findNext(QString,DataModel::FindLocation,bool,bool)));
+    connect(m_findDialog, SIGNAL(findNext(QString,DataModel::FindLocation,bool,bool,bool)),
+            this, SLOT(findNext(QString,DataModel::FindLocation,bool,bool,bool)));
     connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool&)), SLOT(updateTranslateHit(bool&)));
     connect(m_translateDialog, SIGNAL(activated(int)), SLOT(translate(int)));
 
@@ -993,6 +994,8 @@ void MainWindow::findAgain()
         bool hadMessage = false;
         for (int i = 0; i < m_dataModel->modelCount(); ++i) {
             if (MessageItem *m = m_dataModel->messageItem(dataIndex, i)) {
+                if (m_findSkipObsolete && m->isObsolete())
+                    continue;
                 bool found = true;
                 do {
                     if (!hadMessage) {
@@ -1748,7 +1751,8 @@ bool MainWindow::next(bool checkUnfinished)
     return index.isValid();
 }
 
-void MainWindow::findNext(const QString &text, DataModel::FindLocation where, bool matchCase, bool ignoreAccelerators)
+void MainWindow::findNext(const QString &text, DataModel::FindLocation where,
+                          bool matchCase, bool ignoreAccelerators, bool skipObsolete)
 {
     if (text.isEmpty())
         return;
@@ -1756,6 +1760,7 @@ void MainWindow::findNext(const QString &text, DataModel::FindLocation where, bo
     m_findWhere = where;
     m_findMatchCase = matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive;
     m_findIgnoreAccelerators = ignoreAccelerators;
+    m_findSkipObsolete = skipObsolete;
     m_ui.actionFindNext->setEnabled(true);
     findAgain();
 }
index cd18b6a..ee2ba5e 100644 (file)
@@ -162,7 +162,8 @@ private slots:
     void toggleFinished(const QModelIndex &index);
     void prevUnfinished();
     void nextUnfinished();
-    void findNext(const QString &text, DataModel::FindLocation where, bool matchCase, bool ignoreAccelerators);
+    void findNext(const QString &text, DataModel::FindLocation where,
+                  bool matchCase, bool ignoreAccelerators, bool skipObsolete);
     void revalidate();
     void toggleStatistics();
     void onWhatsThis();
@@ -235,6 +236,7 @@ private:
     QString m_findText;
     Qt::CaseSensitivity m_findMatchCase;
     bool m_findIgnoreAccelerators;
+    bool m_findSkipObsolete;
     DataModel::FindLocation m_findWhere;
 
     TranslateDialog *m_translateDialog;