summaryrefslogtreecommitdiffstats
path: root/src/utilities/batch
diff options
context:
space:
mode:
Diffstat (limited to 'src/utilities/batch')
-rw-r--r--src/utilities/batch/CMakeLists.txt17
-rw-r--r--src/utilities/batch/batchalbumssyncmetadata.cpp183
-rw-r--r--src/utilities/batch/batchalbumssyncmetadata.h82
-rw-r--r--src/utilities/batch/batchsyncmetadata.cpp166
-rw-r--r--src/utilities/batch/batchsyncmetadata.h89
-rw-r--r--src/utilities/batch/batchthumbsgenerator.cpp233
-rw-r--r--src/utilities/batch/batchthumbsgenerator.h83
-rw-r--r--src/utilities/batch/imageinfoalbumsjob.cpp125
-rw-r--r--src/utilities/batch/imageinfoalbumsjob.h80
-rw-r--r--src/utilities/batch/imageinfojob.cpp163
-rw-r--r--src/utilities/batch/imageinfojob.h78
11 files changed, 1299 insertions, 0 deletions
diff --git a/src/utilities/batch/CMakeLists.txt b/src/utilities/batch/CMakeLists.txt
new file mode 100644
index 00000000..82ed9611
--- /dev/null
+++ b/src/utilities/batch/CMakeLists.txt
@@ -0,0 +1,17 @@
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/src/libs/dialogs
+ ${CMAKE_SOURCE_DIR}/src/libs/thumbbar
+ ${CMAKE_SOURCE_DIR}/src/libs/widgets/common
+)
+
+
+##### batch library (static)
+
+tde_add_library( batch STATIC_PIC AUTOMOC
+ SOURCES
+ batchthumbsgenerator.cpp batchalbumssyncmetadata.cpp
+ imageinfojob.cpp imageinfoalbumsjob.cpp batchsyncmetadata.cpp
+ LINK
+ tdecore-shared
+)
diff --git a/src/utilities/batch/batchalbumssyncmetadata.cpp b/src/utilities/batch/batchalbumssyncmetadata.cpp
new file mode 100644
index 00000000..fab48652
--- /dev/null
+++ b/src/utilities/batch/batchalbumssyncmetadata.cpp
@@ -0,0 +1,183 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-22-01
+ * Description : batch sync pictures metadata from all Albums
+ * with digiKam database
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqtimer.h>
+#include <tqdatetime.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+#include <tdeapplication.h>
+#include <kiconloader.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "album.h"
+#include "albummanager.h"
+#include "imageinfojob.h"
+#include "metadatahub.h"
+#include "batchalbumssyncmetadata.h"
+#include "batchalbumssyncmetadata.moc"
+
+namespace Digikam
+{
+
+class BatchAlbumsSyncMetadataPriv
+{
+public:
+
+ BatchAlbumsSyncMetadataPriv()
+ {
+ cancel = false;
+ imageInfoJob = 0;
+ palbumList = AlbumManager::instance()->allPAlbums();
+ duration.start();
+ }
+
+ bool cancel;
+
+ TQTime duration;
+
+ ImageInfoJob *imageInfoJob;
+
+ AlbumList palbumList;
+ AlbumList::Iterator albumsIt;
+};
+
+BatchAlbumsSyncMetadata::BatchAlbumsSyncMetadata(TQWidget* parent)
+ : DProgressDlg(parent)
+{
+ d = new BatchAlbumsSyncMetadataPriv;
+ d->imageInfoJob = new ImageInfoJob();
+ setValue(0);
+ setCaption(i18n("Sync All Images' Metadata"));
+ setLabel(i18n("<b>Syncing the metadata of all images with the digiKam database. Please wait...</b>"));
+ setButtonText(i18n("&Abort"));
+ resize(600, 300);
+ TQTimer::singleShot(500, this, TQ_SLOT(slotStart()));
+}
+
+BatchAlbumsSyncMetadata::~BatchAlbumsSyncMetadata()
+{
+ delete d;
+}
+
+void BatchAlbumsSyncMetadata::slotStart()
+{
+ setTitle(i18n("Parsing all albums"));
+ setTotalSteps(d->palbumList.count());
+
+ connect(d->imageInfoJob, TQ_SIGNAL(signalItemsInfo(const ImageInfoList&)),
+ this, TQ_SLOT(slotAlbumParsed(const ImageInfoList&)));
+
+ connect(d->imageInfoJob, TQ_SIGNAL(signalCompleted()),
+ this, TQ_SLOT(slotComplete()));
+
+ d->albumsIt = d->palbumList.begin();
+ parseAlbum();
+}
+
+void BatchAlbumsSyncMetadata::parseAlbum()
+{
+ if (d->albumsIt == d->palbumList.end()) // All is done.
+ {
+ TQTime t;
+ t = t.addMSecs(d->duration.elapsed());
+ setLabel(i18n("<b>The metadata of all images has been synchronized with the digiKam database.</b>"));
+ setTitle(i18n("Duration: %1").arg(t.toString()));
+ setButtonText(i18n("&Close"));
+ advance(1);
+ abort();
+ }
+ else if (!(*d->albumsIt)->isRoot())
+ {
+ d->imageInfoJob->allItemsFromAlbum(*d->albumsIt);
+ DDebug() << "Sync Items from Album :" << (*d->albumsIt)->kurl().directory() << endl;
+ }
+ else
+ {
+ d->albumsIt++;
+ parseAlbum();
+ }
+}
+
+void BatchAlbumsSyncMetadata::slotAlbumParsed(const ImageInfoList& list)
+{
+ TQPixmap pix = tdeApp->iconLoader()->loadIcon(
+ "folder_image", TDEIcon::NoGroup, 32);
+
+ ImageInfoList imageInfoList = list;
+
+ if (!imageInfoList.isEmpty())
+ {
+ addedAction(pix, imageInfoList.first()->kurl().directory());
+
+ for (ImageInfo *info = imageInfoList.first(); info; info = imageInfoList.next())
+ {
+ MetadataHub fileHub;
+ // read in from database
+ fileHub.load(info);
+ // write out to file DMetadata
+ fileHub.write(info->filePath());
+ }
+ }
+
+ advance(1);
+ d->albumsIt++;
+ parseAlbum();
+}
+
+void BatchAlbumsSyncMetadata::slotComplete()
+{
+ advance(1);
+ d->albumsIt++;
+ parseAlbum();
+}
+
+void BatchAlbumsSyncMetadata::slotCancel()
+{
+ abort();
+ done(Cancel);
+}
+
+void BatchAlbumsSyncMetadata::closeEvent(TQCloseEvent *e)
+{
+ abort();
+ e->accept();
+}
+
+void BatchAlbumsSyncMetadata::abort()
+{
+ d->cancel = true;
+ d->imageInfoJob->stop();
+ emit signalComplete();
+}
+
+} // namespace Digikam
+
+
diff --git a/src/utilities/batch/batchalbumssyncmetadata.h b/src/utilities/batch/batchalbumssyncmetadata.h
new file mode 100644
index 00000000..8363ce4d
--- /dev/null
+++ b/src/utilities/batch/batchalbumssyncmetadata.h
@@ -0,0 +1,82 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-22-01
+ * Description : batch sync pictures metadata with
+ * digiKam database
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef BATCHALBUMSSYNCMETADATA_H
+#define BATCHALBUMSSYNCMETADATA_H
+
+// Local includes.
+
+#include "imageinfo.h"
+#include "dprogressdlg.h"
+
+class TQWidget;
+
+class KURL;
+
+namespace Digikam
+{
+
+class BatchAlbumsSyncMetadataPriv;
+
+class BatchAlbumsSyncMetadata : public DProgressDlg
+{
+ TQ_OBJECT
+
+
+public:
+
+ BatchAlbumsSyncMetadata(TQWidget* parent);
+ ~BatchAlbumsSyncMetadata();
+
+signals:
+
+ void signalComplete();
+
+private:
+
+ void abort();
+ void parseAlbum();
+
+protected:
+
+ void closeEvent(TQCloseEvent *e);
+
+protected slots:
+
+ void slotCancel();
+
+private slots:
+
+ void slotStart();
+ void slotAlbumParsed(const ImageInfoList&);
+ void slotComplete();
+
+private:
+
+ BatchAlbumsSyncMetadataPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* BATCHALBUMSSYNCMETADATA_H */
diff --git a/src/utilities/batch/batchsyncmetadata.cpp b/src/utilities/batch/batchsyncmetadata.cpp
new file mode 100644
index 00000000..a9403f10
--- /dev/null
+++ b/src/utilities/batch/batchsyncmetadata.cpp
@@ -0,0 +1,166 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-22-01
+ * Description : batch sync pictures metadata from all Albums
+ * with digiKam database
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqstring.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+#include <tdeapplication.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "album.h"
+#include "imageinfojob.h"
+#include "metadatahub.h"
+#include "statusprogressbar.h"
+#include "batchsyncmetadata.h"
+#include "batchsyncmetadata.moc"
+
+namespace Digikam
+{
+
+class BatchSyncMetadataPriv
+{
+public:
+
+ BatchSyncMetadataPriv()
+ {
+ cancel = false;
+ imageInfoJob = new ImageInfoJob();
+ album = 0;
+ count = 0;
+ imageInfo = 0;
+ }
+
+ bool cancel;
+
+ int count;
+
+ Album *album;
+
+ ImageInfoJob *imageInfoJob;
+
+ ImageInfoList imageInfoList;
+
+ ImageInfo *imageInfo;
+};
+
+BatchSyncMetadata::BatchSyncMetadata(TQObject* parent, Album *album)
+ : TQObject(parent)
+{
+ d = new BatchSyncMetadataPriv;
+ d->album = album;
+}
+
+BatchSyncMetadata::BatchSyncMetadata(TQObject* parent, const ImageInfoList& list)
+ : TQObject(parent)
+{
+ d = new BatchSyncMetadataPriv;
+ d->imageInfoList = list;
+}
+
+BatchSyncMetadata::~BatchSyncMetadata()
+{
+ delete d;
+}
+
+void BatchSyncMetadata::parseAlbum()
+{
+ d->imageInfoJob->allItemsFromAlbum(d->album);
+
+ connect(d->imageInfoJob, TQ_SIGNAL(signalItemsInfo(const ImageInfoList&)),
+ this, TQ_SLOT(slotAlbumParsed(const ImageInfoList&)));
+
+ connect(d->imageInfoJob, TQ_SIGNAL(signalCompleted()),
+ this, TQ_SLOT(slotComplete()));
+}
+
+void BatchSyncMetadata::slotComplete()
+{
+ if (d->imageInfoList.isEmpty())
+ complete();
+}
+
+void BatchSyncMetadata::slotAlbumParsed(const ImageInfoList& list)
+{
+ d->imageInfoList = list;
+ parseList();
+}
+
+void BatchSyncMetadata::parseList()
+{
+ emit signalProgressBarMode(StatusProgressBar::CancelProgressBarMode,
+ i18n("Synchonizing images' Metadata with database. Please wait..."));
+
+ d->imageInfo = d->imageInfoList.first();
+ parsePicture();
+}
+
+void BatchSyncMetadata::parsePicture()
+{
+ if (!d->imageInfo) // All is done.
+ {
+ complete();
+ slotAbort();
+ }
+ else if (d->cancel)
+ {
+ complete();
+ }
+ else
+ {
+ MetadataHub fileHub;
+ // read in from database
+ fileHub.load(d->imageInfo);
+ // write out to file DMetadata
+ fileHub.write(d->imageInfo->filePath());
+
+ emit signalProgressValue((int)((d->count++/(float)d->imageInfoList.count())*100.0));
+
+ d->imageInfo = d->imageInfoList.next();
+
+ tdeApp->processEvents();
+ parsePicture();
+ }
+}
+
+void BatchSyncMetadata::slotAbort()
+{
+ d->cancel = true;
+ d->imageInfoJob->stop();
+}
+
+void BatchSyncMetadata::complete()
+{
+ emit signalProgressBarMode(StatusProgressBar::TextMode, TQString());
+ emit signalComplete();
+}
+
+} // namespace Digikam
+
+
diff --git a/src/utilities/batch/batchsyncmetadata.h b/src/utilities/batch/batchsyncmetadata.h
new file mode 100644
index 00000000..c9b69ac7
--- /dev/null
+++ b/src/utilities/batch/batchsyncmetadata.h
@@ -0,0 +1,89 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-22-01
+ * Description : batch sync pictures metadata with
+ * digiKam database
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef BATCHSYNCMETADATA_H
+#define BATCHSYNCMETADATA_H
+
+// TQt includes.
+
+#include <tqobject.h>
+
+// Local includes.
+
+#include "imageinfo.h"
+
+class KURL;
+
+namespace Digikam
+{
+
+class Album;
+class BatchSyncMetadataPriv;
+
+class BatchSyncMetadata : public TQObject
+{
+ TQ_OBJECT
+
+
+public:
+
+ /** Constructor witch sync all metatada pictures from an Album */
+ BatchSyncMetadata(TQObject* parent, Album *album);
+
+ /** Constructor witch sync all metatada from an images list */
+ BatchSyncMetadata(TQObject* parent, const ImageInfoList& list);
+
+ ~BatchSyncMetadata();
+
+ void parseList();
+ void parseAlbum();
+
+signals:
+
+ void signalComplete();
+ void signalProgressValue(int);
+ void signalProgressBarMode(int, const TQString&);
+
+public slots:
+
+ void slotAbort();
+
+private:
+
+ void parsePicture();
+ void complete();
+
+private slots:
+
+ void slotAlbumParsed(const ImageInfoList&);
+ void slotComplete();
+
+private:
+
+ BatchSyncMetadataPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* BATCHSYNCMETADATA_H */
diff --git a/src/utilities/batch/batchthumbsgenerator.cpp b/src/utilities/batch/batchthumbsgenerator.cpp
new file mode 100644
index 00000000..f0bd0103
--- /dev/null
+++ b/src/utilities/batch/batchthumbsgenerator.cpp
@@ -0,0 +1,233 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-30-08
+ * Description : batch thumbnails generator
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// C Ansi includes.
+
+extern "C"
+{
+#include <unistd.h>
+}
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqtimer.h>
+#include <tqdir.h>
+#include <tqfileinfo.h>
+#include <tqdatetime.h>
+
+// KDE includes.
+
+#include <kmdcodec.h>
+#include <tdelocale.h>
+#include <tdeapplication.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "album.h"
+#include "albumdb.h"
+#include "albummanager.h"
+#include "albumsettings.h"
+#include "thumbnailjob.h"
+#include "batchthumbsgenerator.h"
+#include "batchthumbsgenerator.moc"
+
+namespace Digikam
+{
+
+class BatchThumbsGeneratorPriv
+{
+public:
+
+ BatchThumbsGeneratorPriv()
+ {
+ cancel = false;
+ thumbJob = 0;
+ duration.start();
+ }
+
+ bool cancel;
+
+ TQTime duration;
+
+ TQGuardedPtr<ThumbnailJob> thumbJob;
+};
+
+BatchThumbsGenerator::BatchThumbsGenerator(TQWidget* parent)
+ : DProgressDlg(parent)
+{
+ d = new BatchThumbsGeneratorPriv;
+ setValue(0);
+ setCaption(i18n("Thumbnails processing"));
+ setLabel(i18n("<b>Updating thumbnails database. Please wait...</b>"));
+ setButtonText(i18n("&Abort"));
+ TQTimer::singleShot(500, this, TQ_SLOT(slotRebuildThumbs128()));
+ resize(600, 300);
+}
+
+BatchThumbsGenerator::~BatchThumbsGenerator()
+{
+ if (!d->thumbJob.isNull())
+ {
+ d->thumbJob->kill();
+ d->thumbJob = 0;
+ }
+
+ delete d;
+}
+
+void BatchThumbsGenerator::slotRebuildThumbs128()
+{
+ setTitle(i18n("Processing small thumbs"));
+ rebuildAllThumbs(128);
+
+ connect(this, TQ_SIGNAL(signalRebuildThumbsDone()),
+ this, TQ_SLOT(slotRebuildThumbs256()));
+}
+
+void BatchThumbsGenerator::slotRebuildThumbs256()
+{
+ setTitle(i18n("Processing large thumbs"));
+ rebuildAllThumbs(256);
+
+ disconnect(this, TQ_SIGNAL(signalRebuildThumbsDone()),
+ this, TQ_SLOT(slotRebuildThumbs256()));
+
+ connect(this, TQ_SIGNAL(signalRebuildThumbsDone()),
+ this, TQ_SLOT(slotRebuildAllThumbComplete()));
+}
+
+void BatchThumbsGenerator::slotRebuildAllThumbComplete()
+{
+ TQTime t;
+ t = t.addMSecs(d->duration.elapsed());
+ setLabel(i18n("<b>The thumbnails database has been updated.</b>"));
+ setTitle(i18n("Duration: %1").arg(t.toString()));
+ setButtonText(i18n("&Close"));
+}
+
+void BatchThumbsGenerator::rebuildAllThumbs(int size)
+{
+ TQStringList allPicturesPath;
+ TQString thumbCacheDir = TQDir::homeDirPath() + "/.thumbnails/";
+ TQString filesFilter = AlbumSettings::instance()->getAllFileFilter();
+ bool exifRotate = AlbumSettings::instance()->getExifRotate();
+ AlbumDB *db = AlbumManager::instance()->albumDB();
+ AlbumList palbumList = AlbumManager::instance()->allPAlbums();
+
+ // Get all digiKam albums collection pictures path.
+
+ for (AlbumList::Iterator it = palbumList.begin();
+ !d->cancel && (it != palbumList.end()); ++it )
+ {
+ // Don't use the root album
+ if ((*it)->isRoot())
+ continue;
+
+ db->beginTransaction();
+ TQStringList albumItemsPath = db->getItemURLsInAlbum((*it)->id());
+ db->commitTransaction();
+
+ TQStringList pathSorted;
+ for (TQStringList::iterator it2 = albumItemsPath.begin();
+ !d->cancel && (it2 != albumItemsPath.end()); ++it2)
+ {
+ TQFileInfo fi(*it2);
+ if (filesFilter.contains(fi.extension(false)))
+ pathSorted.append(*it2);
+ }
+
+ allPicturesPath += pathSorted;
+ }
+
+ setTotalSteps(allPicturesPath.count()*2);
+
+ // Remove all current album item thumbs from disk cache.
+
+ for (TQStringList::iterator it = allPicturesPath.begin();
+ !d->cancel && (it != allPicturesPath.end()); ++it)
+ {
+ TQString uri = "file://" + TQDir::cleanDirPath(*it);
+ KMD5 md5(TQFile::encodeName(uri).data());
+ uri = md5.hexDigest();
+
+ TQString smallThumbPath = thumbCacheDir + "normal/" + uri + ".png";
+ TQString bigThumbPath = thumbCacheDir + "large/" + uri + ".png";
+
+ if (size <= 128)
+ ::unlink(TQFile::encodeName(smallThumbPath));
+ else
+ ::unlink(TQFile::encodeName(bigThumbPath));
+ }
+
+ if (!d->thumbJob.isNull())
+ {
+ d->thumbJob->kill();
+ d->thumbJob = 0;
+ }
+
+ d->thumbJob = new ThumbnailJob(KURL::List(allPicturesPath), size, true, exifRotate);
+
+ connect(d->thumbJob, TQ_SIGNAL(signalThumbnail(const KURL&, const TQPixmap&)),
+ this, TQ_SLOT(slotRebuildThumbDone(const KURL&, const TQPixmap&)));
+
+ connect(d->thumbJob, TQ_SIGNAL(signalFailed(const KURL&)),
+ this, TQ_SLOT(slotRebuildThumbDone(const KURL&)));
+
+ connect(d->thumbJob, TQ_SIGNAL(signalCompleted()),
+ this, TQ_SIGNAL(signalRebuildThumbsDone()));
+}
+
+void BatchThumbsGenerator::slotRebuildThumbDone(const KURL& url, const TQPixmap& pix)
+{
+ addedAction(pix, url.path());
+ advance(1);
+}
+
+void BatchThumbsGenerator::slotCancel()
+{
+ abort();
+ done(Cancel);
+}
+
+void BatchThumbsGenerator::closeEvent(TQCloseEvent *e)
+{
+ abort();
+ e->accept();
+}
+
+void BatchThumbsGenerator::abort()
+{
+ d->cancel = true;
+
+ if (!d->thumbJob.isNull())
+ {
+ d->thumbJob->kill();
+ d->thumbJob = 0;
+ }
+
+ emit signalRebuildAllThumbsDone();
+}
+
+} // namespace Digikam
diff --git a/src/utilities/batch/batchthumbsgenerator.h b/src/utilities/batch/batchthumbsgenerator.h
new file mode 100644
index 00000000..091c2783
--- /dev/null
+++ b/src/utilities/batch/batchthumbsgenerator.h
@@ -0,0 +1,83 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-30-08
+ * Description : batch thumbnails generator
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef BATCHTHUMBSGENERATOR_H
+#define BATCHTHUMBSGENERATOR_H
+
+// Local includes.
+
+#include "dprogressdlg.h"
+
+class TQWidget;
+class TQPixmap;
+
+class KURL;
+
+namespace Digikam
+{
+
+class BatchThumbsGeneratorPriv;
+
+class BatchThumbsGenerator : public DProgressDlg
+{
+ TQ_OBJECT
+
+
+public:
+
+ BatchThumbsGenerator(TQWidget* parent);
+ ~BatchThumbsGenerator();
+
+signals:
+
+ void signalRebuildThumbsDone();
+ void signalRebuildAllThumbsDone();
+
+private:
+
+ void rebuildAllThumbs(int size);
+ void abort();
+
+protected:
+
+ void closeEvent(TQCloseEvent *e);
+
+protected slots:
+
+ void slotCancel();
+
+private slots:
+
+ void slotRebuildThumbs128();
+ void slotRebuildThumbs256();
+ void slotRebuildThumbDone(const KURL& url, const TQPixmap& pix=TQPixmap());
+ void slotRebuildAllThumbComplete();
+
+private:
+
+ BatchThumbsGeneratorPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* BATCHTHUMBSGENERATOR_H */
diff --git a/src/utilities/batch/imageinfoalbumsjob.cpp b/src/utilities/batch/imageinfoalbumsjob.cpp
new file mode 100644
index 00000000..4d0e3c55
--- /dev/null
+++ b/src/utilities/batch/imageinfoalbumsjob.cpp
@@ -0,0 +1,125 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-14-02
+ * Description : interface to get image info from an albums list.
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqstring.h>
+
+// KDE includes.
+
+#include <kurl.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "album.h"
+#include "albummanager.h"
+#include "imageinfojob.h"
+#include "imageinfoalbumsjob.h"
+#include "imageinfoalbumsjob.moc"
+
+namespace Digikam
+{
+
+class ImageInfoAlbumsJobPriv
+{
+public:
+
+ ImageInfoAlbumsJobPriv(){}
+
+ AlbumList albumsList;
+ AlbumList::Iterator albumIt;
+
+ ImageInfoList itemsList;
+
+ ImageInfoJob imageInfoJob;
+};
+
+ImageInfoAlbumsJob::ImageInfoAlbumsJob()
+{
+ d = new ImageInfoAlbumsJobPriv;
+
+ connect(&d->imageInfoJob, TQ_SIGNAL(signalItemsInfo(const ImageInfoList&)),
+ this, TQ_SLOT(slotItemsInfo(const ImageInfoList&)));
+
+ connect(&d->imageInfoJob, TQ_SIGNAL(signalCompleted()),
+ this, TQ_SLOT(slotComplete()));
+}
+
+ImageInfoAlbumsJob::~ImageInfoAlbumsJob()
+{
+ delete d;
+}
+
+void ImageInfoAlbumsJob::allItemsFromAlbums(const AlbumList& albumsList)
+{
+ if (albumsList.isEmpty())
+ return;
+
+ d->albumsList = albumsList;
+ d->albumIt = d->albumsList.begin();
+ parseAlbum();
+}
+
+void ImageInfoAlbumsJob::parseAlbum()
+{
+ d->imageInfoJob.allItemsFromAlbum(*d->albumIt);
+}
+
+void ImageInfoAlbumsJob::stop()
+{
+ d->imageInfoJob.stop();
+ d->albumsList.clear();
+}
+
+void ImageInfoAlbumsJob::slotItemsInfo(const ImageInfoList& items)
+{
+ ImageInfo* item;
+ for (ImageInfoListIterator it(items); (item = it.current()); ++it)
+ d->itemsList.append(item);
+
+ ++d->albumIt;
+ if (d->albumIt == d->albumsList.end())
+ {
+ stop();
+ emit signalCompleted(d->itemsList);
+ return;
+ }
+
+ parseAlbum();
+}
+
+void ImageInfoAlbumsJob::slotComplete()
+{
+ ++d->albumIt;
+ if (d->albumIt == d->albumsList.end())
+ {
+ stop();
+ emit signalCompleted(d->itemsList);
+ return;
+ }
+
+ parseAlbum();
+}
+
+} // namespace Digikam
diff --git a/src/utilities/batch/imageinfoalbumsjob.h b/src/utilities/batch/imageinfoalbumsjob.h
new file mode 100644
index 00000000..7b9f477f
--- /dev/null
+++ b/src/utilities/batch/imageinfoalbumsjob.h
@@ -0,0 +1,80 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-14-02
+ * Description : interface to get image info from an albums list.
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef IMAGEINFOALBUMSJOB_H
+#define IMAGEINFOALBUMSJOB_H
+
+// TQt includes.
+
+#include <tqobject.h>
+#include <tqcstring.h>
+
+// Local includes.
+
+#include "albummanager.h"
+#include "imageinfo.h"
+
+namespace TDEIO
+{
+class Job;
+}
+
+namespace Digikam
+{
+
+class ImageInfoAlbumsJobPriv;
+
+class ImageInfoAlbumsJob : public TQObject
+{
+ TQ_OBJECT
+
+
+public:
+
+ ImageInfoAlbumsJob();
+ ~ImageInfoAlbumsJob();
+
+ void allItemsFromAlbums(const AlbumList& albumsList);
+ void stop();
+
+signals:
+
+ void signalCompleted(const ImageInfoList& items);
+
+private slots:
+
+ void slotItemsInfo(const ImageInfoList&);
+ void slotComplete();
+
+private:
+
+ void parseAlbum();
+
+private:
+
+ ImageInfoAlbumsJobPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* IMAGEINFOALBUMSJOB_H */
diff --git a/src/utilities/batch/imageinfojob.cpp b/src/utilities/batch/imageinfojob.cpp
new file mode 100644
index 00000000..58660697
--- /dev/null
+++ b/src/utilities/batch/imageinfojob.cpp
@@ -0,0 +1,163 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-22-01
+ * Description : digikamalbum TDEIO slave interface to get image
+ * info from database.
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqdatastream.h>
+
+// KDE includes.
+
+#include <tdeio/job.h>
+#include <kurl.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "album.h"
+#include "albummanager.h"
+#include "albumsettings.h"
+#include "imageinfojob.h"
+#include "imageinfojob.moc"
+
+namespace Digikam
+{
+
+class ImageInfoJobPriv
+{
+public:
+
+ ImageInfoJobPriv()
+ {
+ job = 0;
+
+ AlbumSettings *settings = AlbumSettings::instance();
+ imagefilter = settings->getImageFileFilter().lower() +
+ settings->getImageFileFilter().upper() +
+ settings->getRawFileFilter().lower() +
+ settings->getRawFileFilter().upper();
+ }
+
+ TQString imagefilter;
+
+ TDEIO::TransferJob *job;
+};
+
+ImageInfoJob::ImageInfoJob()
+{
+ d = new ImageInfoJobPriv;
+}
+
+ImageInfoJob::~ImageInfoJob()
+{
+ delete d;
+}
+
+void ImageInfoJob::allItemsFromAlbum(Album *album)
+{
+ if (d->job)
+ {
+ d->job->kill();
+ d->job = 0;
+ }
+
+ if (!album)
+ return;
+
+ TQByteArray ba;
+ TQDataStream ds(ba, IO_WriteOnly);
+ ds << AlbumManager::instance()->getLibraryPath();
+ ds << album->kurl();
+ ds << d->imagefilter;
+ ds << 0; // getting dimensions (not needed here)
+ ds << 0; // recursive sub-album (not needed here)
+ ds << 0; // recursive sub-tags (not needed here)
+
+ // Protocol = digikamalbums -> tdeio_digikamalbums
+ d->job = new TDEIO::TransferJob(album->kurl(), TDEIO::CMD_SPECIAL,
+ ba, TQByteArray(), false);
+
+ connect(d->job, TQ_SIGNAL(result(TDEIO::Job*)),
+ this, TQ_SLOT(slotResult(TDEIO::Job*)));
+
+ connect(d->job, TQ_SIGNAL(data(TDEIO::Job*, const TQByteArray&)),
+ this, TQ_SLOT(slotData(TDEIO::Job*, const TQByteArray&)));
+}
+
+void ImageInfoJob::stop()
+{
+ if (d->job)
+ {
+ d->job->kill();
+ d->job = 0;
+ }
+}
+
+void ImageInfoJob::slotResult(TDEIO::Job* job)
+{
+ d->job = 0;
+
+ if (job->error())
+ {
+ DWarning() << "Failed to list url: " << job->errorString() << endl;
+ return;
+ }
+
+ emit signalCompleted();
+}
+
+void ImageInfoJob::slotData(TDEIO::Job*, const TQByteArray& data)
+{
+ if (data.isEmpty())
+ return;
+
+ TQ_LLONG imageID;
+ int albumID;
+ TQString name;
+ TQString date;
+ size_t size;
+ TQSize dims;
+ ImageInfoList itemsList;
+ TQDataStream ds(data, IO_ReadOnly);
+
+ while (!ds.atEnd())
+ {
+ ds >> imageID;
+ ds >> albumID;
+ ds >> name;
+ ds >> date;
+ ds >> size;
+ ds >> dims;
+
+ ImageInfo* info = new ImageInfo(imageID, albumID, name,
+ TQDateTime::fromString(date, TQt::ISODate),
+ size, dims);
+
+ itemsList.append(info);
+ }
+
+ emit signalItemsInfo(itemsList);
+}
+
+} // namespace Digikam
diff --git a/src/utilities/batch/imageinfojob.h b/src/utilities/batch/imageinfojob.h
new file mode 100644
index 00000000..0227a628
--- /dev/null
+++ b/src/utilities/batch/imageinfojob.h
@@ -0,0 +1,78 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-22-01
+ * Description : digikamalbum TDEIO slave interface to get image
+ * info from database.
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef IMAGEINFOJOB_H
+#define IMAGEINFOJOB_H
+
+// TQt includes.
+
+#include <tqobject.h>
+#include <tqcstring.h>
+
+// Local includes.
+
+#include "imageinfo.h"
+
+namespace TDEIO
+{
+class Job;
+}
+
+namespace Digikam
+{
+
+class Album;
+class ImageInfoJobPriv;
+
+class ImageInfoJob : public TQObject
+{
+ TQ_OBJECT
+
+
+public:
+
+ ImageInfoJob();
+ ~ImageInfoJob();
+
+ void allItemsFromAlbum(Album *album);
+ void stop();
+
+signals:
+
+ void signalItemsInfo(const ImageInfoList& items);
+ void signalCompleted();
+
+private slots:
+
+ void slotResult(TDEIO::Job* job);
+ void slotData(TDEIO::Job* job, const TQByteArray& data);
+
+private:
+
+ ImageInfoJobPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* IMAGEINFOJOB_H */