NewDialog: Simplify code a bit

Convert some connects to Qt5-style while at it.

Change-Id: Ib5d8af8ccded1005302ad2da3c185c73a8992bd6
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-05-29 17:37:20 +02:00
parent 093a54cbb8
commit 2cd5b448e1
2 changed files with 12 additions and 19 deletions

View File

@@ -224,20 +224,15 @@ NewDialog::NewDialog(QWidget *parent) :
m_ui->templatesView->setModel(m_filterProxyModel); m_ui->templatesView->setModel(m_filterProxyModel);
m_ui->templatesView->setIconSize(QSize(ICON_SIZE, ICON_SIZE)); m_ui->templatesView->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
connect(m_ui->templateCategoryView->selectionModel(), connect(m_ui->templateCategoryView->selectionModel(), &QItemSelectionModel::currentChanged,
SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, &NewDialog::currentCategoryChanged);
this, SLOT(currentCategoryChanged(QModelIndex)));
connect(m_ui->templatesView->selectionModel(), connect(m_ui->templatesView->selectionModel(), &QItemSelectionModel::currentChanged,
SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, &NewDialog::currentItemChanged);
this, SLOT(currentItemChanged(QModelIndex)));
connect(m_ui->templatesView, connect(m_ui->templatesView, &QListView::doubleClicked, this, &NewDialog::accept);
SIGNAL(doubleClicked(QModelIndex)), connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &NewDialog::accept);
this, SLOT(okButtonClicked())); connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &NewDialog::reject);
connect(m_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setSelectedPlatform(QString))); connect(m_ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setSelectedPlatform(QString)));
} }
@@ -453,18 +448,16 @@ void NewDialog::saveState()
m_lastCategory = currentItem->data(Qt::UserRole).toString(); m_lastCategory = currentItem->data(Qt::UserRole).toString();
} }
void NewDialog::okButtonClicked() void NewDialog::accept()
{ {
if (m_ui->templatesView->currentIndex().isValid()) {
hide();
saveState(); saveState();
QDialog::accept();
if (m_ui->templatesView->currentIndex().isValid()) {
IWizardFactory *wizard = currentWizardFactory(); IWizardFactory *wizard = currentWizardFactory();
QTC_ASSERT(wizard, accept(); return); QTC_ASSERT(wizard, accept(); return);
QString path = wizard->runPath(m_defaultLocation); QString path = wizard->runPath(m_defaultLocation);
wizard->runWizard(path, ICore::dialogParent(), selectedPlatform(), m_extraVariables); wizard->runWizard(path, ICore::dialogParent(), selectedPlatform(), m_extraVariables);
close();
} }
} }

View File

@@ -75,7 +75,7 @@ protected:
private slots: private slots:
void currentCategoryChanged(const QModelIndex &); void currentCategoryChanged(const QModelIndex &);
void currentItemChanged(const QModelIndex &); void currentItemChanged(const QModelIndex &);
void okButtonClicked(); void accept();
void reject(); void reject();
void updateOkButton(); void updateOkButton();
void setSelectedPlatform(const QString &platform); void setSelectedPlatform(const QString &platform);