Qt: Add option to copy all visible item or selected tree items in Packet Details pane
The idea is allow to copy data from GUI by user, what is currently case only for tshark. The first option copy every item from Packet Details that are expanded (visibled). The second option do the same but start on currently selected item/tree. (let think about protocols like BT SDP where there is a lot of recursive subtrees) Change-Id: I19c925d21293ceb8af2167c7d2c1b1b36507124e Reviewed-on: https://code.wireshark.org/review/8047 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.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>
This commit is contained in:
parent
62a70e8a0b
commit
9ea521532e
@ -101,6 +101,8 @@ private:
|
||||
};
|
||||
|
||||
enum CopySelected {
|
||||
CopyAllVisibleItems,
|
||||
CopyAllVisibleSelectedTreeItems,
|
||||
CopySelectedDescription,
|
||||
CopySelectedFieldName,
|
||||
CopySelectedValue
|
||||
@ -175,6 +177,8 @@ private:
|
||||
void setForCaptureInProgress(gboolean capture_in_progress = false);
|
||||
QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
|
||||
|
||||
void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
|
||||
|
||||
signals:
|
||||
void showProgress(struct progdlg **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
|
||||
void setCaptureFile(capture_file *cf);
|
||||
@ -276,6 +280,8 @@ private slots:
|
||||
void on_actionFileExportSSLSessionKeys_triggered();
|
||||
|
||||
void actionEditCopyTriggered(MainWindow::CopySelected selection_type);
|
||||
void on_actionCopyAllVisibleItems_triggered();
|
||||
void on_actionCopyAllVisibleSelectedTreeItems_triggered();
|
||||
void on_actionEditCopyDescription_triggered();
|
||||
void on_actionEditCopyFieldName_triggered();
|
||||
void on_actionEditCopyValue_triggered();
|
||||
|
@ -477,6 +477,8 @@
|
||||
<property name="title">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
<addaction name="actionCopyAllVisibleItems"/>
|
||||
<addaction name="actionCopyAllVisibleSelectedTreeItems"/>
|
||||
<addaction name="actionEditCopyDescription"/>
|
||||
<addaction name="actionEditCopyFieldName"/>
|
||||
<addaction name="actionEditCopyValue"/>
|
||||
@ -1061,6 +1063,16 @@
|
||||
<string>Ctrl+Shift+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopyAllVisibleItems">
|
||||
<property name="text">
|
||||
<string>Copy All Visible Items</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopyAllVisibleSelectedTreeItems">
|
||||
<property name="text">
|
||||
<string>Copy All Visible Selected Tree Items</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEditCopyFieldName">
|
||||
<property name="text">
|
||||
<string>Field Name</string>
|
||||
|
@ -1181,7 +1181,8 @@ void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
|
||||
|
||||
// set_menu_sensitivity(ui_manager_main_menubar,
|
||||
// "/Menubar/GoMenu/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
|
||||
|
||||
main_ui_->actionCopyAllVisibleItems->setEnabled(true);
|
||||
main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(can_match_selected);
|
||||
main_ui_->actionEditCopyDescription->setEnabled(can_match_selected);
|
||||
main_ui_->actionEditCopyFieldName->setEnabled(can_match_selected);
|
||||
main_ui_->actionEditCopyValue->setEnabled(can_match_selected);
|
||||
@ -1240,6 +1241,11 @@ void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
|
||||
main_ui_->actionFileExportPacketBytes->setEnabled(false);
|
||||
// set_menu_sensitivity(ui_manager_main_menubar,
|
||||
// "/Menubar/GoMenu/GotoCorrespondingPacket", FALSE);
|
||||
if (capture_file_.capFile() != NULL)
|
||||
main_ui_->actionCopyAllVisibleItems->setEnabled(true);
|
||||
else
|
||||
main_ui_->actionCopyAllVisibleItems->setEnabled(false);
|
||||
main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(false);
|
||||
main_ui_->actionEditCopyDescription->setEnabled(false);
|
||||
main_ui_->actionEditCopyFieldName->setEnabled(false);
|
||||
main_ui_->actionEditCopyValue->setEnabled(false);
|
||||
@ -1669,6 +1675,18 @@ void MainWindow::on_actionFilePrint_triggered()
|
||||
|
||||
// Edit Menu
|
||||
|
||||
void MainWindow::recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level) {
|
||||
if (!item->isExpanded()) return;
|
||||
|
||||
for (int i_item = 0; i_item < item->childCount(); i_item += 1) {
|
||||
clip.append(QString(" ").repeated(ident_level));
|
||||
clip.append(item->child(i_item)->text(0));
|
||||
clip.append("\n");
|
||||
|
||||
recursiveCopyProtoTreeItems(item->child(i_item), clip, ident_level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX This should probably be somewhere else.
|
||||
void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type)
|
||||
{
|
||||
@ -1695,6 +1713,22 @@ void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type
|
||||
clip.append(field_str);
|
||||
g_free(field_str);
|
||||
}
|
||||
break;
|
||||
case CopyAllVisibleItems:
|
||||
for (int i_item = 0; i_item < proto_tree_->topLevelItemCount(); i_item += 1) {
|
||||
clip.append(proto_tree_->topLevelItem(i_item)->text(0));
|
||||
clip.append("\n");
|
||||
|
||||
recursiveCopyProtoTreeItems(proto_tree_->topLevelItem(i_item), clip, 1);
|
||||
}
|
||||
|
||||
break;
|
||||
case CopyAllVisibleSelectedTreeItems:
|
||||
clip.append(proto_tree_->currentItem()->text(0));
|
||||
clip.append("\n");
|
||||
|
||||
recursiveCopyProtoTreeItems(proto_tree_->currentItem(), clip, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1712,6 +1746,16 @@ void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCopyAllVisibleItems_triggered()
|
||||
{
|
||||
actionEditCopyTriggered(CopyAllVisibleItems);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCopyAllVisibleSelectedTreeItems_triggered()
|
||||
{
|
||||
actionEditCopyTriggered(CopyAllVisibleSelectedTreeItems);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEditCopyDescription_triggered()
|
||||
{
|
||||
actionEditCopyTriggered(CopySelectedDescription);
|
||||
|
@ -222,6 +222,8 @@ ProtoTree::ProtoTree(QWidget *parent) :
|
||||
submenu = new QMenu();
|
||||
action->setMenu(submenu);
|
||||
ctx_menu_.addAction(action);
|
||||
submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleItems"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleSelectedTreeItems"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionEditCopyDescription"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionEditCopyFieldName"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionEditCopyValue"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user