Commit 45fd5ccc authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Maintenance tool : add Metadata synchronization option to be able to update...

Maintenance tool : add Metadata synchronization option to be able to update from image metadata to DB or from DB to image metadata.
BUGS: 306246
parent 95a8f469
......@@ -1255,7 +1255,7 @@ IF(DIGIKAM_CAN_BE_COMPILED)
SET(libeditorgui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/utilities/imageeditor/main/imagewindow.cpp
)
SET(libmaintenance_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/imageinfojob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/imageinfoalbumsjob.cpp
......@@ -1268,6 +1268,7 @@ IF(DIGIKAM_CAN_BE_COMPILED)
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/maintenancedlg.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/maintenancemngr.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/maintenancetool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utilities/maintenance/maintenancesettings.cpp
)
SET(libdatabasecore_SRCS
......
......@@ -44,5 +44,5 @@ BUGFIXES FROM KDE BUGZILLA (alias B.K.O | http://bugs.kde.org):
034 ==> 295255 - Running maintenance twice results in error.
035 ==> 320121 - if running maintenance, "rebuild thumbnails", digiKam hangs endlessly.
036 ==> 306282 - Improvements for maintenance tool.
037 ==>
037 ==> 306246 - Add new maintainance option to update DB using image metadata.
038 ==>
......@@ -42,7 +42,7 @@
#include <kiconloader.h>
#include <kstandarddirs.h>
#include <knuminput.h>
#include <khbox.h>
#include <kvbox.h>
#include <kseparator.h>
#include <kconfig.h>
......@@ -50,6 +50,7 @@
#include "setup.h"
#include "facescansettings.h"
#include "metadatasynchronizer.h"
using namespace KDcrawIface;
......@@ -79,9 +80,10 @@ public:
scanThumbs(0),
scanFingerPrints(0),
metadataSetup(0),
syncDirection(0),
faceScannedHandling(0),
hbox(0),
hbox2(0),
vbox(0),
hbox3(0),
similarity(0),
expanderBox(0)
......@@ -97,6 +99,7 @@ public:
static const QString configDuplicates;
static const QString configSimilarity;
static const QString configMetadata;
static const QString configSyncDirection;
static const QString configFaceDetection;
static const QString configFaceScannedHandling;
......@@ -105,9 +108,10 @@ public:
QCheckBox* scanThumbs;
QCheckBox* scanFingerPrints;
QPushButton* metadataSetup;
QComboBox* syncDirection;
QComboBox* faceScannedHandling;
KHBox* hbox;
KHBox* hbox2;
KVBox* vbox;
KHBox* hbox3;
KIntNumInput* similarity;
RExpanderBox* expanderBox;
......@@ -122,6 +126,7 @@ const QString MaintenanceDlg::Private::configScanFingerPrints("ScanFingerPrints"
const QString MaintenanceDlg::Private::configDuplicates("Duplicates");
const QString MaintenanceDlg::Private::configSimilarity("Similarity");
const QString MaintenanceDlg::Private::configMetadata("Metadata");
const QString MaintenanceDlg::Private::configSyncDirection("SyncDirection");
const QString MaintenanceDlg::Private::configFaceDetection("FaceDetection");
const QString MaintenanceDlg::Private::configFaceScannedHandling("FaceScannedHandling");
......@@ -182,13 +187,22 @@ MaintenanceDlg::MaintenanceDlg(QWidget* const parent)
// --------------------------------------------------------------------------------------
d->hbox2 = new KHBox;
new QLabel(i18n("Check metadata setup panel for details: "), d->hbox2);
QWidget* const space2 = new QWidget(d->hbox2);
d->hbox2->setStretchFactor(space2, 10);
d->metadataSetup = new QPushButton(i18n("Settings..."), d->hbox2);
d->expanderBox->insertItem(Private::Metadata, d->hbox2, SmallIcon("run-build-file"),
i18n("Sync image metadata with Database"), "Metadata", false);
d->vbox = new KVBox;
KHBox* const hbox21 = new KHBox(d->vbox);
new QLabel(i18n("Sync Direction: "), hbox21);
QWidget* const space4 = new QWidget(hbox21);
hbox21->setStretchFactor(space4, 10);
d->syncDirection = new QComboBox(hbox21);
d->syncDirection->addItem(i18n("From database to image metadata"), MetadataSynchronizer::WriteFromDatabaseToFile);
d->syncDirection->addItem(i18n("From image metadata to database"), MetadataSynchronizer::ReadFromFileToDatabase);
KHBox* const hbox22 = new KHBox(d->vbox);
new QLabel(i18n("Check metadata setup panel for details: "), hbox22);
QWidget* const space2 = new QWidget(hbox22);
hbox22->setStretchFactor(space2, 10);
d->metadataSetup = new QPushButton(i18n("Settings..."), hbox22);
d->expanderBox->insertItem(Private::Metadata, d->vbox, SmallIcon("run-build-file"),
i18n("Sync Metadata and Database"), "Metadata", false);
d->expanderBox->setCheckBoxVisible(Private::Metadata, true);
// --------------------------------------------------------------------------------------
......@@ -196,7 +210,7 @@ MaintenanceDlg::MaintenanceDlg(QWidget* const parent)
d->hbox3 = new KHBox;
new QLabel(i18n("Faces data management: "), d->hbox3);
QWidget* const space3 = new QWidget(d->hbox3);
d->hbox2->setStretchFactor(space3, 10);
d->hbox3->setStretchFactor(space3, 10);
d->faceScannedHandling = new QComboBox(d->hbox3);
d->faceScannedHandling->addItem(i18n("Skip images already scanned"), FaceScanSettings::Skip);
d->faceScannedHandling->addItem(i18n("Scan again and merge results"), FaceScanSettings::Merge);
......@@ -255,6 +269,7 @@ MaintenanceSettings MaintenanceDlg::settings() const
prm.duplicates = d->expanderBox->isChecked(Private::Duplicates);
prm.similarity = d->similarity->value();
prm.metadata = d->expanderBox->isChecked(Private::Metadata);
prm.syncDirection = d->syncDirection->currentIndex();
prm.faceDetection = d->expanderBox->isChecked(Private::FaceDetection);
prm.faceSettings.alreadyScannedHandling = (FaceScanSettings::AlreadyScannedHandling)d->faceScannedHandling->currentIndex();
return prm;
......@@ -276,6 +291,7 @@ void MaintenanceDlg::readSettings()
d->expanderBox->setChecked(Private::Duplicates, group.readEntry(d->configDuplicates, prm.duplicates));
d->similarity->setValue(group.readEntry(d->configSimilarity, prm.similarity));
d->expanderBox->setChecked(Private::Metadata, group.readEntry(d->configMetadata, prm.metadata));
d->syncDirection->setCurrentIndex(group.readEntry(d->configSyncDirection, prm.syncDirection));
d->expanderBox->setChecked(Private::FaceDetection, group.readEntry(d->configFaceDetection, prm.faceDetection));
d->faceScannedHandling->setCurrentIndex(group.readEntry(d->configFaceScannedHandling, (int)prm.faceSettings.alreadyScannedHandling));
......@@ -301,6 +317,7 @@ void MaintenanceDlg::writeSettings()
group.writeEntry(d->configDuplicates, prm.duplicates);
group.writeEntry(d->configSimilarity, prm.similarity);
group.writeEntry(d->configMetadata, prm.metadata);
group.writeEntry(d->configSyncDirection, prm.syncDirection);
group.writeEntry(d->configFaceDetection, prm.faceDetection);
group.writeEntry(d->configFaceScannedHandling, (int)prm.faceSettings.alreadyScannedHandling);
}
......@@ -322,7 +339,7 @@ void MaintenanceDlg::slotItemToggled(int index, bool b)
break;
case Private::Metadata:
d->hbox2->setEnabled(b);
d->vbox->setEnabled(b);
break;
case Private::FaceDetection:
......
......@@ -102,16 +102,7 @@ bool MaintenanceMngr::isRunning() const
void MaintenanceMngr::setSettings(const MaintenanceSettings& settings)
{
d->settings = settings;
kDebug() << "settings.newItems : " << d->settings.newItems;
kDebug() << "settings.thumbnails : " << d->settings.thumbnails;
kDebug() << "settings.scanThumbs : " << d->settings.scanThumbs;
kDebug() << "settings.fingerPrints : " << d->settings.fingerPrints;
kDebug() << "settings.scanFingerPrints : " << d->settings.scanFingerPrints;
kDebug() << "settings.duplicates : " << d->settings.duplicates;
kDebug() << "settings.similarity : " << d->settings.similarity;
kDebug() << "settings.metadata : " << d->settings.metadata;
kDebug() << "settings.facedetection : " << d->settings.faceDetection;
kDebug() << "settings.faceScannedHandling : " << d->settings.faceSettings.alreadyScannedHandling;
kDebug() << d->settings;
d->duration.start();
stage1();
......@@ -126,32 +117,32 @@ void MaintenanceMngr::slotToolCompleted(ProgressItem* tool)
if (tool == dynamic_cast<ProgressItem*>(d->newItemsFinder))
{
d->newItemsFinder = 0;
stage2();
stage2();
}
else if (tool == dynamic_cast<ProgressItem*>(d->thumbsGenerator))
{
d->thumbsGenerator = 0;
stage3();
stage3();
}
else if (tool == dynamic_cast<ProgressItem*>(d->fingerPrintsGenerator))
{
d->fingerPrintsGenerator = 0;
stage4();
stage4();
}
else if (tool == dynamic_cast<ProgressItem*>(d->duplicatesFinder))
{
d->duplicatesFinder = 0;
stage5();
stage5();
}
else if (tool == dynamic_cast<ProgressItem*>(d->metadataSynchronizer))
{
d->metadataSynchronizer = 0;
stage6();
stage6();
}
else if (tool == dynamic_cast<ProgressItem*>(d->faceDetector))
{
d->faceDetector = 0;
done();
done();
}
}
......@@ -164,7 +155,7 @@ void MaintenanceMngr::slotToolCanceled(ProgressItem* tool)
tool == dynamic_cast<ProgressItem*>(d->metadataSynchronizer) ||
tool == dynamic_cast<ProgressItem*>(d->faceDetector))
{
cancel();
cancel();
}
}
......@@ -187,7 +178,7 @@ void MaintenanceMngr::stage1()
void MaintenanceMngr::stage2()
{
kDebug() << "stage2";
if (d->settings.thumbnails)
{
bool rebuildAll = (d->settings.scanThumbs == false);
......@@ -240,7 +231,7 @@ void MaintenanceMngr::stage5()
if (d->settings.metadata)
{
d->metadataSynchronizer = new MetadataSynchronizer(MetadataSynchronizer::WriteFromDatabaseToFile);
d->metadataSynchronizer = new MetadataSynchronizer(MetadataSynchronizer::SyncDirection(d->settings.syncDirection));
d->metadataSynchronizer->setNotificationEnabled(false);
d->metadataSynchronizer->start();
}
......@@ -253,7 +244,7 @@ void MaintenanceMngr::stage5()
void MaintenanceMngr::stage6()
{
kDebug() << "stage6";
if (d->settings.faceDetection)
{
d->faceDetector = new FaceDetector(d->settings.faceSettings);
......
......@@ -24,9 +24,14 @@
#ifndef MAINTENANCESETTINGS_H
#define MAINTENANCESETTINGS_H
// Qt includes
#include <QDebug>
// Local includes
#include "facescansettings.h"
#include "metadatasynchronizer.h"
namespace Digikam
{
......@@ -36,22 +41,8 @@ class MaintenanceSettings
public:
MaintenanceSettings()
{
newItems = false;
thumbnails = false;
scanThumbs = false;
fingerPrints = false;
scanFingerPrints = false;
duplicates = false;
similarity = 90;
metadata = false;
faceDetection = false;
};
virtual ~MaintenanceSettings()
{
};
MaintenanceSettings();
virtual ~MaintenanceSettings();
public:
......@@ -73,8 +64,10 @@ public:
/// Similarity between items to compare, in percents.
int similarity;
/// Sync image metadata with DB
/// Sync metadata and DB
bool metadata;
/// Sync direction (image metadata <-> DB)
int syncDirection;
/// Scan for faces
bool faceDetection;
......@@ -82,6 +75,9 @@ public:
FaceScanSettings faceSettings;
};
//! kDebug() stream operator. Writes property @a s to the debug output in a nicely formatted way.
QDebug operator<<(QDebug dbg, const MaintenanceSettings& s);
} // namespace Digikam
#endif // MAINTENANCESETTINGS_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment