libkdepim
kconfigpropagator.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KCONFIGPROPAGATOR_H
00022 #define KCONFIGPROPAGATOR_H
00023
00024 #include <qstring.h>
00025 #include <qvaluelist.h>
00026 #include <qdom.h>
00027 #include <qptrlist.h>
00028
00029 #include <kdepimmacros.h>
00030
00031 class KConfigSkeleton;
00032 class KConfigSkeletonItem;
00033
00034 class KDE_EXPORT KConfigPropagator
00035 {
00036 public:
00037
00041 KConfigPropagator();
00048 KConfigPropagator( KConfigSkeleton *skeleton, const QString &kcfgFile );
00049 virtual ~KConfigPropagator() {}
00050
00051 KConfigSkeleton *skeleton() { return mSkeleton; }
00052
00053
00054
00055
00056 void commit();
00057
00058 class KDE_EXPORT Condition
00059 {
00060 public:
00061 Condition() : isValid( false ) {}
00062
00063 QString file;
00064 QString group;
00065 QString key;
00066 QString value;
00067
00068 bool isValid;
00069 };
00070
00071 class KDE_EXPORT Rule
00072 {
00073 public:
00074 typedef QValueList<Rule> List;
00075
00076 Rule() : hideValue( false ) {}
00077
00078 QString sourceFile;
00079 QString sourceGroup;
00080 QString sourceEntry;
00081
00082 QString targetFile;
00083 QString targetGroup;
00084 QString targetEntry;
00085
00086 Condition condition;
00087
00088 bool hideValue;
00089 };
00090
00091 class KDE_EXPORT Change
00092 {
00093 public:
00094 typedef QPtrList<Change> List;
00095
00096 Change( const QString &title ) : mTitle( title ) {}
00097 virtual ~Change();
00098
00099 void setTitle( const QString &title ) { mTitle = title; }
00100 QString title() const { return mTitle; }
00101
00102 virtual QString arg1() const { return QString::null; }
00103 virtual QString arg2() const { return QString::null; }
00104
00105 virtual void apply() = 0;
00106
00107 private:
00108 QString mTitle;
00109 };
00110
00111 class KDE_EXPORT ChangeConfig : public Change
00112 {
00113 public:
00114 ChangeConfig();
00115 ~ChangeConfig() {}
00116
00117 QString arg1() const;
00118 QString arg2() const;
00119
00120 void apply();
00121
00122 QString file;
00123 QString group;
00124 QString name;
00125 QString label;
00126 QString value;
00127 bool hideValue;
00128 };
00129
00130 void updateChanges();
00131
00132 Change::List changes();
00133
00134 Rule::List rules();
00135
00136 protected:
00137 void init();
00138
00143 virtual void addCustomChanges( Change::List & ) {}
00144
00145 KConfigSkeletonItem *findItem( const QString &group, const QString &name );
00146
00147 QString itemValueAsString( KConfigSkeletonItem * );
00148
00149 void readKcfgFile();
00150
00151 Rule parsePropagation( const QDomElement &e );
00152 Condition parseCondition( const QDomElement &e );
00153
00154 void parseConfigEntryPath( const QString &path, QString &file,
00155 QString &group, QString &entry );
00156
00157 private:
00158 KConfigSkeleton *mSkeleton;
00159 QString mKcfgFile;
00160
00161 Rule::List mRules;
00162 Change::List mChanges;
00163 };
00164
00165 #endif
|