Qt: Fixup the Display Filter Expression syntax logic.
authorGerald Combs <gerald@wireshark.org>
Fri, 15 Jan 2016 19:35:47 +0000 (11:35 -0800)
committerGerald Combs <gerald@wireshark.org>
Mon, 18 Jan 2016 16:37:43 +0000 (16:37 +0000)
In the Display Filter Expression dialog, only disable the OK button when
we have an invalid filter.

Move the deprecated warning string from DisplayFilterEdit::checkFilter
to SyntaxLineEdit::checkDisplayFilter so that we can use it in more
places.

Change-Id: I938f5f10258f4fd9dd3a33c174dd9958c9634766
Reviewed-on: https://code.wireshark.org/review/13317
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
ui/qt/display_filter_edit.cpp
ui/qt/display_filter_expression_dialog.cpp
ui/qt/syntax_line_edit.cpp
ui/qt/syntax_line_edit.h

index 4d555025710c018f7eef6ae72eb26bf7edc4686b..d91c8565c6ab8245ece5a0521ee09a0d869c5a01 100644 (file)
@@ -318,13 +318,7 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text)
     switch (syntaxState()) {
     case Deprecated:
     {
-        /*
-         * We're being lazy and only printing the first "problem" token.
-         * Would it be better to print all of them?
-         */
-        QString deprecatedMsg(tr("\"%1\" may have unexpected results (see the User's Guide)")
-                .arg(deprecatedToken()));
-        emit pushFilterSyntaxWarning(deprecatedMsg);
+        emit pushFilterSyntaxWarning(syntaxErrorMessage());
         break;
     }
     case Invalid:
index bee50f322fd4fcf4314065150949c0b6ee1eb403..0a109fc213a7727b7af43b41b2636e60d8c8516f 100644 (file)
@@ -196,7 +196,7 @@ void DisplayFilterExpressionDialog::updateWidgets()
     QPushButton *ok_bt = ui->buttonBox->button(QDialogButtonBox::Ok);
     if (ok_bt) {
         bool ok_enable = !ui->displayFilterLineEdit->text().isEmpty()
-                && (ui->displayFilterLineEdit->syntaxState() == SyntaxLineEdit::Valid);
+                && (ui->displayFilterLineEdit->syntaxState() != SyntaxLineEdit::Invalid);
         ok_bt->setEnabled(ok_enable);
     }
 }
index ce898b8f587adfeecdd6a1e5c04494c1ab990798..565b732c046337006e15538c22401bf13b4e8f59 100644 (file)
@@ -133,11 +133,6 @@ QString SyntaxLineEdit::styleSheet() const {
     return style_sheet_;
 }
 
-QString SyntaxLineEdit::deprecatedToken()
-{
-    return deprecated_token_;
-}
-
 void SyntaxLineEdit::setStyleSheet(const QString &style_sheet) {
     style_sheet_ = style_sheet;
     QLineEdit::setStyleSheet(style_sheet_ + state_style_sheet_);
@@ -168,7 +163,6 @@ void SyntaxLineEdit::checkDisplayFilter(QString filter)
         return;
     }
 
-    deprecated_token_.clear();
     dfilter_t *dfp = NULL;
     gchar *err_msg;
     if (dfilter_compile(filter.toUtf8().constData(), &dfp, &err_msg)) {
@@ -179,7 +173,12 @@ void SyntaxLineEdit::checkDisplayFilter(QString filter)
         if (depr) {
             // You keep using that word. I do not think it means what you think it means.
             setSyntaxState(SyntaxLineEdit::Deprecated);
-            deprecated_token_ = (const char *) g_ptr_array_index(depr, 0);
+            /*
+             * We're being lazy and only printing the first "problem" token.
+             * Would it be better to print all of them?
+             */
+            syntax_error_message_ = tr("\"%1\" may have unexpected results (see the User's Guide)")
+                    .arg((const char *) g_ptr_array_index(depr, 0));
         } else {
             setSyntaxState(SyntaxLineEdit::Valid);
         }
index 3184e7a81d9771dddfa8a037ac61f2e5c585e374..013f69dd62585d7166a26097ca4445d23821a757 100644 (file)
@@ -76,7 +76,6 @@ private:
     SyntaxState syntax_state_;
     QString style_sheet_;
     QString state_style_sheet_;
-    QString deprecated_token_;
     QString syntax_error_message_;
     QString token_chars_;
     QColor busy_fg_;