aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/uat_delegate.h
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-10-04 01:47:26 +0200
committerAnders Broman <a.broman58@gmail.com>2016-10-12 03:53:27 +0000
commit1cd22559a8a907263f1d032e8066482b22f8fbe3 (patch)
tree44c7aae97f98276ce86eca0951bf847e47846f3c /ui/qt/uat_delegate.h
parent9434f25275b1ff838a9976903f180de7da4b00e4 (diff)
Qt: convert UatDialog to model/view pattern, improve UX
Fixes: - Fix crash (heap-use-after-free) on removing a record while editing. - Mark a record as invalid if any of the fields fail the validation. (Fixes crash in at least the ISAKMP dissector.) - Prevent saving of invalid UAT entries (e.g. empty UATs). - Do not close the dialog on pressing Enter/Escape while editing, close the editor instead. - Fix HTML injection in the error messages. Improvements: - Tab-navigation now works between fields. - The field editor is now closed once the focus is lost. - Fields that fail validation are marked (currently with a pink color). - The error hint selection has become smarter (see comments in UatDialog::checkForErrorHint). - Properly recognizes PT_TXTMOD_HEXBYTES formats like "aa:bb" (previously it would not expect the ":" and report a bad length). A validator prevents invalid strings from being entered. - The OK button is disabled when new/edited records are bad. Notably, existing (possibly invalid) records are skipped. (Bug 7471). Live validation (while typing in the editor) was dropped during conversion, but it can be added later if desired. Drag and drop reordering still needs to be implemented. Bug: 11714 Bug: 7471 Change-Id: Ic0b6a177f90503fbd65b5001d8a87a10e38f4d64 Reviewed-on: https://code.wireshark.org/review/17994 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/uat_delegate.h')
-rw-r--r--ui/qt/uat_delegate.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/qt/uat_delegate.h b/ui/qt/uat_delegate.h
new file mode 100644
index 0000000000..795161a686
--- /dev/null
+++ b/ui/qt/uat_delegate.h
@@ -0,0 +1,57 @@
+/* uat_delegate.h
+ * Delegates for editing various field types in a UAT record.
+ *
+ * Copyright 2016 Peter Wu <peter@lekensteyn.nl>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef UAT_DELEGATE_H
+#define UAT_DELEGATE_H
+
+#include <config.h>
+#include <glib.h>
+#include <epan/uat-int.h>
+#include <QStyledItemDelegate>
+
+class UatDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ UatDelegate(QObject *parent = 0);
+
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const;
+ void setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const;
+
+#if 0
+ void updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const;
+#endif
+
+ bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
+
+private:
+ uat_field_t *indexToField(const QModelIndex &index) const;
+ QString openFileDialog(uat_field_t *field, const QString &cur_path) const;
+};
+#endif // UAT_DELEGATE_H