summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-11-10 13:15:19 +0100
committerMontel Laurent <[email protected]>2015-11-10 13:15:19 +0100
commitd4388880723801523b66b257022c4342513156e5 (patch)
tree7c57f5f4694134b00ea5cde78cab7853d501f7b0
parent45e4596a557b49dc0e8d2be2411f09510ba0a0cb (diff)
Reduce duplicate code
-rw-r--r--pimsettingexporter/core/abstractimportexportjob.cpp25
-rw-r--r--pimsettingexporter/core/abstractimportexportjob.h2
-rw-r--r--pimsettingexporter/core/addressbook/importaddressbookjob.cpp28
-rw-r--r--pimsettingexporter/core/addressbook/importaddressbookjob.h1
-rw-r--r--pimsettingexporter/core/notes/exportnotesjob.cpp1
5 files changed, 30 insertions, 27 deletions
diff --git a/pimsettingexporter/core/abstractimportexportjob.cpp b/pimsettingexporter/core/abstractimportexportjob.cpp
index 951bc75..ba67ee1 100644
--- a/pimsettingexporter/core/abstractimportexportjob.cpp
+++ b/pimsettingexporter/core/abstractimportexportjob.cpp
@@ -543,3 +543,28 @@ void AbstractImportExportJob::storeDirectory(const QString &subDirectory)
}
}
}
+
+void AbstractImportExportJob::importDataSubdirectory(const QString &subdirectoryRelativePath)
+{
+ const KArchiveEntry *themeEntry = mArchiveDirectory->entry(Utils::dataPath() + subdirectoryRelativePath);
+ if (themeEntry && themeEntry->isDirectory()) {
+ const KArchiveDirectory *themeDir = static_cast<const KArchiveDirectory *>(themeEntry);
+ Q_FOREACH (const QString &entryName, themeDir->entries()) {
+ const KArchiveEntry *entry = themeDir->entry(entryName);
+ if (entry && entry->isDirectory()) {
+ QString subFolderName = entryName;
+ QDir themeDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(entryName));
+ int i = 1;
+ while (themeDirectory.exists()) {
+ subFolderName = entryName + QStringLiteral("_%1").arg(i);
+ themeDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(subFolderName));
+ ++i;
+ }
+ copyToDirectory(entry, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(subFolderName));
+ }
+ }
+ }
+
+}
+
+
diff --git a/pimsettingexporter/core/abstractimportexportjob.h b/pimsettingexporter/core/abstractimportexportjob.h
index a767aa1..1847d11 100644
--- a/pimsettingexporter/core/abstractimportexportjob.h
+++ b/pimsettingexporter/core/abstractimportexportjob.h
@@ -111,6 +111,8 @@ protected:
void setProgressDialogLabel(const QString &text);
void storeDirectory(const QString &subDirectory);
+ void importDataSubdirectory(const QString &subdirectoryRelativePath);
+
QHash<QString, Akonadi::Collection::Id> mHashConvertPathCollectionId;
QVector<resourceFiles> mListResourceFile;
diff --git a/pimsettingexporter/core/addressbook/importaddressbookjob.cpp b/pimsettingexporter/core/addressbook/importaddressbookjob.cpp
index d0f3bd7..2b09dc7 100644
--- a/pimsettingexporter/core/addressbook/importaddressbookjob.cpp
+++ b/pimsettingexporter/core/addressbook/importaddressbookjob.cpp
@@ -278,31 +278,7 @@ void ImportAddressbookJob::importkaddressBookConfig(const KArchiveFile *file, co
}
- importSubdirectory(QStringLiteral("/kaddressbook/viewertemplates/"));
- importSubdirectory(QStringLiteral("/kaddressbook/printing/"));
+ importDataSubdirectory(QStringLiteral("/kaddressbook/viewertemplates/"));
+ importDataSubdirectory(QStringLiteral("/kaddressbook/printing/"));
kaddressBookConfig->sync();
}
-
-void ImportAddressbookJob::importSubdirectory(const QString &subdirectoryRelativePath)
-{
- const KArchiveEntry *themeEntry = mArchiveDirectory->entry(Utils::dataPath() + subdirectoryRelativePath);
- if (themeEntry && themeEntry->isDirectory()) {
- const KArchiveDirectory *themeDir = static_cast<const KArchiveDirectory *>(themeEntry);
- Q_FOREACH (const QString &entryName, themeDir->entries()) {
- const KArchiveEntry *entry = themeDir->entry(entryName);
- if (entry && entry->isDirectory()) {
- QString subFolderName = entryName;
- QDir themeDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(entryName));
- int i = 1;
- while (themeDirectory.exists()) {
- subFolderName = entryName + QStringLiteral("_%1").arg(i);
- themeDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(subFolderName));
- ++i;
- }
- copyToDirectory(entry, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + subdirectoryRelativePath + QStringLiteral("/%1").arg(subFolderName));
- }
- }
- }
-
-}
-
diff --git a/pimsettingexporter/core/addressbook/importaddressbookjob.h b/pimsettingexporter/core/addressbook/importaddressbookjob.h
index dafd090..9bdaf5b 100644
--- a/pimsettingexporter/core/addressbook/importaddressbookjob.h
+++ b/pimsettingexporter/core/addressbook/importaddressbookjob.h
@@ -36,7 +36,6 @@ protected Q_SLOTS:
void slotNextStep() Q_DECL_OVERRIDE;
private:
- void importSubdirectory(const QString &subdirectoryRelativePath);
void searchAllFiles(const KArchiveDirectory *dir, const QString &prefix);
void storeAddressBookArchiveResource(const KArchiveDirectory *dir, const QString &prefix);
void importkaddressBookConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
diff --git a/pimsettingexporter/core/notes/exportnotesjob.cpp b/pimsettingexporter/core/notes/exportnotesjob.cpp
index 57c0fc2..acdf4d3 100644
--- a/pimsettingexporter/core/notes/exportnotesjob.cpp
+++ b/pimsettingexporter/core/notes/exportnotesjob.cpp
@@ -163,5 +163,6 @@ void ExportNotesJob::backupConfig()
backupFile(tmp.fileName(), Utils::configsPath(), globalNoteSettingsStr);
delete knoteConfig;
}
+ storeDirectory(QStringLiteral("/knotes/print/theme/"));
Q_EMIT info(i18n("Config backup done."));
}