aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2015-03-09 08:11:13 +0100
committerMichal Labedzki <michal.labedzki@tieto.com>2015-05-15 06:05:01 +0000
commit57716e13659a8c9c26124e249a86fce9577d609f (patch)
tree4e2d950b9364a4541c9c5bf72774db2689f75d4e /ui
parent7f424b5a550f0a5f6d370b46b8ffbb327754fa3d (diff)
Qt: Implement "Apply as Column" for packet context
Implement the same functionality for "Apply as Column" as it exists in the GTK version of Wireshark. Especially for the context menu in the packet view panel. Change-Id: Id25b7797616ff3b3acf7aa920395516c8a4e9bf9 Reviewed-on: https://code.wireshark.org/review/7604 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/preference_utils.c10
-rw-r--r--ui/preference_utils.h4
-rw-r--r--ui/qt/main_window.h1
-rw-r--r--ui/qt/main_window.ui5
-rw-r--r--ui/qt/main_window_slots.cpp23
-rw-r--r--ui/qt/proto_tree.cpp7
6 files changed, 39 insertions, 11 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c
index 1bed39bd2f..1e358bd7d0 100644
--- a/ui/preference_utils.c
+++ b/ui/preference_utils.c
@@ -273,11 +273,12 @@ prefs_main_write(void)
}
}
-void
+gint
column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field, gint custom_occurrence)
{
GList *clp;
fmt_data *cfmt, *last_cfmt;
+ gint colnr;
cfmt = (fmt_data *) g_malloc(sizeof(fmt_data));
/*
@@ -291,13 +292,16 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field,
cfmt->custom_occurrence = custom_occurrence;
cfmt->resolved = TRUE;
+ colnr = g_list_length(prefs.col_list);
+
if (custom_field) {
cfmt->visible = TRUE;
clp = g_list_last(prefs.col_list);
last_cfmt = (fmt_data *) clp->data;
if (last_cfmt->fmt == COL_INFO) {
/* Last column is COL_INFO, add custom column before this */
- prefs.col_list = g_list_insert(prefs.col_list, cfmt, g_list_length(prefs.col_list)-1);
+ colnr -= 1;
+ prefs.col_list = g_list_insert(prefs.col_list, cfmt, colnr);
} else {
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
@@ -305,6 +309,8 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field,
cfmt->visible = FALSE; /* Will be set to TRUE in visible_toggled() when added to list */
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
+
+ return colnr;
}
void
diff --git a/ui/preference_utils.h b/ui/preference_utils.h
index e4117d682e..882555d70a 100644
--- a/ui/preference_utils.h
+++ b/ui/preference_utils.h
@@ -86,8 +86,10 @@ extern void prefs_main_write(void);
* @param title column title
* @param custom_field column custom field
* @param custom_occurrence custom occurrence
+ *
+ * @return The index of the inserted column
*/
-void column_prefs_add_custom(gint fmt, const gchar *title,
+gint column_prefs_add_custom(gint fmt, const gchar *title,
const gchar *custom_field,
gint custom_occurrence);
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index e4becaf39e..1d379079ce 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -356,6 +356,7 @@ private slots:
#endif
void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
+ void on_actionAnalyzeCreateAColumn_triggered();
void on_actionAnalyzeAAFSelected_triggered();
void on_actionAnalyzeAAFNotSelected_triggered();
void on_actionAnalyzeAAFAndSelected_triggered();
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index d62d46c1aa..d05587f108 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -1206,11 +1206,8 @@
</property>
</action>
<action name="actionAnalyzeCreateAColumn">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
- <string>Create a Column</string>
+ <string>Apply as Column</string>
</property>
<property name="toolTip">
<string>Create a packet list column from the selected field.</string>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 41b8371d1d..354f0b8dce 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1233,8 +1233,8 @@ void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter",
// proto_can_match_selected(cf->finfo_selected, cf->edt));
-// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/CreateAColumn",
-// hfinfo->type != FT_NONE);
+ main_ui_->actionAnalyzeCreateAColumn->setEnabled(can_match_selected);
+
main_ui_->actionAnalyzeAAFSelected->setEnabled(can_match_selected);
main_ui_->actionAnalyzeAAFNotSelected->setEnabled(can_match_selected);
main_ui_->actionAnalyzeAAFAndSelected->setEnabled(can_match_selected);
@@ -1287,7 +1287,8 @@ void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
main_ui_->actionEditCopyFieldName->setEnabled(false);
main_ui_->actionEditCopyValue->setEnabled(false);
main_ui_->actionEditCopyAsFilter->setEnabled(false);
-// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/CreateAColumn", FALSE);
+
+ main_ui_->actionAnalyzeCreateAColumn->setEnabled(false);
main_ui_->actionAnalyzeAAFSelected->setEnabled(false);
main_ui_->actionAnalyzeAAFNotSelected->setEnabled(false);
@@ -2192,6 +2193,22 @@ void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::Act
filterAction(field_filter, action, filter_type);
}
+void MainWindow::on_actionAnalyzeCreateAColumn_triggered()
+{
+ gint colnr = 0;
+
+ if ( capture_file_.capFile() != 0 && capture_file_.capFile()->finfo_selected != 0 )
+ {
+ colnr = column_prefs_add_custom(COL_CUSTOM, capture_file_.capFile()->finfo_selected->hfinfo->name,
+ capture_file_.capFile()->finfo_selected->hfinfo->abbrev,0);
+
+ packet_list_->redrawVisiblePackets();
+ packet_list_->resizeColumnToContents(colnr);
+
+ prefs_main_write();
+ }
+}
+
// XXX We could probably create the analyze and prepare actions
// dynamically using FilterActions and consolidate the methods
// below into one callback.
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index c12b2dc48d..ac2dac3a52 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -167,8 +167,13 @@ ProtoTree::ProtoTree(QWidget *parent) :
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewExpandAll"));
ctx_menu_.addAction(window()->findChild<QAction *>("actionViewCollapseAll"));
ctx_menu_.addSeparator();
-// " <menuitem name='CreateAColumn' action='/Create a Column'/>\n"
+
+ action = window()->findChild<QAction *>("actionAnalyzeCreateAColumn");
+ ctx_menu_.addAction(action);
+ ctx_menu_.addSeparator();
+
action = window()->findChild<QAction *>("actionApply_as_Filter");
+
submenu = new QMenu();
action->setMenu(submenu);
ctx_menu_.addAction(action);