summaryrefslogtreecommitdiffstats
path: root/libkdepim/kconfigpropagator.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /libkdepim/kconfigpropagator.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdepim/kconfigpropagator.h')
-rw-r--r--libkdepim/kconfigpropagator.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/libkdepim/kconfigpropagator.h b/libkdepim/kconfigpropagator.h
new file mode 100644
index 000000000..7c5c92cc5
--- /dev/null
+++ b/libkdepim/kconfigpropagator.h
@@ -0,0 +1,165 @@
+/*
+ This file is part of libkdepim.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef KCONFIGPROPAGATOR_H
+#define KCONFIGPROPAGATOR_H
+
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <qdom.h>
+#include <qptrlist.h>
+
+#include <kdepimmacros.h>
+
+class KConfigSkeleton;
+class KConfigSkeletonItem;
+
+class KDE_EXPORT KConfigPropagator
+{
+ public:
+
+ /**
+ Create KConfigPropagator object without associated source configuration.
+ */
+ KConfigPropagator();
+ /**
+ Create KConfigPropagator object.
+
+ @param skeleton KConfigSkeleton object used as source for the propagation
+ @param kcfgFile file name of kcfg file containing the propagation rules
+ */
+ KConfigPropagator( KConfigSkeleton *skeleton, const QString &kcfgFile );
+ virtual ~KConfigPropagator() {}
+
+ KConfigSkeleton *skeleton() { return mSkeleton; }
+
+ /*
+ Commit changes according to propagation rules.
+ */
+ void commit();
+
+ class KDE_EXPORT Condition
+ {
+ public:
+ Condition() : isValid( false ) {}
+
+ QString file;
+ QString group;
+ QString key;
+ QString value;
+
+ bool isValid;
+ };
+
+ class KDE_EXPORT Rule
+ {
+ public:
+ typedef QValueList<Rule> List;
+
+ Rule() : hideValue( false ) {}
+
+ QString sourceFile;
+ QString sourceGroup;
+ QString sourceEntry;
+
+ QString targetFile;
+ QString targetGroup;
+ QString targetEntry;
+
+ Condition condition;
+
+ bool hideValue;
+ };
+
+ class KDE_EXPORT Change
+ {
+ public:
+ typedef QPtrList<Change> List;
+
+ Change( const QString &title ) : mTitle( title ) {}
+ virtual ~Change();
+
+ void setTitle( const QString &title ) { mTitle = title; }
+ QString title() const { return mTitle; }
+
+ virtual QString arg1() const { return QString::null; }
+ virtual QString arg2() const { return QString::null; }
+
+ virtual void apply() = 0;
+
+ private:
+ QString mTitle;
+ };
+
+ class KDE_EXPORT ChangeConfig : public Change
+ {
+ public:
+ ChangeConfig();
+ ~ChangeConfig() {}
+
+ QString arg1() const;
+ QString arg2() const;
+
+ void apply();
+
+ QString file;
+ QString group;
+ QString name;
+ QString label;
+ QString value;
+ bool hideValue;
+ };
+
+ void updateChanges();
+
+ Change::List changes();
+
+ Rule::List rules();
+
+ protected:
+ void init();
+
+ /**
+ Implement this function in a subclass if you want to add changes which
+ can't be expressed as propagations in the kcfg file.
+ */
+ virtual void addCustomChanges( Change::List & ) {}
+
+ KConfigSkeletonItem *findItem( const QString &group, const QString &name );
+
+ QString itemValueAsString( KConfigSkeletonItem * );
+
+ void readKcfgFile();
+
+ Rule parsePropagation( const QDomElement &e );
+ Condition parseCondition( const QDomElement &e );
+
+ void parseConfigEntryPath( const QString &path, QString &file,
+ QString &group, QString &entry );
+
+ private:
+ KConfigSkeleton *mSkeleton;
+ QString mKcfgFile;
+
+ Rule::List mRules;
+ Change::List mChanges;
+};
+
+#endif