Commit 974c3fda authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clean up code

parent ab8a336c
Pipeline #25768 failed with stage
in 13 minutes and 22 seconds
......@@ -40,6 +40,17 @@ ImportAddressbookJobInterface::~ImportAddressbookJobInterface()
{
}
QString ImportAddressbookJobInterface::configLocation() const
{
return installConfigLocation();
}
QString ImportAddressbookJobInterface::installConfigLocation() const
{
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/');
}
void ImportAddressbookJobInterface::start()
{
Q_EMIT title(i18n("Starting to import KAddressBook settings..."));
......@@ -97,6 +108,10 @@ void ImportAddressbookJobInterface::restoreConfig()
if (kaddressbookrcentry && kaddressbookrcentry->isFile()) {
const KArchiveFile *kaddressbookrcFile = static_cast<const KArchiveFile *>(kaddressbookrcentry);
const QString kaddressbookrc = configLocation() + kaddressbookStr;
// + const QString searchExistingGlobalNoterc = configLocation() + globalNoteStr;
// + const QString installPathGlobalNoterc = installConfigLocation() + globalNoteStr;
if (QFileInfo::exists(kaddressbookrc)) {
if (overwriteConfigMessageBox(kaddressbookStr)) {
importkaddressBookConfig(kaddressbookrcFile, kaddressbookrc, kaddressbookStr, Utils::configsPath());
......
......@@ -38,13 +38,14 @@ protected:
void slotNextStep() override;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
virtual Q_REQUIRED_RESULT QString configLocation() const = 0;
virtual Q_REQUIRED_RESULT QString configLocation() const;
void restoreResources();
private:
Q_REQUIRED_RESULT bool isAConfigFile(const QString &name) const override;
void importkaddressBookConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
void restoreConfig();
void addSpecificResourceSettings(const KSharedConfig::Ptr &resourceConfig, const QString &resourceName, QMap<QString, QVariant> &settings) override;
Q_REQUIRED_RESULT QString installConfigLocation() const;
};
#endif // IMPORTADDRESSBOOKJOBINTERFACE_H
......@@ -37,11 +37,6 @@ ImportAddressbookJobInterfaceImpl::~ImportAddressbookJobInterfaceImpl()
{
}
QString ImportAddressbookJobInterfaceImpl::configLocation() const
{
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/');
}
Akonadi::Collection::Id ImportAddressbookJobInterfaceImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterImpl converter;
......
......@@ -37,7 +37,6 @@ protected:
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree = false) override;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString configLocation() const override;
};
#endif // IMPORTADDRESSBOOKJOBINTERFACEIMPL_H
......@@ -33,6 +33,11 @@ ImportNotesJobInterfaceTestImpl::~ImportNotesJobInterfaceTestImpl()
QVERIFY(QDir(QDir::tempPath() + QLatin1Char('/') + Utils::backupnote()).removeRecursively());
}
void ImportNotesJobInterfaceTestImpl::setExistingPathConfig(const QString &path)
{
mExistingPathConfig = path;
}
Akonadi::Collection::Id ImportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
......@@ -67,6 +72,5 @@ QString ImportNotesJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResou
QString ImportNotesJobInterfaceTestImpl::configLocation() const
{
//TODO
return {};
return mExistingPathConfig;
}
......@@ -30,6 +30,7 @@ class ImportNotesJobInterfaceTestImpl : public ImportNotesJobInterface, public E
public:
explicit ImportNotesJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportNotesJobInterfaceTestImpl();
void setExistingPathConfig(const QString &path);
protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
......@@ -38,6 +39,8 @@ protected:
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString configLocation() const override;
private:
QString mExistingPathConfig;
};
#endif // IMPORTNOTESJOBINTERFACETESTIMPL_H
......@@ -74,6 +74,11 @@ bool ImportNotesJobInterface::isAConfigFile(const QString &name) const
return name.endsWith(QLatin1String("rc")) && (name.contains(QLatin1String("akonadi_akonotes_resource_")));
}
QString ImportNotesJobInterface::configLocation() const
{
return installConfigLocation();
}
QString ImportNotesJobInterface::installConfigLocation() const
{
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/');
......
......@@ -33,7 +33,7 @@ public:
void start() override;
protected:
virtual Q_REQUIRED_RESULT QString configLocation() const = 0;
virtual Q_REQUIRED_RESULT QString configLocation() const;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
void slotNextStep() override;
......
......@@ -34,11 +34,6 @@ ImportNotesJobInterfaceImpl::ImportNotesJobInterfaceImpl(QObject *parent, Utils:
initializeImportJob();
}
QString ImportNotesJobInterfaceImpl::configLocation() const
{
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/');
}
ImportNotesJobInterfaceImpl::~ImportNotesJobInterfaceImpl()
{
}
......
......@@ -38,7 +38,6 @@ protected:
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree = false) override;
void synchronizeResource(const QStringList &lst) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString configLocation() const override;
};
#endif // IMPORTNOTESJOB_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