diff options
author | Michal Labedzki <michal.labedzki@tieto.com> | 2016-04-30 19:13:29 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-10-20 07:34:37 +0000 |
commit | afcbcdf272d270ef08b214c6571336c376a24e1a (patch) | |
tree | dc59651af05cebf8b9765aa1695ab4a54f4df781 /ui/qt/bluetooth_hci_summary_dialog.cpp | |
parent | 82696cabd6686eb1c5e86421237baf90a339f54c (diff) |
Qt/Bluetooth: Add Mark/Unmark functionality
Add Mark/Unmark functionality for tree/table widget items, user can now
mark row or cell.
Change-Id: I31b9ca128d97da4fb959ae2d92f5c1646ebea478
Reviewed-on: https://code.wireshark.org/review/18266
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/bluetooth_hci_summary_dialog.cpp')
-rw-r--r-- | ui/qt/bluetooth_hci_summary_dialog.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/ui/qt/bluetooth_hci_summary_dialog.cpp b/ui/qt/bluetooth_hci_summary_dialog.cpp index 235a4bb770..e7ec986683 100644 --- a/ui/qt/bluetooth_hci_summary_dialog.cpp +++ b/ui/qt/bluetooth_hci_summary_dialog.cpp @@ -22,10 +22,13 @@ #include "bluetooth_hci_summary_dialog.h" #include <ui_bluetooth_hci_summary_dialog.h> +#include "color_utils.h" + #include "epan/epan.h" #include "epan/addr_resolv.h" #include "epan/to_str.h" #include "epan/epan_dissect.h" +#include "epan/prefs.h" #include "epan/dissectors/packet-bluetooth.h" #include "epan/dissectors/packet-bthci_cmd.h" #include "epan/dissectors/packet-bthci_evt.h" @@ -116,6 +119,8 @@ BluetoothHciSummaryDialog::BluetoothHciSummaryDialog(QWidget &parent, CaptureFil ui->tableTreeWidget->setStyleSheet("QTreeView::item:hover{background-color:lightyellow; color:black;}"); + context_menu_.addActions(QList<QAction *>() << ui->actionMark_Unmark_Cell); + context_menu_.addActions(QList<QAction *>() << ui->actionMark_Unmark_Row); context_menu_.addActions(QList<QAction *>() << ui->actionCopy_Cell); context_menu_.addActions(QList<QAction *>() << ui->actionCopy_Rows); context_menu_.addActions(QList<QAction *>() << ui->actionCopy_All); @@ -182,10 +187,14 @@ void BluetoothHciSummaryDialog::changeEvent(QEvent *event) } -void BluetoothHciSummaryDialog::keyPressEvent(QKeyEvent *) +void BluetoothHciSummaryDialog::keyPressEvent(QKeyEvent *event) { -/* NOTE: Do nothing, but in real it "takes focus" from button_box so allow user +/* NOTE: Do nothing*, but in real it "takes focus" from button_box so allow user * to use Enter button to jump to frame from tree widget */ +/* * - reimplement shortcuts from contex menu */ + + if (event->modifiers() & Qt::ControlModifier && event->key()== Qt::Key_M) + on_actionMark_Unmark_Row_triggered(); } @@ -208,6 +217,48 @@ void BluetoothHciSummaryDialog::tableItemCollapsed(QTreeWidgetItem *) } } +void BluetoothHciSummaryDialog::on_actionMark_Unmark_Cell_triggered() +{ + QBrush fg; + QBrush bg; + + if (ui->tableTreeWidget->currentItem()->background(ui->tableTreeWidget->currentColumn()) == QBrush(ColorUtils::fromColorT(&prefs.gui_marked_bg))) { + fg = QBrush(); + bg = QBrush(); + } else { + fg = QBrush(ColorUtils::fromColorT(&prefs.gui_marked_fg)); + bg = QBrush(ColorUtils::fromColorT(&prefs.gui_marked_bg)); + } + + ui->tableTreeWidget->currentItem()->setForeground(ui->tableTreeWidget->currentColumn(), fg); + ui->tableTreeWidget->currentItem()->setBackground(ui->tableTreeWidget->currentColumn(), bg); +} + +void BluetoothHciSummaryDialog::on_actionMark_Unmark_Row_triggered() +{ + QBrush fg; + QBrush bg; + bool is_marked = TRUE; + + for (int i = 0; i < ui->tableTreeWidget->columnCount(); i += 1) { + if (ui->tableTreeWidget->currentItem()->background(i) != QBrush(ColorUtils::fromColorT(&prefs.gui_marked_bg))) + is_marked = FALSE; + } + + if (is_marked) { + fg = QBrush(); + bg = QBrush(); + } else { + fg = QBrush(ColorUtils::fromColorT(&prefs.gui_marked_fg)); + bg = QBrush(ColorUtils::fromColorT(&prefs.gui_marked_bg)); + } + + for (int i = 0; i < ui->tableTreeWidget->columnCount(); i += 1) { + ui->tableTreeWidget->currentItem()->setForeground(i, fg); + ui->tableTreeWidget->currentItem()->setBackground(i, bg); + } +} + void BluetoothHciSummaryDialog::on_actionCopy_Cell_triggered() { QClipboard *clipboard = QApplication::clipboard(); |