Changeset View
Changeset View
Standalone View
Standalone View
plugins/filetemplates/outputpage.cpp
Show All 22 Lines | |||||
23 | #include <language/codegen/sourcefiletemplate.h> | 23 | #include <language/codegen/sourcefiletemplate.h> | ||
24 | #include <language/codegen/templaterenderer.h> | 24 | #include <language/codegen/templaterenderer.h> | ||
25 | #include <KConfigGroup> | 25 | #include <KConfigGroup> | ||
26 | #include <KSharedConfig> | 26 | #include <KSharedConfig> | ||
27 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
28 | #include <KUrlRequester> | 28 | #include <KUrlRequester> | ||
29 | 29 | | |||
30 | #include <QSpinBox> | 30 | #include <QSpinBox> | ||
31 | #include <QSignalMapper> | | |||
32 | #include <QLabel> | 31 | #include <QLabel> | ||
33 | 32 | | |||
34 | namespace KDevelop { | 33 | namespace KDevelop { | ||
35 | 34 | | |||
36 | struct OutputPagePrivate | 35 | struct OutputPagePrivate | ||
37 | { | 36 | { | ||
38 | explicit OutputPagePrivate(OutputPage* page_) | 37 | explicit OutputPagePrivate(OutputPage* page_) | ||
39 | : page(page_) | 38 | : page(page_) | ||
40 | , output(nullptr) | 39 | , output(nullptr) | ||
41 | { } | 40 | { } | ||
42 | OutputPage* page; | 41 | OutputPage* page; | ||
43 | Ui::OutputLocationDialog* output; | 42 | Ui::OutputLocationDialog* output; | ||
44 | QSignalMapper urlChangedMapper; | | |||
45 | 43 | | |||
46 | QHash<QString, KUrlRequester*> outputFiles; | 44 | QHash<QString, KUrlRequester*> outputFiles; | ||
47 | QHash<QString, QSpinBox*> outputLines; | 45 | QHash<QString, QSpinBox*> outputLines; | ||
48 | QHash<QString, QSpinBox*> outputColumns; | 46 | QHash<QString, QSpinBox*> outputColumns; | ||
49 | QList<QLabel*> labels; | 47 | QList<QLabel*> labels; | ||
50 | 48 | | |||
51 | QHash<QString, QUrl> defaultUrls; | 49 | QHash<QString, QUrl> defaultUrls; | ||
52 | QHash<QString, QUrl> lowerCaseUrls; | 50 | QHash<QString, QUrl> lowerCaseUrls; | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
137 | OutputPage::OutputPage(QWidget* parent) | 135 | OutputPage::OutputPage(QWidget* parent) | ||
138 | : QWidget(parent) | 136 | : QWidget(parent) | ||
139 | , d(new OutputPagePrivate(this)) | 137 | , d(new OutputPagePrivate(this)) | ||
140 | { | 138 | { | ||
141 | d->output = new Ui::OutputLocationDialog; | 139 | d->output = new Ui::OutputLocationDialog; | ||
142 | d->output->setupUi(this); | 140 | d->output->setupUi(this); | ||
143 | d->output->messageWidget->setVisible(false); | 141 | d->output->messageWidget->setVisible(false); | ||
144 | 142 | | |||
145 | connect(&d->urlChangedMapper, static_cast<void(QSignalMapper::*)(const QString&)>(&QSignalMapper::mapped), | | |||
146 | this, [&] (const QString& field) { d->updateFileRange(field); }); | | |||
147 | connect(d->output->lowerFilenameCheckBox, &QCheckBox::stateChanged, | 143 | connect(d->output->lowerFilenameCheckBox, &QCheckBox::stateChanged, | ||
148 | this, [&] { d->updateFileNames(); }); | 144 | this, [&] { d->updateFileNames(); }); | ||
149 | } | 145 | } | ||
150 | 146 | | |||
151 | OutputPage::~OutputPage() | 147 | OutputPage::~OutputPage() | ||
152 | { | 148 | { | ||
153 | delete d->output; | 149 | delete d->output; | ||
154 | delete d; | 150 | delete d; | ||
Show All 11 Lines | 154 | { | |||
166 | { | 162 | { | ||
167 | d->output->urlFormLayout->takeAt(0); | 163 | d->output->urlFormLayout->takeAt(0); | ||
168 | } | 164 | } | ||
169 | while (d->output->positionFormLayout->count() > 0) | 165 | while (d->output->positionFormLayout->count() > 0) | ||
170 | { | 166 | { | ||
171 | d->output->positionFormLayout->takeAt(0); | 167 | d->output->positionFormLayout->takeAt(0); | ||
172 | } | 168 | } | ||
173 | 169 | | |||
174 | foreach (KUrlRequester* req, d->outputFiles) | | |||
175 | { | | |||
176 | d->urlChangedMapper.removeMappings(req); | | |||
177 | } | | |||
178 | | ||||
179 | qDeleteAll(d->outputFiles); | 170 | qDeleteAll(d->outputFiles); | ||
180 | qDeleteAll(d->outputLines); | 171 | qDeleteAll(d->outputLines); | ||
181 | qDeleteAll(d->outputColumns); | 172 | qDeleteAll(d->outputColumns); | ||
182 | qDeleteAll(d->labels); | 173 | qDeleteAll(d->labels); | ||
183 | 174 | | |||
184 | d->outputFiles.clear(); | 175 | d->outputFiles.clear(); | ||
185 | d->outputLines.clear(); | 176 | d->outputLines.clear(); | ||
186 | d->outputColumns.clear(); | 177 | d->outputColumns.clear(); | ||
187 | d->labels.clear(); | 178 | d->labels.clear(); | ||
188 | 179 | | |||
189 | const int outputFilesCount = fileTemplate.outputFiles().count(); | 180 | const int outputFilesCount = fileTemplate.outputFiles().count(); | ||
190 | d->output->urlGroupBox->setTitle(i18np("Output file", "Output files", outputFilesCount)); | 181 | d->output->urlGroupBox->setTitle(i18np("Output file", "Output files", outputFilesCount)); | ||
191 | d->output->positionGroupBox->setTitle(i18np("Location within existing file", "Location within existing files", outputFilesCount)); | 182 | d->output->positionGroupBox->setTitle(i18np("Location within existing file", "Location within existing files", outputFilesCount)); | ||
192 | 183 | | |||
193 | foreach (const SourceFileTemplate::OutputFile& file, fileTemplate.outputFiles()) | 184 | foreach (const SourceFileTemplate::OutputFile& file, fileTemplate.outputFiles()) | ||
194 | { | 185 | { | ||
195 | d->fileIdentifiers << file.identifier; | 186 | const QString id = file.identifier; | ||
187 | d->fileIdentifiers << id; | ||||
196 | 188 | | |||
197 | const QString fileLabelText = i18n("%1:", file.label); | 189 | const QString fileLabelText = i18n("%1:", file.label); | ||
198 | QLabel* label = new QLabel(fileLabelText, this); | 190 | QLabel* label = new QLabel(fileLabelText, this); | ||
199 | d->labels << label; | 191 | d->labels << label; | ||
200 | KUrlRequester* requester = new KUrlRequester(this); | 192 | KUrlRequester* requester = new KUrlRequester(this); | ||
201 | requester->setMode( KFile::File | KFile::LocalOnly ); | 193 | requester->setMode( KFile::File | KFile::LocalOnly ); | ||
202 | 194 | | |||
203 | d->urlChangedMapper.setMapping(requester, file.identifier); | 195 | connect(requester, &KUrlRequester::textChanged, this, [this, id] () { d->updateFileRange(id); }); | ||
204 | connect(requester, &KUrlRequester::textChanged, &d->urlChangedMapper, static_cast<void(QSignalMapper::*)()>(&QSignalMapper::map)); | | |||
205 | 196 | | |||
206 | d->output->urlFormLayout->addRow(label, requester); | 197 | d->output->urlFormLayout->addRow(label, requester); | ||
207 | d->outputFiles.insert(file.identifier, requester); | 198 | d->outputFiles.insert(file.identifier, requester); | ||
208 | 199 | | |||
209 | label = new QLabel(fileLabelText, this); | 200 | label = new QLabel(fileLabelText, this); | ||
210 | d->labels << label; | 201 | d->labels << label; | ||
211 | QHBoxLayout* layout = new QHBoxLayout; | 202 | QHBoxLayout* layout = new QHBoxLayout; | ||
212 | 203 | | |||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |