summaryrefslogtreecommitdiff
path: root/ui/qt/uat_dialog.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_dialog.h
parent9434f25275b1ff838a9976903f180de7da4b00e4 (diff)
downloadwireshark-1cd22559a8a907263f1d032e8066482b22f8fbe3.tar.gz
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_dialog.h')
-rw-r--r--ui/qt/uat_dialog.h31
1 files changed, 8 insertions, 23 deletions
diff --git a/ui/qt/uat_dialog.h b/ui/qt/uat_dialog.h
index c86ab97818..9bfa49a8b0 100644
--- a/ui/qt/uat_dialog.h
+++ b/ui/qt/uat_dialog.h
@@ -26,12 +26,12 @@
#include <glib.h>
-#include "syntax_line_edit.h"
#include "geometry_state_dialog.h"
+#include "uat_model.h"
+#include "uat_delegate.h"
class QComboBox;
class QPushButton;
-class QTreeWidgetItem;
struct epan_uat;
@@ -49,18 +49,9 @@ public:
void setUat(struct epan_uat *uat = NULL);
-protected:
- void keyPressEvent(QKeyEvent *evt);
-
private slots:
- void on_uatTreeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
- void on_uatTreeWidget_itemActivated(QTreeWidgetItem *item, int column);
- void on_uatTreeWidget_itemSelectionChanged();
- void lineEditPrefDestroyed();
- void enumPrefDestroyed();
- void enumPrefCurrentIndexChanged(int index);
- void stringPrefTextChanged(const QString & text);
- void stringPrefEditingFinished();
+ void modelDataChanged(const QModelIndex &topLeft);
+ void viewCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
void acceptChanges();
void rejectChanges();
void on_newToolButton_clicked();
@@ -70,22 +61,16 @@ private slots:
private:
Ui::UatDialog *ui;
+ UatModel *uat_model_;
+ UatDelegate *uat_delegate_;
QPushButton *ok_button_;
QPushButton *help_button_;
struct epan_uat *uat_;
- int cur_column_;
- SyntaxLineEdit *cur_line_edit_;
- QString saved_string_pref_;
- QComboBox *cur_combo_box_;
- int saved_combo_idx_;
- QString fieldString(guint row, guint column);
- void updateItem(QTreeWidgetItem &item);
- void updateItems();
- void activateLastItem();
+ void checkForErrorHint(const QModelIndex &current, const QModelIndex &previous);
+ bool trySetErrorHintFromField(const QModelIndex &index);
void applyChanges();
void addRecord(bool copy_from_current = false);
- const QByteArray unhexbytes(const QString input, QString &err);
};
#endif // UAT_DIALOG_H