aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArvind Dalvi <ardalvi@outlook.in>2019-05-04 05:56:00 +0000
committerAnders Broman <a.broman58@gmail.com>2019-05-26 06:34:46 +0000
commit13c5960a2c2ca2af50f78a24cd22e2a55df8d0b2 (patch)
tree7977b61382244541a356d7a66ee8995102f620e6
parenta6bd22dfa6c9a6fed05ef043f3ed262abcf7b722 (diff)
Copy selected lines from Packet List view for existing formats.
For all platforms that is supported by Qt framework... - Select copy/<options> from context menu and it will copy selected lines. Note: This change implements part 1 of another change, # 33007. And has been tested on Windows 10 only. Change-Id: Iba2668d7c411aa33de77003fe116e63e6f650b3d Reviewed-on: https://code.wireshark.org/review/33074 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/packet_list.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 4b4051f425..d99dcd04d2 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -278,6 +278,8 @@ PacketList::PacketList(QWidget *parent) :
this, SIGNAL(showProtocolPreferences(QString)));
connect(&proto_prefs_menu_, SIGNAL(editProtocolPreference(preference*,pref_module*)),
this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
+
+ setSelectionMode(ExtendedSelection);
}
void PacketList::colorsChanged()
@@ -1609,32 +1611,39 @@ void PacketList::copySummary()
int copy_type = ca->data().toInt(&ok);
if (!ok) return;
- QStringList col_parts;
- int row = currentIndex().row();
- for (int col = 0; col < packet_list_model_->columnCount(); col++) {
- if (get_column_visible(col)) {
- col_parts << packet_list_model_->data(packet_list_model_->index(row, col), Qt::DisplayRole).toString();
+ QString copy_text;
+ QModelIndexList selectedRows = selectionModel()->selectedRows();
+ qSort(selectedRows);
+
+ foreach(QModelIndex index, selectedRows) {
+ QStringList col_parts;
+ int row = index.row();
+ for (int col = 0; col < packet_list_model_->columnCount(); col++) {
+ if (get_column_visible(col)) {
+ col_parts << packet_list_model_->data(packet_list_model_->index(row, col), Qt::DisplayRole).toString();
+ }
+ }
+ switch (copy_type) {
+ case copy_summary_csv_:
+ copy_text += "\"";
+ copy_text += col_parts.join("\",\"");
+ copy_text += "\"";
+ copy_text += "\n";
+ break;
+ case copy_summary_yaml_:
+ copy_text += "----\n";
+ copy_text += QString("# Packet %1 from %2\n").arg(row).arg(cap_file_->filename);
+ copy_text += "- ";
+ copy_text += col_parts.join("\n- ");
+ copy_text += "\n";
+ break;
+ case copy_summary_text_:
+ default:
+ copy_text += col_parts.join("\t");
+ copy_text += "\n";
}
}
- QString copy_text;
- switch (copy_type) {
- case copy_summary_csv_:
- copy_text = "\"";
- copy_text += col_parts.join("\",\"");
- copy_text += "\"";
- break;
- case copy_summary_yaml_:
- copy_text = "----\n";
- copy_text += QString("# Packet %1 from %2\n").arg(row).arg(cap_file_->filename);
- copy_text += "- ";
- copy_text += col_parts.join("\n- ");
- copy_text += "\n";
- break;
- case copy_summary_text_:
- default:
- copy_text = col_parts.join("\t");
- }
wsApp->clipboard()->setText(copy_text);
}