Commit d9afaa00 authored by Francesco Riosa's avatar Francesco Riosa
Browse files

Split of settings/migration for images/thumbs DB

This is the first step in really managing the Image metadata database
and the Thumbnail cache database as different entities.

Only changes in the gui are included and as is the code is not
functional, still need to be done:

1) change the structure of digikamrc and it's migration
2) define interaction between widgets in the new migration dialog
3) port and possibly unify "Settings -> database migration" with
"Settings -> configure digikam -> database settings"
4) add a "Backup" button

CCBUG: 277242
GUI: some new strings, work in progress
parent 9aa51f16
......@@ -1544,10 +1544,10 @@ QString AlbumSettings::getDatabaseName() const
return d->databaseParams.databaseName;
}
QString AlbumSettings::getDatabaseNameThumbnails() const
{
return d->databaseParams.databaseNameThumbnails;
}
//fr QString AlbumSettings::getDatabaseNameThumbnails() const
//fr {
//fr return d->databaseParams.databaseNameThumbnails;
//fr }
QString AlbumSettings::getDatabaseHostName() const
{
......@@ -1584,10 +1584,10 @@ void AlbumSettings::setDatabaseName(const QString& databaseName)
d->databaseParams.databaseName = databaseName;
}
void AlbumSettings::setDatabaseNameThumbnails(const QString& databaseNameThumbnails)
{
d->databaseParams.databaseNameThumbnails = databaseNameThumbnails;
}
//fr void AlbumSettings::setDatabaseNameThumbnails(const QString& databaseNameThumbnails)
//fr {
//fr d->databaseParams.databaseNameThumbnails = databaseNameThumbnails;
//fr }
void AlbumSettings::setDatabaseHostName(const QString& hostName)
{
......
......@@ -333,8 +333,8 @@ public:
QString getDatabaseName() const;
void setDatabaseName(const QString& databaseName);
QString getDatabaseNameThumbnails() const;
void setDatabaseNameThumbnails(const QString& databaseNameThumbnails);
//fr QString getDatabaseNameThumbnails() const;
//fr void setDatabaseNameThumbnails(const QString& databaseNameThumbnails);
QString getDatabaseHostName() const;
void setDatabaseHostName(const QString& hostName);
......
......@@ -49,7 +49,7 @@ static const char* configGroupDatabase = "Database Settings";
static const char* configInternalDatabaseServer = "Internal Database Server";
static const char* configDatabaseType = "Database Type";
static const char* configDatabaseName = "Database Name";
static const char* configDatabaseNameThumbnails = "Database Name Thumbnails";
//fr static const char* configDatabaseNameThumbnails = "Database Name Thumbnails";
static const char* configDatabaseHostName = "Database Hostname";
static const char* configDatabasePort = "Database Port";
static const char* configDatabaseUsername = "Database Username";
......@@ -206,7 +206,7 @@ void DatabaseParameters::readFromConfig(KSharedConfig::Ptr config, const QString
databaseType = group.readEntry(configDatabaseType, QString());
databaseName = group.readEntry(configDatabaseName, QString());
databaseNameThumbnails = group.readEntry(configDatabaseNameThumbnails, QString());
//fr databaseNameThumbnails = group.readEntry(configDatabaseNameThumbnails, QString());
hostName = group.readEntry(configDatabaseHostName, QString());
port = group.readEntry(configDatabasePort, -1);
userName = group.readEntry(configDatabaseUsername, QString());
......@@ -357,7 +357,7 @@ void DatabaseParameters::writeToConfig(KSharedConfig::Ptr config, const QString&
group.writeEntry(configDatabaseType, databaseType);
group.writeEntry(configDatabaseName, dbName);
group.writeEntry(configDatabaseNameThumbnails, dbNameThumbs);
//fr group.writeEntry(configDatabaseNameThumbnails, dbNameThumbs);
group.writeEntry(configDatabaseHostName, hostName);
group.writeEntry(configDatabasePort, port);
group.writeEntry(configDatabaseUsername, userName);
......
......@@ -44,6 +44,7 @@
// Local includes
#include "config-digikam.h"
#include "albumsettings.h"
#include "databaseaccess.h"
#include "databasewidget.h"
......@@ -95,24 +96,51 @@ class MigrationDlg::MigrationDlgPriv
public:
MigrationDlgPriv() :
fromDatabaseWidget(0),
toDatabaseWidget(0),
migrateButton(0),
cancelButton(0),
// Img database
fromImgDatabaseWidget(0),
toImgDatabaseWidget(0),
migrateImgButton(0),
cancelImgButton(0),
#ifdef USE_THUMBS_DB
// Thumb database
fromThumbDatabaseWidget(0),
toThumbDatabaseWidget(0),
migrateThumbButton(0),
cancelThumbButton(0),
#endif
// Global
overallStepTitle(0),
progressBar(0),
progressBarSmallStep(0),
sameDatabase(0),
internalFromServer(0),
#ifdef HAVE_INTERNALMYSQL
internalToServer(0),
#endif
copyThread(0)
{
}
DatabaseWidget* fromDatabaseWidget;
DatabaseWidget* toDatabaseWidget;
QPushButton* migrateButton;
QPushButton* cancelButton;
// Img database
DatabaseWidget* fromImgDatabaseWidget;
DatabaseWidget* toImgDatabaseWidget;
QPushButton* migrateImgButton;
QPushButton* cancelImgButton;
#ifdef USE_THUMBS_DB
// Thumb database
DatabaseWidget* fromThumbDatabaseWidget;
DatabaseWidget* toThumbDatabaseWidget;
QPushButton* migrateThumbButton;
QPushButton* cancelThumbButton;
#endif
// Global
QLabel* overallStepTitle;
QProgressBar* progressBar;
QProgressBar* progressBarSmallStep;
QCheckBox* sameDatabase;
QCheckBox* internalFromServer;
#ifdef HAVE_INTERNALMYSQL
QCheckBox* internalToServer;
#endif
DatabaseCopyThread* copyThread;
};
......@@ -131,11 +159,23 @@ MigrationDlg::~MigrationDlg()
void MigrationDlg::setupMainArea()
{
d->copyThread = new DatabaseCopyThread(this);
d->fromDatabaseWidget = new DatabaseWidget(this);
d->toDatabaseWidget = new DatabaseWidget(this);
d->migrateButton = new QPushButton(i18n("Migrate ->"), this);
d->cancelButton = new QPushButton(i18n("Cancel"), this);
d->cancelButton->setEnabled(false);
d->fromImgDatabaseWidget = new DatabaseWidget(this, i18n("current images DB"));
d->toImgDatabaseWidget = new DatabaseWidget(this, i18n("dest. images DB"));
d->migrateImgButton = new QPushButton(i18n("Migrate ->"), this);
d->cancelImgButton = new QPushButton(i18n("Cancel"), this);
d->cancelImgButton->setEnabled(false);
#ifdef USE_THUMBS_DB
d->fromThumbDatabaseWidget = new DatabaseWidget(this, i18n("current thumbnail DB"));
d->toThumbDatabaseWidget = new DatabaseWidget(this, i18n("dest. thumbnail DB"));
d->migrateThumbButton = new QPushButton(i18n("Migrate ->"), this);
d->cancelThumbButton = new QPushButton(i18n("Cancel"), this);
d->cancelThumbButton->setEnabled(false);
#endif
d->sameDatabase = new QCheckBox(i18n("Same database"), this);
d->internalFromServer = new QCheckBox(i18n("Internal server"), this);
#ifdef HAVE_INTERNALMYSQL
d->internalToServer = new QCheckBox(i18n("Internal server"), this);
#endif
QGroupBox* progressBox = new QGroupBox(i18n("Progress Information"), this);
QVBoxLayout* vlay = new QVBoxLayout(progressBox);
......@@ -157,13 +197,26 @@ void MigrationDlg::setupMainArea()
QGridLayout* layout = new QGridLayout;
mainWidget->setLayout(layout);
layout->addWidget(d->fromDatabaseWidget, 0, 0, 4, 1);
layout->addWidget(d->migrateButton, 1, 1);
layout->addWidget(d->cancelButton, 2, 1);
layout->addWidget(d->toDatabaseWidget, 0, 2, 4, 1);
layout->addWidget(progressBox, 4, 0, 1, 3);
// layout->addWidget(d->progressBar, 4, 0, 1, 3);
// layout->addWidget(d->progressBarSmallStep, 5, 0, 1, 3);
layout->addWidget(d->internalFromServer, 0, 0);
#ifdef HAVE_INTERNALMYSQL
layout->addWidget(d->internalToServer, 0, 2);
#endif
layout->addWidget(d->fromImgDatabaseWidget, 1, 0, 3, 1);
layout->addWidget(d->migrateImgButton, 2, 1);
layout->addWidget(d->cancelImgButton, 3, 1);
layout->addWidget(d->toImgDatabaseWidget, 1, 2, 3, 1);
layout->addWidget(d->sameDatabase, 5, 2);
#ifdef USE_THUMBS_DB
layout->addWidget(d->fromThumbDatabaseWidget, 6, 0, 3, 1);
layout->addWidget(d->migrateThumbButton, 7, 1);
layout->addWidget(d->cancelThumbButton, 8, 1);
layout->addWidget(d->toThumbDatabaseWidget, 6, 2, 3, 1);
#endif
layout->addWidget(progressBox, 10, 0, 1, 3);
setMainWidget(mainWidget);
dataInit();
......@@ -171,8 +224,19 @@ void MigrationDlg::setupMainArea()
// setup dialog
setButtons(Close);
connect(d->migrateButton, SIGNAL(clicked()),
this, SLOT(performCopy()));
connect(d->migrateImgButton, SIGNAL(clicked()),
this, SLOT(performImgCopy()));
connect(d->cancelImgButton, SIGNAL(clicked()),
&(d->copyThread->copyManager), SLOT(stopProcessing()));
#ifdef USE_THUMBS_DB
connect(d->migrateThumbButton, SIGNAL(clicked()),
this, SLOT(performThumbCopy()));
connect(d->cancelThumbButton, SIGNAL(clicked()),
&(d->copyThread->copyManager), SLOT(stopProcessing()));
#endif
// connect signal handlers for copy d->copyThread
connect(&(d->copyThread->copyManager), SIGNAL(finished(int, QString)),
......@@ -187,43 +251,82 @@ void MigrationDlg::setupMainArea()
connect(this, SIGNAL(closeClicked()),
&(d->copyThread->copyManager), SLOT(stopProcessing()));
connect(d->cancelButton, SIGNAL(clicked()),
&(d->copyThread->copyManager), SLOT(stopProcessing()));
}
void MigrationDlg::performCopy()
void MigrationDlg::performImgCopy()
{
KMessageBox::information(this, i18n("TODO: performImgCopy") );
return;
DatabaseParameters toDBParameters = d->toImgDatabaseWidget->getDatabaseParameters();
DatabaseParameters fromDBParameters = d->fromImgDatabaseWidget->getDatabaseParameters();
d->copyThread->init(fromDBParameters, toDBParameters);
lockInputFields();
d->copyThread->start();
}
#ifdef USE_THUMBS_DB
void MigrationDlg::performThumbCopy()
{
DatabaseParameters toDBParameters = d->toDatabaseWidget->getDatabaseParameters();
DatabaseParameters fromDBParameters = d->fromDatabaseWidget->getDatabaseParameters();
KMessageBox::information(this, i18n("TODO: performThumbCopy") );
return;
DatabaseParameters toDBParameters = d->toThumbDatabaseWidget->getDatabaseParameters();
DatabaseParameters fromDBParameters = d->fromThumbDatabaseWidget->getDatabaseParameters();
d->copyThread->init(fromDBParameters, toDBParameters);
lockInputFields();
d->copyThread->start();
}
#endif
void MigrationDlg::dataInit()
{
d->fromDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
d->toDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
d->fromImgDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
d->toImgDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
#ifdef USE_THUMBS_DB
//fr TODO: change database name
d->fromThumbDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
d->toThumbDatabaseWidget->setParametersFromSettings(AlbumSettings::instance());
#endif
}
void MigrationDlg::unlockInputFields()
{
d->fromDatabaseWidget->setEnabled(true);
d->toDatabaseWidget->setEnabled(true);
d->migrateButton->setEnabled(true);
d->fromImgDatabaseWidget->setEnabled(true);
d->toImgDatabaseWidget->setEnabled(true);
d->migrateImgButton->setEnabled(true);
#ifdef USE_THUMBS_DB
d->fromThumbDatabaseWidget->setEnabled(true);
d->toThumbDatabaseWidget->setEnabled(true);
d->migrateThumbButton->setEnabled(true);
#endif
d->progressBar->setValue(0);
d->progressBarSmallStep->setValue(0);
d->cancelButton->setEnabled(false);
d->cancelImgButton->setEnabled(false);
#ifdef USE_THUMBS_DB
d->cancelThumbButton->setEnabled(false);
#endif
}
void MigrationDlg::lockInputFields()
{
d->fromDatabaseWidget->setEnabled(false);
d->toDatabaseWidget->setEnabled(false);
d->migrateButton->setEnabled(false);
d->cancelButton->setEnabled(true);
d->fromImgDatabaseWidget->setEnabled(false);
d->toImgDatabaseWidget->setEnabled(false);
d->migrateImgButton->setEnabled(false);
#ifdef USE_THUMBS_DB
d->fromThumbDatabaseWidget->setEnabled(false);
d->toThumbDatabaseWidget->setEnabled(false);
d->migrateThumbButton->setEnabled(false);
#endif
d->cancelImgButton->setEnabled(true);
#ifdef USE_THUMBS_DB
d->cancelThumbButton->setEnabled(true);
#endif
}
void MigrationDlg::handleFinish(int finishState, QString errorMsg)
......
......@@ -77,7 +77,10 @@ public:
private Q_SLOTS:
void performCopy();
void performImgCopy();
#ifdef USE_THUMBS_DB
void performThumbCopy();
#endif
void unlockInputFields();
void lockInputFields();
......
......@@ -67,10 +67,10 @@ public:
QGroupBox* expertSettings;
};
DatabaseWidget::DatabaseWidget(QWidget* parent)
DatabaseWidget::DatabaseWidget(QWidget* parent, const QString & title)
: QWidget(parent), d(new DatabaseWidgetPriv)
{
setupMainArea();
setupMainArea(title);
}
DatabaseWidget::~DatabaseWidget()
......@@ -78,7 +78,7 @@ DatabaseWidget::~DatabaseWidget()
delete d;
}
void DatabaseWidget::setupMainArea()
void DatabaseWidget::setupMainArea(const QString & title)
{
setAutoFillBackground(false);
......@@ -87,7 +87,7 @@ void DatabaseWidget::setupMainArea()
// --------------------------------------------------------
QGroupBox* dbPathBox = new QGroupBox(i18n("Database File Path"), this);
QGroupBox* dbPathBox = new QGroupBox(title, this);
QVBoxLayout* vlay = new QVBoxLayout(dbPathBox);
d->databasePathLabel = new QLabel(i18n("<p>The location where the database file will be stored on your system. "
"There is one common database file for all root albums.<br/>"
......@@ -102,12 +102,12 @@ void DatabaseWidget::setupMainArea()
QLabel* databaseTypeLabel = new QLabel(i18n("Type"));
databaseType = new QComboBox();
QLabel* internalServerLabel = new QLabel(i18n("Internal Server"));
internalServer = new QCheckBox();
//fr QLabel* internalServerLabel = new QLabel(i18n("Internal Server"));
//fr internalServer = new QCheckBox();
QLabel* databaseNameLabel = new QLabel(i18n("Schema Name"));
databaseName = new QLineEdit();
QLabel* databaseNameThumbnailsLabel = new QLabel(i18n("Thumbnails<br>Schema Name"));
databaseNameThumbnails = new QLineEdit();
//fr QLabel* databaseNameThumbnailsLabel = new QLabel(i18n("Thumbnails<br>Schema Name"));
//fr databaseNameThumbnails = new QLineEdit();
QLabel* hostNameLabel = new QLabel(i18n("Host Name"));
hostName = new QLineEdit();
QLabel* hostPortLabel = new QLabel(i18n("Port"));
......@@ -131,13 +131,13 @@ void DatabaseWidget::setupMainArea()
QFormLayout* expertSettinglayout = new QFormLayout();
d->expertSettings->setLayout(expertSettinglayout);
#ifdef HAVE_INTERNALMYSQL
expertSettinglayout->addRow(internalServerLabel, internalServer);
#endif // HAVE_INTERNALMYSQL
//fr #ifdef HAVE_INTERNALMYSQL
//fr expertSettinglayout->addRow(internalServerLabel, internalServer);
//fr #endif // HAVE_INTERNALMYSQL
expertSettinglayout->addRow(hostNameLabel, hostName);
expertSettinglayout->addRow(hostPortLabel, hostPort);
expertSettinglayout->addRow(databaseNameLabel, databaseName);
expertSettinglayout->addRow(databaseNameThumbnailsLabel, databaseNameThumbnails);
//fr expertSettinglayout->addRow(databaseNameThumbnailsLabel, databaseNameThumbnails);
expertSettinglayout->addRow(userNameLabel, userName);
expertSettinglayout->addRow(passwordLabel, password);
expertSettinglayout->addRow(connectionOptionsLabel, connectionOptions);
......@@ -180,10 +180,10 @@ void DatabaseWidget::setupMainArea()
connect(databaseType, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotHandleDBTypeIndexChanged(int)));
#ifdef HAVE_INTERNALMYSQL
connect(internalServer, SIGNAL(stateChanged(int)),
this, SLOT(slotHandleInternalServerCheckbox(int)));
#endif // HAVE_INTERNALMYSQL
//fr #ifdef HAVE_INTERNALMYSQL
//fr connect(internalServer, SIGNAL(stateChanged(int)),
//fr this, SLOT(slotHandleInternalServerCheckbox(int)));
//fr #endif // HAVE_INTERNALMYSQL
connect(checkDatabaseConnectionButton, SIGNAL(clicked()),
this, SLOT(checkDatabaseConnection()));
......@@ -254,16 +254,16 @@ void DatabaseWidget::setDatabaseInputFields(const QString& currentIndexStr)
adjustSize();
}
void DatabaseWidget::slotHandleInternalServerCheckbox(int enableFields)
{
hostName->setEnabled(enableFields == Qt::Unchecked);
hostPort->setEnabled(enableFields == Qt::Unchecked);
databaseName->setEnabled(enableFields == Qt::Unchecked);
databaseNameThumbnails->setEnabled(enableFields == Qt::Unchecked);
userName->setEnabled(enableFields == Qt::Unchecked);
password->setEnabled(enableFields == Qt::Unchecked);
connectionOptions->setEnabled(enableFields == Qt::Unchecked);
}
//fr void DatabaseWidget::slotHandleInternalServerCheckbox(int enableFields)
//fr {
//fr hostName->setEnabled(enableFields == Qt::Unchecked);
//fr hostPort->setEnabled(enableFields == Qt::Unchecked);
//fr databaseName->setEnabled(enableFields == Qt::Unchecked);
//fr //fr databaseNameThumbnails->setEnabled(enableFields == Qt::Unchecked);
//fr userName->setEnabled(enableFields == Qt::Unchecked);
//fr password->setEnabled(enableFields == Qt::Unchecked);
//fr connectionOptions->setEnabled(enableFields == Qt::Unchecked);
//fr }
void DatabaseWidget::checkDatabaseConnection()
{
......@@ -322,13 +322,13 @@ void DatabaseWidget::setParametersFromSettings(const AlbumSettings* settings)
originalDbType = settings->getDatabaseType();
databasePathEdit->setUrl(settings->getDatabaseFilePath());
#ifdef HAVE_INTERNALMYSQL
internalServer->setChecked(settings->getInternalDatabaseServer());
#else
internalServer->setChecked(false);
#endif // HAVE_INTERNALMYSQL
//fr #ifdef HAVE_INTERNALMYSQL
//fr internalServer->setChecked(settings->getInternalDatabaseServer());
//fr #else
//fr internalServer->setChecked(false);
//fr #endif // HAVE_INTERNALMYSQL
databaseName->setText(settings->getDatabaseName());
databaseNameThumbnails->setText(settings->getDatabaseNameThumbnails());
//fr databaseNameThumbnails->setText(settings->getDatabaseNameThumbnails());
hostName->setText(settings->getDatabaseHostName());
hostPort->setValue(settings->getDatabasePort());
connectionOptions->setText(settings->getDatabaseConnectoptions());
......@@ -355,7 +355,8 @@ DatabaseParameters DatabaseWidget::getDatabaseParameters()
{
DatabaseParameters parameters;
if (currentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()) || !internalServer->isChecked())
//fr if (currentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()) || !internalServer->isChecked())
if (currentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()))
{
parameters.connectOptions = connectionOptions->text();
parameters.databaseType = currentDatabaseType();
......@@ -367,12 +368,14 @@ DatabaseParameters DatabaseWidget::getDatabaseParameters()
if (parameters.databaseType == QString(DatabaseParameters::SQLiteDatabaseType()))
{
parameters.databaseName = QDir::cleanPath(databasePathEdit->url().toLocalFile() + '/' + "digikam4.db");
parameters.databaseNameThumbnails = parameters.databaseName;
//fr parameters.databaseNameThumbnails = parameters.databaseName;
parameters.databaseNameThumbnails = parameters.databaseName; //fr
}
else
{
parameters.databaseName = databaseName->text();
parameters.databaseNameThumbnails = databaseNameThumbnails->text();
//fr parameters.databaseNameThumbnails = databaseNameThumbnails->text();
parameters.databaseNameThumbnails = parameters.databaseName; //fr
}
}
else
......
......@@ -53,7 +53,7 @@ class DatabaseWidget : public QWidget
public:
DatabaseWidget(QWidget* parent = 0);
DatabaseWidget(QWidget* parent = 0, const QString & title = QString(""));
~DatabaseWidget();
public:
......@@ -65,7 +65,7 @@ public:
QSpinBox* hostPort;
QLineEdit* databaseName;
QLineEdit* databaseNameThumbnails;
//fr QLineEdit* databaseNameThumbnails;
QLineEdit* hostName;
QLineEdit* connectionOptions;
QLineEdit* userName;
......@@ -86,13 +86,13 @@ public Q_SLOTS:
void slotChangeDatabasePath(const KUrl&);
void slotDatabasePathEdited(const QString&);
void slotHandleDBTypeIndexChanged(int index);
void slotHandleInternalServerCheckbox(int enableFields);
//fr void slotHandleInternalServerCheckbox(int enableFields);
void checkDatabaseConnection();
private:
void checkDBPath();
void setupMainArea();
void setupMainArea(const QString & title);
private:
......
......@@ -177,7 +177,7 @@ void SetupDatabase::applySettings()
settings->setInternalDatabaseServer(true);
settings->setDatabaseType(d->databaseWidget->currentDatabaseType());
settings->setDatabaseName(internalServerParameters.databaseName);
settings->setDatabaseNameThumbnails(internalServerParameters.databaseName);
//fr settings->setDatabaseNameThumbnails(internalServerParameters.databaseName);
settings->setDatabaseConnectoptions(internalServerParameters.connectOptions);
settings->setDatabaseHostName(internalServerParameters.hostName);
settings->setDatabasePort(internalServerParameters.port);
......@@ -189,7 +189,7 @@ void SetupDatabase::applySettings()
settings->setInternalDatabaseServer(d->databaseWidget->internalServer->isChecked());
settings->setDatabaseType(d->databaseWidget->currentDatabaseType());
settings->setDatabaseName(d->databaseWidget->databaseName->text());
settings->setDatabaseNameThumbnails(d->databaseWidget->databaseNameThumbnails->text());
//fr settings->setDatabaseNameThumbnails(d->databaseWidget->databaseNameThumbnails->text());
settings->setDatabaseConnectoptions(d->databaseWidget->connectionOptions->text());
settings->setDatabaseHostName(d->databaseWidget->hostName->text());
settings->setDatabasePort(d->databaseWidget->hostPort->text().toInt());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment