MCPcopy Create free account
hub / github.com/KDE/kdevelop / validateData

Method validateData

plugins/appwizard/projectselectionpage.cpp:168–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void ProjectSelectionPage::validateData()
169{
170 QUrl url = ui->locationUrl->url();
171 if( !url.isLocalFile() || url.isEmpty() )
172 {
173 ui->locationValidWidget->setText( i18n("Invalid location") );
174 ui->locationValidWidget->animatedShow();
175 emit invalid();
176 return;
177 }
178
179 if (projectName().isEmpty()) {
180 ui->locationValidWidget->setText( i18n("Empty project name") );
181 ui->locationValidWidget->animatedShow();
182 emit invalid();
183 return;
184 }
185
186 if (!projectName().isEmpty()) {
187 QString projectName = this->projectName();
188 QString templatefile = m_wizardDialog->appInfo().appTemplate;
189
190 // Read template file
191 KConfig config(templatefile);
192 KConfigGroup configgroup(&config, QStringLiteral("General"));
193 QString pattern = configgroup.readEntry( "ValidProjectName" , "^[a-zA-Z][a-zA-Z0-9_-]+$" );
194
195 // Validation
196 int pos = 0;
197 const QRegularExpressionValidator validator(QRegularExpression{pattern});
198 if( validator.validate(projectName, pos) == QValidator::Invalid )
199 {
200 ui->locationValidWidget->setText( i18n("Invalid project name") );
201 ui->locationValidWidget->animatedShow();
202 emit invalid();
203 return;
204 }
205 }
206
207 QDir tDir(url.toLocalFile());
208 while (!tDir.exists() && !tDir.isRoot()) {
209 if (!tDir.cdUp()) {
210 break;
211 }
212 }
213
214 if (tDir.exists())
215 {
216 QFileInfo tFileInfo(tDir.absolutePath());
217 if (!tFileInfo.isWritable() || !tFileInfo.isExecutable())
218 {
219 ui->locationValidWidget->setText( i18n("Unable to create subdirectories, "
220 "missing permissions on: %1", tDir.absolutePath()) );
221 ui->locationValidWidget->animatedShow();
222 emit invalid();
223 return;
224 }
225 }

Callers

nothing calls this directly

Calls 15

projectNameMethod · 0.95
isLocalFileMethod · 0.80
appInfoMethod · 0.80
readEntryMethod · 0.80
toLocalFileMethod · 0.80
existsMethod · 0.80
QDirClass · 0.50
urlMethod · 0.45
isEmptyMethod · 0.45
setTextMethod · 0.45
validateMethod · 0.45
isWritableMethod · 0.45

Tested by

no test coverage detected