Changeset View
Changeset View
Standalone View
Standalone View
plugins/appwizard/projectselectionpage.cpp
Show All 20 Lines | |||||
21 | #include <KMessageBox> | 21 | #include <KMessageBox> | ||
22 | #include <KNS3/DownloadDialog> | 22 | #include <KNS3/DownloadDialog> | ||
23 | 23 | | |||
24 | #include <interfaces/icore.h> | 24 | #include <interfaces/icore.h> | ||
25 | #include <interfaces/iprojectcontroller.h> | 25 | #include <interfaces/iprojectcontroller.h> | ||
26 | #include <language/codegen/templatepreviewicon.h> | 26 | #include <language/codegen/templatepreviewicon.h> | ||
27 | 27 | | |||
28 | #include <util/multilevellistview.h> | 28 | #include <util/multilevellistview.h> | ||
29 | #include <util/scopeddialog.h> | ||||
29 | 30 | | |||
30 | #include "ui_projectselectionpage.h" | 31 | #include "ui_projectselectionpage.h" | ||
31 | #include "projecttemplatesmodel.h" | 32 | #include "projecttemplatesmodel.h" | ||
32 | 33 | | |||
33 | using namespace KDevelop; | 34 | using namespace KDevelop; | ||
34 | 35 | | |||
35 | ProjectSelectionPage::ProjectSelectionPage(ProjectTemplatesModel *templatesModel, AppWizardDialog *wizardDialog) | 36 | ProjectSelectionPage::ProjectSelectionPage(ProjectTemplatesModel *templatesModel, AppWizardDialog *wizardDialog) | ||
36 | : AppWizardPageWidget(wizardDialog), m_templatesModel(templatesModel) | 37 | : AppWizardPageWidget(wizardDialog), m_templatesModel(templatesModel) | ||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Line(s) | |||||
300 | 301 | | |||
301 | void ProjectSelectionPage::loadFileClicked() | 302 | void ProjectSelectionPage::loadFileClicked() | ||
302 | { | 303 | { | ||
303 | const QStringList supportedMimeTypes { | 304 | const QStringList supportedMimeTypes { | ||
304 | QStringLiteral("application/x-desktop"), | 305 | QStringLiteral("application/x-desktop"), | ||
305 | QStringLiteral("application/x-bzip-compressed-tar"), | 306 | QStringLiteral("application/x-bzip-compressed-tar"), | ||
306 | QStringLiteral("application/zip") | 307 | QStringLiteral("application/zip") | ||
307 | }; | 308 | }; | ||
308 | QFileDialog fileDialog(this, i18n("Load Template From File")); | 309 | ScopedDialog<QFileDialog> fileDialog(this, i18n("Load Template From File")); | ||
309 | fileDialog.setMimeTypeFilters(supportedMimeTypes); | 310 | fileDialog->setMimeTypeFilters(supportedMimeTypes); | ||
310 | fileDialog.setFileMode(QFileDialog::ExistingFiles); | 311 | fileDialog->setFileMode(QFileDialog::ExistingFiles); | ||
311 | 312 | | |||
312 | if (!fileDialog.exec()) { | 313 | if (!fileDialog->exec()) { | ||
313 | return; | 314 | return; | ||
314 | } | 315 | } | ||
315 | 316 | | |||
316 | for (const auto& fileName : fileDialog.selectedFiles()) { | 317 | for (const auto& fileName : fileDialog->selectedFiles()) { | ||
317 | QString destination = m_templatesModel->loadTemplateFile(fileName); | 318 | QString destination = m_templatesModel->loadTemplateFile(fileName); | ||
318 | QModelIndexList indexes = m_templatesModel->templateIndexes(destination); | 319 | QModelIndexList indexes = m_templatesModel->templateIndexes(destination); | ||
319 | if (indexes.size() > 2) | 320 | if (indexes.size() > 2) | ||
320 | { | 321 | { | ||
321 | m_listView->setCurrentIndex(indexes.at(1)); | 322 | m_listView->setCurrentIndex(indexes.at(1)); | ||
322 | ui->templateType->setCurrentIndex(indexes.at(2).row()); | 323 | ui->templateType->setCurrentIndex(indexes.at(2).row()); | ||
323 | } | 324 | } | ||
324 | } | 325 | } | ||
325 | } | 326 | } | ||
326 | 327 | | |||
327 | void ProjectSelectionPage::moreTemplatesClicked() | 328 | void ProjectSelectionPage::moreTemplatesClicked() | ||
328 | { | 329 | { | ||
329 | KNS3::DownloadDialog dialog(QStringLiteral("kdevappwizard.knsrc"), this); | 330 | ScopedDialog<KNS3::DownloadDialog> dialog(QStringLiteral("kdevappwizard.knsrc"), this); | ||
330 | dialog.exec(); | | |||
331 | 331 | | |||
332 | auto entries = dialog.changedEntries(); | 332 | if (!dialog->exec()) | ||
anthonyfieroni: Check should be done on every exec afterwards dialog is used, cause potentially it can be… | |||||
Do you mean like this? DownloadDialog does not delete itself, so I'm wondering what could go wrong, since changedEntries will just be empty. croick: Do you mean like this? DownloadDialog does not delete itself, so I'm wondering what could go… | |||||
333 | return; | ||||
334 | | ||||
335 | auto entries = dialog->changedEntries(); | ||||
333 | if (entries.isEmpty()) { | 336 | if (entries.isEmpty()) { | ||
334 | return; | 337 | return; | ||
335 | } | 338 | } | ||
336 | 339 | | |||
337 | m_templatesModel->refresh(); | 340 | m_templatesModel->refresh(); | ||
338 | bool updated = false; | 341 | bool updated = false; | ||
339 | 342 | | |||
340 | foreach (const KNS3::Entry& entry, entries) | 343 | foreach (const KNS3::Entry& entry, entries) | ||
Show All 27 Lines |
Check should be done on every exec afterwards dialog is used, cause potentially it can be deleted