void SyntaxLineEdit::checkDisplayFilter(QString filter) { if (filter.isEmpty()) { setSyntaxState(SyntaxLineEdit::Empty); return; } dfilter_t *dfp = NULL; gchar *err_msg; if (dfilter_compile(filter.toUtf8().constData(), &dfp, &err_msg)) { GPtrArray *depr = NULL; if (dfp) { depr = dfilter_deprecated_tokens(dfp); } if (depr) { // You keep using that word. I do not think it means what you think it means. setSyntaxState(SyntaxLineEdit::Deprecated); /* * 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); } } else { setSyntaxState(SyntaxLineEdit::Invalid); syntax_error_message_ = QString::fromUtf8(err_msg); g_free(err_msg); } dfilter_free(dfp); }
void DisplayFilterEdit::checkFilter(const QString& text) { dfilter_t *dfp; guchar c; clear_button_->setVisible(!text.isEmpty()); popFilterSyntaxStatus(); if (field_name_only_ && (c = proto_check_field_name(text.toUtf8().constData()))) { setSyntaxState(Invalid); emit pushFilterSyntaxStatus(QString().sprintf("Illegal character in field name: '%c'", c)); } else if (dfilter_compile(text.toUtf8().constData(), &dfp)) { GPtrArray *depr = NULL; if (dfp != NULL) { depr = dfilter_deprecated_tokens(dfp); } if (text.isEmpty()) { setSyntaxState(Empty); } else if (depr) { /* You keep using that word. I do not think it means what you think it means. */ setSyntaxState(Deprecated); /* * We're being lazy and only printing the first "problem" token. * Would it be better to print all of them? */ emit pushFilterSyntaxWarning(QString().sprintf("\"%s\" may have unexpected results (see the User's Guide)", (const char *) g_ptr_array_index(depr, 0))); } else { setSyntaxState(Valid); } dfilter_free(dfp); } else { setSyntaxState(Invalid); QString invalidMsg(tr("Invalid filter")); if (dfilter_error_msg) { invalidMsg.append(QString().sprintf(": %s", dfilter_error_msg)); } emit pushFilterSyntaxStatus(invalidMsg); } bookmark_button_->setEnabled(syntaxState() == Valid || syntaxState() == Deprecated); if (apply_button_) { apply_button_->setEnabled(SyntaxState() != Invalid); } }