456
469
DatabaseParameters params = DatabaseAccess::parameters();
458
471
// New database type SQLITE
459
if (newParams.isSQLite()){
472
if (newParams.isSQLite())
460
474
QDir newDir(newParams.getDatabaseNameOrDir());
461
475
QFileInfo newFile(newDir, QString("digikam4.db"));
463
477
if (!newFile.exists())
479
QFileInfo digikam3DB(newDir, "digikam3.db");
480
QFileInfo digikamVeryOldDB(newDir, "digikam.db");
482
if (digikam3DB.exists() || digikamVeryOldDB.exists())
465
QFileInfo digikam3DB(newDir, "digikam3.db");
466
QFileInfo digikamVeryOldDB(newDir, "digikam.db");
484
KGuiItem copyCurrent(i18n("Copy Current Database"), "edit-copy");
485
KGuiItem startFresh(i18n("Create New Database"), "document-new");
486
KGuiItem upgrade(i18n("Upgrade Database"), "view-refresh");
468
if (digikam3DB.exists() || digikamVeryOldDB.exists())
489
if (params.isSQLite())
470
KGuiItem copyCurrent(i18n("Copy Current Database"), "edit-copy");
471
KGuiItem startFresh(i18n("Create New Database"), "document-new");
472
KGuiItem upgrade(i18n("Upgrade Database"), "view-refresh");
474
if (params.isSQLite())
476
result = KMessageBox::warningYesNoCancel(0,
477
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
478
"A database file from an older version of digiKam is found in this folder.</p> "
479
"<p>Would you like to upgrade the old database file, start with a new database, "
480
"or copy the current database to this location and continue using it?</p> ",
482
i18n("New database folder"),
483
upgrade, startFresh, copyCurrent);
485
result = KMessageBox::warningYesNo(0,
486
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
487
"A database file from an older version of digiKam is found in this folder.</p> "
488
"<p>Would you like to upgrade the old database file or start with a new database?</p>",
490
i18n("New database folder"),
491
upgrade, startFresh);
494
if (result == KMessageBox::Yes)
496
// SchemaUpdater expects Album Path to point to the album root of the 0.9 db file.
497
// Restore this situation.
498
KSharedConfigPtr config = KGlobal::config();
499
KConfigGroup group = config->group("Album Settings");
500
group.writeEntry("Album Path", newDir.path());
503
else if (result == KMessageBox::No)
505
moveToBackup(digikam3DB);
506
moveToBackup(digikamVeryOldDB);
508
else if (result == KMessageBox::Cancel)
510
QDir oldDir(d->dbName);
511
QFileInfo oldFile(params.SQLiteDatabaseFile());
512
copyToNewLocation(oldFile, newFile, i18n("Failed to copy the old database file (\"%1\") "
513
"to its new location (\"%2\"). "
514
"Trying to upgrade old databases.",
515
oldFile.filePath(), newFile.filePath()));
491
result = KMessageBox::warningYesNoCancel(0,
492
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
493
"A database file from an older version of digiKam is found in this folder.</p> "
494
"<p>Would you like to upgrade the old database file, start with a new database, "
495
"or copy the current database to this location and continue using it?</p> ",
497
i18n("New database folder"),
498
upgrade, startFresh, copyCurrent);
520
int result = KMessageBox::Yes;
521
if (params.isSQLite())
523
KGuiItem copyCurrent(i18n("Copy Current Database"), "edit-copy");
524
KGuiItem startFresh(i18n("Create New Database"), "document-new");
525
result = KMessageBox::warningYesNo(0,
526
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database.</p>"
527
"<p>Would you like to copy the current database to this location "
528
"and continue using it, or start with a new database?</p> ",
530
i18n("New database folder"),
531
startFresh, copyCurrent);
502
result = KMessageBox::warningYesNo(0,
503
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
504
"A database file from an older version of digiKam is found in this folder.</p> "
505
"<p>Would you like to upgrade the old database file or start with a new database?</p>",
507
i18n("New database folder"),
508
upgrade, startFresh);
534
if (result == KMessageBox::No)
536
QDir oldDir(d->dbName);
537
QFileInfo oldFile(params.SQLiteDatabaseFile());
538
copyToNewLocation(oldFile, newFile);
544
int result = KMessageBox::No;
545
if (params.isSQLite())
547
KGuiItem replaceItem(i18n("Copy Current Database"), "edit-copy");
548
KGuiItem useExistingItem(i18n("Use Existing File"), "document-open");
549
result = KMessageBox::warningYesNo(0,
550
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
551
"There is already a database file in this location.</p> "
552
"<p>Would you like to use this existing file as the new database, or remove it "
553
"and copy the current database to this place?</p> ",
555
i18n("New database folder"),
556
replaceItem, useExistingItem);
558
511
if (result == KMessageBox::Yes)
561
if (moveToBackup(newFile))
563
QDir oldDir(d->dbName);
564
QFileInfo oldFile(params.SQLiteDatabaseFile());
567
copyToNewLocation(oldFile, newFile);
513
// SchemaUpdater expects Album Path to point to the album root of the 0.9 db file.
514
// Restore this situation.
515
KSharedConfigPtr config = KGlobal::config();
516
KConfigGroup group = config->group("Album Settings");
517
group.writeEntry("Album Path", newDir.path());
520
else if (result == KMessageBox::No)
522
moveToBackup(digikam3DB);
523
moveToBackup(digikamVeryOldDB);
525
else if (result == KMessageBox::Cancel)
527
QDir oldDir(d->dbName);
528
QFileInfo oldFile(params.SQLiteDatabaseFile());
529
copyToNewLocation(oldFile, newFile, i18n("Failed to copy the old database file (\"%1\") "
530
"to its new location (\"%2\"). "
531
"Trying to upgrade old databases.",
532
oldFile.filePath(), newFile.filePath()));
537
int result = KMessageBox::Yes;
539
if (params.isSQLite())
541
KGuiItem copyCurrent(i18n("Copy Current Database"), "edit-copy");
542
KGuiItem startFresh(i18n("Create New Database"), "document-new");
543
result = KMessageBox::warningYesNo(0,
544
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database.</p>"
545
"<p>Would you like to copy the current database to this location "
546
"and continue using it, or start with a new database?</p> ",
548
i18n("New database folder"),
549
startFresh, copyCurrent);
552
if (result == KMessageBox::No)
554
QDir oldDir(d->dbName);
555
QFileInfo oldFile(params.SQLiteDatabaseFile());
556
copyToNewLocation(oldFile, newFile);
562
int result = KMessageBox::No;
564
if (params.isSQLite())
566
KGuiItem replaceItem(i18n("Copy Current Database"), "edit-copy");
567
KGuiItem useExistingItem(i18n("Use Existing File"), "document-open");
568
result = KMessageBox::warningYesNo(0,
569
i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
570
"There is already a database file in this location.</p> "
571
"<p>Would you like to use this existing file as the new database, or remove it "
572
"and copy the current database to this place?</p> ",
574
i18n("New database folder"),
575
replaceItem, useExistingItem);
578
if (result == KMessageBox::Yes)
581
if (moveToBackup(newFile))
583
QDir oldDir(d->dbName);
584
QFileInfo oldFile(params.SQLiteDatabaseFile());
587
copyToNewLocation(oldFile, newFile);
573
593
if (setDatabase(newParams, false))
801
834
// -- UUID Checking ---------------------------------------------------------
803
836
QList<CollectionLocation> disappearedLocations = CollectionManager::instance()->checkHardWiredLocations();
804
foreach (const CollectionLocation &loc, disappearedLocations)
837
foreach (const CollectionLocation& loc, disappearedLocations)
806
839
QString locDescription;
807
840
QStringList candidateIds, candidateDescriptions;
808
841
CollectionManager::instance()->migrationCandidates(loc, &locDescription, &candidateIds, &candidateDescriptions);
809
842
kDebug() << "Migration candidates for" << locDescription << ":" << candidateIds << candidateDescriptions;
811
KDialog *dialog = new KDialog;
844
KDialog* dialog = new KDialog;
813
QWidget *widget = new QWidget;
814
QGridLayout *mainLayout = new QGridLayout;
846
QWidget* widget = new QWidget;
847
QGridLayout* mainLayout = new QGridLayout;
815
848
mainLayout->setColumnStretch(1, 1);
817
QLabel *deviceIconLabel = new QLabel;
850
QLabel* deviceIconLabel = new QLabel;
818
851
deviceIconLabel->setPixmap(KIconLoader::global()->loadIcon("drive-harddisk", KIconLoader::NoGroup, KIconLoader::SizeHuge));
819
852
mainLayout->addWidget(deviceIconLabel, 0, 0);
821
QLabel *mainLabel = new QLabel(
822
i18n("<p>The collection </p><p><b>%1</b><br/>(%2)</p><p> is currently not found on your system.<br/> "
823
"Please choose the most appropriate option to handle this situation:</p>",
824
loc.label(), locDescription));
854
QLabel* mainLabel = new QLabel(
855
i18n("<p>The collection </p><p><b>%1</b><br/>(%2)</p><p> is currently not found on your system.<br/> "
856
"Please choose the most appropriate option to handle this situation:</p>",
857
loc.label(), locDescription));
825
858
mainLabel->setWordWrap(true);
826
859
mainLayout->addWidget(mainLabel, 0, 1);
828
QGroupBox *groupBox = new QGroupBox;
861
QGroupBox* groupBox = new QGroupBox;
829
862
mainLayout->addWidget(groupBox, 1, 0, 1, 2);
831
QGridLayout *layout = new QGridLayout;
864
QGridLayout* layout = new QGridLayout;
832
865
layout->setColumnStretch(1, 1);
834
QRadioButton *migrateButton = 0;
835
KComboBox *migrateChoices = 0;
867
QRadioButton* migrateButton = 0;
868
KComboBox* migrateChoices = 0;
836
870
if (!candidateIds.isEmpty())
838
872
migrateButton = new QRadioButton;
839
QLabel *migrateLabel = new QLabel(
840
i18n("<p>The collection is still available, but the identifier changed.<br/>"
841
"This can be caused by restoring a backup, changing the partition layout "
842
"or the file system settings.<br/>"
843
"The collection is now located at this place:</p>"));
873
QLabel* migrateLabel = new QLabel(
874
i18n("<p>The collection is still available, but the identifier changed.<br/>"
875
"This can be caused by restoring a backup, changing the partition layout "
876
"or the file system settings.<br/>"
877
"The collection is now located at this place:</p>"));
844
878
migrateLabel->setWordWrap(true);
846
880
migrateChoices = new KComboBox;
847
882
for (int i=0; i<candidateIds.size(); ++i)
848
884
migrateChoices->addItem(candidateDescriptions[i], candidateIds[i]);
850
887
layout->addWidget(migrateButton, 0, 0, Qt::AlignTop);
851
888
layout->addWidget(migrateLabel, 0, 1);
852
889
layout->addWidget(migrateChoices, 1, 1);
855
QRadioButton *isRemovableButton = new QRadioButton;
856
QLabel *isRemovableLabel = new QLabel(
857
i18n("The collection is located on a storage device which is not always attached. "
858
"Mark the collection as a removable collection."));
892
QRadioButton* isRemovableButton = new QRadioButton;
893
QLabel* isRemovableLabel = new QLabel(
894
i18n("The collection is located on a storage device which is not always attached. "
895
"Mark the collection as a removable collection."));
859
896
isRemovableLabel->setWordWrap(true);
860
897
layout->addWidget(isRemovableButton, 2, 0, Qt::AlignTop);
861
898
layout->addWidget(isRemovableLabel, 2, 1);
863
QRadioButton *solveManuallyButton = new QRadioButton;
864
QLabel *solveManuallyLabel = new QLabel(
865
i18n("Take no action now. I would like to solve the problem "
866
"later using the setup dialog"));
900
QRadioButton* solveManuallyButton = new QRadioButton;
901
QLabel* solveManuallyLabel = new QLabel(
902
i18n("Take no action now. I would like to solve the problem "
903
"later using the setup dialog"));
867
904
solveManuallyLabel->setWordWrap(true);
868
905
layout->addWidget(solveManuallyButton, 3, 0, Qt::AlignTop);
869
906
layout->addWidget(solveManuallyLabel, 3, 1);
1072
1133
// listen to location status changes
1073
connect(CollectionManager::instance(), SIGNAL(locationStatusChanged(const CollectionLocation &, int)),
1074
this, SLOT(slotCollectionLocationStatusChanged(const CollectionLocation &, int)));
1075
connect(CollectionManager::instance(), SIGNAL(locationPropertiesChanged(const CollectionLocation &)),
1076
this, SLOT(slotCollectionLocationPropertiesChanged(const CollectionLocation &)));
1134
connect(CollectionManager::instance(), SIGNAL(locationStatusChanged(const CollectionLocation&, int)),
1135
this, SLOT(slotCollectionLocationStatusChanged(const CollectionLocation&, int)));
1136
connect(CollectionManager::instance(), SIGNAL(locationPropertiesChanged(const CollectionLocation&)),
1137
this, SLOT(slotCollectionLocationPropertiesChanged(const CollectionLocation&)));
1078
1139
// reload albums
1081
1142
// listen to album database changes
1082
connect(DatabaseAccess::databaseWatch(), SIGNAL(albumChange(const AlbumChangeset &)),
1083
this, SLOT(slotAlbumChange(const AlbumChangeset &)));
1084
connect(DatabaseAccess::databaseWatch(), SIGNAL(tagChange(const TagChangeset &)),
1085
this, SLOT(slotTagChange(const TagChangeset &)));
1086
connect(DatabaseAccess::databaseWatch(), SIGNAL(searchChange(const SearchChangeset &)),
1087
this, SLOT(slotSearchChange(const SearchChangeset &)));
1143
connect(DatabaseAccess::databaseWatch(), SIGNAL(albumChange(const AlbumChangeset&)),
1144
this, SLOT(slotAlbumChange(const AlbumChangeset&)));
1145
connect(DatabaseAccess::databaseWatch(), SIGNAL(tagChange(const TagChangeset&)),
1146
this, SLOT(slotTagChange(const TagChangeset&)));
1147
connect(DatabaseAccess::databaseWatch(), SIGNAL(searchChange(const SearchChangeset&)),
1148
this, SLOT(slotSearchChange(const SearchChangeset&)));
1088
1149
// listen to collection image changes
1089
connect(DatabaseAccess::databaseWatch(), SIGNAL(collectionImageChange(const CollectionImageChangeset &)),
1090
this, SLOT(slotCollectionImageChange(const CollectionImageChangeset &)));
1091
connect(DatabaseAccess::databaseWatch(), SIGNAL(imageTagChange(const ImageTagChangeset &)),
1092
this, SLOT(slotImageTagChange(const ImageTagChangeset &)));
1150
connect(DatabaseAccess::databaseWatch(), SIGNAL(collectionImageChange(const CollectionImageChangeset&)),
1151
this, SLOT(slotCollectionImageChange(const CollectionImageChangeset&)));
1152
connect(DatabaseAccess::databaseWatch(), SIGNAL(imageTagChange(const ImageTagChangeset&)),
1153
this, SLOT(slotImageTagChange(const ImageTagChangeset&)));
1094
1155
emit signalAllAlbumsLoaded();