Commit 3eadab9f authored by Laurent Montel's avatar Laurent Montel 😁

Use importexportprogressindicatorbase.h

parent a2fa909c
......@@ -17,6 +17,7 @@
#include "abstractimportexportjob.h"
#include "archivestorage.h"
#include "importexportprogressindicatorbase.h"
#include "synchronizeresourcejob.h"
#include "mailcommon/util/mailutil.h"
......@@ -44,13 +45,14 @@ AbstractImportExportJob::AbstractImportExportJob(QWidget *parent, ArchiveStorage
mArchiveStorage(archiveStorage),
mIdentityManager(new KPIMIdentities::IdentityManager( false, this, "mIdentityManager" )),
mTempDir(0),
mProgressDialog(0),
mArchiveDirectory(0),
mNumberOfStep(numberOfStep),
mCreateResource(0),
mIndex(-1),
mImportExportProgressIndicator(new ImportExportProgressIndicatorBase(this)),
mParent(parent)
{
connect(mImportExportProgressIndicator, SIGNAL(info(QString)), this, SIGNAL(info(QString)));
}
AbstractImportExportJob::~AbstractImportExportJob()
......@@ -58,44 +60,36 @@ AbstractImportExportJob::~AbstractImportExportJob()
delete mCreateResource;
delete mIdentityManager;
delete mTempDir;
delete mProgressDialog;
}
void AbstractImportExportJob::createProgressDialog()
{
if (!mProgressDialog) {
mProgressDialog = new QProgressDialog(mParent);
mProgressDialog->setWindowModality(Qt::WindowModal);
mProgressDialog->setMinimum(0);
mProgressDialog->setMaximum(mNumberOfStep);
}
mProgressDialog->show();
mProgressDialog->setValue(0);
mImportExportProgressIndicator->createProgressDialog();
}
bool AbstractImportExportJob::wasCanceled() const
{
if (mProgressDialog)
return mProgressDialog->wasCanceled();
return false;
return mImportExportProgressIndicator->wasCanceled();
}
void AbstractImportExportJob::increaseProgressDialog()
{
if (mProgressDialog) {
mProgressDialog->setValue(mProgressDialog->value()+1);
}
mImportExportProgressIndicator->increaseProgressDialog();
}
void AbstractImportExportJob::showInfo(const QString &text)
{
if (mProgressDialog) {
mProgressDialog->setLabelText(text);
}
Q_EMIT info(text);
mImportExportProgressIndicator->showInfo(text);
}
void AbstractImportExportJob::setImportExportProgressIndicator(ImportExportProgressIndicatorBase *importExportProgressIndicator)
{
delete mImportExportProgressIndicator;
mImportExportProgressIndicator = importExportProgressIndicator;
}
KZip *AbstractImportExportJob::archive() const
{
return mArchiveStorage->archive();
......
......@@ -23,7 +23,6 @@
#include <QStringList>
class QWidget;
class QProgressDialog;
class ArchiveStorage;
class KArchiveDirectory;
class KTempDir;
......@@ -39,7 +38,7 @@ class IdentityManager;
namespace PimCommon {
class CreateResource;
}
class ImportExportProgressIndicatorBase;
class AbstractImportExportJob : public QObject
{
Q_OBJECT
......@@ -54,6 +53,8 @@ public:
static int archiveVersion();
static void setArchiveVersion(int version);
void setImportExportProgressIndicator(ImportExportProgressIndicatorBase *importExportProgressIndicator);
Q_SIGNALS:
void info(const QString &);
void error(const QString &);
......@@ -110,7 +111,6 @@ protected:
KPIMIdentities::IdentityManager *mIdentityManager;
KTempDir *mTempDir;
QProgressDialog *mProgressDialog;
const KArchiveDirectory* mArchiveDirectory;
int mNumberOfStep;
PimCommon::CreateResource *mCreateResource;
......@@ -120,6 +120,7 @@ protected:
static int sArchiveVersion;
private:
ImportExportProgressIndicatorBase *mImportExportProgressIndicator;
QWidget *mParent;
};
......
......@@ -18,7 +18,8 @@
#include "importexportprogressindicatorbase.h"
ImportExportProgressIndicatorBase::ImportExportProgressIndicatorBase(QObject *parent)
: QObject(parent)
: QObject(parent),
mNumberOfStep(0)
{
}
......@@ -30,16 +31,26 @@ ImportExportProgressIndicatorBase::~ImportExportProgressIndicatorBase()
void ImportExportProgressIndicatorBase::increaseProgressDialog()
{
//Nothing
}
void ImportExportProgressIndicatorBase::createProgressDialog()
{
//Nothing
}
void ImportExportProgressIndicatorBase::showInfo(const QString &text)
{
Q_EMIT info(text);
}
bool ImportExportProgressIndicatorBase::wasCanceled() const
{
return false;
}
void ImportExportProgressIndicatorBase::setNumberOfStep(int numberOfStep)
{
mNumberOfStep = numberOfStep;
}
......@@ -31,6 +31,13 @@ public:
virtual void createProgressDialog();
virtual void showInfo(const QString &text);
virtual bool wasCanceled() const;
void setNumberOfStep(int numberOfStep);
Q_SIGNALS:
void info(const QString &text);
protected:
int mNumberOfStep;
};
#endif // IMPORTEXPORTPROGRESSINDICATORBASE_H
......@@ -17,30 +17,53 @@
#include "importexportprogressindicatorgui.h"
ImportExportProgressIndicatorGui::ImportExportProgressIndicatorGui(QObject *parent)
: ImportExportProgressIndicatorBase(parent)
#include <qprogressdialog.h>
ImportExportProgressIndicatorGui::ImportExportProgressIndicatorGui(QWidget *parentWidget, QObject *parent)
: ImportExportProgressIndicatorBase(parent),
mProgressDialog(0),
mParentWidget(parentWidget)
{
}
ImportExportProgressIndicatorGui::~ImportExportProgressIndicatorGui()
{
delete mProgressDialog;
}
void ImportExportProgressIndicatorGui::increaseProgressDialog()
{
if (mProgressDialog) {
mProgressDialog->setValue(mProgressDialog->value()+1);
}
}
void ImportExportProgressIndicatorGui::createProgressDialog()
{
if (!mProgressDialog) {
mProgressDialog = new QProgressDialog(mParentWidget);
mProgressDialog->setWindowModality(Qt::WindowModal);
mProgressDialog->setMinimum(0);
mProgressDialog->setMaximum(mNumberOfStep);
}
mProgressDialog->show();
mProgressDialog->setValue(0);
}
void ImportExportProgressIndicatorGui::showInfo(const QString &text)
{
if (mProgressDialog) {
mProgressDialog->setLabelText(text);
}
Q_EMIT info(text);
}
bool ImportExportProgressIndicatorGui::wasCanceled() const
{
if (mProgressDialog)
return mProgressDialog->wasCanceled();
return false;
}
......@@ -19,18 +19,22 @@
#define IMPORTEXPORTPROGRESSINDICATORGUI_H
#include "importexportprogressindicatorbase.h"
class QProgressDialog;
class ImportExportProgressIndicatorGui : public ImportExportProgressIndicatorBase
{
Q_OBJECT
public:
explicit ImportExportProgressIndicatorGui(QObject *parent = 0);
explicit ImportExportProgressIndicatorGui(QWidget *parentWidget, QObject *parent = 0);
~ImportExportProgressIndicatorGui();
void increaseProgressDialog();
void createProgressDialog();
void showInfo(const QString &text);
bool wasCanceled() const;
private:
QProgressDialog *mProgressDialog;
QWidget *mParentWidget;
};
#endif // IMPORTEXPORTPROGRESSINDICATORGUI_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