forked from osmocom/wireshark
Qt: We show preference panes using their module names.
PreferencesDialog::setPane takes a preference module name. Fix a comparison in PrefModuleTreeView::setPane and update some variable names in order to make things a bit more obvious. Modernize some related code while we're here. Bug: 16250 Change-Id: I8f4c7e5261a219e3f32e6e9a71574d81b1852219 Reviewed-on: https://code.wireshark.org/review/35304 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
f2c2b9687d
commit
7be2d964f0
|
@ -130,9 +130,8 @@ void AddressEditorFrame::updateWidgets()
|
|||
|
||||
void AddressEditorFrame::on_nameResolutionPreferencesToolButton_clicked()
|
||||
{
|
||||
static const QString module_name = "nameres";
|
||||
on_buttonBox_rejected();
|
||||
emit showNameResolutionPreferences(module_name);
|
||||
emit showNameResolutionPreferences("nameres");
|
||||
}
|
||||
|
||||
void AddressEditorFrame::on_addressComboBox_currentIndexChanged(const QString &)
|
||||
|
|
|
@ -538,16 +538,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(welcome_page_, SIGNAL(recentFileActivated(QString)),
|
||||
this, SLOT(openCaptureFile(QString)));
|
||||
|
||||
connect(main_ui_->addressEditorFrame, SIGNAL(redissectPackets()),
|
||||
this, SLOT(redissectPackets()));
|
||||
connect(main_ui_->addressEditorFrame, SIGNAL(showNameResolutionPreferences(QString)),
|
||||
this, SLOT(showPreferencesDialog(QString)));
|
||||
connect(main_ui_->preferenceEditorFrame, SIGNAL(showProtocolPreferences(QString)),
|
||||
this, SLOT(showPreferencesDialog(QString)));
|
||||
connect(main_ui_->filterExpressionFrame, SIGNAL(showPreferencesDialog(QString)),
|
||||
this, SLOT(showPreferencesDialog(QString)));
|
||||
connect(main_ui_->filterExpressionFrame, SIGNAL(filterExpressionsChanged()),
|
||||
filter_expression_toolbar_, SLOT(filterExpressionsChanged()));
|
||||
connect(main_ui_->addressEditorFrame, &AddressEditorFrame::redissectPackets,
|
||||
this, &MainWindow::redissectPackets);
|
||||
connect(main_ui_->addressEditorFrame, &AddressEditorFrame::showNameResolutionPreferences,
|
||||
this, &MainWindow::showPreferencesDialog);
|
||||
connect(main_ui_->preferenceEditorFrame, &PreferenceEditorFrame::showProtocolPreferences,
|
||||
this, &MainWindow::showPreferencesDialog);
|
||||
connect(main_ui_->filterExpressionFrame, &FilterExpressionFrame::showPreferencesDialog,
|
||||
this, &MainWindow::showPreferencesDialog);
|
||||
connect(main_ui_->filterExpressionFrame, &FilterExpressionFrame::filterExpressionsChanged,
|
||||
filter_expression_toolbar_, &FilterExpressionToolBar::filterExpressionsChanged);
|
||||
|
||||
/* Connect change of capture file */
|
||||
connect(this, SIGNAL(setCaptureFile(capture_file*)),
|
||||
|
|
|
@ -495,7 +495,7 @@ private slots:
|
|||
void on_actionDeleteAllPacketComments_triggered();
|
||||
void deleteAllPacketCommentsFinished(int result);
|
||||
void on_actionEditConfigurationProfiles_triggered();
|
||||
void showPreferencesDialog(QString pane_name);
|
||||
void showPreferencesDialog(QString module_name);
|
||||
void on_actionEditPreferences_triggered();
|
||||
|
||||
void showHideMainWidgets(QAction *action);
|
||||
|
|
|
@ -2242,13 +2242,13 @@ void MainWindow::on_actionEditConfigurationProfiles_triggered()
|
|||
cp_dialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::showPreferencesDialog(QString pane_name)
|
||||
void MainWindow::showPreferencesDialog(QString module_name)
|
||||
{
|
||||
PreferencesDialog *pref_dialog = new PreferencesDialog(this);
|
||||
connect(pref_dialog, SIGNAL(destroyed(QObject*)), wsApp, SLOT(flushAppSignals()));
|
||||
saveWindowGeometry(); // Save in case the layout panes are rearranged
|
||||
|
||||
pref_dialog->setPane(pane_name);
|
||||
pref_dialog->setPane(module_name);
|
||||
pref_dialog->setWindowModality(Qt::ApplicationModal);
|
||||
pref_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
pref_dialog->show();
|
||||
|
|
|
@ -167,8 +167,7 @@ void PreferenceEditorFrame::showEvent(QShowEvent *event)
|
|||
void PreferenceEditorFrame::on_modulePreferencesToolButton_clicked()
|
||||
{
|
||||
if (module_) {
|
||||
QString module_name = module_->name;
|
||||
emit showProtocolPreferences(module_name);
|
||||
emit showProtocolPreferences(module_->name);
|
||||
}
|
||||
on_buttonBox_rejected();
|
||||
}
|
||||
|
|
|
@ -138,9 +138,9 @@ PreferencesDialog::~PreferencesDialog()
|
|||
prefs_modules_foreach_submodules(NULL, module_prefs_clean_stash, NULL);
|
||||
}
|
||||
|
||||
void PreferencesDialog::setPane(const QString pane_name)
|
||||
void PreferencesDialog::setPane(const QString module_name)
|
||||
{
|
||||
pd_ui_->prefsView->setPane(pane_name);
|
||||
pd_ui_->prefsView->setPane(module_name);
|
||||
}
|
||||
|
||||
void PreferencesDialog::showEvent(QShowEvent *)
|
||||
|
|
|
@ -33,7 +33,12 @@ public:
|
|||
explicit PreferencesDialog(QWidget *parent = 0);
|
||||
~PreferencesDialog();
|
||||
|
||||
void setPane(const QString pane_name);
|
||||
/**
|
||||
* Show the preference pane corresponding to the a preference module name.
|
||||
* @param module_name A preference module name, e.g. the "name" parameter passed
|
||||
* to prefs_register_module or a protocol name.
|
||||
*/
|
||||
void setPane(const QString module_name);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *evt);
|
||||
|
|
|
@ -18,27 +18,27 @@ PrefModuleTreeView::PrefModuleTreeView(QWidget *parent) : QTreeView(parent),
|
|||
{
|
||||
}
|
||||
|
||||
void PrefModuleTreeView::setPane(const QString pane_name)
|
||||
void PrefModuleTreeView::setPane(const QString module_name)
|
||||
{
|
||||
QModelIndex newIndex, modelIndex, appearanceIndex, protocolIndex, statIndex;
|
||||
QString modelTreeName;
|
||||
QString moduleName;
|
||||
int row;
|
||||
|
||||
//look for the pane name in the main tree before trying children
|
||||
for (row = 0; row < model()->rowCount(); row++)
|
||||
{
|
||||
modelIndex = model()->index(row, ModulePrefsModel::colName);
|
||||
modelTreeName = model()->data(modelIndex, Qt::DisplayRole).toString();
|
||||
moduleName = model()->data(modelIndex, ModulePrefsModel::ModuleName).toString();
|
||||
|
||||
if (modelTreeName.compare(appearanceName_) == 0) {
|
||||
if (moduleName.compare(appearanceName_) == 0) {
|
||||
appearanceIndex = modelIndex;
|
||||
} else if (modelTreeName.compare("Protocols") == 0) {
|
||||
} else if (moduleName.compare("Protocols") == 0) {
|
||||
protocolIndex = modelIndex;
|
||||
} else if (modelTreeName.compare("Statistics") == 0) {
|
||||
} else if (moduleName.compare("Statistics") == 0) {
|
||||
statIndex = modelIndex;
|
||||
}
|
||||
|
||||
if (modelTreeName.compare(pane_name) == 0) {
|
||||
if (moduleName.compare(module_name) == 0) {
|
||||
newIndex = modelIndex;
|
||||
break;
|
||||
}
|
||||
|
@ -46,17 +46,17 @@ void PrefModuleTreeView::setPane(const QString pane_name)
|
|||
|
||||
//Look through appearance children
|
||||
if (!newIndex.isValid()) {
|
||||
newIndex = findModule(appearanceIndex, pane_name);
|
||||
newIndex = findModule(appearanceIndex, module_name);
|
||||
}
|
||||
|
||||
//Look through protocol children
|
||||
if (!newIndex.isValid()) {
|
||||
newIndex = findModule(protocolIndex, pane_name);
|
||||
newIndex = findModule(protocolIndex, module_name);
|
||||
}
|
||||
|
||||
//Look through stat children
|
||||
if (!newIndex.isValid()) {
|
||||
newIndex = findModule(statIndex, pane_name);
|
||||
newIndex = findModule(statIndex, module_name);
|
||||
}
|
||||
|
||||
setCurrentIndex(newIndex);
|
||||
|
@ -90,9 +90,9 @@ void PrefModuleTreeView::currentChanged(const QModelIndex ¤t, const QModel
|
|||
{
|
||||
if (current.isValid())
|
||||
{
|
||||
QString pane_name = model()->data(current, ModulePrefsModel::ModuleName).toString();
|
||||
QString module_name = model()->data(current, ModulePrefsModel::ModuleName).toString();
|
||||
|
||||
emit goToPane(pane_name);
|
||||
emit goToPane(module_name);
|
||||
}
|
||||
|
||||
QTreeView::currentChanged(current, previous);
|
||||
|
|
|
@ -20,10 +20,10 @@ class PrefModuleTreeView : public QTreeView
|
|||
public:
|
||||
PrefModuleTreeView(QWidget *parent = 0);
|
||||
|
||||
void setPane(const QString pane_name);
|
||||
void setPane(const QString module_name);
|
||||
|
||||
signals:
|
||||
void goToPane(QString pane);
|
||||
void goToPane(QString module_name);
|
||||
|
||||
protected slots:
|
||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
|
|
@ -210,7 +210,7 @@ void WirelessFrame::on_helperToolButton_clicked()
|
|||
|
||||
void WirelessFrame::on_prefsToolButton_clicked()
|
||||
{
|
||||
emit showWirelessPreferences(QString("wlan"));
|
||||
emit showWirelessPreferences("wlan");
|
||||
}
|
||||
|
||||
void WirelessFrame::getInterfaceInfo()
|
||||
|
|
Loading…
Reference in New Issue