2012-01-04 22:13:01 +00:00
|
|
|
/* display_filter_combo.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "qt_ui_utils.h"
|
2013-05-22 22:39:05 +00:00
|
|
|
#include "ui/recent_utils.h"
|
2012-01-18 19:59:13 +00:00
|
|
|
#include "ui/recent.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
#include "display_filter_edit.h"
|
|
|
|
#include "display_filter_combo.h"
|
2012-12-07 01:46:20 +00:00
|
|
|
#include "wireshark_application.h"
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2012-12-05 19:04:59 +00:00
|
|
|
#include <QCompleter>
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
// If we ever add support for multiple windows this will need to be replaced.
|
|
|
|
static DisplayFilterCombo *cur_display_filter_combo = NULL;
|
|
|
|
|
|
|
|
DisplayFilterCombo::DisplayFilterCombo(QWidget *parent) :
|
|
|
|
QComboBox(parent)
|
|
|
|
{
|
|
|
|
setEditable(true);
|
2013-11-21 01:28:17 +00:00
|
|
|
setLineEdit(new DisplayFilterEdit(this, false));
|
2012-01-04 22:13:01 +00:00
|
|
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
2012-03-07 10:16:33 +00:00
|
|
|
setAccessibleName(tr("Display filter selector"));
|
2012-01-04 22:13:01 +00:00
|
|
|
cur_display_filter_combo = this;
|
|
|
|
setStyleSheet(
|
|
|
|
"QComboBox {"
|
2013-04-24 11:07:25 +00:00
|
|
|
#ifdef Q_OS_MAC
|
2012-12-07 21:53:03 +00:00
|
|
|
" border: 1px solid gray;"
|
|
|
|
#else
|
2012-12-07 21:22:16 +00:00
|
|
|
" border: 1px solid palette(shadow);"
|
2012-12-07 21:53:03 +00:00
|
|
|
#endif
|
2012-01-04 22:13:01 +00:00
|
|
|
" border-radius: 3px;"
|
|
|
|
" padding: 0px 0px 0px 0px;"
|
|
|
|
" margin-left: 0px;"
|
|
|
|
" min-width: 20em;"
|
|
|
|
" }"
|
|
|
|
|
|
|
|
"QComboBox::drop-down {"
|
|
|
|
" subcontrol-origin: padding;"
|
|
|
|
" subcontrol-position: top right;"
|
|
|
|
" width: 16px;"
|
|
|
|
" border-left-width: 0px;"
|
|
|
|
" }"
|
|
|
|
|
|
|
|
"QComboBox::down-arrow {"
|
|
|
|
" image: url(:/dfilter/dfilter_dropdown.png);"
|
|
|
|
" }"
|
|
|
|
|
|
|
|
"QComboBox::down-arrow:on { /* shift the arrow when popup is open */"
|
|
|
|
" top: 1px;"
|
|
|
|
" left: 1px;"
|
|
|
|
"}"
|
|
|
|
);
|
|
|
|
completer()->setCompletionMode(QCompleter::PopupCompletion);
|
2014-03-11 04:27:50 +00:00
|
|
|
#ifndef QT_NO_TOOLTIP
|
|
|
|
setToolTip(tr("Select from previously used filters"));
|
|
|
|
#endif // QT_NO_TOOLTIP
|
2012-12-07 01:46:20 +00:00
|
|
|
|
2013-01-18 00:50:14 +00:00
|
|
|
connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(updateMaxCount()));
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
2012-01-18 19:59:13 +00:00
|
|
|
extern "C" void dfilter_recent_combo_write_all(FILE *rf) {
|
2012-01-04 22:13:01 +00:00
|
|
|
if (!cur_display_filter_combo)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cur_display_filter_combo->writeRecent(rf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayFilterCombo::writeRecent(FILE *rf) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count(); i++) {
|
2014-11-29 18:29:26 +00:00
|
|
|
const QByteArray& filter = itemText(i).toUtf8();
|
|
|
|
if (!filter.isEmpty()) {
|
|
|
|
fprintf(rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter.constData());
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 01:46:20 +00:00
|
|
|
void DisplayFilterCombo::applyDisplayFilter()
|
|
|
|
{
|
|
|
|
DisplayFilterEdit *df_edit = qobject_cast<DisplayFilterEdit *>(lineEdit());
|
|
|
|
|
|
|
|
if (df_edit) df_edit->applyDisplayFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayFilterCombo::updateMaxCount()
|
|
|
|
{
|
|
|
|
setMaxCount(prefs.gui_recent_df_entries_max);
|
|
|
|
}
|
|
|
|
|
2012-12-26 05:57:06 +00:00
|
|
|
extern "C" gboolean dfilter_combo_add_recent(const gchar *filter) {
|
2012-01-04 22:13:01 +00:00
|
|
|
if (!cur_display_filter_combo)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
cur_display_filter_combo->addItem(filter);
|
|
|
|
cur_display_filter_combo->clearEditText();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-04 08:18:31 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|