Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4c2a1b57 authored by Laurent Montel's avatar Laurent Montel 😁

Add more method in importexportprogressindicatorbase

parent 39aeb2d3
......@@ -52,6 +52,7 @@ AbstractImportExportJob::AbstractImportExportJob(QWidget *parent, ArchiveStorage
mImportExportProgressIndicator(new ImportExportProgressIndicatorBase(this)),
mParent(parent)
{
mImportExportProgressIndicator->setNumberOfStep(numberOfStep);
connect(mImportExportProgressIndicator, SIGNAL(info(QString)), this, SIGNAL(info(QString)));
}
......@@ -87,6 +88,7 @@ void AbstractImportExportJob::setImportExportProgressIndicator(ImportExportProgr
{
delete mImportExportProgressIndicator;
mImportExportProgressIndicator = importExportProgressIndicator;
mImportExportProgressIndicator->setNumberOfStep(mNumberOfStep);
}
......@@ -117,12 +119,12 @@ void AbstractImportExportJob::backupFile(const QString&filename, const QString&
int AbstractImportExportJob::mergeConfigMessageBox(const QString &configName) const
{
return KMessageBox::warningYesNoCancel(mParent,i18n("\"%1\" already exists. Do you want to overwrite it or merge it?", configName),i18n("Restore"),KGuiItem(i18n("Overwrite")),KGuiItem(i18n("Merge")) );
return mImportExportProgressIndicator->mergeConfigMessageBox(configName);
}
bool AbstractImportExportJob::overwriteConfigMessageBox(const QString &configName) const
{
return (KMessageBox::warningYesNo(mParent,i18n("\"%1\" already exists. Do you want to overwrite it?", configName),i18n("Restore")) == KMessageBox::Yes);
return mImportExportProgressIndicator->overwriteConfigMessageBox(configName);
}
void AbstractImportExportJob::overwriteDirectory(const QString &path, const KArchiveEntry *entry)
......@@ -140,7 +142,7 @@ void AbstractImportExportJob::overwriteDirectory(const QString &path, const KArc
bool AbstractImportExportJob::overwriteDirectoryMessageBox(const QString &directory) const
{
return (KMessageBox::warningYesNo(mParent,i18n("Directory \"%1\" already exists. Do you want to overwrite it?", directory),i18n("Restore")) == KMessageBox::Yes);
return mImportExportProgressIndicator->overwriteDirectoryMessageBox(directory);
}
void AbstractImportExportJob::convertRealPathToCollection(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix)
......@@ -240,7 +242,7 @@ void AbstractImportExportJob::copyToFile(const KArchiveFile *archivefile, const
destination.remove();
}
if (!file.copy(dest)) {
KMessageBox::error(mParent,i18n("File \"%1\" cannot be copied to \"%2\".",filename,dest),i18n("Copy file"));
mImportExportProgressIndicator->showErrorMessage(i18n("File \"%1\" cannot be copied to \"%2\".",filename,dest), i18n("Copy file"));
}
}
......
......@@ -16,6 +16,7 @@
*/
#include "importexportprogressindicatorbase.h"
#include <KMessageBox>
ImportExportProgressIndicatorBase::ImportExportProgressIndicatorBase(QObject *parent)
: QObject(parent),
......@@ -54,3 +55,25 @@ void ImportExportProgressIndicatorBase::setNumberOfStep(int numberOfStep)
mNumberOfStep = numberOfStep;
}
int ImportExportProgressIndicatorBase::mergeConfigMessageBox(const QString &configName) const
{
return KMessageBox::Yes;
}
bool ImportExportProgressIndicatorBase::overwriteConfigMessageBox(const QString &configName) const
{
Q_UNUSED(configName);
return true;
}
bool ImportExportProgressIndicatorBase::overwriteDirectoryMessageBox(const QString &directory) const
{
Q_UNUSED(directory);
return true;
}
void ImportExportProgressIndicatorBase::showErrorMessage(const QString &message, const QString &title)
{
Q_UNUSED(message);
Q_UNUSED(title);
}
......@@ -32,10 +32,16 @@ public:
virtual void showInfo(const QString &text);
virtual bool wasCanceled() const;
virtual int mergeConfigMessageBox(const QString &configName) const;
virtual bool overwriteConfigMessageBox(const QString &configName) const;
virtual bool overwriteDirectoryMessageBox(const QString &directory) const;
virtual void showErrorMessage(const QString &message, const QString &title);
void setNumberOfStep(int numberOfStep);
Q_SIGNALS:
void info(const QString &text);
protected:
int mNumberOfStep;
};
......
......@@ -18,6 +18,8 @@
#include "importexportprogressindicatorgui.h"
#include <qprogressdialog.h>
#include <KMessageBox>
#include <KLocalizedString>
ImportExportProgressIndicatorGui::ImportExportProgressIndicatorGui(QWidget *parentWidget, QObject *parent)
: ImportExportProgressIndicatorBase(parent),
......@@ -66,4 +68,23 @@ bool ImportExportProgressIndicatorGui::wasCanceled() const
return false;
}
int ImportExportProgressIndicatorGui::mergeConfigMessageBox(const QString &configName) const
{
return KMessageBox::warningYesNoCancel(mParentWidget,i18n("\"%1\" already exists. Do you want to overwrite it or merge it?", configName),i18n("Restore"),KGuiItem(i18n("Overwrite")),KGuiItem(i18n("Merge")) );
}
bool ImportExportProgressIndicatorGui::overwriteConfigMessageBox(const QString &configName) const
{
return (KMessageBox::warningYesNo(mParentWidget,i18n("\"%1\" already exists. Do you want to overwrite it?", configName),i18n("Restore")) == KMessageBox::Yes);
}
bool ImportExportProgressIndicatorGui::overwriteDirectoryMessageBox(const QString &directory) const
{
return (KMessageBox::warningYesNo(mParentWidget,i18n("Directory \"%1\" already exists. Do you want to overwrite it?", directory),i18n("Restore")) == KMessageBox::Yes);
}
void ImportExportProgressIndicatorGui::showErrorMessage(const QString &message, const QString &title)
{
KMessageBox::error(mParentWidget, message, title);
}
......@@ -32,6 +32,10 @@ public:
void showInfo(const QString &text);
bool wasCanceled() const;
int mergeConfigMessageBox(const QString &configName) const;
bool overwriteConfigMessageBox(const QString &configName) const;
bool overwriteDirectoryMessageBox(const QString &directory) const;
void showErrorMessage(const QString &message, const QString &title);
private:
QProgressDialog *mProgressDialog;
QWidget *mParentWidget;
......
......@@ -17,6 +17,7 @@
#include "pimsettingsbackuprestore.h"
#include "archivestorage.h"
#include "importexportprogressindicatorgui.h"
#include "mail/exportmailjob.h"
#include "mail/importmailjob.h"
......@@ -305,6 +306,7 @@ void PimSettingsBackupRestore::restoreFinished()
void PimSettingsBackupRestore::executeJob()
{
mImportExportData->setImportExportProgressIndicator(new ImportExportProgressIndicatorGui(mParentWidget, this));
connect(mImportExportData, SIGNAL(info(QString)), SIGNAL(addInfo(QString)));
connect(mImportExportData, SIGNAL(error(QString)), SIGNAL(addError(QString)));
connect(mImportExportData, SIGNAL(title(QString)), SIGNAL(addTitle(QString)));
......
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