Skip to content

Commit

Permalink
https://github.com/StephaneCouturier/Katalog/issues/496
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneCouturier committed Apr 14, 2024
1 parent 981a1b6 commit 7314d14
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 68 deletions.
23 changes: 7 additions & 16 deletions src/collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,13 @@ void Collection::generateCollectionFiles()
if(databaseMode=="Memory"){
QFile deviceFile(deviceFilePath);
if (!deviceFile.exists()) {
// Create the necessary directories
//QFileInfo fileInfo(deviceFile);
//QString path = fileInfo.absolutePath();
//QDir dir;
//if (!dir.mkpath(path)) {
// qDebug() << "DEBUG Failed to create directories:";
//}
//}
//else {
//Create an empty CSV file
if (deviceFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
//File opened successfully, no need to write anything
deviceFile.close(); // Close the file after creating it
} else {
qDebug() << "DEBUG Failed to create file:" << deviceFile.errorString();
}
//Create an empty CSV file
if (deviceFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
//File opened successfully, no need to write anything
deviceFile.close(); // Close the file after creating it
} else {
qDebug() << "DEBUG Failed to create file:" << deviceFile.errorString();
}
}
}
}
Expand Down
103 changes: 51 additions & 52 deletions src/mainwindow_tab_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,55 +423,57 @@
//Load Tags
reloadTagsData();

//Verify Collection version and trigger migration to v2.0
QFile statitsticsFile(collection->statisticsDeviceFilePath);
if (statitsticsFile.exists()){
collection->version = "2.0";
}
else{
collection->version = "1.x";

QMessageBox msgBox;
QString message;
message += "<br/>";
message += "<b>" + tr("Collection Upgrade Required") + "</b>";
message += "<br/><br/>";
message += tr("Katalog has detected that the selected collection was created with an earlier version.");
message += "<br/>";
message += tr("<br/>Current collection folder: ") + QString::fromUtf8("<br/><b>%1</b>").arg(collection->folder);
message += "<br/>";
message += tr("<br/>Current collection version: ") + QString::fromUtf8("<br/><b>%1</b>").arg(collection->version);
message += "<br/><br/><br/>";
message += tr("To utilize this collection with Katalog 2.0, it needs to be upgraded.");
message += "<br/><br/>";
message += tr("The upgrade process can be performed automatically, but it is strongly advised to <b>back up the collection folder/files before proceeding</b>.");
message += "<br/><br/>";
message += tr("What would you like to do?");
message += "<br/><br/>";

msgBox.setWindowTitle("Katalog");
msgBox.setText(message);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.setButtonText(QMessageBox::Yes, "Upgrade Now");
msgBox.setButtonText(QMessageBox::No, "Choose a Different Folder");
msgBox.setButtonText(QMessageBox::Cancel, "Exit Application");

int result = msgBox.exec();

if (result == QMessageBox::Yes) {
// Trigger migration
migrateCollection();

} else if (result == QMessageBox::No) {
// Select other folder
on_Settings_pushButton_SelectFolder_clicked();
return;

} else if (result == QMessageBox::Cancel) {
// Quit app
qApp->deleteLater();
return;
//Verify Collection version and trigger migration
if(collection->databaseMode=="Memory"){
QFile statitsticsFile(collection->statisticsDeviceFilePath);
if (statitsticsFile.exists()){
collection->version = "2.0";
}
else{
collection->version = "1.x";

QMessageBox msgBox;
QString message;
message += "<br/>";
message += "<b>" + tr("Collection Upgrade Required") + "</b>";
message += "<br/><br/>";
message += tr("Katalog has detected that the selected collection was created with an earlier version.");
message += "<br/>";
message += tr("<br/>Current collection folder: ") + QString::fromUtf8("<br/><b>%1</b>").arg(collection->folder);
message += "<br/>";
message += tr("<br/>Current collection version: ") + QString::fromUtf8("<br/><b>%1</b>").arg(collection->version);
message += "<br/><br/><br/>";
message += tr("To utilize this collection with Katalog 2.0, it needs to be upgraded.");
message += "<br/><br/>";
message += tr("The upgrade process can be performed automatically, but it is strongly advised to <b>back up the collection folder/files before proceeding</b>.");
message += "<br/><br/>";
message += tr("What would you like to do?");
message += "<br/><br/>";

msgBox.setWindowTitle("Katalog");
msgBox.setText(message);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.setButtonText(QMessageBox::Yes, "Upgrade Now");
msgBox.setButtonText(QMessageBox::No, "Choose a Different Folder");
msgBox.setButtonText(QMessageBox::Cancel, "Exit Application");

int result = msgBox.exec();

if (result == QMessageBox::Yes) {
// Trigger migration
migrateCollection();

} else if (result == QMessageBox::No) {
// Select other folder
on_Settings_pushButton_SelectFolder_clicked();
return;

} else if (result == QMessageBox::Cancel) {
// Quit app
qApp->deleteLater();
return;
}
}
}
}
Expand Down Expand Up @@ -555,6 +557,3 @@
//Reset selected values (to avoid actions on the last selected ones)
resetSelection();
}



0 comments on commit 7314d14

Please sign in to comment.