aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/models/uat_delegate.cpp
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-07-23 10:53:43 -0400
committerAnders Broman <a.broman58@gmail.com>2017-08-07 17:25:02 +0000
commit5b3e3ee58748ac1fd9201d2d3facbed1b9b1e800 (patch)
tree9b19a5d0f8abb396dd6063fa887892581e286b8a /ui/qt/models/uat_delegate.cpp
parentf63b0241c9eeb1ef3dc1e915820c440119c30526 (diff)
Use UAT model for I/O graph
Convert from using TreeWidgetItems to UAT model/delegate. More of the GUI is "just handled" within the table. Required to add support for "colors" and "protocol fields" to UAT types. Also needed to add some hacks for "custom" UAT field handlers for backwards compatibility with the existing UAT structure used. Because UAT functionality was switched completely to the model, some information in the table was "lost in translation" because the UATs themselves aren't translated to other languages. TODO: 2. Better "order of operations"? A bunch of NULL/size checks needed to be added to prevent crashing. Now with model/"view" should events/functions be reordered? Bug: 13585 Change-Id: I2bbba78182317c4fada07b927c05d0c6f4cdc0fe Reviewed-on: https://code.wireshark.org/review/22766 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/models/uat_delegate.cpp')
-rw-r--r--ui/qt/models/uat_delegate.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/ui/qt/models/uat_delegate.cpp b/ui/qt/models/uat_delegate.cpp
index 9d77337aef..f28ae3e355 100644
--- a/ui/qt/models/uat_delegate.cpp
+++ b/ui/qt/models/uat_delegate.cpp
@@ -29,9 +29,12 @@
#include <QFileDialog>
#include <QLineEdit>
#include <QCheckBox>
+#include <QColorDialog>
#include <ui/qt/widgets/display_filter_edit.h>
+#include <ui/qt/widgets/field_filter_edit.h>
#include <ui/qt/widgets/editor_file_dialog.h>
+#include <ui/qt/widgets/editor_color_dialog.h>
UatDelegate::UatDelegate(QObject *parent) : QStyledItemDelegate(parent)
{
@@ -50,7 +53,6 @@ QWidget *UatDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &
switch (field->mode) {
case PT_TXTMOD_DIRECTORYNAME:
- {
if (index.isValid()) {
QString filename_old = index.model()->data(index, Qt::EditRole).toString();
EditorFileDialog* fileDialog = new EditorFileDialog(index, parent, QString(field->title), filename_old);
@@ -64,10 +66,8 @@ QWidget *UatDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &
//shouldn't happen
return 0;
- }
case PT_TXTMOD_FILENAME:
- {
if (index.isValid()) {
QString filename_old = index.model()->data(index, Qt::EditRole).toString();
EditorFileDialog* fileDialog = new EditorFileDialog(index, parent, QString(field->title), filename_old);
@@ -82,7 +82,22 @@ QWidget *UatDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &
//shouldn't happen
return 0;
- }
+
+ case PT_TXTMOD_COLOR:
+ if (index.isValid()) {
+ QColor color(index.model()->data(index, Qt::DecorationRole).toString());
+ EditorColorDialog *colorDialog = new EditorColorDialog(index, color, new QWidget(parent));
+
+ colorDialog->setWindowFlags(Qt::Window);
+
+ //Use signals to accept data from cell
+ connect(colorDialog, SIGNAL(acceptEdit(const QModelIndex &)), this, SLOT(applyColor(const QModelIndex &)));
+ return colorDialog;
+ }
+
+ //shouldn't happen
+ return 0;
+
case PT_TXTMOD_ENUM:
{
// Note: the string repr. is written, not the integer value.
@@ -103,6 +118,11 @@ QWidget *UatDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &
DisplayFilterEdit *editor = new DisplayFilterEdit(parent);
return editor;
}
+ case PT_TXTMOD_PROTO_FIELD:
+ {
+ FieldFilterEdit *editor = new FieldFilterEdit(parent);
+ return editor;
+ }
case PT_TXTMOD_HEXBYTES:
{
// Requires input of the form "ab cd ef" (with possibly no or a colon
@@ -174,8 +194,10 @@ void UatDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
}
case PT_TXTMOD_DIRECTORYNAME:
case PT_TXTMOD_FILENAME:
+ case PT_TXTMOD_COLOR:
//do nothing, dialog signals will update table
break;
+
default:
QStyledItemDelegate::setModelData(editor, model, index);
}
@@ -229,6 +251,16 @@ void UatDelegate::applyDirectory(const QModelIndex& index)
}
}
+void UatDelegate::applyColor(const QModelIndex& index)
+{
+ if (index.isValid()) {
+ QColorDialog *colorDialog = static_cast<QColorDialog*>(sender());
+ QColor newColor = colorDialog->currentColor();
+ ((QAbstractItemModel *)index.model())->setData(index, newColor.name(), Qt::EditRole);
+ }
+}
+
+
/* * Editor modelines
*
* Local Variables: