| 216 | } |
| 217 | |
| 218 | void OpenProjectDialog::validateOpenUrl( const QUrl& url_ ) |
| 219 | { |
| 220 | URLInfo urlInfo = ::urlInfo(url_); |
| 221 | |
| 222 | const QUrl url = url_.adjusted(QUrl::StripTrailingSlash); |
| 223 | |
| 224 | // openPage is used only in KDE |
| 225 | if (openPage) { |
| 226 | if ( urlInfo.isValid ) { |
| 227 | // reset header |
| 228 | openPage->setHeader(i18n("Open \"%1\" as project", url.fileName())); |
| 229 | } else { |
| 230 | // report error |
| 231 | KColorScheme scheme(palette().currentColorGroup()); |
| 232 | const QString errorMsg = i18n("Selected URL is invalid"); |
| 233 | openPage->setHeader(QStringLiteral("<font color='%1'>%2</font>") |
| 234 | .arg(scheme.foreground(KColorScheme::NegativeText).color().name(), errorMsg) |
| 235 | ); |
| 236 | setAppropriate( projectInfoPage, false ); |
| 237 | setAppropriate( openPage, true ); |
| 238 | setValid( openPage, false ); |
| 239 | return; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | m_selected = url; |
| 244 | |
| 245 | if( urlInfo.isDir || urlInfo.extension != ShellExtension::getInstance()->projectFileExtension() ) |
| 246 | { |
| 247 | m_urlIsDirectory = urlInfo.isDir; |
| 248 | setAppropriate( projectInfoPage, true ); |
| 249 | m_url = url; |
| 250 | if( !urlInfo.isDir ) { |
| 251 | m_url = m_url.adjusted(QUrl::StripTrailingSlash | QUrl::RemoveFilename); |
| 252 | } |
| 253 | auto* page = qobject_cast<ProjectInfoPage*>( projectInfoPage->widget() ); |
| 254 | if( page ) |
| 255 | { |
| 256 | page->setProjectName( m_url.fileName() ); |
| 257 | // clear the filelist |
| 258 | m_fileList.clear(); |
| 259 | |
| 260 | if( urlInfo.isDir ) { |
| 261 | // If a dir was selected fetch all files in it |
| 262 | KIO::ListJob* job = KIO::listDir( m_url ); |
| 263 | connect( job, &KIO::ListJob::entries, |
| 264 | this, &OpenProjectDialog::storeFileList); |
| 265 | KJobWidgets::setWindow(job, Core::self()->uiController()->activeMainWindow()); |
| 266 | job->exec(); |
| 267 | } else { |
| 268 | // Else we'll just take the given file |
| 269 | m_fileList << url.fileName(); |
| 270 | } |
| 271 | // Now find a manager for the file(s) in our filelist. |
| 272 | QVector<ProjectFileChoice> choices; |
| 273 | for (const auto& file : std::as_const(m_fileList)) { |
| 274 | auto plugins = projectManagerForFile(file); |
| 275 | if ( plugins.contains(QStringLiteral("<built-in>")) ) { |
nothing calls this directly
no test coverage detected