aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/models/uat_model.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_model.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_model.cpp')
-rw-r--r--ui/qt/models/uat_model.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/ui/qt/models/uat_model.cpp b/ui/qt/models/uat_model.cpp
index 5b0813f0a6..b782247b13 100644
--- a/ui/qt/models/uat_model.cpp
+++ b/ui/qt/models/uat_model.cpp
@@ -85,18 +85,25 @@ QVariant UatModel::data(const QModelIndex &index, int role) const
guint length = 0;
field->cb.tostr(rec, &str, &length, field->cbdata.tostr, field->fld_data);
- if (field->mode == PT_TXTMOD_HEXBYTES) {
+ switch (field->mode) {
+ case PT_TXTMOD_HEXBYTES:
+ {
char* temp_str = bytes_to_str(NULL, (const guint8 *) str, length);
g_free(str);
QString qstr(temp_str);
wmem_free(NULL, temp_str);
return qstr;
- } else if (field->mode == PT_TXTMOD_BOOL) {
+ }
+ case PT_TXTMOD_BOOL:
return "";
- } else {
+ case PT_TXTMOD_COLOR:
+ return QVariant();
+ default:
+ {
QString qstr(str);
g_free(str);
return qstr;
+ }
}
}
@@ -106,7 +113,8 @@ QVariant UatModel::data(const QModelIndex &index, int role) const
guint length = 0;
enum Qt::CheckState state = Qt::Unchecked;
field->cb.tostr(rec, &str, &length, field->cbdata.tostr, field->fld_data);
- if (g_strcmp0(str, "TRUE") == 0)
+ if ((g_strcmp0(str, "TRUE") == 0) ||
+ (g_strcmp0(str, "Enabled") == 0))
state = Qt::Checked;
g_free(str);
@@ -127,6 +135,16 @@ QVariant UatModel::data(const QModelIndex &index, int role) const
return QVariant();
}
+ if (role == Qt::DecorationRole) {
+ if (field->mode == PT_TXTMOD_COLOR) {
+ char *str = NULL;
+ guint length = 0;
+ field->cb.tostr(rec, &str, &length, field->cbdata.tostr, field->fld_data);
+
+ return QColor(QString(str));
+ }
+ }
+
// expose error message if any.
if (role == Qt::UserRole + 1) {
if (errors.contains(index.column())) {