Commit 79c8d720 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Start to import/export Kalendar config

parent 5bbe4dd7
Pipeline #169033 passed with stage
in 3 minutes and 47 seconds
......@@ -173,6 +173,33 @@ void ExportCalendarJobInterface::exportReminderAgentConfig()
}
}
void ExportCalendarJobInterface::exportKalendarConfig()
{
const QString kalendarStr(QStringLiteral("kalendarrc"));
const QString kalendarrc = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + kalendarStr;
if (QFileInfo::exists(kalendarrc)) {
KSharedConfigPtr kalendar = KSharedConfig::openConfig(kalendarrc);
QTemporaryFile tmp;
tmp.open();
KConfig *kalendarConfig = kalendar->copyTo(tmp.fileName());
const QString globalCollectionsStr(QStringLiteral("GlobalCollectionSelection"));
if (kalendarConfig->hasGroup(globalCollectionsStr)) {
KConfigGroup group = kalendarConfig->group(globalCollectionsStr);
const QString selectionKey(QStringLiteral("Selection"));
convertCollectionListToRealPath(group, selectionKey);
// Add Current
}
// Add Resources Colors
kalendarConfig->sync();
backupFile(tmp.fileName(), Utils::configsPath(), kalendarStr);
delete kalendarConfig;
}
}
void ExportCalendarJobInterface::exportKorganizerConfig()
{
const QString korganizerStr(QStringLiteral("korganizerrc"));
......@@ -219,6 +246,7 @@ void ExportCalendarJobInterface::backupConfig()
exportKorganizerConfig();
exportEventViewConfig();
exportReminderAgentConfig();
exportKalendarConfig();
backupConfigFile(QStringLiteral("calendar_printing.rc"));
......
......@@ -35,6 +35,7 @@ private:
void exportEventViewConfig();
void exportKorganizerConfig();
void exportReminderAgentConfig();
void exportKalendarConfig();
void backupConfig();
int mIndexIdentifier = 0;
......
......@@ -160,6 +160,20 @@ void ImportCalendarJobInterface::restoreConfig()
}
}
const QString kalendarStr(QStringLiteral("kalendarrc"));
const KArchiveEntry *kalendarentry = mArchiveDirectory->entry(Utils::configsPath() + kalendarStr);
if (kalendarentry && kalendarentry->isFile()) {
const auto kalendarentryFile = static_cast<const KArchiveFile *>(kalendarentry);
const QString kalendarentrycrc = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + kalendaracStr;
if (QFileInfo::exists(kalendarentrycrc)) {
if (overwriteConfigMessageBox(kalendaracStr)) {
importKalendarConfig(kalendarentryFile, kalendarentrycrc, kalendaracStr, Utils::configsPath());
}
} else {
importKalendarConfig(kalendarentryFile, kalendarentrycrc, kalendaracStr, Utils::configsPath());
}
}
const QString freebusyStr(QStringLiteral("freebusyurls"));
const KArchiveEntry *freebusyentry = mArchiveDirectory->entry(Utils::dataPath() + QLatin1String("korganizer/") + freebusyStr);
if (freebusyentry && freebusyentry->isFile()) {
......@@ -217,6 +231,17 @@ void ImportCalendarJobInterface::importkorganizerConfig(const KArchiveFile *file
korganizerConfig->sync();
}
void ImportCalendarJobInterface::importKalendarConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix)
{
copyToFile(file, config, filename, prefix);
KSharedConfig::Ptr kalendarConfig = KSharedConfig::openConfig(config);
convertCollectionListStrToAkonadiId(kalendarConfig, QStringLiteral("GlobalCollectionSelection"), QStringLiteral("Selection"), true);
// TODO Resources Colors
kalendarConfig->sync();
}
void ImportCalendarJobInterface::importReminderAgentConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix)
{
copyToFile(file, config, filename, prefix);
......
......@@ -32,6 +32,7 @@ private:
void importkorganizerConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
void importeventViewConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
void importReminderAgentConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
void importKalendarConfig(const KArchiveFile *file, const QString &config, const QString &filename, const QString &prefix);
void restoreResources();
void restoreConfig();
void addSpecificResourceSettings(const KSharedConfig::Ptr &resourceConfig, const QString &resourceName, QMap<QString, QVariant> &settings) override;
......
......@@ -115,6 +115,7 @@ Root
| |---------dkimsettingsrc
| |---------confirmbeforedeletingrc
| |---------akonadi_newmailnotifier_agentrc
| |---------kalendarrc
|
|-----akonadi
| |---------<archive akonadi>
......
Supports Markdown
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