Changeset View
Changeset View
Standalone View
Standalone View
plugins/filetemplates/templateselectionpage.cpp
Show All 30 Lines | |||||
31 | #include <interfaces/icore.h> | 31 | #include <interfaces/icore.h> | ||
32 | #include <interfaces/iproject.h> | 32 | #include <interfaces/iproject.h> | ||
33 | #include <interfaces/iprojectcontroller.h> | 33 | #include <interfaces/iprojectcontroller.h> | ||
34 | #include <interfaces/isession.h> | 34 | #include <interfaces/isession.h> | ||
35 | 35 | | |||
36 | #include "ui_templateselection.h" | 36 | #include "ui_templateselection.h" | ||
37 | 37 | | |||
38 | #include <QFileDialog> | 38 | #include <QFileDialog> | ||
39 | #include <QPointer> | ||||
39 | #include <QPushButton> | 40 | #include <QPushButton> | ||
40 | #include <QTemporaryDir> | 41 | #include <QTemporaryDir> | ||
41 | 42 | | |||
42 | #include <KConfigGroup> | 43 | #include <KConfigGroup> | ||
43 | #include <KLocalizedString> | 44 | #include <KLocalizedString> | ||
44 | #include <KNS3/DownloadDialog> | 45 | #include <KNS3/DownloadDialog> | ||
45 | #include <KTextEditor/Document> | 46 | #include <KTextEditor/Document> | ||
46 | 47 | | |||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | |||||
154 | 155 | | |||
155 | void TemplateSelectionPagePrivate::loadFileClicked() | 156 | void TemplateSelectionPagePrivate::loadFileClicked() | ||
156 | { | 157 | { | ||
157 | const QStringList filters{ | 158 | const QStringList filters{ | ||
158 | QStringLiteral("application/x-desktop"), | 159 | QStringLiteral("application/x-desktop"), | ||
159 | QStringLiteral("application/x-bzip-compressed-tar"), | 160 | QStringLiteral("application/x-bzip-compressed-tar"), | ||
160 | QStringLiteral("application/zip") | 161 | QStringLiteral("application/zip") | ||
161 | }; | 162 | }; | ||
162 | QFileDialog dlg(page); | 163 | QPointer<QFileDialog> dlg = new QFileDialog(page); | ||
163 | dlg.setMimeTypeFilters(filters); | 164 | dlg->setMimeTypeFilters(filters); | ||
164 | dlg.setFileMode(QFileDialog::ExistingFiles); | 165 | dlg->setFileMode(QFileDialog::ExistingFiles); | ||
165 | 166 | | |||
166 | if (!dlg.exec()) | 167 | if (!dlg->exec()) | ||
167 | { | 168 | { | ||
169 | delete dlg; | ||||
168 | return; | 170 | return; | ||
169 | } | 171 | } | ||
170 | 172 | | |||
171 | foreach(const QString& fileName, dlg.selectedFiles()) | 173 | foreach(const QString& fileName, dlg->selectedFiles()) | ||
172 | { | 174 | { | ||
173 | QString destination = model->loadTemplateFile(fileName); | 175 | QString destination = model->loadTemplateFile(fileName); | ||
174 | QModelIndexList indexes = model->templateIndexes(destination); | 176 | QModelIndexList indexes = model->templateIndexes(destination); | ||
175 | int n = indexes.size(); | 177 | int n = indexes.size(); | ||
176 | if (n > 1) | 178 | if (n > 1) | ||
177 | { | 179 | { | ||
178 | ui->view->setCurrentIndex(indexes[1]); | 180 | ui->view->setCurrentIndex(indexes[1]); | ||
179 | } | 181 | } | ||
180 | } | 182 | } | ||
183 | | ||||
184 | delete dlg; | ||||
181 | } | 185 | } | ||
182 | 186 | | |||
183 | void TemplateSelectionPage::saveConfig() | 187 | void TemplateSelectionPage::saveConfig() | ||
184 | { | 188 | { | ||
185 | KSharedConfigPtr config; | 189 | KSharedConfigPtr config; | ||
186 | if (IProject* project = ICore::self()->projectController()->findProjectForUrl(d->assistant->baseUrl())) | 190 | if (IProject* project = ICore::self()->projectController()->findProjectForUrl(d->assistant->baseUrl())) | ||
187 | { | 191 | { | ||
188 | config = project->projectConfiguration(); | 192 | config = project->projectConfiguration(); | ||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |