Commit 210a1fcc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent 6f8259d7
......@@ -626,7 +626,14 @@ void AbstractImportExportJob::convertCollectionStrToAkonadiId(const KSharedConfi
{
if (config->hasGroup(groupName)) {
KConfigGroup eventGroup = config->group(groupName);
const QString eventLastEventSelectedFolder(key);
convertRealPathToCollection(eventGroup, eventLastEventSelectedFolder, false);
convertRealPathToCollection(eventGroup, key, false);
}
}
void AbstractImportExportJob::convertCollectionListStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key, bool addCollectionPrefix)
{
if (config->hasGroup(groupName)) {
KConfigGroup group = config->group(groupName);
convertRealPathToCollectionList(group, key, addCollectionPrefix);
}
}
......@@ -126,6 +126,7 @@ protected:
static int sArchiveVersion;
void convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key);
void convertCollectionListStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key, bool addCollectionPrefix);
private:
void slotAllResourceSynchronized();
void slotSynchronizeInstanceDone(const QString &, const QString &identifier);
......
......@@ -200,12 +200,8 @@ void ImportAddressbookJob::importkaddressBookConfig(const KArchiveFile *file, co
copyToFile(file, config, filename, prefix);
KSharedConfig::Ptr kaddressBookConfig = KSharedConfig::openConfig(config);
const QString collectionViewCheckStateStr(QStringLiteral("CollectionViewCheckState"));
if (kaddressBookConfig->hasGroup(collectionViewCheckStateStr)) {
KConfigGroup group = kaddressBookConfig->group(collectionViewCheckStateStr);
const QString selectionKey(QStringLiteral("Selection"));
convertRealPathToCollectionList(group, selectionKey, true);
}
convertCollectionListStrToAkonadiId(kaddressBookConfig, QStringLiteral("CollectionViewCheckState"), QStringLiteral("Selection"), true);
const QString collectionViewStateStr(QStringLiteral("CollectionViewState"));
if (kaddressBookConfig->hasGroup(collectionViewStateStr)) {
......
......@@ -176,12 +176,7 @@ void ImportAlarmJob::importkalarmConfig(const KArchiveFile *kalarmFile, const QS
copyToFile(kalarmFile, kalarmrc, filename, prefix);
KSharedConfig::Ptr kalarmConfig = KSharedConfig::openConfig(kalarmrc);
const QString collectionsStr(QStringLiteral("Collections"));
if (kalarmConfig->hasGroup(collectionsStr)) {
KConfigGroup group = kalarmConfig->group(collectionsStr);
const QString selectionKey(QStringLiteral("FavoriteCollectionIds"));
convertRealPathToCollectionList(group, selectionKey, false);
}
convertCollectionListStrToAkonadiId(kalarmConfig, QStringLiteral("Collections"), QStringLiteral("FavoriteCollectionIds"), false);
kalarmConfig->sync();
}
......@@ -295,19 +295,8 @@ void ImportCalendarJob::importkorganizerConfig(const KArchiveFile *file, const Q
copyToFile(file, config, filename, prefix);
KSharedConfig::Ptr korganizerConfig = KSharedConfig::openConfig(config);
const QString collectionsStr(QStringLiteral("GlobalCollectionSelection"));
if (korganizerConfig->hasGroup(collectionsStr)) {
KConfigGroup group = korganizerConfig->group(collectionsStr);
const QString selectionKey(QStringLiteral("Selection"));
convertRealPathToCollectionList(group, selectionKey, true);
}
const QString collectionTreeViewStr(QStringLiteral("CollectionTreeView"));
if (korganizerConfig->hasGroup(collectionTreeViewStr)) {
KConfigGroup group = korganizerConfig->group(collectionTreeViewStr);
const QString selectionKey(QStringLiteral("Expansion"));
convertRealPathToCollectionList(group, selectionKey, true);
}
convertCollectionListStrToAkonadiId(korganizerConfig, QStringLiteral("GlobalCollectionSelection"), QStringLiteral("Selection"), true);
convertCollectionListStrToAkonadiId(korganizerConfig, QStringLiteral("CollectionTreeView"), QStringLiteral("Expansion"), true);
korganizerConfig->sync();
}
......
......@@ -1207,22 +1207,11 @@ void ImportMailJob::importKmailConfig(const KArchiveFile *kmailsnippet, const QS
convertRealPathToCollectionList(favoriteGroup, expensionKey);
}
const QString favoriteCollectionStr(QStringLiteral("FavoriteCollections"));
if (kmailConfig->hasGroup(favoriteCollectionStr)) {
KConfigGroup favoriteGroup = kmailConfig->group(favoriteCollectionStr);
convertCollectionListStrToAkonadiId(kmailConfig, QStringLiteral("FavoriteCollections"), QStringLiteral("FavoriteCollectionIds"), false);
const QString favoriteCollectionIdsStr(QStringLiteral("FavoriteCollectionIds"));
convertRealPathToCollectionList(favoriteGroup, favoriteCollectionIdsStr, false);
}
const QString favoriteCollectionOrderStr(QStringLiteral("FavoriteCollectionsOrder"));
if (kmailConfig->hasGroup(favoriteCollectionOrderStr)) {
KConfigGroup favoriteGroupOrder = kmailConfig->group(favoriteCollectionOrderStr);
//For favorite id for root collection == 0 and we store only folder => c
convertCollectionListStrToAkonadiId(kmailConfig, QStringLiteral("FavoriteCollectionsOrder"), QStringLiteral("0"), true);
//For favorite id for root collection == 0 and we store only folder => c
const QString favoriteCollectionOrderIdsStr(QStringLiteral("0"));
convertRealPathToCollectionList(favoriteGroupOrder, favoriteCollectionOrderIdsStr, true);
}
//Event collection
convertCollectionStrToAkonadiId(kmailConfig, QStringLiteral("Event"), QStringLiteral("LastEventSelectedFolder"));
......@@ -1232,12 +1221,8 @@ void ImportMailJob::importKmailConfig(const KArchiveFile *kmailsnippet, const QS
convertCollectionStrToAkonadiId(kmailConfig, QStringLiteral("Note"), QStringLiteral("LastNoteSelectedFolder"));
//FolderSelectionDialog collection
const QString folderSelectionCollectionStr(QStringLiteral("FolderSelectionDialog"));
if (kmailConfig->hasGroup(folderSelectionCollectionStr)) {
KConfigGroup folderSelectionGroup = kmailConfig->group(folderSelectionCollectionStr);
const QString folderSelectionSelectedFolder(QStringLiteral("LastSelectedFolder"));
convertRealPathToCollectionList(folderSelectionGroup, folderSelectionSelectedFolder, false);
}
convertCollectionListStrToAkonadiId(kmailConfig, QStringLiteral("FolderSelectionDialog"), QStringLiteral("LastSelectedFolder"), false);
//Convert MessageListTab collection id
const QString messageListPaneStr(QStringLiteral("MessageListPane"));
......
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