| 166 | } |
| 167 | |
| 168 | void 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 | } |
nothing calls this directly
no test coverage detected