diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:33 +0000 |
commit | 9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9 (patch) | |
tree | 2784370cda9bbf2da9114d70f05399c0b229d28c /ui/qt/models/pref_models.cpp | |
parent | Adding debian version 4.2.6-1. (diff) | |
download | wireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.tar.xz wireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ui/qt/models/pref_models.cpp')
-rw-r--r-- | ui/qt/models/pref_models.cpp | 103 |
1 files changed, 84 insertions, 19 deletions
diff --git a/ui/qt/models/pref_models.cpp b/ui/qt/models/pref_models.cpp index b86230f0..3480a8db 100644 --- a/ui/qt/models/pref_models.cpp +++ b/ui/qt/models/pref_models.cpp @@ -23,10 +23,10 @@ #include <QApplication> // XXX Should we move this to ui/preference_utils? -static GHashTable * pref_ptr_to_pref_ = NULL; +static GHashTable * pref_ptr_to_pref_; pref_t *prefFromPrefPtr(void *pref_ptr) { - return (pref_t *)g_hash_table_lookup(pref_ptr_to_pref_, (gpointer) pref_ptr); + return (pref_t *)g_hash_table_lookup(pref_ptr_to_pref_, (void *) pref_ptr); } static void prefInsertPrefPtr(void * pref_ptr, pref_t * pref) @@ -34,8 +34,8 @@ static void prefInsertPrefPtr(void * pref_ptr, pref_t * pref) if (! pref_ptr_to_pref_) pref_ptr_to_pref_ = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); - gpointer key = (gpointer) pref_ptr; - gpointer val = (gpointer) pref; + void *key = (void *) pref_ptr; + void *val = (void *) pref; /* Already existing entries will be ignored */ if ((void *)g_hash_table_lookup(pref_ptr_to_pref_, key) == NULL) @@ -47,6 +47,7 @@ PrefsItem::PrefsItem(module_t *module, pref_t *pref, PrefsItem* parent) pref_(pref), module_(module), name_(module->name ? module->name : module->parent->name), + help_(QString()), changed_(false) { if (pref_ != NULL) { @@ -59,9 +60,19 @@ PrefsItem::PrefsItem(const QString name, PrefsItem* parent) pref_(NULL), module_(NULL), name_(name), + help_(QString()), changed_(false) { +} +PrefsItem::PrefsItem(PrefsModel::PrefsModelType type, PrefsItem* parent) + : ModelHelperTreeItem<PrefsItem>(parent), + pref_(NULL), + module_(NULL), + name_(PrefsModel::typeToString(type)), + help_(PrefsModel::typeToHelp(type)), + changed_(false) +{ } PrefsItem::~PrefsItem() @@ -113,6 +124,20 @@ QString PrefsItem::getModuleTitle() const return QString(module_->title); } +QString PrefsItem::getModuleHelp() const +{ + if (module_ == nullptr) + return help_; + + module_t *pref_module = module_; + + while (pref_module->help == nullptr && pref_module->parent) { + pref_module = pref_module->parent; + } + + return pref_module->help; +} + void PrefsItem::setChanged(bool changed) { changed_ = changed; @@ -232,8 +257,8 @@ QVariant PrefsModel::data(const QModelIndex &index, int role) const return QVariant(); } -static guint -fill_prefs(module_t *module, gpointer root_ptr) +static unsigned +fill_prefs(module_t *module, void *root_ptr) { PrefsItem* root_item = static_cast<PrefsItem*>(root_ptr); @@ -275,32 +300,32 @@ fill_prefs(module_t *module, gpointer root_ptr) void PrefsModel::populate() { - prefs_modules_foreach_submodules(NULL, fill_prefs, (gpointer)root_); + prefs_modules_foreach_submodules(NULL, fill_prefs, (void *)root_); //Add the "specially handled" preferences PrefsItem *appearance_item, *appearance_subitem, *special_item; - appearance_item = new PrefsItem(typeToString(PrefsModel::Appearance), root_); + appearance_item = new PrefsItem(PrefsModel::Appearance, root_); root_->prependChild(appearance_item); - appearance_subitem = new PrefsItem(typeToString(PrefsModel::Layout), appearance_item); + appearance_subitem = new PrefsItem(PrefsModel::Layout, appearance_item); appearance_item->prependChild(appearance_subitem); - appearance_subitem = new PrefsItem(typeToString(PrefsModel::Columns), appearance_item); + appearance_subitem = new PrefsItem(PrefsModel::Columns, appearance_item); appearance_item->prependChild(appearance_subitem); - appearance_subitem = new PrefsItem(typeToString(PrefsModel::FontAndColors), appearance_item); + appearance_subitem = new PrefsItem(PrefsModel::FontAndColors, appearance_item); appearance_item->prependChild(appearance_subitem); - special_item = new PrefsItem(typeToString(PrefsModel::Capture), root_); + special_item = new PrefsItem(PrefsModel::Capture, root_); root_->prependChild(special_item); - special_item = new PrefsItem(typeToString(PrefsModel::Expert), root_); + special_item = new PrefsItem(PrefsModel::Expert, root_); root_->prependChild(special_item); - special_item = new PrefsItem(typeToString(PrefsModel::FilterButtons), root_); + special_item = new PrefsItem(PrefsModel::FilterButtons, root_); root_->prependChild(special_item); #ifdef HAVE_LIBGNUTLS - special_item = new PrefsItem(typeToString(PrefsModel::RSAKeys), root_); + special_item = new PrefsItem(PrefsModel::RSAKeys, root_); root_->prependChild(special_item); #endif - special_item = new PrefsItem(typeToString(PrefsModel::Advanced), root_); + special_item = new PrefsItem(PrefsModel::Advanced, root_); root_->prependChild(special_item); } @@ -324,6 +349,44 @@ QString PrefsModel::typeToString(int type) return typeStr; } +QString PrefsModel::typeToHelp(int type) +{ + QString helpStr; + + switch(type) + { + case Appearance: + helpStr = QString("ChCustPreferencesSection.html#_appearance"); + break; + case Columns: + helpStr = QString("ChCustPreferencesSection.html#_columns"); + break; + case FontAndColors: + helpStr = QString("ChCustPreferencesSection.html#_font_and_colors"); + break; + case Layout: + helpStr = QString("ChCustPreferencesSection.html#_layout"); + break; + case Capture: + helpStr = QString("ChCustPreferencesSection.html#_capture"); + break; + case Expert: + helpStr = QString("ChCustPreferencesSection.html#ChCustPrefsExpertSection"); + break; + case FilterButtons: + helpStr = QString("ChCustPreferencesSection.html#ChCustFilterButtons"); + break; + case RSAKeys: + helpStr = QString("ChCustPreferencesSection.html#ChCustPrefsRSASection"); + break; + case Advanced: + helpStr = QString("ChCustPreferencesSection.html#_advanced"); + break; + } + + return helpStr; +} + AdvancedPrefsModel::AdvancedPrefsModel(QObject * parent) : QSortFilterProxyModel(parent), filter_(), @@ -470,11 +533,10 @@ bool AdvancedPrefsModel::setData(const QModelIndex &dataindex, const QVariant &v item->setChanged(true); switch (item->getPrefType()) { - case PREF_DECODE_AS_UINT: case PREF_UINT: { bool ok; - guint new_val = value.toString().toUInt(&ok, prefs_get_uint_base(item->getPref())); + unsigned new_val = value.toString().toUInt(&ok, prefs_get_uint_base(item->getPref())); if (ok) prefs_set_uint_value(item->getPref(), new_val, pref_stashed); @@ -487,6 +549,7 @@ bool AdvancedPrefsModel::setData(const QModelIndex &dataindex, const QVariant &v prefs_set_enum_value(item->getPref(), value.toInt(), pref_stashed); break; case PREF_STRING: + case PREF_DISSECTOR: prefs_set_string_value(item->getPref(), value.toString().toStdString().c_str(), pref_stashed); break; case PREF_PASSWORD: @@ -543,7 +606,7 @@ Qt::ItemFlags AdvancedPrefsModel::flags(const QModelIndex &index) const Qt::ItemFlags flags = QAbstractItemModel::flags(index); if (item->getPref() == NULL) { - /* Base modules aren't changable */ + /* Base modules aren't changeable */ flags &= ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable); } else { flags |= Qt::ItemIsEditable; @@ -683,6 +746,8 @@ QVariant ModulePrefsModel::data(const QModelIndex &dataindex, int role) const return sourceModel()->data(modelIndex, role); case ModuleName: return item->getModuleName(); + case ModuleHelp: + return item->getModuleHelp(); default: break; } |