aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-07-27 16:17:44 -0700
committerGerald Combs <gerald@wireshark.org>2015-07-28 03:54:38 +0000
commit65a1f60e70184faf0238e4df2585af056be1e4c7 (patch)
tree5d071fb00afc44faf08c489ccf98d073033fb0ab /ui
parent01bc31cded7290433704e9ef98a90e338c3ea28b (diff)
Add "Disable Protocol..." to the ProtoTree context menu.
Assume that "I don't want to see this" counts as a preference and add it under the "Protocol Preferences" submenu. Change-Id: I396e2476509db9df895826f8817b191893bcb14a Reviewed-on: https://code.wireshark.org/review/9812 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/enabled_protocols_dialog.cpp36
-rw-r--r--ui/qt/enabled_protocols_dialog.h9
-rw-r--r--ui/qt/protocol_preferences_menu.cpp32
-rw-r--r--ui/qt/protocol_preferences_menu.h3
4 files changed, 63 insertions, 17 deletions
diff --git a/ui/qt/enabled_protocols_dialog.cpp b/ui/qt/enabled_protocols_dialog.cpp
index 2c278d58a6..7026f9607f 100644
--- a/ui/qt/enabled_protocols_dialog.cpp
+++ b/ui/qt/enabled_protocols_dialog.cpp
@@ -39,11 +39,18 @@ enum
DESCRIPTION_COLUMN
};
+enum
+{
+ enable_type_ = 1000,
+ protocol_type_ = 1001,
+ heuristic_type_ = 1002
+};
+
class EnableProtocolTreeWidgetItem : public QTreeWidgetItem
{
public:
- EnableProtocolTreeWidgetItem(QTreeWidgetItem *parent, QString proto_name, QString short_name, bool enable) :
- QTreeWidgetItem (parent),
+ EnableProtocolTreeWidgetItem(QTreeWidgetItem *parent, QString proto_name, QString short_name, bool enable, int type = enable_type_) :
+ QTreeWidgetItem (parent, type),
short_name_(short_name),
proto_name_(proto_name),
enable_(enable)
@@ -79,10 +86,11 @@ class ProtocolTreeWidgetItem : public EnableProtocolTreeWidgetItem
{
public:
ProtocolTreeWidgetItem(QTreeWidgetItem *parent, const protocol_t *protocol) :
- EnableProtocolTreeWidgetItem (parent, proto_get_protocol_long_name(protocol), proto_get_protocol_short_name(protocol), proto_is_protocol_enabled(protocol)),
+ EnableProtocolTreeWidgetItem (parent, proto_get_protocol_long_name(protocol), proto_get_protocol_short_name(protocol), proto_is_protocol_enabled(protocol), protocol_type_),
protocol_(protocol)
{
}
+ const protocol_t *protocol() { return protocol_; }
protected:
virtual void applyValuePrivate(gboolean value)
@@ -98,7 +106,7 @@ class HeuristicTreeWidgetItem : public EnableProtocolTreeWidgetItem
{
public:
HeuristicTreeWidgetItem(QTreeWidgetItem *parent, heur_dtbl_entry_t *heuristic) :
- EnableProtocolTreeWidgetItem (parent, heuristic->display_name, heuristic->short_name, heuristic->enabled),
+ EnableProtocolTreeWidgetItem (parent, heuristic->display_name, heuristic->short_name, heuristic->enabled, heuristic_type_),
heuristic_(heuristic)
{
}
@@ -135,7 +143,6 @@ EnabledProtocolsDialog::EnabledProtocolsDialog(QWidget *parent) :
{
protocol = find_protocol_by_id(i);
ProtocolTreeWidgetItem* protocol_row = new ProtocolTreeWidgetItem(ui->protocol_tree_->invisibleRootItem(), protocol);
- ui->protocol_tree_->addTopLevelItem(protocol_row);
proto_heuristic_dissector_foreach(protocol, addHeuristicItem, protocol_row);
}
@@ -162,6 +169,25 @@ EnabledProtocolsDialog::~EnabledProtocolsDialog()
delete ui;
}
+void EnabledProtocolsDialog::selectProtocol(_protocol *protocol)
+{
+ QTreeWidgetItemIterator it(ui->protocol_tree_->invisibleRootItem());
+ while (*it)
+ {
+ if ((*it)->type() == protocol_type_)
+ {
+ ProtocolTreeWidgetItem* protocol_item = dynamic_cast<ProtocolTreeWidgetItem*>((ProtocolTreeWidgetItem*)(*it));
+ if (protocol_item && protocol_item->protocol() == protocol) {
+ protocol_item->setSelected(true);
+ ui->protocol_tree_->scrollToItem((*it));
+ return;
+ }
+ }
+
+ ++it;
+ }
+}
+
void EnabledProtocolsDialog::addHeuristicItem(gpointer data, gpointer user_data)
{
heur_dtbl_entry_t* heur = (heur_dtbl_entry_t*)data;
diff --git a/ui/qt/enabled_protocols_dialog.h b/ui/qt/enabled_protocols_dialog.h
index 129b856135..6054f7dfd4 100644
--- a/ui/qt/enabled_protocols_dialog.h
+++ b/ui/qt/enabled_protocols_dialog.h
@@ -28,6 +28,8 @@ namespace Ui {
class EnabledProtocolsDialog;
}
+struct _protocol;
+
class QAbstractButton;
class EnabledProtocolsDialog : public QDialog
@@ -37,20 +39,15 @@ class EnabledProtocolsDialog : public QDialog
public:
explicit EnabledProtocolsDialog(QWidget *parent);
~EnabledProtocolsDialog();
+ void selectProtocol(struct _protocol *protocol);
private slots:
void on_invert_button__clicked();
-
void on_enable_all_button__clicked();
-
void on_disable_all_button__clicked();
-
void on_search_line_edit__textChanged(const QString &search_re);
-
void on_buttonBox_accepted();
-
void on_buttonBox_clicked(QAbstractButton *button);
-
void on_buttonBox_helpRequested();
private:
diff --git a/ui/qt/protocol_preferences_menu.cpp b/ui/qt/protocol_preferences_menu.cpp
index 81fd630a71..31fb882331 100644
--- a/ui/qt/protocol_preferences_menu.cpp
+++ b/ui/qt/protocol_preferences_menu.cpp
@@ -32,6 +32,7 @@
#include "protocol_preferences_menu.h"
+#include "enabled_protocols_dialog.h"
#include "qt_ui_utils.h"
#include "uat_dialog.h"
#include "wireshark_application.h"
@@ -178,25 +179,32 @@ void ProtocolPreferencesMenu::setModule(const char *module_name)
{
QAction *action;
int proto_id = -1;
- protocol_t *protocol;
+
+ if (module_name) {
+ proto_id = proto_get_id_by_filter_name(module_name);
+ }
clear();
module_name_.clear();
module_ = NULL;
- if (!module_name ||
- (proto_id = proto_get_id_by_filter_name(module_name)) < 0 ||
- !(protocol = find_protocol_by_id(proto_id))) {
+ protocol_ = find_protocol_by_id(proto_id);
+ const QString proto_name = proto_get_protocol_long_name(protocol_);
+ if (!module_name || proto_id < 0 || !protocol_) {
action = addAction(tr("No protocol preferences available"));
action->setDisabled(true);
return;
}
+ QAction *disable_action = new QAction(tr("Disable %1" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name), this);
+ connect(disable_action, SIGNAL(triggered(bool)), this, SLOT(disableProtocolTriggered()));
+
module_ = prefs_find_module(module_name);
- const QString proto_name = proto_get_protocol_long_name(protocol);
if (!module_ || !prefs_is_registered_protocol(module_name)) {
action = addAction(tr("%1 has no preferences").arg(proto_name));
action->setDisabled(true);
+ addSeparator();
+ addAction(disable_action);
return;
}
@@ -205,10 +213,14 @@ void ProtocolPreferencesMenu::setModule(const char *module_name)
action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name));
action->setData(QString(module_name));
connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered()));
-
addSeparator();
prefs_pref_foreach(module_, add_prefs_menu_item, this);
+
+ if (!actions().last()->isSeparator()) {
+ addSeparator();
+ }
+ addAction(disable_action);
}
void ProtocolPreferencesMenu::addMenuItem(preference *pref)
@@ -269,6 +281,14 @@ void ProtocolPreferencesMenu::addMenuItem(preference *pref)
}
}
+void ProtocolPreferencesMenu::disableProtocolTriggered()
+{
+ EnabledProtocolsDialog enable_proto_dialog(this);
+ enable_proto_dialog.selectProtocol(protocol_);
+ hide();
+ enable_proto_dialog.exec();
+}
+
void ProtocolPreferencesMenu::modulePreferencesTriggered()
{
if (!module_name_.isEmpty()) {
diff --git a/ui/qt/protocol_preferences_menu.h b/ui/qt/protocol_preferences_menu.h
index d85855a4a7..9a5e9dc800 100644
--- a/ui/qt/protocol_preferences_menu.h
+++ b/ui/qt/protocol_preferences_menu.h
@@ -24,6 +24,7 @@
#include <QMenu>
+struct _protocol;
struct pref_module;
struct preference;
@@ -44,8 +45,10 @@ signals:
private:
QString module_name_;
struct pref_module *module_;
+ struct _protocol *protocol_;
private slots:
+ void disableProtocolTriggered();
void modulePreferencesTriggered();
void editorPreferenceTriggered();
void boolPreferenceTriggered();