Commit 37fdcdea authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Add a signal in scan controller to dispatch progress of scan in...

Add a signal in scan controller to dispatch progress of scan in ScheduleCollectionScan mode through NewItemsFinder from Maintenance collection tools.
Fix ImportUI which dispatch trough StatusProgressBar download information to ProgressMAnager which handing up a progress item when download is completed.
BUGS: 302904
FIXED-IN: 3.3.0
parent a40a6948
......@@ -784,6 +784,7 @@ void ScanController::run()
SimpleCollectionScannerObserver observer(&d->continuePartialScan);
scanner.setObserver(&observer);
scanner.partialScan(task);
emit partialScanDone(task);
}
else if (doUpdateUniqueHash)
{
......
......@@ -212,6 +212,7 @@ Q_SIGNALS:
void collectionScanStarted(const QString& message);
void scanningProgress(float progress);
void collectionScanFinished();
void partialScanDone(const QString& path);
private Q_SLOTS:
......
......@@ -4,10 +4,10 @@
* http://www.digikam.org
*
* Date : 2007-01-24
* Description : a progress bar used to display file access
* Description : a progress bar used to display action
* progress or a text in status bar.
*
* Copyright (C) 2007-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007-2013 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
......@@ -46,7 +46,7 @@
namespace Digikam
{
class StatusProgressBar::StatusProgressBarPriv
class StatusProgressBar::Private
{
public:
......@@ -57,7 +57,7 @@ public:
ProgressBar
};
StatusProgressBarPriv() :
Private() :
notify(false),
progressWidget(0),
cancelButton(0),
......@@ -79,17 +79,17 @@ public:
KSqueezedTextLabel* textLabel;
};
StatusProgressBar::StatusProgressBar(QWidget* parent)
: QStackedWidget(parent), d(new StatusProgressBarPriv)
StatusProgressBar::StatusProgressBar(QWidget* const parent)
: QStackedWidget(parent), d(new Private)
{
setAttribute(Qt::WA_DeleteOnClose);
setFocusPolicy(Qt::NoFocus);
d->textLabel = new KSqueezedTextLabel(this);
d->progressWidget = new QWidget(this);
QHBoxLayout* hBox = new QHBoxLayout(d->progressWidget);
d->progressBar = new QProgressBar(d->progressWidget);
d->cancelButton = new QPushButton(d->progressWidget);
d->textLabel = new KSqueezedTextLabel(this);
d->progressWidget = new QWidget(this);
QHBoxLayout* const hBox = new QHBoxLayout(d->progressWidget);
d->progressBar = new QProgressBar(d->progressWidget);
d->cancelButton = new QPushButton(d->progressWidget);
d->cancelButton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
d->cancelButton->setFocusPolicy(Qt::NoFocus);
d->cancelButton->setIcon(SmallIcon("dialog-cancel"));
......@@ -104,8 +104,8 @@ StatusProgressBar::StatusProgressBar(QWidget* parent)
hBox->setMargin(0);
hBox->setSpacing(0);
insertWidget(StatusProgressBarPriv::TextLabel, d->textLabel);
insertWidget(StatusProgressBarPriv::ProgressBar, d->progressWidget);
insertWidget(Private::TextLabel, d->textLabel);
insertWidget(Private::ProgressBar, d->progressWidget);
connect(d->cancelButton, SIGNAL(clicked()),
this, SIGNAL(signalCancelButtonPressed()) );
......@@ -150,7 +150,7 @@ void StatusProgressBar::setProgressValue(int v)
if (d->notify)
{
ProgressItem* item = currentProgressItem();
ProgressItem* const item = currentProgressItem();
if (item)
{
item->setCompletedItems(v);
......@@ -170,7 +170,7 @@ void StatusProgressBar::setProgressTotalSteps(int v)
if (d->notify)
{
ProgressItem* item = currentProgressItem();
ProgressItem* const item = currentProgressItem();
if (item)
item->setTotalItems(v);
}
......@@ -183,7 +183,7 @@ void StatusProgressBar::setProgressText(const QString& text)
if (d->notify)
{
ProgressItem* item = currentProgressItem();
ProgressItem* const item = currentProgressItem();
if (item)
item->setStatus(text);
}
......@@ -193,13 +193,13 @@ void StatusProgressBar::progressBarMode(int mode, const QString& text)
{
if (mode == TextMode)
{
setCurrentIndex(StatusProgressBarPriv::TextLabel);
setCurrentIndex(Private::TextLabel);
setProgressValue(0);
setText(text);
if (d->notify)
{
ProgressItem* item = currentProgressItem();
ProgressItem* const item = currentProgressItem();
if (item)
item->setComplete();
}
......@@ -207,43 +207,50 @@ void StatusProgressBar::progressBarMode(int mode, const QString& text)
else if (mode == ProgressBarMode)
{
d->cancelButton->hide();
setCurrentIndex(StatusProgressBarPriv::ProgressBar);
setCurrentIndex(Private::ProgressBar);
setProgressText(text);
if (d->notify)
{
ProgressItem* item = ProgressManager::createProgressItem(d->title, QString(), false, !d->icon.isNull());
ProgressItem* const item = ProgressManager::createProgressItem(d->title, QString(), false, !d->icon.isNull());
item->setTotalItems(d->progressBar->maximum());
item->setCompletedItems(d->progressBar->value());
if (!d->icon.isNull()) item->setThumbnail(d->icon);
if (!d->icon.isNull())
item->setThumbnail(d->icon);
connect(item, SIGNAL(progressItemCanceled(ProgressItem*)),
this, SIGNAL(signalCancelButtonPressed()));
d->progressId = item->id();
d->progressId = item->id();
}
}
else // CancelProgressBarMode
{
d->cancelButton->show();
setCurrentIndex(StatusProgressBarPriv::ProgressBar);
setCurrentIndex(Private::ProgressBar);
setProgressText(text);
if (d->notify)
{
ProgressItem* item = ProgressManager::createProgressItem(d->title, QString(), true, !d->icon.isNull());
ProgressItem* const item = ProgressManager::createProgressItem(d->title, QString(), true, !d->icon.isNull());
item->setTotalItems(d->progressBar->maximum());
item->setCompletedItems(d->progressBar->value());
if (!d->icon.isNull()) item->setThumbnail(d->icon);
if (!d->icon.isNull())
item->setThumbnail(d->icon);
connect(item, SIGNAL(progressItemCanceled(ProgressItem*)),
this, SIGNAL(signalCancelButtonPressed()));
d->progressId = item->id();
d->progressId = item->id();
}
}
}
ProgressItem* StatusProgressBar::currentProgressItem() const
{
kDebug() << d->progressId;
return ProgressManager::instance()->findItembyId(d->progressId);
return (ProgressManager::instance()->findItembyId(d->progressId));
}
} // namespace Digikam
......@@ -4,10 +4,10 @@
* http://www.digikam.org
*
* Date : 2007-01-24
* Description : a progress bar used to display file access
* Description : a progress bar used to display action
* progress or a text in status bar.
*
* Copyright (C) 2007-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007-2013 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
......@@ -54,7 +54,7 @@ public:
public:
explicit StatusProgressBar(QWidget* parent=0);
explicit StatusProgressBar(QWidget* const parent=0);
~StatusProgressBar();
void setAlignment(Qt::Alignment a);
......@@ -85,8 +85,8 @@ private:
private:
class StatusProgressBarPriv;
StatusProgressBarPriv* const d;
class Private;
Private* const d;
};
} // namespace Digikam
......
......@@ -1048,8 +1048,9 @@ void ImportUI::slotBusy(bool val)
slotNewSelection(d->view->selectedUrls().count() > 0);
m_animLogo->stop();
d->statusProgressBar->setNotify(false);
d->statusProgressBar->setProgressValue(0);
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode, i18n("Ready"));
// like WDestructiveClose, but after camera controller operation has safely finished
if (d->closed)
{
......@@ -1575,7 +1576,7 @@ void ImportUI::slotDownloaded(const QString& folder, const QString& file, int st
{
if (d->deleteAfter)
{
// No need passive pop-up here, because wil ask to confirm items deletion with dialog.
// No need passive pop-up here, because we will ask to confirm items deletion with dialog.
deleteItems(true, true);
}
else
......
......@@ -53,6 +53,7 @@ public:
FinderMode mode;
QStringList foldersToScan;
QStringList foldersScanned;
};
NewItemsFinder::NewItemsFinder(const FinderMode mode, const QStringList& foldersToScan, ProgressItem* const parent)
......@@ -69,9 +70,13 @@ NewItemsFinder::NewItemsFinder(const FinderMode mode, const QStringList& folders
connect(ScanController::instance(), SIGNAL(completeScanDone()),
this, SLOT(slotDone()));
connect(ScanController::instance(), SIGNAL(partialScanDone(QString)),
this, SLOT(slotPartialScanDone(QString)));
d->mode = mode;
d->foldersToScan = foldersToScan;
d->foldersToScan.sort();
}
NewItemsFinder::~NewItemsFinder()
......@@ -107,8 +112,9 @@ void NewItemsFinder::slotStart()
case ScheduleCollectionScan:
{
kDebug() << "scan mode: ScheduleCollectionScan";
kDebug() << "scan mode: ScheduleCollectionScan :: " << d->foldersToScan;
d->foldersScanned.clear();
foreach(const QString& folder, d->foldersToScan)
ScanController::instance()->scheduleCollectionScan(folder);
......@@ -143,6 +149,23 @@ void NewItemsFinder::slotCancel()
MaintenanceTool::slotCancel();
}
void NewItemsFinder::slotPartialScanDone(const QString& path)
{
// Check if path scanned is included in planed list.
if (d->foldersToScan.contains(path) && !d->foldersScanned.contains(path))
{
d->foldersScanned.append(path);
d->foldersScanned.sort();
// Check if all planed scanning is done
if (d->foldersScanned == d->foldersToScan)
{
slotDone();
}
}
}
void NewItemsFinder::slotDone()
{
//kDebug() << "fired!! ";
......
......@@ -51,13 +51,14 @@ public:
public:
explicit NewItemsFinder(const FinderMode mode = CompleteCollectionScan, const QStringList& foldersToScan = QStringList(),
ProgressItem* const parent = 0);
ProgressItem* const parent = 0);
~NewItemsFinder();
private Q_SLOTS:
void slotStart();
void slotScanStarted(const QString&);
void slotPartialScanDone(const QString&);
void slotTotalFilesToScan(int);
void slotFilesScanned(int);
void slotCancel();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment