[kde-doc-english] [digikam] /: Split "images" and "thumbnails" databases.

Francesco Riosa francesco+kde at pnpitalia.it
Mon Sep 5 22:39:17 UTC 2011


Git commit 37f5f5d59f174bcedc86438365f9a7270a1bd677 by Francesco Riosa.
Committed on 06/09/2011 at 00:29.
Pushed by riosa into branch 'master'.

Split "images" and "thumbnails" databases.

This commit splits the configure options of the images and thumbnail
databases, will then be possible use different database servers.
Also the migration dialog is now more flexible.

GUI: migrationdlg.cpp databasewidget.cpp
CCBUG: 277242

M  +1    -1    databaseserver/databaseserver.cpp
M  +35   -22   digikam/album/albummanager.cpp
M  +6    -1    digikam/album/albummanager.h
M  +7    -7    digikam/database/databaseguierrorhandler.cpp
M  +1    -1    digikam/database/dbstatdlg.cpp
M  +18   -3    digikam/main/digikamapp.cpp
M  +110  -39   digikam/utils/albumsettings.cpp
M  +39   -18   digikam/utils/albumsettings.h
M  +1    -1    digikam/utils/componentsinfo.h
M  +3    -0    digikam/utils/config-digikam.h.cmake
M  +14   -14   libs/database/databasecorebackend.cpp
M  +1    -1    libs/database/databaseoperationgroup.cpp
M  +422  -200  libs/database/databaseparameters.cpp
M  +44   -30   libs/database/databaseparameters.h
M  +5    -5    libs/database/schemaupdater.cpp
M  +1    -1    libs/database/thumbnailschemaupdater.cpp
M  +2    -0    libs/dialogs/migrationdlg.cpp
M  +1    -0    libs/dialogs/migrationdlg.h
M  +363  -152  libs/widgets/common/databasewidget.cpp
M  +40   -19   libs/widgets/common/databasewidget.h
M  +2    -2    utilities/nepomuk/digikamnepomukservice.cpp
M  +65   -34   utilities/setup/setupdatabase.cpp

http://commits.kde.org/digikam/37f5f5d59f174bcedc86438365f9a7270a1bd677

diff --git a/databaseserver/databaseserver.cpp b/databaseserver/databaseserver.cpp
index d5f456d..d9b31bd 100644
--- a/databaseserver/databaseserver.cpp
+++ b/databaseserver/databaseserver.cpp
@@ -146,7 +146,7 @@ DatabaseServerError DatabaseServer::startMYSQLDatabaseProcess()
 {
     DatabaseServerError result;
     const QString dbType(DatabaseParameters::MySQLDatabaseType());
-    DatabaseParameters internalServerParameters = DatabaseParameters::defaultParameters(dbType);
+    DatabaseParameters internalServerParameters = DatabaseParameters::defaultParameters(dbType, true);
 
     //TODO Don't know if this is needed, because after the thread is finished, the database server manager should close
     d->pollThread->stop = false;
diff --git a/digikam/album/albummanager.cpp b/digikam/album/albummanager.cpp
index 39c74b6..e3bd305 100644
--- a/digikam/album/albummanager.cpp
+++ b/digikam/album/albummanager.cpp
@@ -77,6 +77,7 @@ extern "C"
 
 // Local includes
 
+#include "config-digikam.h"
 #include "albumdb.h"
 #include "album.h"
 #include "albumsettings.h"
@@ -239,7 +240,7 @@ public:
         // build list
         foreach (const QFileInfo& info, fileInfoList)
         {
-            // ignore digikam4.db and journal and other temporary files
+            // ignore DIGIKAM4DB and journal and other temporary files
             if (!dirWatchBlackList.contains(info.fileName()))
             {
                 modList << info.lastModified();
@@ -405,16 +406,28 @@ void AlbumManager::cleanUp()
     }
 }
 
-bool AlbumManager::databaseEqual(const QString& dbType, const QString& dbName,
+bool AlbumManager::imgDatabaseEqual(const QString& dbType, const QString& dbName,
                                  const QString& dbHostName, int dbPort, bool dbInternalServer) const
 {
     DatabaseParameters params = DatabaseAccess::parameters();
 
-    return params.databaseType   == dbType          &&
-           params.databaseName   == dbName          &&
-           params.hostName       == dbHostName      &&
-           params.port           == dbPort          &&
+    return params.imgDatabaseType   == dbType          &&
+           params.imgDatabaseName   == dbName          &&
+           params.imgHostName       == dbHostName      &&
+           params.imgPort           == dbPort          &&
            params.internalServer == dbInternalServer;
+	   //FIXME: dbInternalServer
+}
+
+bool AlbumManager::tmbDatabaseEqual(const QString& dbType, const QString& dbName,
+                                 const QString& dbHostName, int dbPort) const
+{
+    DatabaseParameters params = DatabaseAccess::parameters();
+
+    return params.tmbDatabaseType   == dbType          &&
+           params.tmbDatabaseName   == dbName          &&
+           params.tmbHostName       == dbHostName      &&
+           params.tmbPort           == dbPort;
 }
 
 static bool moveToBackup(const QFileInfo& info)
@@ -465,7 +478,7 @@ void AlbumManager::checkDatabaseDirsAfterFirstRun(const QString& dbPath, const Q
     QDir               newDir(dbPath);
     QDir               albumDir(albumPath);
     DatabaseParameters newParams = DatabaseParameters::parametersForSQLiteDefaultFile(newDir.path());
-    QFileInfo          digikam4DB(newParams.SQLiteDatabaseFile());
+    QFileInfo          digikam4DB(newParams.imgSQLiteDatabaseFile());
 
     if (!digikam4DB.exists())
     {
@@ -510,10 +523,10 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
     DatabaseParameters params = DatabaseAccess::parameters();
 
     // New database type SQLITE
-    if (newParams.isSQLite())
+    if (newParams.isImgSQLite())
     {
-        QDir newDir(newParams.getDatabaseNameOrDir());
-        QFileInfo newFile(newDir, QString("digikam4.db"));
+        QDir newDir(newParams.getImgDatabaseNameOrDir());
+        QFileInfo newFile(newDir, QString(DIGIKAM4DB));
 
         if (!newFile.exists())
         {
@@ -527,7 +540,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
                 KGuiItem upgrade(i18n("Upgrade Database"), "view-refresh");
                 int result = -1;
 
-                if (params.isSQLite())
+                if (params.isImgSQLite())
                 {
                     result = KMessageBox::warningYesNoCancel(0,
                                                              i18n("<p>You have chosen the folder \"%1\" as the new place to store the database. "
@@ -566,7 +579,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
                 else if (result == KMessageBox::Cancel)
                 {
                     QDir oldDir(d->dbName);
-                    QFileInfo oldFile(params.SQLiteDatabaseFile());
+                    QFileInfo oldFile(params.imgSQLiteDatabaseFile());
                     copyToNewLocation(oldFile, newFile, i18n("Failed to copy the old database file (\"%1\") "
                                                              "to its new location (\"%2\"). "
                                                              "Trying to upgrade old databases.",
@@ -577,7 +590,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
             {
                 int result = KMessageBox::Yes;
 
-                if (params.isSQLite())
+                if (params.isImgSQLite())
                 {
                     KGuiItem copyCurrent(i18n("Copy Current Database"), "edit-copy");
                     KGuiItem startFresh(i18n("Create New Database"), "document-new");
@@ -593,7 +606,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
                 if (result == KMessageBox::No)
                 {
                     QDir oldDir(d->dbName);
-                    QFileInfo oldFile(params.SQLiteDatabaseFile());
+                    QFileInfo oldFile(params.imgSQLiteDatabaseFile());
                     copyToNewLocation(oldFile, newFile);
                 }
             }
@@ -602,7 +615,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
         {
             int result = KMessageBox::No;
 
-            if (params.isSQLite())
+            if (params.isImgSQLite())
             {
                 KGuiItem replaceItem(i18n("Copy Current Database"), "edit-copy");
                 KGuiItem useExistingItem(i18n("Use Existing File"), "document-open");
@@ -622,7 +635,7 @@ void AlbumManager::changeDatabase(const DatabaseParameters& newParams)
                 if (moveToBackup(newFile))
                 {
                     QDir oldDir(d->dbName);
-                    QFileInfo oldFile(params.SQLiteDatabaseFile());
+                    QFileInfo oldFile(params.imgSQLiteDatabaseFile());
 
                     // then copy
                     copyToNewLocation(oldFile, newFile);
@@ -986,9 +999,9 @@ bool AlbumManager::setDatabase(const DatabaseParameters& params, bool priority,
 #ifdef USE_THUMBS_DB
     QApplication::setOverrideCursor(Qt::WaitCursor);
 
-    if (params.isSQLite())
+    if (params.isTmbSQLite())
     {
-        d->dirWatchBlackList << "thumbnails-digikam.db" << "thumbnails-digikam.db-journal";
+        d->dirWatchBlackList << THUMBNAILS_DIGIKAMDB << "thumbnails-digikam.db-journal";
     }
 
     ThumbnailLoadThread::initializeThumbnailDatabase(DatabaseAccess::parameters().thumbnailParameters(),
@@ -1003,9 +1016,9 @@ bool AlbumManager::setDatabase(const DatabaseParameters& params, bool priority,
     // -- ---------------------------------------------------------
 
     // measures to filter out KDirWatch signals caused by database operations
-    if (params.isSQLite())
+    if (params.isImgSQLite())
     {
-        QFileInfo dbFile(params.SQLiteDatabaseFile());
+        QFileInfo dbFile(params.imgSQLiteDatabaseFile());
         d->dirWatchBlackList << dbFile.fileName() << dbFile.fileName() + "-journal";
 
         // ensure this is done after setting up the black list
@@ -3401,7 +3414,7 @@ void AlbumManager::slotDirWatchDirty(const QString& path)
 
     DatabaseParameters params = DatabaseAccess::parameters();
 
-    if (params.isSQLite())
+    if (params.isImgSQLite())
     {
         QFileInfo info(path);
         QDir dir;
@@ -3415,7 +3428,7 @@ void AlbumManager::slotDirWatchDirty(const QString& path)
             dir = info.dir();
         }
 
-        QFileInfo dbFile(params.SQLiteDatabaseFile());
+        QFileInfo dbFile(params.imgSQLiteDatabaseFile());
 
         // Workaround for broken KDirWatch in KDE 4.2.4
         if (path.startsWith(dbFile.filePath()))
diff --git a/digikam/album/albummanager.h b/digikam/album/albummanager.h
index d8a577d..6ed5326 100644
--- a/digikam/album/albummanager.h
+++ b/digikam/album/albummanager.h
@@ -125,7 +125,12 @@ public:
     /**
     * Checks if the given database path is equal to the current one
     */
-    bool databaseEqual(const QString& dbType, const QString& dbName, const QString& dbHostName, int dbPort, bool dbInternalServer) const;
+    bool imgDatabaseEqual(const QString& dbType, const QString& dbName, const QString& dbHostName, int dbPort, bool dbInternalServer) const;
+
+    /**
+    * Checks if the given database path is equal to the current one
+    */
+    bool tmbDatabaseEqual(const QString& dbType, const QString& dbName, const QString& dbHostName, int dbPort) const;
 
     /**
     * starts scanning the libraryPath and listing the albums. If the
diff --git a/digikam/database/databaseguierrorhandler.cpp b/digikam/database/databaseguierrorhandler.cpp
index 153d6dc..ea2da31 100644
--- a/digikam/database/databaseguierrorhandler.cpp
+++ b/digikam/database/databaseguierrorhandler.cpp
@@ -81,16 +81,16 @@ DatabaseConnectionChecker::~DatabaseConnectionChecker()
 void DatabaseConnectionChecker::run()
 {
     QString databaseID("ConnectionTest");
-    QSqlDatabase databaseHandler = QSqlDatabase::addDatabase(d->parameters.databaseType, databaseID);
-    databaseHandler.setHostName(d->parameters.hostName);
-    databaseHandler.setPort(d->parameters.port);
+    QSqlDatabase databaseHandler = QSqlDatabase::addDatabase(d->parameters.imgDatabaseType, databaseID);
+    databaseHandler.setHostName(d->parameters.imgHostName);
+    databaseHandler.setPort(d->parameters.imgPort);
 
-    databaseHandler.setDatabaseName(d->parameters.databaseName);
+    databaseHandler.setDatabaseName(d->parameters.imgDatabaseName);
 
-    databaseHandler.setUserName(d->parameters.userName);
-    databaseHandler.setPassword(d->parameters.password);
+    databaseHandler.setUserName(d->parameters.imgUserName);
+    databaseHandler.setPassword(d->parameters.imgPassword);
 
-    databaseHandler.setConnectOptions(d->parameters.connectOptions);
+    databaseHandler.setConnectOptions(d->parameters.imgConnectOptions);
 
     int iteration = 1;
 
diff --git a/digikam/database/dbstatdlg.cpp b/digikam/database/dbstatdlg.cpp
index 9231b0e..d210521 100644
--- a/digikam/database/dbstatdlg.cpp
+++ b/digikam/database/dbstatdlg.cpp
@@ -78,7 +78,7 @@ DBStatDlg::DBStatDlg(QWidget* parent)
     new QTreeWidgetItem(listView(), QStringList() << i18n("Tags") << QString::number(tags));
 
     // Database Backend information
-    QString dbBe = AlbumSettings::instance()->getDatabaseType();
+    QString dbBe = AlbumSettings::instance()->getImgDatabaseType();
     new QTreeWidgetItem(listView(), QStringList() << i18n("Database backend") << dbBe);
 
     if (dbBe != QString("QSQLITE"))
diff --git a/digikam/main/digikamapp.cpp b/digikam/main/digikamapp.cpp
index 0a6033d..47c696a 100644
--- a/digikam/main/digikamapp.cpp
+++ b/digikam/main/digikamapp.cpp
@@ -2493,13 +2493,28 @@ void DigikamApp::slotSetupChanged()
     //if(AlbumSettings::instance()->getAlbumLibraryPath() != AlbumManager::instance()->getLibraryPath())
     //  d->view->clearHistory();
 
-    if (!AlbumManager::instance()->databaseEqual(AlbumSettings::instance()->getDatabaseType(),
-                                                 AlbumSettings::instance()->getDatabaseName(), AlbumSettings::instance()->getDatabaseHostName(),
-                                                 AlbumSettings::instance()->getDatabasePort(), AlbumSettings::instance()->getInternalDatabaseServer()))
+    //FIXME: getInternalDatabaseServer
+    if (!AlbumManager::instance()->imgDatabaseEqual(AlbumSettings::instance()->getImgDatabaseType(),
+                                                 AlbumSettings::instance()->getImgDatabaseName(),
+						 AlbumSettings::instance()->getImgDatabaseHostName(),
+                                                 AlbumSettings::instance()->getImgDatabasePort(),
+						 AlbumSettings::instance()->getInternalDatabaseServer()))
     {
         AlbumManager::instance()->changeDatabase(AlbumSettings::instance()->getDatabaseParameters());
     }
 
+    if (!AlbumManager::instance()->tmbDatabaseEqual(AlbumSettings::instance()->getTmbDatabaseType(),
+                                                 AlbumSettings::instance()->getTmbDatabaseName(),
+						 AlbumSettings::instance()->getTmbDatabaseHostName(),
+                                                 AlbumSettings::instance()->getTmbDatabasePort()))
+    {
+        AlbumManager::instance()->changeDatabase(AlbumSettings::instance()->getDatabaseParameters());
+    }
+
+
+
+
+
     if (AlbumSettings::instance()->getShowFolderTreeViewItemsCount())
     {
         AlbumManager::instance()->prepareItemCounts();
diff --git a/digikam/utils/albumsettings.cpp b/digikam/utils/albumsettings.cpp
index 8fdc4c0..6d98192 100644
--- a/digikam/utils/albumsettings.cpp
+++ b/digikam/utils/albumsettings.cpp
@@ -754,15 +754,26 @@ void AlbumSettings::emitSetupChanged()
     emit setupChanged();
 }
 
-QString AlbumSettings::getDatabaseFilePath() const
+QString AlbumSettings::getImgDatabaseFilePath() const
 {
-    return d->databaseParams.getDatabaseNameOrDir();
+    return d->databaseParams.getImgDatabaseNameOrDir();
 }
 
-void AlbumSettings::setDatabaseFilePath(const QString& path)
+QString AlbumSettings::getTmbDatabaseFilePath() const
 {
-    d->databaseParams.setDatabasePath(path);
-    d->databaseParams.setThumbsDatabasePath(path);
+    return d->databaseParams.getImgDatabaseNameOrDir();
+}
+
+void AlbumSettings::setImgDatabaseFilePath(const QString& path)
+{
+    d->databaseParams.setImgDatabasePath(path);
+    d->databaseParams.setTmbDatabasePath(path);
+}
+
+void AlbumSettings::setTmbDatabaseFilePath(const QString& path)
+{
+    d->databaseParams.setImgDatabasePath(path);
+    d->databaseParams.setTmbDatabasePath(path);
 }
 
 void AlbumSettings::setShowSplashScreen(bool val)
@@ -1541,89 +1552,149 @@ void AlbumSettings::setDatabaseParameters(const DatabaseParameters& params)
     d->databaseParams = params;
 }
 
-QString AlbumSettings::getDatabaseType() const
+QString AlbumSettings::getImgDatabaseType() const
 {
-    return d->databaseParams.databaseType;
+    return d->databaseParams.imgDatabaseType;
 }
 
-void AlbumSettings::setDatabaseType(const QString& databaseType)
+void AlbumSettings::setImgDatabaseType(const QString& databaseType)
 {
-    d->databaseParams.databaseType = databaseType;
+    d->databaseParams.imgDatabaseType = databaseType;
 }
 
-QString AlbumSettings::getDatabaseConnectoptions() const
+QString AlbumSettings::getImgDatabaseConnectoptions() const
 {
-    return d->databaseParams.connectOptions;
+    return d->databaseParams.imgConnectOptions;
 }
 
-QString AlbumSettings::getDatabaseName() const
+QString AlbumSettings::getImgDatabaseName() const
 {
-    return d->databaseParams.databaseName;
+    return d->databaseParams.imgDatabaseName;
 }
 
-QString AlbumSettings::getDatabaseNameThumbnails() const
+QString AlbumSettings::getImgDatabaseHostName() const
 {
-    return d->databaseParams.databaseNameThumbnails;
+    return d->databaseParams.imgHostName;
 }
 
-QString AlbumSettings::getDatabaseHostName() const
+QString AlbumSettings::getImgDatabasePassword() const
 {
-    return d->databaseParams.hostName;
+    return d->databaseParams.imgPassword;
 }
 
-QString AlbumSettings::getDatabasePassword() const
+int AlbumSettings::getImgDatabasePort() const
 {
-    return d->databaseParams.password;
+    return d->databaseParams.imgPort;
 }
 
-int AlbumSettings::getDatabasePort() const
+QString AlbumSettings::getImgDatabaseUserName() const
 {
-    return d->databaseParams.port;
+    return d->databaseParams.imgUserName;
 }
 
-QString AlbumSettings::getDatabaseUserName() const
+void AlbumSettings::setImgDatabaseConnectoptions(const QString& connectoptions)
 {
-    return d->databaseParams.userName;
+    d->databaseParams.imgConnectOptions = connectoptions;
 }
 
-bool AlbumSettings::getInternalDatabaseServer() const
+void AlbumSettings::setImgDatabaseName(const QString& databaseName)
 {
-    return d->databaseParams.internalServer;
+    d->databaseParams.imgDatabaseName = databaseName;
+}
+
+void AlbumSettings::setImgDatabaseHostName(const QString& hostName)
+{
+    d->databaseParams.imgHostName = hostName;
+}
+
+void AlbumSettings::setImgDatabasePassword(const QString& password)
+{
+    d->databaseParams.imgPassword = password;
+}
+
+void AlbumSettings::setImgDatabasePort(int port)
+{
+    d->databaseParams.imgPort = port;
+}
+
+void AlbumSettings::setImgDatabaseUserName(const QString& userName)
+{
+    d->databaseParams.imgUserName = userName;
+}
+
+QString AlbumSettings::getTmbDatabaseType() const
+{
+    return d->databaseParams.tmbDatabaseType;
 }
 
-void AlbumSettings::setDatabaseConnectoptions(const QString& connectoptions)
+void AlbumSettings::setTmbDatabaseType(const QString& databaseType)
 {
-    d->databaseParams.connectOptions = connectoptions;
+    d->databaseParams.tmbDatabaseType = databaseType;
 }
 
-void AlbumSettings::setDatabaseName(const QString& databaseName)
+QString AlbumSettings::getTmbDatabaseConnectoptions() const
 {
-    d->databaseParams.databaseName = databaseName;
+    return d->databaseParams.tmbConnectOptions;
 }
 
-void AlbumSettings::setDatabaseNameThumbnails(const QString& databaseNameThumbnails)
+QString AlbumSettings::getTmbDatabaseName() const
 {
-    d->databaseParams.databaseNameThumbnails = databaseNameThumbnails;
+    return d->databaseParams.tmbDatabaseName;
 }
 
-void AlbumSettings::setDatabaseHostName(const QString& hostName)
+QString AlbumSettings::getTmbDatabaseHostName() const
 {
-    d->databaseParams.hostName = hostName;
+    return d->databaseParams.tmbHostName;
 }
 
-void AlbumSettings::setDatabasePassword(const QString& password)
+QString AlbumSettings::getTmbDatabasePassword() const
 {
-    d->databaseParams.password = password;
+    return d->databaseParams.tmbPassword;
 }
 
-void AlbumSettings::setDatabasePort(int port)
+int AlbumSettings::getTmbDatabasePort() const
 {
-    d->databaseParams.port = port;
+    return d->databaseParams.tmbPort;
 }
 
-void AlbumSettings::setDatabaseUserName(const QString& userName)
+QString AlbumSettings::getTmbDatabaseUserName() const
 {
-    d->databaseParams.userName = userName;
+    return d->databaseParams.tmbUserName;
+}
+
+void AlbumSettings::setTmbDatabaseConnectoptions(const QString& connectoptions)
+{
+    d->databaseParams.tmbConnectOptions = connectoptions;
+}
+
+void AlbumSettings::setTmbDatabaseName(const QString& databaseName)
+{
+    d->databaseParams.tmbDatabaseName = databaseName;
+}
+
+void AlbumSettings::setTmbDatabaseHostName(const QString& hostName)
+{
+    d->databaseParams.tmbHostName = hostName;
+}
+
+void AlbumSettings::setTmbDatabasePassword(const QString& password)
+{
+    d->databaseParams.tmbPassword = password;
+}
+
+void AlbumSettings::setTmbDatabasePort(int port)
+{
+    d->databaseParams.tmbPort = port;
+}
+
+void AlbumSettings::setTmbDatabaseUserName(const QString& userName)
+{
+    d->databaseParams.tmbUserName = userName;
+}
+
+bool AlbumSettings::getInternalDatabaseServer() const
+{
+    return d->databaseParams.internalServer;
 }
 
 void AlbumSettings::setInternalDatabaseServer(const bool useInternalDBServer)
diff --git a/digikam/utils/albumsettings.h b/digikam/utils/albumsettings.h
index 1b90359..c96cd94 100644
--- a/digikam/utils/albumsettings.h
+++ b/digikam/utils/albumsettings.h
@@ -103,8 +103,11 @@ public:
     bool showToolTipsIsValid()      const;
     bool showAlbumToolTipsIsValid() const;
 
-    void setDatabaseFilePath(const QString& path);
-    QString getDatabaseFilePath() const;
+    void setImgDatabaseFilePath(const QString& path);
+    QString getImgDatabaseFilePath() const;
+
+    void setTmbDatabaseFilePath(const QString& path);
+    QString getTmbDatabaseFilePath() const;
 
     void setShowSplashScreen(bool val);
     bool getShowSplashScreen() const;
@@ -327,29 +330,47 @@ public:
     DatabaseParameters getDatabaseParameters() const;
     void setDatabaseParameters(const DatabaseParameters& params);
 
-    QString getDatabaseType() const;
-    void setDatabaseType(const QString& databaseType);
+    QString getImgDatabaseType() const;
+    void setImgDatabaseType(const QString& databaseType);
+
+    QString getImgDatabaseConnectoptions() const;
+    void setImgDatabaseConnectoptions(const QString& connectoptions);
+
+    QString getImgDatabaseName() const;
+    void setImgDatabaseName(const QString& databaseName);
+
+    QString getImgDatabaseHostName() const;
+    void setImgDatabaseHostName(const QString& hostName);
+
+    QString getImgDatabasePassword() const;
+    void setImgDatabasePassword(const QString& password);
+
+    int getImgDatabasePort() const;
+    void setImgDatabasePort(int port);
+
+    QString getImgDatabaseUserName() const;
+    void setImgDatabaseUserName(const QString& userName);
 
-    QString getDatabaseConnectoptions() const;
-    void setDatabaseConnectoptions(const QString& connectoptions);
+    QString getTmbDatabaseType() const;
+    void setTmbDatabaseType(const QString& databaseType);
 
-    QString getDatabaseName() const;
-    void setDatabaseName(const QString& databaseName);
+    QString getTmbDatabaseConnectoptions() const;
+    void setTmbDatabaseConnectoptions(const QString& connectoptions);
 
-    QString getDatabaseNameThumbnails() const;
-    void setDatabaseNameThumbnails(const QString& databaseNameThumbnails);
+    QString getTmbDatabaseName() const;
+    void setTmbDatabaseName(const QString& databaseName);
 
-    QString getDatabaseHostName() const;
-    void setDatabaseHostName(const QString& hostName);
+    QString getTmbDatabaseHostName() const;
+    void setTmbDatabaseHostName(const QString& hostName);
 
-    QString getDatabasePassword() const;
-    void setDatabasePassword(const QString& password);
+    QString getTmbDatabasePassword() const;
+    void setTmbDatabasePassword(const QString& password);
 
-    int getDatabasePort() const;
-    void setDatabasePort(int port);
+    int getTmbDatabasePort() const;
+    void setTmbDatabasePort(int port);
 
-    QString getDatabaseUserName() const;
-    void setDatabaseUserName(const QString& userName);
+    QString getTmbDatabaseUserName() const;
+    void setTmbDatabaseUserName(const QString& userName);
 
     bool getInternalDatabaseServer() const;
     void setInternalDatabaseServer(const bool useInternalDBServer);
diff --git a/digikam/utils/componentsinfo.h b/digikam/utils/componentsinfo.h
index efc2b02..21e41cc 100644
--- a/digikam/utils/componentsinfo.h
+++ b/digikam/utils/componentsinfo.h
@@ -80,7 +80,7 @@ static inline void showDigikamComponentsInfo()
 
     // Database Backend information
 
-    QString dbBe = AlbumSettings::instance()->getDatabaseType();
+    QString dbBe = AlbumSettings::instance()->getImgDatabaseType();
     list.insert(i18n("Database backend"), dbBe);
 
     if (dbBe != QString("QSQLITE"))
diff --git a/digikam/utils/config-digikam.h.cmake b/digikam/utils/config-digikam.h.cmake
index 83c04e7..84dc74b 100644
--- a/digikam/utils/config-digikam.h.cmake
+++ b/digikam/utils/config-digikam.h.cmake
@@ -24,6 +24,9 @@
 #ifndef CONFIG_DIGIKAM_H
 #define CONFIG_DIGIKAM_H
 
+#define DIGIKAM4DB "digikam4.db"
+#define THUMBNAILS_DIGIKAMDB "thumbnails-digikam.db"
+
 /* Define to 1 if you have KDEPIM shared library installed */
 #cmakedefine HAVE_KDEPIMLIBS 1
 
diff --git a/libs/database/databasecorebackend.cpp b/libs/database/databasecorebackend.cpp
index 55927a6..e6b0663 100644
--- a/libs/database/databasecorebackend.cpp
+++ b/libs/database/databasecorebackend.cpp
@@ -188,11 +188,11 @@ bool DatabaseCoreBackendPrivate::open(QSqlDatabase& db)
 
     QThread* thread = QThread::currentThread();
 
-    db = QSqlDatabase::addDatabase(parameters.databaseType, connectionName(thread));
+    db = QSqlDatabase::addDatabase(parameters.imgDatabaseType, connectionName(thread));
 
-    QString connectOptions = parameters.connectOptions;
+    QString connectOptions = parameters.imgConnectOptions;
 
-    if (parameters.isSQLite())
+    if (parameters.isImgSQLite())
     {
         QStringList toAdd;
         // enable shared cache, especially useful with SQLite >= 3.5.0
@@ -208,12 +208,12 @@ bool DatabaseCoreBackendPrivate::open(QSqlDatabase& db)
         connectOptions += toAdd.join(";");
     }
 
-    db.setDatabaseName(parameters.databaseName);
+    db.setDatabaseName(parameters.imgDatabaseName);
     db.setConnectOptions(connectOptions);
-    db.setHostName(parameters.hostName);
-    db.setPort(parameters.port);
-    db.setUserName(parameters.userName);
-    db.setPassword(parameters.password);
+    db.setHostName(parameters.imgHostName);
+    db.setPort(parameters.imgPort);
+    db.setUserName(parameters.imgUserName);
+    db.setPassword(parameters.imgPassword);
 
     bool success = db.open();
 
@@ -274,18 +274,18 @@ bool DatabaseCoreBackendPrivate::isInUIThread() const
 
 bool DatabaseCoreBackendPrivate::reconnectOnError() const
 {
-    return parameters.isMySQL();
+    return parameters.isImgMySQL();
 }
 
 bool DatabaseCoreBackendPrivate::isSQLiteLockError(const SqlQuery& query) const
 {
-    return parameters.isSQLite()
+    return parameters.isImgSQLite()
            && (query.lastError().number() == 5 /*SQLITE_BUSY*/ || query.lastError().number() == 6/*SQLITE_LOCKED*/);
 }
 
 bool DatabaseCoreBackendPrivate::isSQLiteLockTransactionError(const QSqlError& lastError) const
 {
-    return parameters.isSQLite()
+    return parameters.isImgSQLite()
            && lastError.type() == QSqlError::TransactionError
            && lastError.databaseText() == QLatin1String("database is locked");
     // wouldnt it be great if they gave us the database error number...
@@ -294,7 +294,7 @@ bool DatabaseCoreBackendPrivate::isSQLiteLockTransactionError(const QSqlError& l
 bool DatabaseCoreBackendPrivate::isConnectionError(const SqlQuery& query) const
 {
     // the backend returns connection error e.g. for Constraint Failed errors.
-    if (parameters.isSQLite())
+    if (parameters.isImgSQLite())
     {
         return false;
     }
@@ -583,7 +583,7 @@ DatabaseCoreBackend::~DatabaseCoreBackend()
 DatabaseConfigElement DatabaseCoreBackend::configElement() const
 {
     Q_D(const DatabaseCoreBackend);
-    return DatabaseConfigElement::element(d->parameters.databaseType);
+    return DatabaseConfigElement::element(d->parameters.imgDatabaseType);
 }
 
 DatabaseAction DatabaseCoreBackend::getDBAction(const QString& actionName) const
@@ -745,7 +745,7 @@ void DatabaseCoreBackend::slotMainThreadFinished()
 
 bool DatabaseCoreBackend::isCompatible(const DatabaseParameters& parameters)
 {
-    return QSqlDatabase::drivers().contains(parameters.databaseType);
+    return QSqlDatabase::drivers().contains(parameters.imgDatabaseType);
 }
 
 bool DatabaseCoreBackend::open(const DatabaseParameters& parameters)
diff --git a/libs/database/databaseoperationgroup.cpp b/libs/database/databaseoperationgroup.cpp
index f9ab94a..256739c 100644
--- a/libs/database/databaseoperationgroup.cpp
+++ b/libs/database/databaseoperationgroup.cpp
@@ -62,7 +62,7 @@ public:
 
     bool needsTransaction() const
     {
-        return DatabaseAccess::parameters().isSQLite();
+        return DatabaseAccess::parameters().isImgSQLite();
     }
 
     void acquire()
diff --git a/libs/database/databaseparameters.cpp b/libs/database/databaseparameters.cpp
index f483ad7..4bdc122 100644
--- a/libs/database/databaseparameters.cpp
+++ b/libs/database/databaseparameters.cpp
@@ -42,11 +42,33 @@
 #include <kdebug.h>
 #include <kstandarddirs.h>
 
+// Local includes
+
+#include "config-digikam.h"
+
 namespace Digikam
 {
 
 static const char* configGroupDatabase = "Database Settings";
 static const char* configInternalDatabaseServer = "Internal Database Server";
+
+static const char* configImgDatabaseType = "Images Type";
+static const char* configImgDatabaseName = "Images Name";
+static const char* configImgDatabaseHostName = "Images Hostname";
+static const char* configImgDatabasePort = "Images Port";
+static const char* configImgDatabaseUsername = "Images Username";
+static const char* configImgDatabasePassword = "Images Password";
+static const char* configImgDatabaseConnectOptions = "Images Connectoptions";
+
+static const char* configTmbDatabaseType = "Thumbnails Type";
+static const char* configTmbDatabaseName = "Thumbnails Name";
+static const char* configTmbDatabaseHostName = "Thumbnails Hostname";
+static const char* configTmbDatabasePort = "Thumbnails Port";
+static const char* configTmbDatabaseUsername = "Thumbnails Username";
+static const char* configTmbDatabasePassword = "Thumbnails Password";
+static const char* configTmbDatabaseConnectOptions = "Thumbnails Connectoptions";
+
+// legacy
 static const char* configDatabaseType = "Database Type";
 static const char* configDatabaseName = "Database Name";
 static const char* configDatabaseNameThumbnails = "Database Name Thumbnails";
@@ -55,48 +77,50 @@ static const char* configDatabasePort = "Database Port";
 static const char* configDatabaseUsername = "Database Username";
 static const char* configDatabasePassword = "Database Password";
 static const char* configDatabaseConnectOptions = "Database Connectoptions";
-// legacy
 static const char* configDatabaseFilePathEntry = "Database File Path";
 static const char* configAlbumPathEntry = "Album Path";
 
-static const char* digikam4db = "digikam4.db";
-static const char* thumbnails_digikamdb = "thumbnails-digikam.db";
-
 DatabaseParameters::DatabaseParameters()
-    : port(-1)
-{
-}
-
-DatabaseParameters::DatabaseParameters(const QString& type,
-                                       const QString& databaseName,
-                                       const QString& connectOptions,
-                                       const QString& hostName,
-                                       int port,
-                                       bool internalServer,
-                                       const QString& userName,
-                                       const QString& password,
-                                       const QString& databaseNameThumbnails)
-    : databaseType(type), databaseName(databaseName),
-      connectOptions(connectOptions), hostName(hostName),
-      port(port), internalServer(internalServer), userName(userName),
-      password(password), databaseNameThumbnails(databaseNameThumbnails)
+    : imgPort(-1), tmbPort(-1)
+{
+}
+
+DatabaseParameters::DatabaseParameters(const QString& imgType,
+                                       const QString& tmbType,
+                                       const QString& imgDatabaseName,
+                                       const QString& tmbDatabaseName,
+                                       const QString& imgConnectOptions,
+                                       const QString& tmbConnectOptions,
+                                       const QString& imgHostName,
+                                       const QString& tmbHostName,
+                                                   int imgPort,
+                                                   int tmbPort,
+                                       const QString& imgUserName,
+                                       const QString& tmbUserName,
+                                       const QString& imgPassword,
+                                       const QString& tmbPassword,
+                                       bool internalServer)
+    : imgDatabaseType(imgType),
+      tmbDatabaseType(tmbType),
+      imgDatabaseName(imgDatabaseName),
+      tmbDatabaseName(tmbDatabaseName),
+      imgConnectOptions(imgConnectOptions),
+      tmbConnectOptions(tmbConnectOptions),
+      imgHostName(imgHostName),
+      tmbHostName(tmbHostName),
+      imgPort(imgPort),
+      tmbPort(tmbPort),
+      imgUserName(imgUserName),
+      tmbUserName(tmbUserName),
+      imgPassword(imgPassword),
+      tmbPassword(tmbPassword),
+      internalServer(internalServer)
 {
 }
 
 DatabaseParameters::DatabaseParameters(const KUrl& url)
-    : port(-1), internalServer(false)
+    :imgPort(-1), tmbPort(-1), internalServer(false)
 {
-    databaseType   = url.queryItem("databaseType");
-    databaseName   = url.queryItem("databaseName");
-    databaseNameThumbnails   = url.queryItem("databaseNameThumbnails");
-    connectOptions = url.queryItem("connectOptions");
-    hostName       = url.queryItem("hostName");
-    QString queryPort = url.queryItem("port");
-
-    if (!queryPort.isNull())
-    {
-        port = queryPort.toInt();
-    }
 
 #ifdef HAVE_INTERNALMYSQL
     QString queryServer = url.queryItem("internalServer");
@@ -109,21 +133,77 @@ DatabaseParameters::DatabaseParameters(const KUrl& url)
     internalServer = false;
 #endif // HAVE_INTERNALMYSQL
 
-    userName       = url.queryItem("userName");
-    password       = url.queryItem("password");
+    imgDatabaseType   = url.queryItem("imgDatabaseType");
+    imgDatabaseName   = url.queryItem("imgDatabaseName");
+    imgConnectOptions = url.queryItem("imgConnectOptions");
+    imgHostName       = url.queryItem("imgHostName");
+    QString queryPort = url.queryItem("imgPort");
+    imgUserName       = url.queryItem("imgUserName");
+    imgPassword       = url.queryItem("imgPassword");
+
+    if (!queryPort.isNull())
+    {
+        imgPort = queryPort.toInt();
+    }
+
+    tmbDatabaseType   = url.queryItem("tmbDatabaseType");
+    tmbDatabaseName   = url.queryItem("tmbDatabaseName");
+    tmbConnectOptions = url.queryItem("tmbConnectOptions");
+    tmbHostName       = url.queryItem("tmbHostName");
+    queryPort         = url.queryItem("tmbPort");
+    tmbUserName       = url.queryItem("tmbUserName");
+    tmbPassword       = url.queryItem("tmbPassword");
+
+    if (!queryPort.isNull())
+    {
+        tmbPort = queryPort.toInt();
+    }
+
+//     // legacy
+//     if (imgDatabaseType.isNull())
+//     {
+//         kDebug(50003) << "Legacy configuration found, adapting ";
+//         imgDatabaseType   = url.queryItem("databaseType");
+//         imgDatabaseName   = url.queryItem("databaseName");
+//         imgConnectOptions = url.queryItem("connectOptions");
+//         imgHostName       = url.queryItem("hostName");
+//         QString queryPort = url.queryItem("port");
+//         imgUserName       = url.queryItem("userName");
+//         imgPassword       = url.queryItem("password");
+// 
+//         tmbDatabaseType   = url.queryItem("databaseType");
+//         tmbDatabaseName   = url.queryItem("databaseNameThumbnails");
+//         tmbConnectOptions = url.queryItem("connectOptions");
+//         tmbHostName       = url.queryItem("hostName");
+//         QString queryPort = url.queryItem("port");
+//         tmbUserName       = url.queryItem("userName");
+//         tmbPassword       = url.queryItem("password");
+// 
+//         if (!queryPort.isNull())
+//         {
+//             imgPort = queryPort.toInt();
+//             tmbPort = queryPort.toInt();
+//         }
+//     }
 }
 
 bool DatabaseParameters::operator==(const DatabaseParameters& other) const
 {
-    return databaseType   == other.databaseType &&
-           databaseName   == other.databaseName &&
-           databaseNameThumbnails == other.databaseNameThumbnails &&
-           connectOptions == other.connectOptions &&
-           hostName       == other.hostName &&
-           port           == other.port &&
-           internalServer == other.internalServer &&
-           userName       == other.userName &&
-           password       == other.password;
+    return internalServer    == other.internalServer &&
+           imgDatabaseType   == other.imgDatabaseType &&
+           imgDatabaseName   == other.imgDatabaseName &&
+           imgConnectOptions == other.imgConnectOptions &&
+           imgHostName       == other.imgHostName &&
+           imgPort           == other.imgPort &&
+           imgUserName       == other.imgUserName &&
+           imgPassword       == other.imgPassword &&
+           tmbDatabaseType   == other.tmbDatabaseType &&
+           tmbDatabaseName   == other.tmbDatabaseName &&
+           tmbConnectOptions == other.tmbConnectOptions &&
+           tmbHostName       == other.tmbHostName &&
+           tmbPort           == other.tmbPort &&
+           tmbUserName       == other.tmbUserName &&
+           tmbPassword       == other.tmbPassword;
 }
 
 bool DatabaseParameters::operator!=(const DatabaseParameters& other) const
@@ -133,22 +213,33 @@ bool DatabaseParameters::operator!=(const DatabaseParameters& other) const
 
 bool DatabaseParameters::isValid() const
 {
-    if (isSQLite())
+    if (isImgSQLite())
     {
-        return !databaseName.isEmpty();
+        return !imgDatabaseName.isEmpty() &&
+               !tmbDatabaseName.isEmpty();
     }
 
     return false;
 }
 
-bool DatabaseParameters::isSQLite() const
+bool DatabaseParameters::isImgSQLite() const
+{
+    return imgDatabaseType == "QSQLITE";
+}
+
+bool DatabaseParameters::isImgMySQL() const
+{
+    return imgDatabaseType == "QMYSQL";
+}
+
+bool DatabaseParameters::isTmbSQLite() const
 {
-    return databaseType == "QSQLITE";
+    return tmbDatabaseType == "QSQLITE";
 }
 
-bool DatabaseParameters::isMySQL() const
+bool DatabaseParameters::isTmbMySQL() const
 {
-    return databaseType == "QMYSQL";
+    return tmbDatabaseType == "QMYSQL";
 }
 
 QString DatabaseParameters::SQLiteDatabaseType()
@@ -161,11 +252,21 @@ QString DatabaseParameters::MySQLDatabaseType()
     return "QMYSQL";
 }
 
-QString DatabaseParameters::SQLiteDatabaseFile() const
+QString DatabaseParameters::imgSQLiteDatabaseFile() const
 {
-    if (isSQLite())
+    if (isImgSQLite())
     {
-        return databaseName;
+        return imgDatabaseName;
+    }
+
+    return QString();
+}
+
+QString DatabaseParameters::tmbSQLiteDatabaseFile() const
+{
+    if (isTmbSQLite())
+    {
+        return tmbDatabaseName;
     }
 
     return QString();
@@ -174,13 +275,22 @@ QString DatabaseParameters::SQLiteDatabaseFile() const
 QByteArray DatabaseParameters::hash() const
 {
     KMD5 md5;
-    md5.update(databaseType.toUtf8());
-    md5.update(databaseName.toUtf8());
-    md5.update(connectOptions.toUtf8());
-    md5.update(hostName.toUtf8());
-    md5.update((const char*)&port, sizeof(int));
-    md5.update(userName.toUtf8());
-    md5.update(password.toUtf8());
+    md5.update(imgDatabaseType.toUtf8());
+    md5.update(imgDatabaseName.toUtf8());
+    md5.update(imgConnectOptions.toUtf8());
+    md5.update(imgHostName.toUtf8());
+    md5.update((const char*)&imgPort, sizeof(int));
+    md5.update(imgUserName.toUtf8());
+    md5.update(imgPassword.toUtf8());
+
+    md5.update(tmbDatabaseType.toUtf8());
+    md5.update(tmbDatabaseName.toUtf8());
+    md5.update(tmbConnectOptions.toUtf8());
+    md5.update(tmbHostName.toUtf8());
+    md5.update((const char*)&tmbPort, sizeof(int));
+    md5.update(tmbUserName.toUtf8());
+    md5.update(tmbPassword.toUtf8());
+
     return md5.hexDigest();
 }
 
@@ -204,71 +314,92 @@ void DatabaseParameters::readFromConfig(KSharedConfig::Ptr config, const QString
         group = config->group(configGroup);
     }
 
-    databaseType             = group.readEntry(configDatabaseType, QString());
-    databaseName             = group.readEntry(configDatabaseName, QString());
-    databaseNameThumbnails   = group.readEntry(configDatabaseNameThumbnails, QString());
-    hostName                 = group.readEntry(configDatabaseHostName, QString());
-    port                     = group.readEntry(configDatabasePort, -1);
-    userName                 = group.readEntry(configDatabaseUsername, QString());
-    password                 = group.readEntry(configDatabasePassword, QString());
-    connectOptions           = group.readEntry(configDatabaseConnectOptions, QString());
 #ifdef HAVE_INTERNALMYSQL
     internalServer           = group.readEntry(configInternalDatabaseServer, false);
 #else
     internalServer           = false;
 #endif // HAVE_INTERNALMYSQL
 
-    if (isSQLite() && !databaseName.isNull())
+    imgDatabaseType             = group.readEntry(configImgDatabaseType, QString());
+    imgDatabaseName             = group.readEntry(configImgDatabaseName, QString());
+    imgHostName                 = group.readEntry(configImgDatabaseHostName, QString());
+    imgPort                     = group.readEntry(configImgDatabasePort, -1);
+    imgUserName                 = group.readEntry(configImgDatabaseUsername, QString());
+    imgPassword                 = group.readEntry(configImgDatabasePassword, QString());
+    imgConnectOptions           = group.readEntry(configImgDatabaseConnectOptions, QString());
+
+    tmbDatabaseType             = group.readEntry(configTmbDatabaseType, QString());
+    tmbDatabaseName             = group.readEntry(configTmbDatabaseName, QString());
+    tmbHostName                 = group.readEntry(configTmbDatabaseHostName, QString());
+    tmbPort                     = group.readEntry(configTmbDatabasePort, -1);
+    tmbUserName                 = group.readEntry(configTmbDatabaseUsername, QString());
+    tmbPassword                 = group.readEntry(configTmbDatabasePassword, QString());
+    tmbConnectOptions           = group.readEntry(configTmbDatabaseConnectOptions, QString());
+
+//     if (imgDatabaseType.isNull())
+//     {
+//         kDebug(50003) << "Legacy configuration found, adapting ";
+// 
+//         imgDatabaseType         = group.readEntry(configDatabaseType, QString());
+//         imgDatabaseName         = group.readEntry(configDatabaseName, QString());
+//         imgHostName             = group.readEntry(configDatabaseHostName, QString());
+//         imgPort                 = group.readEntry(configDatabasePort, -1);
+//         imgUserName             = group.readEntry(configDatabaseUsername, QString());
+//         imgPassword             = group.readEntry(configDatabasePassword, QString());
+//         imgConnectOptions       = group.readEntry(configDatabaseConnectOptions, QString());
+// 
+//         tmbDatabaseType         = group.readEntry(configDatabaseType, QString());
+//         tmbDatabaseName         = group.readEntry(configDatabaseNameThumbnails, QString());
+//         tmbHostName             = group.readEntry(configDatabaseHostName, QString());
+//         tmbPort                 = group.readEntry(configDatabasePort, -1);
+//         tmbUserName             = group.readEntry(configDatabaseUsername, QString());
+//         tmbPassword             = group.readEntry(configDatabasePassword, QString());
+//         tmbConnectOptions       = group.readEntry(configDatabaseConnectOptions, QString());
+//     }
+
+    if (isImgSQLite() && !imgDatabaseName.isNull())
+    {
+        QString orgName = imgDatabaseName;
+        setImgDatabasePath(orgName);
+    }
+    if (isTmbSQLite() && !tmbDatabaseName.isNull())
     {
-        QString orgName = databaseName;
-        setDatabasePath(orgName);
-        setThumbsDatabasePath(orgName);
+        QString orgName = tmbDatabaseName;
+        setTmbDatabasePath(orgName);
     }
 }
 
-void DatabaseParameters::setDatabasePath(const QString& folderOrFileOrName)
+void DatabaseParameters::setImgDatabasePath(const QString& folderOrFileOrName)
 {
-    if (isSQLite())
+    if (isImgSQLite())
     {
-        databaseName = databaseFileSQLite(folderOrFileOrName);
+        imgDatabaseName = databaseFileSQLite(folderOrFileOrName, QString(DIGIKAM4DB));
     }
     else
     {
-        databaseName = folderOrFileOrName;
+        imgDatabaseName = folderOrFileOrName;
     }
 }
 
-void DatabaseParameters::setThumbsDatabasePath(const QString& folderOrFileOrName)
+void DatabaseParameters::setTmbDatabasePath(const QString& folderOrFileOrName)
 {
-    if (isSQLite())
+    if (isImgSQLite())
     {
-        databaseNameThumbnails = thumbnailDatabaseFileSQLite(folderOrFileOrName);
+        tmbDatabaseName = databaseFileSQLite(folderOrFileOrName, QString(THUMBNAILS_DIGIKAMDB));
     }
     else
     {
-        databaseNameThumbnails = folderOrFileOrName;
+        tmbDatabaseName = folderOrFileOrName;
     }
 }
 
-QString DatabaseParameters::databaseFileSQLite(const QString& folderOrFile)
+QString DatabaseParameters::databaseFileSQLite(const QString& folderOrFile, const QString& fileName)
 {
     QFileInfo fileInfo(folderOrFile);
 
     if (fileInfo.isDir())
     {
-        return QDir::cleanPath(fileInfo.filePath() + QDir::separator() + digikam4db);
-    }
-
-    return QDir::cleanPath(folderOrFile);
-}
-
-QString DatabaseParameters::thumbnailDatabaseFileSQLite(const QString& folderOrFile)
-{
-    QFileInfo fileInfo(folderOrFile);
-
-    if (fileInfo.isDir())
-    {
-        return QDir::cleanPath(fileInfo.filePath() + QDir::separator() + thumbnails_digikamdb);
+        return QDir::cleanPath(fileInfo.filePath() + QDir::separator() + fileName);
     }
 
     return QDir::cleanPath(folderOrFile);
@@ -278,49 +409,72 @@ void DatabaseParameters::legacyAndDefaultChecks(const QString& suggestedPath, KS
 {
     // Additional semantic checks for the database section.
     // If the internal server should be started, then the connection options must be reset
-    if (databaseType == "QMYSQL" && internalServer)
+    if (imgDatabaseType == "QMYSQL" && internalServer)
     {
         const QString miscDir = KStandardDirs::locateLocal("data", "digikam/db_misc");
-        databaseType= "QMYSQL";
-        databaseName = "digikam";
-        internalServer = true;
-        databaseNameThumbnails = "digikam";
-        hostName = QString();
-        port = -1;
-        userName = "root";
-        password = QString();
-        connectOptions = QString::fromLatin1("UNIX_SOCKET=%1/mysql.socket").arg(miscDir);
+        tmbDatabaseType=    imgDatabaseType= "QMYSQL";
+        tmbDatabaseName =   imgDatabaseName = "digikam";
+        tmbHostName =       imgHostName = QString();
+        tmbPort =           imgPort = -1;
+        tmbUserName =       imgUserName = "root";
+        tmbPassword =       imgPassword = QString();
+        tmbConnectOptions = imgConnectOptions = QString::fromLatin1("UNIX_SOCKET=%1/mysql.socket").arg(miscDir);
     }
 
-    if (databaseType.isEmpty())
+    if (imgDatabaseType.isEmpty())
     {
-        // Empty 1.3 config: migration from older versions
-        KConfigGroup group  = config->group("Album Settings");
+        // Empty 2.1 config: migration from older versions
+        KConfigGroup group = config->group(configGroupDatabase);
 
-        QString databaseFilePath;
+        kDebug(50003) << "Trying to read legacy configuration";
 
-        // 1.0 - 1.2 style database file path?
-        if (group.hasKey(configDatabaseFilePathEntry))
-        {
-            databaseFilePath = group.readEntry(configDatabaseFilePathEntry, QString());
-        }
-        // <= 0.9 style album path entry?
-        else if (group.hasKey(configAlbumPathEntry))
-        {
-            databaseFilePath = group.readEntry(configAlbumPathEntry, QString());
-        }
-        else if (!suggestedPath.isNull())
+        if (group.hasKey(configDatabaseType))
         {
-            databaseFilePath = suggestedPath;
+            imgDatabaseType         = group.readEntry(configDatabaseType, QString());
+            imgDatabaseName         = group.readEntry(configDatabaseName, QString());
+            imgHostName             = group.readEntry(configDatabaseHostName, QString());
+            imgPort                 = group.readEntry(configDatabasePort, -1);
+            imgUserName             = group.readEntry(configDatabaseUsername, QString());
+            imgPassword             = group.readEntry(configDatabasePassword, QString());
+            imgConnectOptions       = group.readEntry(configDatabaseConnectOptions, QString());
+
+            tmbDatabaseType         = group.readEntry(configDatabaseType, QString());
+            tmbDatabaseName         = group.readEntry(configDatabaseNameThumbnails, QString());
+            tmbHostName             = group.readEntry(configDatabaseHostName, QString());
+            tmbPort                 = group.readEntry(configDatabasePort, -1);
+            tmbUserName             = group.readEntry(configDatabaseUsername, QString());
+            tmbPassword             = group.readEntry(configDatabasePassword, QString());
+            tmbConnectOptions       = group.readEntry(configDatabaseConnectOptions, QString());
         }
-
-
-        if (!databaseFilePath.isEmpty())
+        else
         {
-            *this = parametersForSQLite(databaseFileSQLite(databaseFilePath));
+            // Empty 1.3 config
+            group  = config->group("Album Settings");
+
+            QString databaseFilePath;
+
+            // 1.0 - 1.2 style database file path?
+            if (group.hasKey(configDatabaseFilePathEntry))
+            {
+                databaseFilePath = group.readEntry(configDatabaseFilePathEntry, QString());
+            }
+            // <= 0.9 style album path entry?
+            else if (group.hasKey(configAlbumPathEntry))
+            {
+                databaseFilePath = group.readEntry(configAlbumPathEntry, QString());
+            }
+            else if (!suggestedPath.isNull())
+            {
+                databaseFilePath = suggestedPath;
+            }
+
+            if (!databaseFilePath.isEmpty())
+            {
+                *this = parametersForSQLite(databaseFileSQLite(databaseFilePath, QString(DIGIKAM4DB)));
+            }
+
+            // Be aware that schema updating from  <= 0.9 requires reading the "Album Path", so dont remove it here
         }
-
-        // Be aware that schema updating from  <= 0.9 requires reading the "Album Path", so dont remove it here
     }
 }
 
@@ -352,185 +506,253 @@ void DatabaseParameters::writeToConfig(KSharedConfig::Ptr config, const QString&
         group = config->group(configGroup);
     }
 
-    QString dbName = getDatabaseNameOrDir();
-    QString dbNameThumbs = getThumbsDatabaseNameOrDir();
+    QString dbImgName = getImgDatabaseNameOrDir();
+    QString dbTmbName = getTmbDatabaseNameOrDir();
+
+    group.writeEntry(configImgDatabaseType, imgDatabaseType);
+    group.writeEntry(configImgDatabaseName, dbImgName);
+    group.writeEntry(configImgDatabaseHostName, imgHostName);
+    group.writeEntry(configImgDatabasePort, imgPort);
+    group.writeEntry(configImgDatabaseUsername, imgUserName);
+    group.writeEntry(configImgDatabasePassword, imgPassword);
+    group.writeEntry(configImgDatabaseConnectOptions, imgConnectOptions);
+
+    group.writeEntry(configTmbDatabaseType, tmbDatabaseType);
+    group.writeEntry(configTmbDatabaseName, dbTmbName);
+    group.writeEntry(configTmbDatabaseHostName, tmbHostName);
+    group.writeEntry(configTmbDatabasePort, tmbPort);
+    group.writeEntry(configTmbDatabaseUsername, tmbUserName);
+    group.writeEntry(configTmbDatabasePassword, tmbPassword);
+    group.writeEntry(configTmbDatabaseConnectOptions, tmbConnectOptions);
 
-    group.writeEntry(configDatabaseType, databaseType);
-    group.writeEntry(configDatabaseName, dbName);
-    group.writeEntry(configDatabaseNameThumbnails, dbNameThumbs);
-    group.writeEntry(configDatabaseHostName, hostName);
-    group.writeEntry(configDatabasePort, port);
-    group.writeEntry(configDatabaseUsername, userName);
-    group.writeEntry(configDatabasePassword, password);
-    group.writeEntry(configDatabaseConnectOptions, connectOptions);
     group.writeEntry(configInternalDatabaseServer, internalServer);
+
 }
 
-QString DatabaseParameters::getDatabaseNameOrDir() const
+QString DatabaseParameters::getImgDatabaseNameOrDir() const
 {
-    if (isSQLite())
+    if (isImgSQLite())
     {
-        return databaseDirectorySQLite(databaseName);
+        return imgDatabaseDirectorySQLite(imgDatabaseName);
     }
 
-    return databaseName;
+    return imgDatabaseName;
 }
 
-QString DatabaseParameters::getThumbsDatabaseNameOrDir() const
+QString DatabaseParameters::getTmbDatabaseNameOrDir() const
 {
-    if (isSQLite())
+    if (isTmbSQLite())
     {
-        return thumbnailDatabaseDirectorySQLite(databaseNameThumbnails);
+        return tmbDatabaseDirectorySQLite(tmbDatabaseName);
     }
 
-    return databaseNameThumbnails;
+    return tmbDatabaseName;
 }
 
-QString DatabaseParameters::databaseDirectorySQLite(const QString& path)
+QString DatabaseParameters::imgDatabaseDirectorySQLite(const QString& path)
 {
-    if (path.endsWith(digikam4db))
+    if (path.endsWith(DIGIKAM4DB))
     {
         QString chopped(path);
-        chopped.chop(QString(digikam4db).length());
+        chopped.chop(QString(DIGIKAM4DB).length());
         return chopped;
     }
 
     return path;
 }
 
-QString DatabaseParameters::thumbnailDatabaseDirectorySQLite(const QString& path)
+QString DatabaseParameters::tmbDatabaseDirectorySQLite(const QString& path)
 {
-    if (path.endsWith(thumbnails_digikamdb))
+    if (path.endsWith(THUMBNAILS_DIGIKAMDB))
     {
         QString chopped(path);
-        chopped.chop(QString(thumbnails_digikamdb).length());
+        chopped.chop(QString(THUMBNAILS_DIGIKAMDB).length());
         return chopped;
     }
 
     return path;
 }
 
-DatabaseParameters DatabaseParameters::defaultParameters(const QString databaseType)
+DatabaseParameters DatabaseParameters::defaultParameters(const QString databaseType, const bool isInternal)
 {
     DatabaseParameters parameters;
 
     // only the database name is needed
     DatabaseConfigElement config = DatabaseConfigElement::element(databaseType);
 
-    parameters.databaseType     = databaseType;
-    parameters.databaseName     = config.databaseName;
-    parameters.hostName         = config.hostName;
-    parameters.userName         = config.userName;
-    parameters.password         = config.password;
-    parameters.port             = config.port.toInt();
-
-    const QString miscDir     = KStandardDirs::locateLocal("data", "digikam/db_misc");
-    QString connectOptions = config.connectOptions;
-    connectOptions.replace(QString("$$DBMISCPATH$$"), miscDir);
+    parameters.tmbDatabaseType = parameters.imgDatabaseType = databaseType;
+    parameters.tmbDatabaseName = parameters.imgDatabaseName = config.databaseName;
+    parameters.tmbHostName     = parameters.imgHostName     = config.hostName;
+    parameters.tmbUserName     = parameters.imgUserName     = config.userName;
+    parameters.tmbPassword     = parameters.imgPassword     = config.password;
+    parameters.tmbPort         = parameters.imgPort         = config.port.toInt();
 
-    parameters.connectOptions   = connectOptions;
+    if(isInternal) 
+    {
+        const QString miscDir      = KStandardDirs::locateLocal("data", "digikam/db_misc");
+        QString connectOptions = config.connectOptions;
+        connectOptions.replace(QString("$$DBMISCPATH$$"), miscDir);
+        parameters.tmbConnectOptions = parameters.imgConnectOptions = connectOptions;
+    }
+    parameters.tmbConnectOptions = parameters.imgConnectOptions = QLatin1String("");
 
-    kDebug(50003) << "ConnectOptions "<< parameters.connectOptions;
+    kDebug(50003) << "ConnectOptions "<< parameters.imgConnectOptions;
     return parameters;
 }
 
+//FIXME:
 DatabaseParameters DatabaseParameters::thumbnailParameters() const
 {
     DatabaseParameters params = *this;
-    params.databaseName = databaseNameThumbnails;
+    params.tmbDatabaseName = tmbDatabaseName;
     return params;
 }
 
 DatabaseParameters DatabaseParameters::parametersForSQLite(const QString& databaseFile)
 {
+    // this function should only be used on first run, empty settings
     // only the database name is needed
-    DatabaseParameters params("QSQLITE", databaseFile);
-    params.setDatabasePath(databaseFile);
-    params.setThumbsDatabasePath(params.getDatabaseNameOrDir());
+    DatabaseParameters params("QSQLITE", "QSQLITE", databaseFile, databaseFile);
+    params.setImgDatabasePath(databaseFile);
+    params.setTmbDatabasePath(params.getTmbDatabaseNameOrDir());
     return params;
 }
 
 DatabaseParameters DatabaseParameters::parametersForSQLiteDefaultFile(const QString& directory)
 {
-    return parametersForSQLite(QDir::cleanPath(directory + QDir::separator() + digikam4db));
+    // this function should only be used on first run, empty settings
+    return parametersForSQLite(QDir::cleanPath(directory + QDir::separator() + DIGIKAM4DB));
 }
 
 void DatabaseParameters::insertInUrl(KUrl& url) const
 {
     removeFromUrl(url);
 
-    url.addQueryItem("databaseType", databaseType);
-    url.addQueryItem("databaseName", databaseName);
+    if (internalServer)
+    {
+        url.addQueryItem("internalServer", "true");
+    }
+
+    url.addQueryItem("imgDatabaseType", imgDatabaseType);
+    url.addQueryItem("imgDatabaseName", imgDatabaseName);
 
-    if (!connectOptions.isNull())
+    if (!imgConnectOptions.isNull())
     {
-        url.addQueryItem("connectOptions", connectOptions);
+        url.addQueryItem("imgConnectOptions", imgConnectOptions);
     }
 
-    if (!hostName.isNull())
+    if (!imgHostName.isNull())
     {
-        url.addQueryItem("hostName", hostName);
+        url.addQueryItem("imgHostName", imgHostName);
     }
 
-    if (port != -1)
+    if (imgPort != -1)
     {
-        url.addQueryItem("port", QString::number(port));
+        url.addQueryItem("imgPort", QString::number(imgPort));
     }
 
-    if (internalServer)
+    if (!imgUserName.isNull())
     {
-        url.addQueryItem("internalServer", "true");
+        url.addQueryItem("imgUserName", imgUserName);
     }
 
-    if (!userName.isNull())
+    if (!imgPassword.isNull())
     {
-        url.addQueryItem("userName", userName);
+        url.addQueryItem("imgPassword", imgPassword);
     }
 
-    if (!password.isNull())
+    url.addQueryItem("tmbDatabaseType", tmbDatabaseType);
+    url.addQueryItem("tmbDatabaseName", tmbDatabaseName);
+
+
+    if (!tmbConnectOptions.isNull())
+    {
+        url.addQueryItem("tmbConnectOptions", tmbConnectOptions);
+    }
+
+    if (!tmbHostName.isNull())
+    {
+        url.addQueryItem("tmbHostName", tmbHostName);
+    }
+
+    if (tmbPort != -1)
+    {
+        url.addQueryItem("tmbPort", QString::number(tmbPort));
+    }
+
+    if (!tmbUserName.isNull())
     {
-        url.addQueryItem("password", password);
+        url.addQueryItem("tmbUserName", tmbUserName);
+    }
+
+    if (!tmbPassword.isNull())
+    {
+        url.addQueryItem("tmbPassword", tmbPassword);
     }
 }
 
 void DatabaseParameters::removeFromUrl(KUrl& url)
 {
-    url.removeQueryItem("databaseType");
-    url.removeQueryItem("databaseName");
-    url.removeQueryItem("connectOptions");
-    url.removeQueryItem("hostName");
-    url.removeQueryItem("port");
     url.removeQueryItem("internalServer");
-    url.removeQueryItem("userName");
-    url.removeQueryItem("password");
+    url.removeQueryItem("imgDatabaseType");
+    url.removeQueryItem("imgDatabaseName");
+    url.removeQueryItem("imgConnectOptions");
+    url.removeQueryItem("imgHostName");
+    url.removeQueryItem("imgPort");
+    url.removeQueryItem("imgUserName");
+    url.removeQueryItem("imgPassword");
+    url.removeQueryItem("tmbDatabaseType");
+    url.removeQueryItem("tmbDatabaseName");
+    url.removeQueryItem("tmbConnectOptions");
+    url.removeQueryItem("tmbHostName");
+    url.removeQueryItem("tmbPort");
+    url.removeQueryItem("tmbUserName");
+    url.removeQueryItem("tmbPassword");
 }
 
 QDebug operator<<(QDebug dbg, const DatabaseParameters& p)
 {
     dbg.nospace() << "DatabaseParameters: [ Type "
-                  << p.databaseType << ", ";
+                  << p.imgDatabaseType << ", ";
     dbg.nospace() << "Name "
-                  << p.databaseName << " ";
-    dbg.nospace() << "(Thumbnails Name "
-                  << p.databaseNameThumbnails << "); ";
+                  << p.imgDatabaseName << " ";
 
-    if (!p.connectOptions.isEmpty())
+    if (!p.imgConnectOptions.isEmpty())
         dbg.nospace() << "ConnectOptions: "
-                      << p.connectOptions << ", ";
+                      << p.imgConnectOptions << ", ";
 
-    if (!p.hostName.isEmpty())
+    if (!p.imgHostName.isEmpty())
         dbg.nospace() << "Host Name and Port: "
-                      << p.hostName << " " << p.port << "; ";
+                      << p.imgHostName << " " << p.imgPort << "; ";
+
+    if (!p.imgUserName.isEmpty())
+        dbg.nospace() << "Username and Password: "
+                      << p.imgUserName << ", " << p.imgPassword;
 
     if (p.internalServer)
     {
         dbg.nospace() << "Using an Internal Server; ";
     }
+    else
+    {
 
-    if (!p.userName.isEmpty())
-        dbg.nospace() << "Username and Password: "
-                      << p.userName << ", " << p.password;
+    dbg.nospace() << "tmb.Type "
+                  << p.tmbDatabaseType << ", ";
+    dbg.nospace() << "tmb.Name "
+                  << p.tmbDatabaseName << " ";
+
+    if (!p.tmbConnectOptions.isEmpty())
+        dbg.nospace() << "tmb.ConnectOptions: "
+                      << p.tmbConnectOptions << ", ";
 
+    if (!p.tmbHostName.isEmpty())
+        dbg.nospace() << "tmb.Host Name and Port: "
+                      << p.tmbHostName << " " << p.tmbPort << "; ";
+
+    if (!p.tmbUserName.isEmpty())
+        dbg.nospace() << "tmb.Username and Password: "
+                      << p.tmbUserName << ", " << p.tmbPassword;
+    }
     dbg.nospace() << "] ";
 
     return dbg.space();
diff --git a/libs/database/databaseparameters.h b/libs/database/databaseparameters.h
index 7785b09..5f189cd 100644
--- a/libs/database/databaseparameters.h
+++ b/libs/database/databaseparameters.h
@@ -55,29 +55,41 @@ public:
       * The values can be read from and written to a KUrl.
       */
 
-    DatabaseParameters(const QString& type,
-                       const QString& databaseName,
-                       const QString& connectOptions = QString(),
-                       const QString& hostName = QString(),
-                       int   port = -1,
-                       bool  internalServer = false,
-                       const QString& userName = QString(),
-                       const QString& password = QString(),
-                       const QString& databaseNameThumbnails = QString());
+    DatabaseParameters(const QString& imgType,
+                       const QString& tmbType,
+                       const QString& imgDatabaseName,
+                       const QString& tmbDatabaseName,
+                       const QString& imgConnectOptions = QString(),
+                       const QString& tmbConnectOptions = QString(),
+                       const QString& imgHostName = QString(),
+                       const QString& tmbHostName = QString(),
+                                  int imgPort = -1,
+                                  int tmbPort = -1,
+                       const QString& imgUserName = QString(),
+                       const QString& tmbUserName = QString(),
+                       const QString& imgPassword = QString(),
+                       const QString& tmbPassword = QString(),
+                       bool internalServer = false);
 
     DatabaseParameters(const KUrl& url);
     DatabaseParameters();
 
-    QString databaseType;
-    QString databaseName;
-    QString connectOptions;
-    QString hostName;
-    int     port;
-    bool    internalServer;
-    QString userName;
-    QString password;
+    QString imgDatabaseType;
+    QString tmbDatabaseType;
+    QString imgDatabaseName;
+    QString tmbDatabaseName;
+    QString imgConnectOptions;
+    QString tmbConnectOptions;
+    QString imgHostName;
+    QString tmbHostName;
+    int     imgPort;
+    int     tmbPort;
+    QString imgUserName;
+    QString tmbUserName;
+    QString imgPassword;
+    QString tmbPassword;
 
-    QString databaseNameThumbnails;
+    bool    internalServer;
 
     void insertInUrl(KUrl& url) const;
     bool operator==(const DatabaseParameters& other) const;
@@ -88,9 +100,12 @@ public:
      */
     bool isValid() const;
 
-    bool isSQLite() const;
-    bool isMySQL() const;
-    QString SQLiteDatabaseFile() const;
+    bool isImgSQLite() const;
+    bool isImgMySQL() const;
+    bool isTmbSQLite() const;
+    bool isTmbMySQL() const;
+    QString imgSQLiteDatabaseFile() const;
+    QString tmbSQLiteDatabaseFile() const;
 
     /**
      *  Returns the databaseType designating the said database.
@@ -106,7 +121,7 @@ public:
     QByteArray hash() const;
 
     /** Return a set of default parameters for the give type */
-    static DatabaseParameters defaultParameters(const QString databaseType);
+    static DatabaseParameters defaultParameters(const QString databaseType, const bool isInternal=false);
 
     static DatabaseParameters parametersFromConfig(KSharedConfig::Ptr config = KGlobal::config(),
             const QString& configGroup = QString());
@@ -121,21 +136,20 @@ public:
      * In case of SQLite, the databaseName typically is a file.
      * With getDatabasePath, you can get the folder.
      */
-    QString getDatabaseNameOrDir() const;
-    QString getThumbsDatabaseNameOrDir() const;
+    QString getImgDatabaseNameOrDir() const;
+    QString getTmbDatabaseNameOrDir() const;
 
     /**
      * In case of SQLite, the databaseName typically is a file.
      * Use this method if you set a file or a folder.
      * For non-SQLite, this simply sets the database name.
      */
-    void setDatabasePath(const QString& folderOrFileOrName);
-    void setThumbsDatabasePath(const QString& folderOrFileOrName);
+    void setImgDatabasePath(const QString& folderOrFileOrName);
+    void setTmbDatabasePath(const QString& folderOrFileOrName);
 
-    static QString databaseFileSQLite(const QString& folderOrFile);
-    static QString thumbnailDatabaseFileSQLite(const QString& folderOrFile);
-    static QString databaseDirectorySQLite(const QString& path);
-    static QString thumbnailDatabaseDirectorySQLite(const QString& path);
+    static QString databaseFileSQLite(const QString& folderOrFile, const QString& fileName);
+    static QString imgDatabaseDirectorySQLite(const QString& path);
+    static QString tmbDatabaseDirectorySQLite(const QString& path);
 
     /** Replaces databaseName with databaseNameThumbnails. */
     DatabaseParameters thumbnailParameters() const;
diff --git a/libs/database/schemaupdater.cpp b/libs/database/schemaupdater.cpp
index 3a4e294..ab962d2 100644
--- a/libs/database/schemaupdater.cpp
+++ b/libs/database/schemaupdater.cpp
@@ -164,7 +164,7 @@ void SchemaUpdater::setObserver(InitializationObserver* observer)
 
 bool SchemaUpdater::startUpdates()
 {
-    if (!m_Parameters.isSQLite())
+    if (!m_Parameters.isImgSQLite())
     {
         // Do we have sufficient privileges
         QStringList insufficientRights;
@@ -275,9 +275,9 @@ bool SchemaUpdater::startUpdates()
         // Version 4 writes "4", and from now on version x writes "x".
         // Version 5 includes the schema changes from 0.9 to 0.10
 
-        if (m_Parameters.isSQLite())
+        if (m_Parameters.isImgSQLite())
         {
-            QFileInfo currentDBFile(m_Parameters.databaseName);
+            QFileInfo currentDBFile(m_Parameters.imgDatabaseName);
             QFileInfo digikam3DB(currentDBFile.dir(), "digikam3.db");
             QFileInfo digikamDB(currentDBFile.dir(), "digikam.db");
 
@@ -329,7 +329,7 @@ bool SchemaUpdater::beginWrapSchemaUpdateStep()
 {
     if (!m_Backend->beginTransaction())
     {
-        QFileInfo currentDBFile(m_Parameters.databaseName);
+        QFileInfo currentDBFile(m_Parameters.imgDatabaseName);
         QString errorMsg = i18n("Failed to open a database transaction on your database file \"%1\". "
                                 "This is unusual. Please check that you can access the file and no "
                                 "other process has currently locked the file. "
@@ -386,7 +386,7 @@ bool SchemaUpdater::makeUpdates()
             }
 
             // v4 was always SQLite
-            QFileInfo currentDBFile(m_Parameters.databaseName);
+            QFileInfo currentDBFile(m_Parameters.imgDatabaseName);
             QString errorMsg = i18n("The schema updating process from version 4 to 6 failed, "
                                     "caused by an error that we did not expect. "
                                     "You can try to discard your old database and start with an empty one. "
diff --git a/libs/database/thumbnailschemaupdater.cpp b/libs/database/thumbnailschemaupdater.cpp
index 193da56..14f11e5 100644
--- a/libs/database/thumbnailschemaupdater.cpp
+++ b/libs/database/thumbnailschemaupdater.cpp
@@ -99,7 +99,7 @@ bool ThumbnailSchemaUpdater::startUpdates()
         kDebug(50003) << "Have a database structure version " << version;
 
         // mini schema update
-        if (version.isEmpty() && m_access->parameters().isSQLite())
+        if (version.isEmpty() && m_access->parameters().isTmbSQLite())
         {
             version = m_access->db()->getSetting("DBVersion");
         }
diff --git a/libs/dialogs/migrationdlg.cpp b/libs/dialogs/migrationdlg.cpp
index c483a66..5d2c5f9 100644
--- a/libs/dialogs/migrationdlg.cpp
+++ b/libs/dialogs/migrationdlg.cpp
@@ -44,6 +44,7 @@
 
 // Local includes
 
+#include "config-digikam.h"
 #include "albumsettings.h"
 #include "databaseaccess.h"
 #include "databasewidget.h"
@@ -189,6 +190,7 @@ void MigrationDlg::setupMainArea()
 
     connect(d->cancelButton, SIGNAL(clicked()),
             &(d->copyThread->copyManager), SLOT(stopProcessing()));
+
 }
 
 void MigrationDlg::performCopy()
diff --git a/libs/dialogs/migrationdlg.h b/libs/dialogs/migrationdlg.h
index 686379e..08ea286 100644
--- a/libs/dialogs/migrationdlg.h
+++ b/libs/dialogs/migrationdlg.h
@@ -36,6 +36,7 @@
 
 // Local includes
 
+#include "config-digikam.h"
 #include "databasewidget.h"
 #include "databasebackend.h"
 #include "databasecopymanager.h"
diff --git a/libs/widgets/common/databasewidget.cpp b/libs/widgets/common/databasewidget.cpp
index 7080bca..4ee8e20 100644
--- a/libs/widgets/common/databasewidget.cpp
+++ b/libs/widgets/common/databasewidget.cpp
@@ -59,18 +59,22 @@ public:
 
     DatabaseWidgetPriv()
     {
-        databasePathLabel = 0;
-        expertSettings    = 0;
+        imgDatabasePathLabel = 0;
+        tmbDatabasePathLabel = 0;
+        imgExpertSettings = 0;
+        tmbExpertSettings = 0;
     }
 
-    QLabel*    databasePathLabel;
-    QGroupBox* expertSettings;
+    QLabel*    imgDatabasePathLabel;
+    QLabel*    tmbDatabasePathLabel;
+    QGroupBox* imgExpertSettings;
+    QGroupBox* tmbExpertSettings;
 };
 
-DatabaseWidget::DatabaseWidget(QWidget* parent)
+DatabaseWidget::DatabaseWidget(QWidget* parent, const QString & title)
     : QWidget(parent), d(new DatabaseWidgetPriv)
 {
-    setupMainArea();
+    setupMainArea(title);
 }
 
 DatabaseWidget::~DatabaseWidget()
@@ -78,7 +82,7 @@ DatabaseWidget::~DatabaseWidget()
     delete d;
 }
 
-void DatabaseWidget::setupMainArea()
+void DatabaseWidget::setupMainArea(const QString & title)
 {
     setAutoFillBackground(false);
 
@@ -87,68 +91,112 @@ 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. "
+    d->imgDatabasePathLabel = 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/>"
                                            "Write access is required to be able to edit image properties.</p>"
                                            "<p>Note: a remote file system, such as NFS, cannot be used here.</p><p></p>"),
                                       dbPathBox);
-    d->databasePathLabel->setWordWrap(true);
-    d->databasePathLabel->setFont(KGlobalSettings::smallestReadableFont());
-
-    databasePathEdit     = new KUrlRequester(dbPathBox);
-    databasePathEdit->setMode(KFile::Directory | KFile::LocalOnly);
-
-    QLabel* databaseTypeLabel           = new QLabel(i18n("Type"));
-    databaseType                        = new QComboBox();
-    QLabel* internalServerLabel         = new QLabel(i18n("Internal Server"));
-    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();
-    QLabel* hostNameLabel               = new QLabel(i18n("Host Name"));
-    hostName                            = new QLineEdit();
-    QLabel* hostPortLabel               = new QLabel(i18n("Port"));
-    hostPort                            = new QSpinBox();
-    hostPort->setMaximum(65535);
-
-    QLabel* connectionOptionsLabel      = new QLabel(i18n("Database<br>Connection<br>Options"));
-    connectionOptions                   = new QLineEdit();
-
-    QLabel* userNameLabel               = new QLabel(i18n("User"));
-    userName                            = new QLineEdit();
-
-    QLabel* passwordLabel               = new QLabel(i18n("Password"));
-    password                            = new QLineEdit();
-    password->setEchoMode(QLineEdit::Password);
-
-    QPushButton* checkDatabaseConnectionButton = new QPushButton(i18n("Check DB Connection"));
-
-    d->expertSettings                   = new QGroupBox();
-    d->expertSettings->setFlat(true);
-    QFormLayout* expertSettinglayout    = new QFormLayout();
-    d->expertSettings->setLayout(expertSettinglayout);
+    d->imgDatabasePathLabel->setWordWrap(true);
+    d->imgDatabasePathLabel->setFont(KGlobalSettings::smallestReadableFont());
+
+    d->tmbDatabasePathLabel = new QLabel(i18n("<p>The location where the database file will be stored on your system. "
+                                           "This file can grow quite big</p>"
+                                           "<p>Note: a remote file system, such as NFS, cannot be used here.</p><p></p>"),
+                                      dbPathBox);
+    d->tmbDatabasePathLabel->setWordWrap(true);
+    d->tmbDatabasePathLabel->setFont(KGlobalSettings::smallestReadableFont());
+
+    imgDatabasePathEdit     = new KUrlRequester(dbPathBox);
+    imgDatabasePathEdit->setMode(KFile::Directory | KFile::LocalOnly);
+
+    tmbDatabasePathEdit     = new KUrlRequester(dbPathBox);
+    tmbDatabasePathEdit->setMode(KFile::Directory | KFile::LocalOnly);
+
+    internalServer                         = new QCheckBox(i18n("Internal Server"));
+
+    QLabel* imgDatabaseTypeLabel           = new QLabel(i18n("Type"));
+    QLabel* imgDatabaseNameLabel           = new QLabel(i18n("Schema Name"));
+    QLabel* imgHostNameLabel               = new QLabel(i18n("Host Name"));
+    QLabel* imgHostPortLabel               = new QLabel(i18n("Port"));
+    QLabel* imgConnectionOptionsLabel      = new QLabel(i18n("Database<br>Connection<br>Options"));
+    QLabel* imgUserNameLabel               = new QLabel(i18n("User"));
+    QLabel* imgPasswordLabel               = new QLabel(i18n("Password"));
+
+    QLabel* tmbDatabaseTypeLabel           = new QLabel(i18n("Type"));
+    QLabel* tmbDatabaseNameLabel           = new QLabel(i18n("Schema Name"));
+    QLabel* tmbHostNameLabel               = new QLabel(i18n("Host Name"));
+    QLabel* tmbHostPortLabel               = new QLabel(i18n("Port"));
+    QLabel* tmbConnectionOptionsLabel      = new QLabel(i18n("Database<br>Connection<br>Options"));
+    QLabel* tmbUserNameLabel               = new QLabel(i18n("User"));
+    QLabel* tmbPasswordLabel               = new QLabel(i18n("Password"));
+
+    imgDatabaseType                        = new QComboBox();
+    imgDatabaseName                        = new QLineEdit();
+    imgHostName                            = new QLineEdit();
+    imgHostPort                            = new QSpinBox();
+    imgHostPort->setMaximum(65535);
+    imgConnectionOptions                   = new QLineEdit();
+    imgUserName                            = new QLineEdit();
+    imgPassword                            = new QLineEdit();
+    imgPassword->setEchoMode(QLineEdit::Password);
+    QPushButton* imgCheckDatabaseConnectionButton = new QPushButton(i18n("Check DB Connection"));
+
+    tmbDatabaseType                        = new QComboBox();
+    tmbDatabaseName                        = new QLineEdit();
+    tmbHostName                            = new QLineEdit();
+    tmbHostPort                            = new QSpinBox();
+    tmbHostPort->setMaximum(65535);
+    tmbConnectionOptions                   = new QLineEdit();
+    tmbUserName                            = new QLineEdit();
+    tmbPassword                            = new QLineEdit();
+    tmbPassword->setEchoMode(QLineEdit::Password);
+    QPushButton* tmbCheckDatabaseConnectionButton = new QPushButton(i18n("Check DB Connection"));
+
+    d->imgExpertSettings                   = new QGroupBox();
+    d->imgExpertSettings->setFlat(true);
+    QFormLayout* imgExpertSettinglayout    = new QFormLayout();
+    d->imgExpertSettings->setLayout(imgExpertSettinglayout);
+
+    d->tmbExpertSettings                   = new QGroupBox();
+    d->tmbExpertSettings->setFlat(true);
+    QFormLayout* tmbExpertSettinglayout    = new QFormLayout();
+    d->tmbExpertSettings->setLayout(tmbExpertSettinglayout);
+
+// #ifdef HAVE_INTERNALMYSQL
+//     expertSettinglayout->addRow(internalServerLabel, internalServer);
+// #endif // HAVE_INTERNALMYSQL
+    imgExpertSettinglayout->addRow(imgHostNameLabel, imgHostName);
+    imgExpertSettinglayout->addRow(imgHostPortLabel, imgHostPort);
+    imgExpertSettinglayout->addRow(imgDatabaseNameLabel, imgDatabaseName);
+    imgExpertSettinglayout->addRow(imgUserNameLabel, imgUserName);
+    imgExpertSettinglayout->addRow(imgPasswordLabel, imgPassword);
+    imgExpertSettinglayout->addRow(imgConnectionOptionsLabel, imgConnectionOptions);
+    imgExpertSettinglayout->addWidget(imgCheckDatabaseConnectionButton);
+
+    tmbExpertSettinglayout->addRow(tmbHostNameLabel, tmbHostName);
+    tmbExpertSettinglayout->addRow(tmbHostPortLabel, tmbHostPort);
+    tmbExpertSettinglayout->addRow(tmbDatabaseNameLabel, tmbDatabaseName);
+    tmbExpertSettinglayout->addRow(tmbUserNameLabel, tmbUserName);
+    tmbExpertSettinglayout->addRow(tmbPasswordLabel, tmbPassword);
+    tmbExpertSettinglayout->addRow(tmbConnectionOptionsLabel, tmbConnectionOptions);
+    tmbExpertSettinglayout->addWidget(tmbCheckDatabaseConnectionButton);
+
+    vlay->addWidget(internalServer);
+
+    vlay->addWidget(imgDatabaseTypeLabel);
+    vlay->addWidget(imgDatabaseType);
+    vlay->addWidget(d->imgDatabasePathLabel);
+    vlay->addWidget(imgDatabasePathEdit);
+    vlay->addWidget(d->imgExpertSettings);
+
+    vlay->addWidget(tmbDatabaseTypeLabel);
+    vlay->addWidget(tmbDatabaseType);
+    vlay->addWidget(tmbDatabasePathEdit);
+    vlay->addWidget(d->tmbDatabasePathLabel);
+    vlay->addWidget(d->tmbExpertSettings);
 
-#ifdef HAVE_INTERNALMYSQL
-    expertSettinglayout->addRow(internalServerLabel, internalServer);
-#endif // HAVE_INTERNALMYSQL
-    expertSettinglayout->addRow(hostNameLabel, hostName);
-    expertSettinglayout->addRow(hostPortLabel, hostPort);
-    expertSettinglayout->addRow(databaseNameLabel, databaseName);
-    expertSettinglayout->addRow(databaseNameThumbnailsLabel, databaseNameThumbnails);
-    expertSettinglayout->addRow(userNameLabel, userName);
-    expertSettinglayout->addRow(passwordLabel, password);
-    expertSettinglayout->addRow(connectionOptionsLabel, connectionOptions);
-
-    expertSettinglayout->addWidget(checkDatabaseConnectionButton);
-
-    vlay->addWidget(databaseTypeLabel);
-    vlay->addWidget(databaseType);
-    vlay->addWidget(d->databasePathLabel);
-    vlay->addWidget(databasePathEdit);
-    vlay->addWidget(d->expertSettings);
     vlay->setSpacing(0);
     vlay->setMargin(KDialog::spacingHint());
 
@@ -161,9 +209,13 @@ void DatabaseWidget::setupMainArea()
 
     // --------- fill with default values ---------------------
 
-    databaseType->addItem(i18n("SQLite"), DatabaseParameters::SQLiteDatabaseType());
-    databaseType->addItem(i18n("MySQL"), DatabaseParameters::MySQLDatabaseType());
-    setDatabaseInputFields(DatabaseParameters::SQLiteDatabaseType());
+    imgDatabaseType->addItem(i18n("SQLite"), DatabaseParameters::SQLiteDatabaseType());
+    imgDatabaseType->addItem(i18n("MySQL"), DatabaseParameters::MySQLDatabaseType());
+    setImgDatabaseInputFields(DatabaseParameters::SQLiteDatabaseType());
+
+    tmbDatabaseType->addItem(i18n("SQLite"), DatabaseParameters::SQLiteDatabaseType());
+    tmbDatabaseType->addItem(i18n("MySQL"), DatabaseParameters::MySQLDatabaseType());
+    setTmbDatabaseInputFields(DatabaseParameters::SQLiteDatabaseType());
 
     // --------------------------------------------------------
 
@@ -171,30 +223,89 @@ void DatabaseWidget::setupMainArea()
 
     // --------------------------------------------------------
 
-    connect(databasePathEdit, SIGNAL(urlSelected(KUrl)),
-            this, SLOT(slotChangeDatabasePath(KUrl)));
-
-    connect(databasePathEdit, SIGNAL(textChanged(QString)),
-            this, SLOT(slotDatabasePathEdited(QString)));
-
-    connect(databaseType, SIGNAL(currentIndexChanged(int)),
-            this, SLOT(slotHandleDBTypeIndexChanged(int)));
-
 #ifdef HAVE_INTERNALMYSQL
     connect(internalServer, SIGNAL(stateChanged(int)),
             this, SLOT(slotHandleInternalServerCheckbox(int)));
-#endif // HAVE_INTERNALMYSQL
+#endif
+
+    connect(imgDatabasePathEdit, SIGNAL(urlSelected(KUrl)),
+            this, SLOT(slotImgChangeDatabasePath(KUrl)));
+
+    connect(imgDatabasePathEdit, SIGNAL(textChanged(QString)),
+            this, SLOT(slotImgDatabasePathEdited(QString)));
+
+    connect(imgDatabaseType, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(slotImgHandleDBTypeIndexChanged(int)));
+
+    connect(imgCheckDatabaseConnectionButton, SIGNAL(clicked()),
+            this, SLOT(slotImgCheckDatabaseConnection()));
+
+    connect(tmbDatabasePathEdit, SIGNAL(urlSelected(KUrl)),
+            this, SLOT(slotTmbChangeDatabasePath(KUrl)));
+
+    connect(tmbDatabasePathEdit, SIGNAL(textChanged(QString)),
+            this, SLOT(slotTmbDatabasePathEdited(QString)));
+
+    connect(tmbDatabaseType, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(slotTmbHandleDBTypeIndexChanged(int)));
+
+    connect(tmbCheckDatabaseConnectionButton, SIGNAL(clicked()),
+            this, SLOT(slotTmbCheckDatabaseConnection()));
+}
+
+QString DatabaseWidget::imgCurrentDatabaseType() const
+{
+    return imgDatabaseType->itemData(imgDatabaseType->currentIndex()).toString();
+}
+
+QString DatabaseWidget::tmbCurrentDatabaseType() const
+{
+    return tmbDatabaseType->itemData(tmbDatabaseType->currentIndex()).toString();
+}
+
+void DatabaseWidget::slotImgChangeDatabasePath(const KUrl& result)
+{
+#ifdef _WIN32
+    // Work around B.K.O #189168
+    KTemporaryFile temp;
+    temp.setPrefix(result.toLocalFile(KUrl::AddTrailingSlash));
+    temp.open();
 
-    connect(checkDatabaseConnectionButton, SIGNAL(clicked()),
-            this, SLOT(checkDatabaseConnection()));
+    if (!result.isEmpty() && !temp.open())
+#else
+    QFileInfo targetPath(result.toLocalFile());
+
+    if (!result.isEmpty() && !targetPath.isWritable())
+#endif
+    {
+        KMessageBox::information(0, i18n("You do not seem to have write access to this database folder.\n"
+                                         "Without this access, the caption and tag features will not work."));
+    }
+
+    checkDBPath();
 }
 
-QString DatabaseWidget::currentDatabaseType() const
+void DatabaseWidget::slotImgDatabasePathEdited(const QString& newPath)
 {
-    return databaseType->itemData(databaseType->currentIndex()).toString();
+#ifndef _WIN32
+
+    if (!newPath.isEmpty() && !QDir::isAbsolutePath(newPath))
+    {
+        imgDatabasePathEdit->setUrl(QString(QDir::homePath() + QLatin1Char('/') + newPath));
+    }
+
+#endif
+
+    checkDBPath();
 }
 
-void DatabaseWidget::slotChangeDatabasePath(const KUrl& result)
+void DatabaseWidget::slotImgHandleDBTypeIndexChanged(int index)
+{
+    const QString& dbType = imgDatabaseType->itemData(index).toString();
+    setImgDatabaseInputFields(dbType);
+}
+
+void DatabaseWidget::slotTmbChangeDatabasePath(const KUrl& result)
 {
 #ifdef _WIN32
     // Work around B.K.O #189168
@@ -216,13 +327,13 @@ void DatabaseWidget::slotChangeDatabasePath(const KUrl& result)
     checkDBPath();
 }
 
-void DatabaseWidget::slotDatabasePathEdited(const QString& newPath)
+void DatabaseWidget::slotTmbDatabasePathEdited(const QString& newPath)
 {
 #ifndef _WIN32
 
     if (!newPath.isEmpty() && !QDir::isAbsolutePath(newPath))
     {
-        databasePathEdit->setUrl(QString(QDir::homePath() + QLatin1Char('/') + newPath));
+        tmbDatabasePathEdit->setUrl(QString(QDir::homePath() + QLatin1Char('/') + newPath));
     }
 
 #endif
@@ -230,25 +341,43 @@ void DatabaseWidget::slotDatabasePathEdited(const QString& newPath)
     checkDBPath();
 }
 
-void DatabaseWidget::slotHandleDBTypeIndexChanged(int index)
+void DatabaseWidget::slotTmbHandleDBTypeIndexChanged(int index)
+{
+    const QString& dbType = tmbDatabaseType->itemData(index).toString();
+    setTmbDatabaseInputFields(dbType);
+}
+
+void DatabaseWidget::setImgDatabaseInputFields(const QString& currentIndexStr)
 {
-    const QString& dbType = databaseType->itemData(index).toString();
-    setDatabaseInputFields(dbType);
+    if (currentIndexStr == QString(DatabaseParameters::SQLiteDatabaseType()))
+    {
+        d->imgDatabasePathLabel->setVisible(true);
+        imgDatabasePathEdit->setVisible(true);
+        d->imgExpertSettings->setVisible(false);
+    }
+    else
+    {
+        d->imgDatabasePathLabel->setVisible(false);
+        imgDatabasePathEdit->setVisible(false);
+        d->imgExpertSettings->setVisible(true);
+    }
+
+    adjustSize();
 }
 
-void DatabaseWidget::setDatabaseInputFields(const QString& currentIndexStr)
+void DatabaseWidget::setTmbDatabaseInputFields(const QString& currentIndexStr)
 {
     if (currentIndexStr == QString(DatabaseParameters::SQLiteDatabaseType()))
     {
-        d->databasePathLabel->setVisible(true);
-        databasePathEdit->setVisible(true);
-        d->expertSettings->setVisible(false);
+        d->tmbDatabasePathLabel->setVisible(true);
+        tmbDatabasePathEdit->setVisible(true);
+        d->tmbExpertSettings->setVisible(false);
     }
     else
     {
-        d->databasePathLabel->setVisible(false);
-        databasePathEdit->setVisible(false);
-        d->expertSettings->setVisible(true);
+        d->tmbDatabasePathLabel->setVisible(false);
+        tmbDatabasePathEdit->setVisible(false);
+        d->tmbExpertSettings->setVisible(true);
     }
 
     adjustSize();
@@ -256,29 +385,35 @@ void DatabaseWidget::setDatabaseInputFields(const QString& currentIndexStr)
 
 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);
+    imgHostName->setEnabled(enableFields == Qt::Unchecked);
+    imgHostPort->setEnabled(enableFields == Qt::Unchecked);
+    imgDatabaseName->setEnabled(enableFields == Qt::Unchecked);
+    imgUserName->setEnabled(enableFields == Qt::Unchecked);
+    imgPassword->setEnabled(enableFields == Qt::Unchecked);
+    imgConnectionOptions->setEnabled(enableFields == Qt::Unchecked);
+
+    tmbHostName->setEnabled(enableFields == Qt::Unchecked);
+    tmbHostPort->setEnabled(enableFields == Qt::Unchecked);
+    tmbDatabaseName->setEnabled(enableFields == Qt::Unchecked);
+    tmbUserName->setEnabled(enableFields == Qt::Unchecked);
+    tmbPassword->setEnabled(enableFields == Qt::Unchecked);
+    tmbConnectionOptions->setEnabled(enableFields == Qt::Unchecked);
 }
 
-void DatabaseWidget::checkDatabaseConnection()
+void DatabaseWidget::slotImgCheckDatabaseConnection()
 {
     // TODO : if chek DB connection operations can be threaded, use DBusyDlg dialog there...
 
     kapp->setOverrideCursor(Qt::WaitCursor);
 
     QString databaseID("ConnectionTest");
-    QSqlDatabase testDatabase     = QSqlDatabase::addDatabase(currentDatabaseType(), databaseID);
+    QSqlDatabase testDatabase     = QSqlDatabase::addDatabase(imgCurrentDatabaseType(), databaseID);
     DatabaseParameters parameters = getDatabaseParameters();
-    testDatabase.setHostName(parameters.hostName);
-    testDatabase.setPort(parameters.port);
-    testDatabase.setUserName(parameters.userName);
-    testDatabase.setPassword(parameters.password);
-    testDatabase.setConnectOptions(parameters.connectOptions);
+    testDatabase.setHostName(parameters.imgHostName);
+    testDatabase.setPort(parameters.imgPort);
+    testDatabase.setUserName(parameters.imgUserName);
+    testDatabase.setPassword(parameters.imgPassword);
+    testDatabase.setConnectOptions(parameters.imgConnectOptions);
 
     kapp->restoreOverrideCursor();
 
@@ -298,55 +433,115 @@ void DatabaseWidget::checkDatabaseConnection()
     QSqlDatabase::removeDatabase(databaseID);
 }
 
+
+void DatabaseWidget::slotTmbCheckDatabaseConnection()
+{
+    // TODO : if chek DB connection operations can be threaded, use DBusyDlg dialog there...
+
+    kapp->setOverrideCursor(Qt::WaitCursor);
+
+    QString databaseID("ConnectionTest");
+    QSqlDatabase testDatabase     = QSqlDatabase::addDatabase(tmbCurrentDatabaseType(), databaseID);
+    DatabaseParameters parameters = getDatabaseParameters();
+    testDatabase.setHostName(parameters.tmbHostName);
+    testDatabase.setPort(parameters.tmbPort);
+    testDatabase.setUserName(parameters.tmbUserName);
+    testDatabase.setPassword(parameters.tmbPassword);
+    testDatabase.setConnectOptions(parameters.tmbConnectOptions);
+
+    kapp->restoreOverrideCursor();
+
+    bool result = testDatabase.open();
+
+    if (result)
+    {
+        KMessageBox::information(0, i18n("Database connection test successful."), i18n("Database connection test"));
+    }
+    else
+    {
+        KMessageBox::error(0, i18n("Database connection test was not successful. <p>Error was: %1</p>",
+                                   testDatabase.lastError().text()), i18n("Database connection test") );
+    }
+
+    testDatabase.close();
+    QSqlDatabase::removeDatabase(databaseID);
+}
+
+
+
 void DatabaseWidget::checkDBPath()
 {
-//    bool dbOk          = false;
-//    bool pathUnchanged = true;
-    QString newPath    = databasePathEdit->url().toLocalFile();
+    QString newPath = imgDatabasePathEdit->url().toLocalFile();
 
-    if (!databasePathEdit->url().path().isEmpty())
+    if (!imgDatabasePathEdit->url().path().isEmpty())
     {
         QDir dbDir(newPath);
-        QDir oldDir(originalDbPath);
-//        dbOk          = dbDir.exists();
-//        pathUnchanged = (dbDir == oldDir);
+        QDir oldDir(imgOriginalDbPath);
     }
 
-    //TODO create an Enable button slot, if the path is vald
-    //d->mainDialog->enableButtonOk(dbOk);
+    newPath = tmbDatabasePathEdit->url().toLocalFile();
+
+    if (!tmbDatabasePathEdit->url().path().isEmpty())
+    {
+        QDir dbDir(newPath);
+        QDir oldDir(tmbOriginalDbPath);
+    }
 }
 
 void DatabaseWidget::setParametersFromSettings(const AlbumSettings* settings)
 {
-    originalDbPath = settings->getDatabaseFilePath();
-    originalDbType = settings->getDatabaseType();
-    databasePathEdit->setUrl(settings->getDatabaseFilePath());
 
 #ifdef HAVE_INTERNALMYSQL
     internalServer->setChecked(settings->getInternalDatabaseServer());
 #else
     internalServer->setChecked(false);
-#endif // HAVE_INTERNALMYSQL
-    databaseName->setText(settings->getDatabaseName());
-    databaseNameThumbnails->setText(settings->getDatabaseNameThumbnails());
-    hostName->setText(settings->getDatabaseHostName());
-    hostPort->setValue(settings->getDatabasePort());
-    connectionOptions->setText(settings->getDatabaseConnectoptions());
+#endif
+
+    imgOriginalDbPath = settings->getImgDatabaseFilePath();
+    imgOriginalDbType = settings->getImgDatabaseType();
+    imgDatabasePathEdit->setUrl(settings->getImgDatabaseFilePath());
+
+    imgDatabaseName->setText(settings->getImgDatabaseName());
+    imgHostName->setText(settings->getImgDatabaseHostName());
+    imgHostPort->setValue(settings->getImgDatabasePort());
+    imgConnectionOptions->setText(settings->getImgDatabaseConnectoptions());
+
+    imgUserName->setText(settings->getImgDatabaseUserName());
+
+    imgPassword->setText(settings->getImgDatabasePassword());
+
 
-    userName->setText(settings->getDatabaseUserName());
+    tmbOriginalDbPath = settings->getTmbDatabaseFilePath();
+    tmbOriginalDbType = settings->getTmbDatabaseType();
+    tmbDatabasePathEdit->setUrl(settings->getTmbDatabaseFilePath());
+
+    tmbDatabaseName->setText(settings->getTmbDatabaseName());
+    tmbHostName->setText(settings->getTmbDatabaseHostName());
+    tmbHostPort->setValue(settings->getTmbDatabasePort());
+    tmbConnectionOptions->setText(settings->getTmbDatabaseConnectoptions());
+
+    tmbUserName->setText(settings->getTmbDatabaseUserName());
+
+    tmbPassword->setText(settings->getTmbDatabasePassword());
 
-    password->setText(settings->getDatabasePassword());
 
     /* Now set the type according the database type from the settings.
      * If no item is found, ignore the setting.
      */
-    for (int i=0; i<databaseType->count(); ++i)
+    for (int i=0; i<imgDatabaseType->count(); ++i)
+    {
+        //kDebug(50003) << "Comparing comboboxentry on index ["<< i <<"] [" << imgDatabaseType->itemData(i)
+        //            << "] with ["<< settings->getImgDatabaseType() << "]";
+        if (imgDatabaseType->itemData(i).toString() == settings->getImgDatabaseType())
+        {
+            imgDatabaseType->setCurrentIndex(i);
+        }
+    }
+    for (int i=0; i<tmbDatabaseType->count(); ++i)
     {
-        //kDebug(50003) << "Comparing comboboxentry on index ["<< i <<"] [" << databaseType->itemData(i)
-        //            << "] with ["<< settings->getDatabaseType() << "]";
-        if (databaseType->itemData(i).toString() == settings->getDatabaseType())
+        if (tmbDatabaseType->itemData(i).toString() == settings->getTmbDatabaseType())
         {
-            databaseType->setCurrentIndex(i);
+            tmbDatabaseType->setCurrentIndex(i);
         }
     }
 }
@@ -355,30 +550,46 @@ DatabaseParameters DatabaseWidget::getDatabaseParameters()
 {
     DatabaseParameters parameters;
 
-    if (currentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()) || !internalServer->isChecked())
+#ifdef HAVE_INTERNALMYSQL
+    if (internalServer->isChecked()) {
+        parameters = DatabaseParameters::defaultParameters(imgCurrentDatabaseType(), true);
+        DatabaseServerStarter::startServerManagerProcess(imgCurrentDatabaseType());
+        return parameters;
+    }
+#endif // HAVE_INTERNALMYSQL
+
+    parameters = DatabaseParameters::defaultParameters(imgCurrentDatabaseType(), false);
+
+    parameters.imgConnectOptions = imgConnectionOptions->text();
+    parameters.imgDatabaseType   = imgCurrentDatabaseType();
+    parameters.imgHostName       = imgHostName->text();
+    parameters.imgPassword       = imgPassword->text();
+    parameters.imgPort           = imgHostPort->text().toInt();
+    parameters.imgUserName       = imgUserName->text();
+
+    if (parameters.imgDatabaseType == QString(DatabaseParameters::SQLiteDatabaseType()))
     {
-        parameters.connectOptions = connectionOptions->text();
-        parameters.databaseType   = currentDatabaseType();
-        parameters.hostName       = hostName->text();
-        parameters.password       = password->text();
-        parameters.port           = hostPort->text().toInt();
-        parameters.userName       = userName->text();
-
-        if (parameters.databaseType == QString(DatabaseParameters::SQLiteDatabaseType()))
-        {
-            parameters.databaseName = QDir::cleanPath(databasePathEdit->url().toLocalFile() + '/' + "digikam4.db");
-            parameters.databaseNameThumbnails = parameters.databaseName;
-        }
-        else
-        {
-            parameters.databaseName = databaseName->text();
-            parameters.databaseNameThumbnails = databaseNameThumbnails->text();
-        }
+        parameters.imgDatabaseName = QDir::cleanPath(imgDatabasePathEdit->url().toLocalFile() + '/' + DIGIKAM4DB);
+    }
+    else
+    {
+        parameters.imgDatabaseName = imgDatabaseName->text();
+    }
+
+    parameters.tmbConnectOptions = tmbConnectionOptions->text();
+    parameters.tmbDatabaseType   = tmbCurrentDatabaseType();
+    parameters.tmbHostName       = tmbHostName->text();
+    parameters.tmbPassword       = tmbPassword->text();
+    parameters.tmbPort           = tmbHostPort->text().toInt();
+    parameters.tmbUserName       = tmbUserName->text();
+
+    if (parameters.tmbDatabaseType == QString(DatabaseParameters::SQLiteDatabaseType()))
+    {
+        parameters.tmbDatabaseName = QDir::cleanPath(tmbDatabasePathEdit->url().toLocalFile() + '/' + THUMBNAILS_DIGIKAMDB);
     }
     else
     {
-        parameters = DatabaseParameters::defaultParameters(currentDatabaseType());
-        DatabaseServerStarter::startServerManagerProcess(currentDatabaseType());
+        parameters.tmbDatabaseName = tmbDatabaseName->text();
     }
 
     return parameters;
diff --git a/libs/widgets/common/databasewidget.h b/libs/widgets/common/databasewidget.h
index a19fc74..b5139b0 100644
--- a/libs/widgets/common/databasewidget.h
+++ b/libs/widgets/common/databasewidget.h
@@ -41,6 +41,7 @@
 
 // Local includes
 
+#include "config-digikam.h"
 #include "albumsettings.h"
 #include "databaseparameters.h"
 
@@ -53,46 +54,66 @@ class DatabaseWidget : public QWidget
 
 public:
 
-    DatabaseWidget(QWidget* parent = 0);
+    DatabaseWidget(QWidget* parent = 0, const QString & title = QString(""));
     ~DatabaseWidget();
 
 public:
 
-    QString        originalDbPath;
-    QString        originalDbType;
-    QComboBox*     databaseType;
     QCheckBox*     internalServer;
-    QSpinBox*      hostPort;
 
-    QLineEdit*     databaseName;
-    QLineEdit*     databaseNameThumbnails;
-    QLineEdit*     hostName;
-    QLineEdit*     connectionOptions;
-    QLineEdit*     userName;
-    QLineEdit*     password;
+    QString        imgOriginalDbPath;
+    QString        imgOriginalDbType;
+    QComboBox*     imgDatabaseType;
+    QSpinBox*      imgHostPort;
 
-    KUrlRequester* databasePathEdit;
+    QLineEdit*     imgDatabaseName;
+    QLineEdit*     imgHostName;
+    QLineEdit*     imgConnectionOptions;
+    QLineEdit*     imgUserName;
+    QLineEdit*     imgPassword;
+
+    QString        tmbOriginalDbPath;
+    QString        tmbOriginalDbType;
+    QComboBox*     tmbDatabaseType;
+    QSpinBox*      tmbHostPort;
+
+    QLineEdit*     tmbDatabaseName;
+    QLineEdit*     tmbHostName;
+    QLineEdit*     tmbConnectionOptions;
+    QLineEdit*     tmbUserName;
+    QLineEdit*     tmbPassword;
+
+    KUrlRequester* imgDatabasePathEdit;
+    KUrlRequester* tmbDatabasePathEdit;
 
 public:
 
     void setParametersFromSettings(const AlbumSettings* settings);
     DatabaseParameters getDatabaseParameters();
 
-    QString currentDatabaseType() const;
-    void setDatabaseInputFields(const QString&);
+    QString imgCurrentDatabaseType() const;
+    QString tmbCurrentDatabaseType() const;
+    void setImgDatabaseInputFields(const QString&);
+    void setTmbDatabaseInputFields(const QString&);
 
 public Q_SLOTS:
 
-    void slotChangeDatabasePath(const KUrl&);
-    void slotDatabasePathEdited(const QString&);
-    void slotHandleDBTypeIndexChanged(int index);
     void slotHandleInternalServerCheckbox(int enableFields);
-    void checkDatabaseConnection();
+
+    void slotImgChangeDatabasePath(const KUrl&);
+    void slotImgDatabasePathEdited(const QString&);
+    void slotImgHandleDBTypeIndexChanged(int index);
+    void slotImgCheckDatabaseConnection();
+
+    void slotTmbChangeDatabasePath(const KUrl&);
+    void slotTmbDatabasePathEdited(const QString&);
+    void slotTmbHandleDBTypeIndexChanged(int index);
+    void slotTmbCheckDatabaseConnection();
 
 private:
 
     void checkDBPath();
-    void setupMainArea();
+    void setupMainArea(const QString & title);
 
 private:
 
diff --git a/utilities/nepomuk/digikamnepomukservice.cpp b/utilities/nepomuk/digikamnepomukservice.cpp
index ecba2ef..194c57d 100644
--- a/utilities/nepomuk/digikamnepomukservice.cpp
+++ b/utilities/nepomuk/digikamnepomukservice.cpp
@@ -373,7 +373,7 @@ void NepomukService::connectToDatabase(const DatabaseParameters& params)
         if (!d->isConnected)
         {
             QString errorMsg = DatabaseAccess().lastError();
-            kDebug() << "Failed to initialize database" << params.databaseName;
+            kDebug() << "Failed to initialize database" << params.imgDatabaseName;
             return;
         }
     }
@@ -1203,7 +1203,7 @@ DatabaseParameters NepomukService::databaseParameters() const
     KSharedConfig::Ptr config = digikamConfig();
     DatabaseParameters params = DatabaseParameters::parametersFromConfig(config);
 
-    if (!params.databaseName.isEmpty())
+    if (!params.imgDatabaseName.isEmpty())
     {
         kDebug() << "Using database path from config file:" << params;
         return params;
diff --git a/utilities/setup/setupdatabase.cpp b/utilities/setup/setupdatabase.cpp
index b9fbea5..aa350bc 100644
--- a/utilities/setup/setupdatabase.cpp
+++ b/utilities/setup/setupdatabase.cpp
@@ -152,53 +152,84 @@ void SetupDatabase::applySettings()
     {
         return;
     }
+    
+    if (d->databaseWidget->internalServer->isChecked())
+    {
+        DatabaseParameters internalServerParameters = \
+            DatabaseParameters::defaultParameters(d->databaseWidget->imgCurrentDatabaseType(), true);
+        settings->setInternalDatabaseServer(true);
+
+        settings->setImgDatabaseType(d->databaseWidget->imgCurrentDatabaseType());
+        settings->setImgDatabaseName(internalServerParameters.imgDatabaseName);
+        settings->setImgDatabaseConnectoptions(internalServerParameters.imgConnectOptions);
+        settings->setImgDatabaseHostName(internalServerParameters.imgHostName);
+        settings->setImgDatabasePort(internalServerParameters.imgPort);
+        settings->setImgDatabaseUserName(internalServerParameters.imgUserName);
+        settings->setImgDatabasePassword(internalServerParameters.imgPassword);
+
+        settings->setTmbDatabaseType(d->databaseWidget->tmbCurrentDatabaseType());
+        settings->setTmbDatabaseName(internalServerParameters.tmbDatabaseName);
+        settings->setTmbDatabaseConnectoptions(internalServerParameters.tmbConnectOptions);
+        settings->setTmbDatabaseHostName(internalServerParameters.tmbHostName);
+        settings->setTmbDatabasePort(internalServerParameters.tmbPort);
+        settings->setTmbDatabaseUserName(internalServerParameters.tmbUserName);
+        settings->setTmbDatabasePassword(internalServerParameters.tmbPassword);
+
+        settings->saveSettings();
+
+        return;
+    }
 
-    if (d->databaseWidget->currentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()))
+    // clear internal database server
+    settings->setInternalDatabaseServer(false);
+    d->databaseWidget->internalServer->setChecked(false);
+
+    if (d->databaseWidget->imgCurrentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()))
     {
-        QString newPath = d->databaseWidget->databasePathEdit->url().path();
-        QDir oldDir(d->databaseWidget->originalDbPath);
+        QString newPath = d->databaseWidget->imgDatabasePathEdit->url().path();
+        QDir oldDir(d->databaseWidget->imgOriginalDbPath);
         QDir newDir(newPath);
 
-        if (oldDir != newDir || d->databaseWidget->currentDatabaseType() != d->databaseWidget->originalDbType)
+        if (oldDir != newDir || d->databaseWidget->imgCurrentDatabaseType() != d->databaseWidget->imgOriginalDbType)
         {
             settings->setDatabaseParameters(DatabaseParameters::parametersForSQLiteDefaultFile(newPath));
-
-            // clear other fields
-            d->databaseWidget->internalServer->setChecked(false);
-
-            settings->saveSettings();
         }
     }
     else
     {
-        if (d->databaseWidget->internalServer->isChecked())
-        {
-            DatabaseParameters internalServerParameters = DatabaseParameters::defaultParameters(d->databaseWidget->currentDatabaseType());
-            settings->setInternalDatabaseServer(true);
-            settings->setDatabaseType(d->databaseWidget->currentDatabaseType());
-            settings->setDatabaseName(internalServerParameters.databaseName);
-            settings->setDatabaseNameThumbnails(internalServerParameters.databaseName);
-            settings->setDatabaseConnectoptions(internalServerParameters.connectOptions);
-            settings->setDatabaseHostName(internalServerParameters.hostName);
-            settings->setDatabasePort(internalServerParameters.port);
-            settings->setDatabaseUserName(internalServerParameters.userName);
-            settings->setDatabasePassword(internalServerParameters.password);
-        }
-        else
+        settings->setImgDatabaseType(d->databaseWidget->imgCurrentDatabaseType());
+        settings->setImgDatabaseName(d->databaseWidget->imgDatabaseName->text());
+        settings->setImgDatabaseConnectoptions(d->databaseWidget->imgConnectionOptions->text());
+        settings->setImgDatabaseHostName(d->databaseWidget->imgHostName->text());
+        settings->setImgDatabasePort(d->databaseWidget->imgHostPort->text().toInt());
+        settings->setImgDatabaseUserName(d->databaseWidget->imgUserName->text());
+        settings->setImgDatabasePassword(d->databaseWidget->imgPassword->text());
+    }
+
+    if (d->databaseWidget->tmbCurrentDatabaseType() == QString(DatabaseParameters::SQLiteDatabaseType()))
+    {
+        QString newPath = d->databaseWidget->tmbDatabasePathEdit->url().path();
+        QDir oldDir(d->databaseWidget->tmbOriginalDbPath);
+        QDir newDir(newPath);
+
+        if (oldDir != newDir || d->databaseWidget->tmbCurrentDatabaseType() != d->databaseWidget->tmbOriginalDbType)
         {
-            settings->setInternalDatabaseServer(d->databaseWidget->internalServer->isChecked());
-            settings->setDatabaseType(d->databaseWidget->currentDatabaseType());
-            settings->setDatabaseName(d->databaseWidget->databaseName->text());
-            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());
-            settings->setDatabaseUserName(d->databaseWidget->userName->text());
-            settings->setDatabasePassword(d->databaseWidget->password->text());
+            settings->setDatabaseParameters(DatabaseParameters::parametersForSQLiteDefaultFile(newPath));
         }
-
-        settings->saveSettings();
     }
+    else
+    {
+        settings->setTmbDatabaseType(d->databaseWidget->tmbCurrentDatabaseType());
+        settings->setTmbDatabaseName(d->databaseWidget->tmbDatabaseName->text());
+        settings->setTmbDatabaseConnectoptions(d->databaseWidget->tmbConnectionOptions->text());
+        settings->setTmbDatabaseHostName(d->databaseWidget->tmbHostName->text());
+        settings->setTmbDatabasePort(d->databaseWidget->tmbHostPort->text().toInt());
+        settings->setTmbDatabaseUserName(d->databaseWidget->tmbUserName->text());
+        settings->setTmbDatabasePassword(d->databaseWidget->tmbPassword->text());
+    }
+
+
+    settings->saveSettings();
 }
 
 void SetupDatabase::readSettings()


More information about the kde-doc-english mailing list