Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/projectcontroller.cpp
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Line(s) | 409 | { | |||
---|---|---|---|---|---|
418 | } | 418 | } | ||
419 | } | 419 | } | ||
420 | 420 | | |||
421 | bool equalProjectFile( const QString& configPath, OpenProjectDialog* dlg ) | 421 | bool equalProjectFile( const QString& configPath, OpenProjectDialog* dlg ) | ||
422 | { | 422 | { | ||
423 | KSharedConfigPtr cfg = KSharedConfig::openConfig( configPath, KConfig::SimpleConfig ); | 423 | KSharedConfigPtr cfg = KSharedConfig::openConfig( configPath, KConfig::SimpleConfig ); | ||
424 | KConfigGroup grp = cfg->group( "Project" ); | 424 | KConfigGroup grp = cfg->group( "Project" ); | ||
425 | QString defaultName = dlg->projectFileUrl().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).fileName(); | 425 | QString defaultName = dlg->projectFileUrl().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).fileName(); | ||
426 | qCDebug(SHELL) << "configPath=" << configPath << "defaultName=" << defaultName | ||||
427 | << "projName=" << dlg->projectName() << "projectMan=" << dlg->projectManager() | ||||
428 | << "grp.Name=" << grp.readEntry( "Name", QString() ) << "grp.Manager=" << grp.readEntry( "Manager", QString() ); | ||||
426 | return (grp.readEntry( "Name", QString() ) == dlg->projectName() || dlg->projectName() == defaultName) && | 429 | return (grp.readEntry( "Name", QString() ) == dlg->projectName() || dlg->projectName() == defaultName) && | ||
427 | grp.readEntry( "Manager", QString() ) == dlg->projectManager(); | 430 | grp.readEntry( "Manager", QString() ) == dlg->projectManager(); | ||
428 | } | 431 | } | ||
429 | 432 | | |||
430 | QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& startUrl, | 433 | QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& startUrl, | ||
431 | const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) | 434 | const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin) | ||
432 | { | 435 | { | ||
433 | Q_ASSERT(d); | 436 | Q_ASSERT(d); | ||
434 | ScopedDialog<OpenProjectDialog> dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, | 437 | ScopedDialog<OpenProjectDialog> dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, | ||
435 | Core::self()->uiController()->activeMainWindow()); | 438 | Core::self()->uiController()->activeMainWindow()); | ||
436 | if(dlg->exec() == QDialog::Rejected) { | 439 | if(dlg->exec() == QDialog::Rejected) { | ||
437 | return QUrl(); | 440 | return QUrl(); | ||
438 | } | 441 | } | ||
439 | 442 | | |||
440 | QUrl projectFileUrl = dlg->projectFileUrl(); | 443 | QUrl projectFileUrl = dlg->projectFileUrl(); | ||
441 | qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg->projectName() << dlg->projectManager(); | 444 | qCDebug(SHELL) << "selected project:" << projectFileUrl << "selectedUrl=" << dlg->selectedUrl() | ||
445 | << "projectName=" << dlg->projectName() << "projectManager=" << dlg->projectManager(); | ||||
442 | if ( dlg->projectManager() == QLatin1String("<built-in>") ) { | 446 | if ( dlg->projectManager() == QLatin1String("<built-in>") ) { | ||
443 | return projectFileUrl; | 447 | return projectFileUrl; | ||
444 | } | 448 | } | ||
445 | 449 | | |||
446 | // controls if existing project file should be saved | 450 | // controls if existing project file should be saved | ||
447 | bool writeProjectConfigToFile = true; | 451 | bool writeProjectConfigToFile = true; | ||
448 | if( projectFileExists( projectFileUrl ) ) | 452 | if( projectFileExists( projectFileUrl ) ) | ||
449 | { | 453 | { | ||
450 | // check whether config is equal | 454 | // check whether we should question the user about overriding an existing project file or not. | ||
451 | bool shouldAsk = true; | 455 | // We don't need to do that when the file we're importing (dlg->selectedUrl) is already an | ||
452 | if( projectFileUrl == dlg->selectedUrl() ) | 456 | // existing .kdev4 project file (we just verified that it exists): | ||
453 | { | 457 | bool isKDevProject = QFileInfo(dlg->selectedUrl().url()).suffix() == QStringLiteral("kdev4"); | ||
458 | bool shouldAsk = !isKDevProject; | ||||
459 | if( !isKDevProject && projectFileUrl == dlg->selectedUrl() ) | ||||
mwolff: I don't get this change, can you explain? the old code checks whether the profileFileUrl (which… | |||||
460 | { | ||||
461 | // We're importing a project from another type of project file, post the | ||||
462 | // override dialog if there's a discrepancy between the project file URL | ||||
463 | // and the information stored in the dialog and the project settings. | ||||
464 | qCWarning(SHELL) << "Importing a foreign project type:" << projectFileUrl.url(); | ||||
454 | if( projectFileUrl.isLocalFile() ) | 465 | if( projectFileUrl.isLocalFile() ) | ||
455 | { | 466 | { | ||
456 | shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), dlg ); | 467 | shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), dlg ); | ||
457 | } else { | 468 | } else { | ||
458 | shouldAsk = false; | 469 | shouldAsk = false; | ||
459 | 470 | | |||
460 | QTemporaryFile tmpFile; | 471 | QTemporaryFile tmpFile; | ||
461 | if (tmpFile.open()) { | 472 | if (tmpFile.open()) { | ||
Show All 23 Lines | 495 | i18n("There already exists a project configuration file at %1.\n" | |||
485 | "Do you want to override it or open the existing file?", projectFileUrl.toDisplayString(QUrl::PreferLocalFile)), | 496 | "Do you want to override it or open the existing file?", projectFileUrl.toDisplayString(QUrl::PreferLocalFile)), | ||
486 | i18n("Override existing project configuration"), yes, no, cancel ); | 497 | i18n("Override existing project configuration"), yes, no, cancel ); | ||
487 | if ( ret == KMessageBox::No ) | 498 | if ( ret == KMessageBox::No ) | ||
488 | { | 499 | { | ||
489 | writeProjectConfigToFile = false; | 500 | writeProjectConfigToFile = false; | ||
490 | } else if ( ret == KMessageBox::Cancel ) | 501 | } else if ( ret == KMessageBox::Cancel ) | ||
491 | { | 502 | { | ||
492 | return QUrl(); | 503 | return QUrl(); | ||
493 | } // else fall through and write new file | 504 | } else { | ||
505 | // confusion can arise when an existing project is overridden and the old settings | ||||
506 | // file remains (http://phabricator.kde.org/T6262). The .kdev4 directory can | ||||
507 | // contain settings files for other projects which shouldn't be deleted, so | ||||
508 | // we delete just the settings file for this project. | ||||
509 | Path settingsFile(projectFileUrl); | ||||
510 | settingsFile.setLastPathSegment(QStringLiteral(".kdev4")); | ||||
511 | settingsFile.addPath(projectFileUrl.fileName()); | ||||
512 | qCDebug(SHELL) << "Deleting old settings file before overriding it:" << settingsFile; | ||||
513 | auto delJob = KIO::del(settingsFile.toUrl()); | ||||
514 | delJob->exec(); | ||||
515 | } | ||||
494 | } else { | 516 | } else { | ||
495 | writeProjectConfigToFile = false; | 517 | writeProjectConfigToFile = false; | ||
496 | } | 518 | } | ||
497 | } | 519 | } | ||
498 | 520 | | |||
499 | if (writeProjectConfigToFile) { | 521 | if (writeProjectConfigToFile) { | ||
500 | Path projectConfigDir(projectFileUrl); | | |||
501 | projectConfigDir.setLastPathSegment(QStringLiteral(".kdev4")); | | |||
502 | auto delJob = KIO::del(projectConfigDir.toUrl()); | | |||
503 | delJob->exec(); | | |||
504 | | ||||
505 | if (!writeProjectSettingsToConfigFile(projectFileUrl, dlg)) { | 522 | if (!writeProjectSettingsToConfigFile(projectFileUrl, dlg)) { | ||
506 | KMessageBox::error(d->m_core->uiControllerInternal()->defaultMainWindow(), | 523 | KMessageBox::error(d->m_core->uiControllerInternal()->defaultMainWindow(), | ||
507 | i18n("Unable to create configuration file %1", projectFileUrl.url())); | 524 | i18n("Unable to create configuration file %1", projectFileUrl.url())); | ||
508 | return QUrl(); | 525 | return QUrl(); | ||
509 | } | 526 | } | ||
510 | } | 527 | } | ||
511 | 528 | | |||
512 | return projectFileUrl; | 529 | return projectFileUrl; | ||
▲ Show 20 Lines • Show All 775 Lines • Show Last 20 Lines |
I don't get this change, can you explain? the old code checks whether the profileFileUrl (which should *always* ends on .kdev4, no?) exists. In that case, we want to ask the user if he wants to override, except if the project file is equal to what we'd write out anyways.
your change seems to completely break this, as isKDevProject should always be true, and then shouldAsk always false?