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 <tqstring.h>
00025 #include <tqvaluelist.h>
00026 #include <tqdom.h>
00027 #include <tqptrlist.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 TQString &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 TQString file;
00064 TQString group;
00065 TQString key;
00066 TQString value;
00067
00068 bool isValid;
00069 };
00070
00071 class KDE_EXPORT Rule
00072 {
00073 public:
00074 typedef TQValueList<Rule> List;
00075
00076 Rule() : hideValue( false ) {}
00077
00078 TQString sourceFile;
00079 TQString sourceGroup;
00080 TQString sourceEntry;
00081
00082 TQString targetFile;
00083 TQString targetGroup;
00084 TQString targetEntry;
00085
00086 Condition condition;
00087
00088 bool hideValue;
00089 };
00090
00091 class KDE_EXPORT Change
00092 {
00093 public:
00094 typedef TQPtrList<Change> List;
00095
00096 Change( const TQString &title ) : mTitle( title ) {}
00097 virtual ~Change();
00098
00099 void setTitle( const TQString &title ) { mTitle = title; }
00100 TQString title() const { return mTitle; }
00101
00102 virtual TQString arg1() const { return TQString(); }
00103 virtual TQString arg2() const { return TQString(); }
00104
00105 virtual void apply() = 0;
00106
00107 private:
00108 TQString mTitle;
00109 };
00110
00111 class KDE_EXPORT ChangeConfig : public Change
00112 {
00113 public:
00114 ChangeConfig();
00115 ~ChangeConfig() {}
00116
00117 TQString arg1() const;
00118 TQString arg2() const;
00119
00120 void apply();
00121
00122 TQString file;
00123 TQString group;
00124 TQString name;
00125 TQString label;
00126 TQString 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 TQString &group, const TQString &name );
00146
00147 TQString itemValueAsString( KConfigSkeletonItem * );
00148
00149 void readKcfgFile();
00150
00151 Rule parsePropagation( const TQDomElement &e );
00152 Condition parseCondition( const TQDomElement &e );
00153
00154 void parseConfigEntryPath( const TQString &path, TQString &file,
00155 TQString &group, TQString &entry );
00156
00157 private:
00158 KConfigSkeleton *mSkeleton;
00159 TQString mKcfgFile;
00160
00161 Rule::List mRules;
00162 Change::List mChanges;
00163 };
00164
00165 #endif
|