SettingsDialog: Modernize connections

Change-Id: Ie157b9b36a13b3e6eba5c158040e7491bd2ff29d
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-20 10:29:32 +01:00
parent 25a14aa2e2
commit 6fb766bf43
2 changed files with 19 additions and 17 deletions

View File

@@ -333,14 +333,15 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
m_categoryList->setSelectionMode(QAbstractItemView::SingleSelection); m_categoryList->setSelectionMode(QAbstractItemView::SingleSelection);
m_categoryList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_categoryList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
connect(m_categoryList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), connect(m_categoryList->selectionModel(), &QItemSelectionModel::currentRowChanged,
this, SLOT(currentChanged(QModelIndex))); this, &SettingsDialog::currentChanged);
// The order of the slot connection matters here, the filter slot // The order of the slot connection matters here, the filter slot
// opens the matching page after the model has filtered. // opens the matching page after the model has filtered.
connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), connect(m_filterLineEdit, &Utils::FancyLineEdit::filterChanged,
m_proxyModel, SLOT(setFilterFixedString(QString))); m_proxyModel, &QSortFilterProxyModel::setFilterFixedString);
connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), this, SLOT(filter(QString))); connect(m_filterLineEdit, &Utils::FancyLineEdit::filterChanged,
this, &SettingsDialog::filter);
m_categoryList->setFocus(); m_categoryList->setFocus();
} }
@@ -412,9 +413,11 @@ void SettingsDialog::createGui()
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Apply | QDialogButtonBox::Apply |
QDialogButtonBox::Cancel); QDialogButtonBox::Cancel);
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); connect(buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this, &SettingsDialog::apply);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
QGridLayout *mainGridLayout = new QGridLayout; QGridLayout *mainGridLayout = new QGridLayout;
mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1); mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1);
@@ -474,8 +477,8 @@ void SettingsDialog::ensureCategoryWidget(Category *category)
tabWidget->addTab(widget, page->displayName()); tabWidget->addTab(widget, page->displayName());
} }
connect(tabWidget, SIGNAL(currentChanged(int)), connect(tabWidget, &QTabWidget::currentChanged,
this, SLOT(currentTabChanged(int))); this, &SettingsDialog::currentTabChanged);
category->tabWidget = tabWidget; category->tabWidget = tabWidget;
category->index = m_stackedLayout->addWidget(tabWidget); category->index = m_stackedLayout->addWidget(tabWidget);
@@ -485,8 +488,8 @@ void SettingsDialog::disconnectTabWidgets()
{ {
foreach (Category *category, m_model->categories()) { foreach (Category *category, m_model->categories()) {
if (category->tabWidget) if (category->tabWidget)
disconnect(category->tabWidget, SIGNAL(currentChanged(int)), disconnect(category->tabWidget, &QTabWidget::currentChanged,
this, SLOT(currentTabChanged(int))); this, &SettingsDialog::currentTabChanged);
} }
} }

View File

@@ -73,7 +73,10 @@ public:
public slots: public slots:
void done(int); void done(int);
private slots: private:
SettingsDialog(QWidget *parent);
~SettingsDialog();
void accept(); void accept();
void reject(); void reject();
void apply(); void apply();
@@ -81,10 +84,6 @@ private slots:
void currentTabChanged(int); void currentTabChanged(int);
void filter(const QString &text); void filter(const QString &text);
private:
SettingsDialog(QWidget *parent);
~SettingsDialog();
void createGui(); void createGui();
void showCategory(int index); void showCategory(int index);
void showPage(Id categoryId, Id pageId); void showPage(Id categoryId, Id pageId);