Commit 00823fa8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code

parent 1775cb73
......@@ -16,6 +16,7 @@ add_library(test_resourceconverter STATIC
testimportfile.cpp
logcreatingressource.cpp
comparefilehelper.cpp
exportimportutil.cpp
)
target_link_libraries(test_resourceconverter PUBLIC KF5::ConfigCore pimdataexporterprivate KF5::Archive Qt5::Test)
......
......@@ -59,10 +59,6 @@ QVector<Utils::AkonadiInstanceInfo> ExportAddressbookJobInterfaceTestImpl::listO
return mListAkonadiInstanceInfo;
}
void ExportAddressbookJobInterfaceTestImpl::setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList)
{
mListAkonadiInstanceInfo = instanceInfoList;
}
void ExportAddressbookJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey)
{
......@@ -86,11 +82,6 @@ QString ExportAddressbookJobInterfaceTestImpl::resourcePath(const QString &agent
return url;
}
void ExportAddressbookJobInterfaceTestImpl::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
ExportAddressbookJobInterfaceTest::ExportAddressbookJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -23,16 +23,13 @@
#include <QObject>
#include "addressbook/exportaddressbookjobinterface.h"
class ExportAddressbookJobInterfaceTestImpl : public ExportAddressbookJobInterface
#include "exportimportutil.h"
class ExportAddressbookJobInterfaceTestImpl : public ExportAddressbookJobInterface, public ExportImportUtil
{
Q_OBJECT
public:
explicit ExportAddressbookJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ExportAddressbookJobInterfaceTestImpl();
void setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList);
void setPathConfig(const QString &pathConfig);
protected:
void exportArchiveResource() override;
......@@ -44,9 +41,6 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
QString mPathConfig;
};
class ExportAddressbookJobInterfaceTest : public QObject
......
......@@ -47,16 +47,6 @@ QVector<Utils::AkonadiInstanceInfo> ExportAlarmJobInterfaceTestImpl::listOfResou
return mListAkonadiInstanceInfo;
}
void ExportAlarmJobInterfaceTestImpl::setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList)
{
mListAkonadiInstanceInfo = instanceInfoList;
}
void ExportAlarmJobInterfaceTestImpl::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
Akonadi::Collection::Id ExportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
......
......@@ -23,24 +23,20 @@
#include <QObject>
#include "alarm/exportalarmjobinterface.h"
#include "exportimportutil.h"
class ExportAlarmJobInterfaceTestImpl : public ExportAlarmJobInterface
class ExportAlarmJobInterfaceTestImpl : public ExportAlarmJobInterface, public ExportImportUtil
{
Q_OBJECT
public:
explicit ExportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ExportAlarmJobInterfaceTestImpl();
void setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList);
void setPathConfig(const QString &pathConfig);
protected:
void exportArchiveResource() override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
QString mPathConfig;
};
class ExportAlarmJobInterfaceTest : public QObject
......
......@@ -66,16 +66,6 @@ QVector<Utils::AkonadiInstanceInfo> ExportCalendarsJobInterfaceTestImpl::listOfR
return mListAkonadiInstanceInfo;
}
void ExportCalendarsJobInterfaceTestImpl::setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList)
{
mListAkonadiInstanceInfo = instanceInfoList;
}
void ExportCalendarsJobInterfaceTestImpl::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
void ExportCalendarsJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest converter;
......
......@@ -23,16 +23,14 @@
#include <QObject>
#include "calendar/exportcalendarjobinterface.h"
class ExportCalendarsJobInterfaceTestImpl : public ExportCalendarJobInterface
#include "exportimportutil.h"
class ExportCalendarsJobInterfaceTestImpl : public ExportCalendarJobInterface, public ExportImportUtil
{
Q_OBJECT
public:
explicit ExportCalendarsJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ExportCalendarsJobInterfaceTestImpl();
void setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList);
void setPathConfig(const QString &pathConfig);
protected:
void exportArchiveResource() override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
......@@ -41,9 +39,6 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
QString mPathConfig;
};
class ExportCalendarsJobInterfaceTest : public QObject
......
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
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 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "exportimportutil.h"
ExportImportUtil::ExportImportUtil()
{
}
void ExportImportUtil::setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList)
{
mListAkonadiInstanceInfo = instanceInfoList;
}
void ExportImportUtil::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
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 of the License, 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.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef EXPORTIMPORTUTIL_H
#define EXPORTIMPORTUTIL_H
#include <QVector>
#include "utils.h"
class ExportImportUtil
{
public:
ExportImportUtil();
void setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList);
void setPathConfig(const QString &pathConfig);
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
QString mPathConfig;
};
#endif // EXPORTIMPORTUTIL_H
......@@ -48,16 +48,6 @@ void ExportNotesJobInterfaceTestImpl::exportArchiveResource()
slotWriteNextArchiveResource();
}
void ExportNotesJobInterfaceTestImpl::setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList)
{
mListAkonadiInstanceInfo = instanceInfoList;
}
void ExportNotesJobInterfaceTestImpl::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
QVector<Utils::AkonadiInstanceInfo> ExportNotesJobInterfaceTestImpl::listOfResource()
{
qDebug() << " QVector<Utils::AkonadiInstanceInfo> ExportNotesJobInterfaceTestImpl::listOfResource()";
......
......@@ -21,19 +21,17 @@
#define EXPORTNOTESJOBINTERFACETEST_H
#include <QObject>
#include "exportimportutil.h"
#include "notes/exportnotesjobinterface.h"
class ExportNotesJobInterfaceTestImpl : public ExportNotesJobInterface
class ExportNotesJobInterfaceTestImpl : public ExportNotesJobInterface, public ExportImportUtil
{
Q_OBJECT
public:
explicit ExportNotesJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ExportNotesJobInterfaceTestImpl();
void setListOfResource(const QVector<Utils::AkonadiInstanceInfo> &instanceInfoList);
void setPathConfig(const QString &pathConfig);
protected:
void exportArchiveResource() override;
void convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) override;
......@@ -41,9 +39,6 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
QString mPathConfig;
};
class ExportNotesJobInterfaceTest : public QObject
......
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