aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/preferences_dialog.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-06-28 08:54:53 -0700
committerMichael Mann <mmann78@netscape.net>2016-06-28 18:40:54 +0000
commit000ac66fce801e4f28e322893ae9280115906330 (patch)
tree2f08de582c7a1925529ae96a690b50c72dcec0b4 /ui/qt/preferences_dialog.cpp
parentff8c6d95b05def3c3c12926c75e95d2a2316919f (diff)
Qt: Make recent preferences changes work with Qt4.
Cast a pointer to a QWidget * so that compilation and pref selection works for Qt4. Add an assert and some comments. Change-Id: Ide89b698220a9af7b7252488f0770ff35081432e Reviewed-on: https://code.wireshark.org/review/16195 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/qt/preferences_dialog.cpp')
-rw-r--r--ui/qt/preferences_dialog.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/ui/qt/preferences_dialog.cpp b/ui/qt/preferences_dialog.cpp
index 7254aa6637..285ba794f7 100644
--- a/ui/qt/preferences_dialog.cpp
+++ b/ui/qt/preferences_dialog.cpp
@@ -75,9 +75,9 @@ enum {
};
enum {
- stacked_role_ = Qt::UserRole + 1,
- module_name_role_,
- mpsa_role_
+ stacked_role_ = Qt::UserRole + 1, // pd_ui_->stackedWidget
+ module_name_role_, // QString
+ mpsa_role_ // QWidget *
};
class AdvancedPrefTreeWidgetItem : public QTreeWidgetItem
@@ -254,7 +254,7 @@ public:
private:
module_t *module_;
- ModulePreferencesScrollArea *mpsa_;
+ QWidget *mpsa_;
};
extern "C" {
@@ -499,6 +499,7 @@ void PreferencesDialog::setPane(PreferencesDialog::PreferencesPane start_pane)
}
}
+// Only valid for ModulePrefTreeWidgetItems.
void PreferencesDialog::setPane(const QString module_name)
{
QTreeWidgetItemIterator pref_it(pd_ui_->prefsTree);
@@ -602,17 +603,18 @@ void PreferencesDialog::on_prefsTree_currentItemChanged(QTreeWidgetItem *current
if (!current) return;
QWidget *new_item = NULL;
+ // "current" might be a QTreeWidgetItem from our .ui file, e.g. "Columns"
+ // or a ModulePrefTreeWidgetItem created by fill_module_prefs, e.g. a
+ // protocol preference. If it's the latter, ensure that the module's
+ // scroll area exists and that it's in the widget stack.
if (current->type() == module_type_) {
ModulePrefTreeWidgetItem *mp_ti = dynamic_cast<ModulePrefTreeWidgetItem *>(current);
- // Ensure that the module's scroll area exists and that it's in the
- // widget stack.
if (mp_ti) mp_ti->ensureModulePreferencesScrollArea(pd_ui_->stackedWidget);
}
new_item = current->data(0, mpsa_role_).value<QWidget *>();
- if (new_item) {
- pd_ui_->stackedWidget->setCurrentWidget(new_item);
- }
+ g_assert(new_item != NULL);
+ pd_ui_->stackedWidget->setCurrentWidget(new_item);
}
void PreferencesDialog::on_advancedSearchLineEdit_textEdited(const QString &search_re)