SVN commit 628789 by cgilles:
digikam from trunk : report progress info to status progress bar when Batch Sync Metadata from current album is used instead a Progress dialog. CCMAIL: [hidden email], "Luka Renko" <[hidden email]>, Marcel Wiesweg <[hidden email]> M +25 -20 digikam/digikamapp.cpp M +6 -5 digikam/digikamapp.h M +10 -1 digikam/digikamview.cpp M +28 -68 utilities/batch/batchsyncmetadata.cpp M +17 -18 utilities/batch/batchsyncmetadata.h --- trunk/extragear/graphics/digikam/digikam/digikamapp.cpp #628788:628789 @@ -3,7 +3,7 @@ * Tom Albers <[hidden email]> * Caulier Gilles <caulier dot gilles at kdemail dot net> * Date : 2002-16-10 - * Description : main interface implementation + * Description : main digiKam interface implementation * * Copyright 2002-2005 by Renchi Raju and Gilles Caulier * Copyright 2006 by Tom Albers @@ -339,13 +339,13 @@ mView->applySettings(mAlbumSettings); connect(mView, SIGNAL(signal_albumSelected(bool)), - this, SLOT(slot_albumSelected(bool))); + this, SLOT(slotAlbumSelected(bool))); connect(mView, SIGNAL(signal_tagSelected(bool)), - this, SLOT(slot_tagSelected(bool))); + this, SLOT(slotTagSelected(bool))); connect(mView, SIGNAL(signal_imageSelected(const QPtrList<ImageInfo>&, bool, bool)), - this, SLOT(slot_imageSelected(const QPtrList<ImageInfo>&, bool, bool))); + this, SLOT(slotImageSelected(const QPtrList<ImageInfo>&, bool, bool))); } void DigikamApp::setupStatusBar() @@ -370,6 +370,9 @@ connect(mStatusNavigateBar, SIGNAL(signalLastItem()), mView, SLOT(slotLastItem())); + + connect(mStatusProgressBar, SIGNAL(signalCancelButtonPressed()), + this, SIGNAL(signalCancelButtonPressed())); } void DigikamApp::setupAccelerators() @@ -510,7 +513,7 @@ SLOT(slotAlbumAddImages()), actionCollection(), "album_addImages"); - mAddImagesAction->setWhatsThis(i18n("This option adds new images to the current Album.")); + mAddImagesAction->setWhatsThis(i18n("This option adds new items to the current Album.")); mAlbumImportAction = new KAction( i18n("Import Folders..."), "albumfolder-importdir", @@ -588,8 +591,8 @@ SLOT(slot_imageEdit()), actionCollection(), "image_edit"); - mImageViewAction->setWhatsThis(i18n("This option allows you to open the Image Editor with the " - "currently selected image.")); + mImageViewAction->setWhatsThis(i18n("This option allows you to open the editor with the " + "current selected item.")); mImageRenameAction = new KAction(i18n("Rename..."), "pencil", @@ -598,8 +601,8 @@ SLOT(slot_imageRename()), actionCollection(), "image_rename"); - mImageRenameAction->setWhatsThis(i18n("This option allows you to rename the filename of the currently selected " - "image.")); + mImageRenameAction->setWhatsThis(i18n("This option allows you to rename the filename " + "of the current selected item")); // Pop up dialog to ask user whether to move to trash mImageDeleteAction = new KAction(i18n("Delete"), @@ -754,7 +757,8 @@ SLOT(slot_thumbSizePlus()), actionCollection(), "album_thumbSizeIncrease"); - mThumbSizePlusAction->setWhatsThis(i18n("This option allows you to increase the Album thumbnails size.")); + mThumbSizePlusAction->setWhatsThis(i18n("This option allows you to increase " + "the Album thumbnails size.")); mThumbSizeMinusAction = new KAction(i18n("Decrease Thumbnail Size"), "viewmag-", @@ -763,7 +767,8 @@ SLOT(slot_thumbSizeMinus()), actionCollection(), "album_thumbSizeDecrease"); - mThumbSizeMinusAction->setWhatsThis(i18n("This option allows you to decrease the Album thumbnails size.")); + mThumbSizeMinusAction->setWhatsThis(i18n("This option allows you to decrease " + "the Album thumbnails size.")); #if KDE_IS_VERSION(3,2,0) mFullScreenAction = KStdAction::fullScreen(this, SLOT(slotToggleFullScreen()), @@ -776,11 +781,12 @@ SLOT(slotToggleFullScreen()), actionCollection(), "full_screen"); - mFullScreenAction->setWhatsThis(i18n("This option allows you to toggle the main windows in full screen mode.")); + mFullScreenAction->setWhatsThis(i18n("This option allows you to toggle the main window " + "in full screen mode.")); #endif mQuitAction = KStdAction::quit(this, - SLOT(slot_exit()), + SLOT(slotExit()), actionCollection(), "app_exit"); @@ -951,7 +957,7 @@ } } -void DigikamApp::slot_albumSelected(bool val) +void DigikamApp::slotAlbumSelected(bool val) { Album *album = mAlbumManager->currentAlbum(); @@ -1048,7 +1054,7 @@ } } -void DigikamApp::slot_tagSelected(bool val) +void DigikamApp::slotTagSelected(bool val) { Album *album = mAlbumManager->currentAlbum(); @@ -1095,7 +1101,7 @@ } } -void DigikamApp::slot_imageSelected(const QPtrList<ImageInfo>& list, bool hasPrev, bool hasNext) +void DigikamApp::slotImageSelected(const QPtrList<ImageInfo>& list, bool hasPrev, bool hasNext) { QPtrList<ImageInfo> selection = list; bool val = selection.isEmpty() ? false : true; @@ -1131,7 +1137,7 @@ mStatusProgressBar->setProgressValue(count); } -void DigikamApp::slot_exit() +void DigikamApp::slotExit() { close(); } @@ -1279,7 +1285,6 @@ connect(cgui, SIGNAL(signalAlbumSettingsChanged()), this, SLOT(slotSetupChanged())); - } void DigikamApp::slotCameraConnect() @@ -1479,12 +1484,12 @@ KIPI::PluginLoader::PluginList list = KipiPluginLoader_->pluginList(); for( KIPI::PluginLoader::PluginList::Iterator it = list.begin() ; it != list.end() ; ++it ) - { + { KIPI::Plugin* plugin = (*it)->plugin(); if ( plugin ) dialog->insert( plugin->actionCollection(), (*it)->comment() ); - } + } dialog->configure(); delete dialog; --- trunk/extragear/graphics/digikam/digikam/digikamapp.h #628788:628789 @@ -3,7 +3,7 @@ * Tom Albers <[hidden email]> * Caulier Gilles <caulier dot gilles at kdemail dot net> * Date : 2002-16-10 - * Description : main interface implementation + * Description : main digiKam interface implementation * * Copyright 2002-2005 by Renchi Raju and Gilles Caulier * Copyright 2006 by Tom Albers @@ -111,6 +111,7 @@ void signalLastItem(); void signalCopyAlbumItemsSelection(); void signalPasteAlbumItemsSelection(); + void signalCancelButtonPressed(); protected: @@ -133,10 +134,10 @@ private slots: - void slot_albumSelected(bool val); - void slot_tagSelected(bool val); - void slot_imageSelected(const QPtrList<ImageInfo>&, bool, bool); - void slot_exit(); + void slotAlbumSelected(bool val); + void slotTagSelected(bool val); + void slotImageSelected(const QPtrList<ImageInfo>&, bool, bool); + void slotExit(); void slotShowTip(); void slotShowKipiHelp(); void slotDonateMoney(); --- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #628788:628789 @@ -749,10 +749,19 @@ BatchSyncMetadata *syncMetadata = new BatchSyncMetadata(this, album); + connect(syncMetadata, SIGNAL(signalProgressBarMode(int, const QString&)), + d->parent, SLOT(slotProgressBarMode(int, const QString&))); + + connect(syncMetadata, SIGNAL(signalProgressValue(int)), + d->parent, SLOT(slotProgressValue(int))); + connect(syncMetadata, SIGNAL(signalComplete()), this, SLOT(slotAlbumSyncPicturesMetadataDone())); - syncMetadata->exec(); + connect(d->parent, SIGNAL(signalCancelButtonPressed()), + syncMetadata, SLOT(slotAbort())); + + syncMetadata->parseAlbum(); } void DigikamView::slotAlbumSyncPicturesMetadataDone() --- trunk/extragear/graphics/digikam/utilities/batch/batchsyncmetadata.cpp #628788:628789 @@ -22,14 +22,11 @@ // QT includes. #include <qstring.h> -#include <qtimer.h> -#include <qdatetime.h> // KDE includes. #include <klocale.h> #include <kapplication.h> -#include <kiconloader.h> // Local includes. @@ -37,6 +34,7 @@ #include "album.h" #include "imageinfojob.h" #include "metadatahub.h" +#include "statusprogressbar.h" #include "batchsyncmetadata.h" #include "batchsyncmetadata.moc" @@ -52,23 +50,14 @@ cancel = false; imageInfoJob = new ImageInfoJob(); album = 0; + count = 0; imageInfo = 0; - duration.start(); - - okPix = KApplication::kApplication()->iconLoader()->loadIcon( - "button_ok", KIcon::NoGroup, 32); - - warnPix = KApplication::kApplication()->iconLoader()->loadIcon( - "messagebox_info", KIcon::NoGroup, 16); } bool cancel; - QTime duration; + int count; - QPixmap okPix; - QPixmap warnPix; - Album *album; ImageInfoJob *imageInfoJob; @@ -78,32 +67,18 @@ ImageInfo *imageInfo; }; -BatchSyncMetadata::BatchSyncMetadata(QWidget* parent, Album *album) - : DProgressDlg(parent) +BatchSyncMetadata::BatchSyncMetadata(QObject* parent, Album *album) + : QObject(parent) { d = new BatchSyncMetadataPriv; d->album = album; - setValue(0); - setCaption(i18n("Sync Pictures Metadata")); - setTitle(i18n("Parsing pictures")); - setLabel(i18n("<b>Sync pictures metadata with digiKam database. Please wait...</b>")); - setButtonText(i18n("&Abort")); - resize(600, 300); - QTimer::singleShot(500, this, SLOT(slotParseAlbum())); } -BatchSyncMetadata::BatchSyncMetadata(QWidget* parent, const ImageInfoList& list) - : DProgressDlg(parent) +BatchSyncMetadata::BatchSyncMetadata(QObject* parent, const ImageInfoList& list) + : QObject(parent) { d = new BatchSyncMetadataPriv; d->imageInfoList = list; - setValue(0); - setCaption(i18n("Sync Pictures Metadata")); - setTitle(i18n("Parsing pictures")); - setLabel(i18n("<b>Sync pictures metadata with digiKam database. Please wait...</b>")); - setButtonText(i18n("&Abort")); - resize(600, 300); - QTimer::singleShot(500, this, SLOT(slotParseList())); } BatchSyncMetadata::~BatchSyncMetadata() @@ -111,7 +86,7 @@ delete d; } -void BatchSyncMetadata::slotParseAlbum() +void BatchSyncMetadata::parseAlbum() { d->imageInfoJob->allItemsFromAlbum(d->album); @@ -122,15 +97,23 @@ this, SLOT(slotComplete())); } +void BatchSyncMetadata::slotComplete() +{ + if (d->imageInfoList.isEmpty()) + complete(); +} + void BatchSyncMetadata::slotAlbumParsed(const ImageInfoList& list) { d->imageInfoList = list; - slotParseList(); + parseList(); } -void BatchSyncMetadata::slotParseList() +void BatchSyncMetadata::parseList() { - setTotalSteps(d->imageInfoList.count()); + emit signalProgressBarMode(StatusProgressBar::CancelProgressBarMode, + i18n("Sync pictures Metadata with database. Please wait...")); + d->imageInfo = d->imageInfoList.first(); parsePicture(); } @@ -140,10 +123,11 @@ if (!d->imageInfo) // All is done. { complete(); + slotAbort(); } else if (d->cancel) { - abort(); + complete(); } else { @@ -151,10 +135,10 @@ // read in from database fileHub.load(d->imageInfo); // write out to file DMetadata - bool result = fileHub.write(d->imageInfo->filePath()); + fileHub.write(d->imageInfo->filePath()); - addedAction(result ? d->okPix : d->warnPix, d->imageInfo->kurl().filename()); - advance(1); + emit signalProgressValue((int)((d->count++/(float)d->imageInfoList.count())*100.0)); + d->imageInfo = d->imageInfoList.next(); kapp->processEvents(); @@ -162,39 +146,15 @@ } } -void BatchSyncMetadata::slotComplete() +void BatchSyncMetadata::slotAbort() { - if (d->imageInfoList.isEmpty()) - complete(); + d->cancel = true; + d->imageInfoJob->stop(); } -void BatchSyncMetadata::slotCancel() -{ - abort(); - done(Cancel); -} - -void BatchSyncMetadata::closeEvent(QCloseEvent *e) -{ - abort(); - e->accept(); -} - void BatchSyncMetadata::complete() { - QTime t; - t = t.addMSecs(d->duration.elapsed()); - setLabel(i18n("<b>Sync pictures metadata with digiKam database done</b>")); - setTitle(i18n("Duration: %1").arg(t.toString())); - setButtonText(i18n("&Close")); - setValue(100); - abort(); -} - -void BatchSyncMetadata::abort() -{ - d->cancel = true; - d->imageInfoJob->stop(); + emit signalProgressBarMode(StatusProgressBar::TextMode, QString::null); emit signalComplete(); } --- trunk/extragear/graphics/digikam/utilities/batch/batchsyncmetadata.h #628788:628789 @@ -22,13 +22,14 @@ #ifndef BATCHSYNCMETADATA_H #define BATCHSYNCMETADATA_H +// Qt includes. + +#include <qobject.h> + // Local includes. #include "imageinfo.h" -#include "dprogressdlg.h" -class QWidget; - class KURL; namespace Digikam @@ -37,42 +38,40 @@ class Album; class BatchSyncMetadataPriv; -class BatchSyncMetadata : public DProgressDlg +class BatchSyncMetadata : public QObject { Q_OBJECT public: /** Constructor witch sync all metatada pictures from an Album */ - BatchSyncMetadata(QWidget* parent, Album *album); + BatchSyncMetadata(QObject* parent, Album *album); /** Constructor witch sync all metatada from a pictures list */ - BatchSyncMetadata(QWidget* parent, const ImageInfoList& list); + BatchSyncMetadata(QObject* parent, const ImageInfoList& list); ~BatchSyncMetadata(); + void parseList(); + void parseAlbum(); + signals: void signalComplete(); + void signalProgressValue(int); + void signalProgressBarMode(int, const QString&); +public slots: + + void slotAbort(); + private: - void complete(); - void abort(); void parsePicture(); + void complete(); -protected: - - void closeEvent(QCloseEvent *e); - -protected slots: - - void slotCancel(); - private slots: - void slotParseList(); - void slotParseAlbum(); void slotAlbumParsed(const ImageInfoList&); void slotComplete(); _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |