summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-09 11:33:36 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-09 11:33:36 (GMT)
commit3ed73e2c234834d0ab11749d0d192c9e9fd5ad17 (patch)
treeec78b0f8becc4981d6efc8b259a4c12756052360
parent89606b5444305e1e64d65d390a90dd2836c5580d (diff)
Avoid to duplicate code
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/configureplugins/configurepluginslistwidget.cpp41
-rw-r--r--src/configureplugins/configurepluginslistwidget.h3
3 files changed, 45 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d0fd65..1776205 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
include(ECMInstallIcons)
-set(PIM_VERSION "5.3.48")
+set(PIM_VERSION "5.3.49")
set(PIMCOMMON_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
diff --git a/src/configureplugins/configurepluginslistwidget.cpp b/src/configureplugins/configurepluginslistwidget.cpp
index 04680a9..e424c9f 100644
--- a/src/configureplugins/configurepluginslistwidget.cpp
+++ b/src/configureplugins/configurepluginslistwidget.cpp
@@ -81,3 +81,44 @@ void ConfigurePluginsListWidget::doResetToDefaultsOther()
void ConfigurePluginsListWidget::initialize()
{
}
+
+void ConfigurePluginsListWidget::savePlugins(const QString &groupName, const QString &prefixSettingKey, const QList<PluginItem *> &listItems)
+{
+ if (listItems.isEmpty()) {
+ return;
+ }
+ QStringList enabledPlugins;
+ QStringList disabledPlugins;
+ Q_FOREACH (PluginItem *item, listItems) {
+ if (item->checkState(0) == Qt::Checked) {
+ enabledPlugins << item->mIdentifier;
+ } else {
+ disabledPlugins << item->mIdentifier;
+ }
+ }
+ PimCommon::PluginUtil::savePluginSettings(groupName,
+ prefixSettingKey,
+ enabledPlugins, disabledPlugins);
+}
+
+void ConfigurePluginsListWidget::fillTopItems(const QVector<PimCommon::PluginUtilData> &lst, const QString &topLevelItemName,
+ const QString &groupName, const QString &prefixKey, QList<PluginItem *> &itemsList)
+{
+ itemsList.clear();
+ if (!lst.isEmpty()) {
+ QTreeWidgetItem *topLevel = new QTreeWidgetItem(mListWidget, QStringList() << topLevelItemName);
+ topLevel->setFlags(topLevel->flags() & ~Qt::ItemIsSelectable);
+ const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(groupName, prefixKey);
+ Q_FOREACH (const PimCommon::PluginUtilData &data, lst) {
+ PluginItem *subItem = new PluginItem(topLevel);
+ subItem->setText(0, data.mName);
+ subItem->mIdentifier = data.mIdentifier;
+ subItem->mDescription = data.mDescription;
+ subItem->mEnableByDefault = data.mEnableByDefault;
+ const bool isPluginActivated = PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, data.mEnableByDefault, data.mIdentifier);
+ subItem->setCheckState(0, isPluginActivated ? Qt::Checked : Qt::Unchecked);
+ itemsList.append(subItem);
+ }
+ }
+}
+
diff --git a/src/configureplugins/configurepluginslistwidget.h b/src/configureplugins/configurepluginslistwidget.h
index 58adec4..dc05d4e 100644
--- a/src/configureplugins/configurepluginslistwidget.h
+++ b/src/configureplugins/configurepluginslistwidget.h
@@ -20,6 +20,7 @@
#include <QWidget>
#include "pimcommon_export.h"
+#include "pimcommon/pluginutil.h"
#include <QTreeWidgetItem>
class QTreeWidget;
@@ -58,6 +59,8 @@ protected:
QString mDescription;
bool mEnableByDefault;
};
+ void savePlugins(const QString &groupName, const QString &prefixSettingKey, const QList<PluginItem *> &listItems);
+ void fillTopItems(const QVector<PimCommon::PluginUtilData> &lst, const QString &topLevelItemName, const QString &groupName, const QString &prefixKey, QList<PluginItem *> &itemsList);
QTreeWidget *mListWidget;
};
}