00001
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
class KConfigSkeleton;
00030
class KConfigSkeletonItem;
00031
00032
class KConfigPropagator
00033 {
00034
public:
00035
00039 KConfigPropagator();
00046 KConfigPropagator( KConfigSkeleton *skeleton,
const QString &kcfgFile );
00047
virtual ~KConfigPropagator() {}
00048
00049 KConfigSkeleton *skeleton() {
return mSkeleton; }
00050
00051
00052
00053
00054
void commit();
00055
00056
class Condition
00057 {
00058
public:
00059 Condition() : isValid( false ) {}
00060
00061
QString file;
00062
QString group;
00063
QString key;
00064
QString value;
00065
00066
bool isValid;
00067 };
00068
00069
class Rule
00070 {
00071
public:
00072
typedef QValueList<Rule> List;
00073
00074 Rule() : hideValue( false ) {}
00075
00076
QString sourceFile;
00077
QString sourceGroup;
00078
QString sourceEntry;
00079
00080
QString targetFile;
00081
QString targetGroup;
00082
QString targetEntry;
00083
00084 Condition condition;
00085
00086
bool hideValue;
00087 };
00088
00089
class Change
00090 {
00091
public:
00092
typedef QPtrList<Change> List;
00093
00094 Change(
const QString &title ) : mTitle( title ) {}
00095
virtual ~Change();
00096
00097
void setTitle(
const QString &title ) { mTitle = title; }
00098
QString title()
const {
return mTitle; }
00099
00100
virtual QString arg1()
const {
return QString::null; }
00101
virtual QString arg2()
const {
return QString::null; }
00102
00103
virtual void apply() = 0;
00104
00105
private:
00106
QString mTitle;
00107 };
00108
00109
class ChangeConfig :
public Change
00110 {
00111
public:
00112 ChangeConfig();
00113 ~ChangeConfig() {}
00114
00115
QString arg1() const;
00116
QString arg2() const;
00117
00118
void apply();
00119
00120
QString file;
00121
QString group;
00122
QString name;
00123
QString label;
00124
QString value;
00125
bool hideValue;
00126 };
00127
00128
void updateChanges();
00129
00130 Change::List changes();
00131
00132 Rule::List rules();
00133
00134 protected:
00135
void init();
00136
00141 virtual
void addCustomChanges( Change::List & ) {}
00142
00143 KConfigSkeletonItem *findItem(
const QString &group,
const QString &name );
00144
00145
QString itemValueAsString( KConfigSkeletonItem * );
00146
00147
void readKcfgFile();
00148
00149 Rule parsePropagation(
const QDomElement &e );
00150 Condition parseCondition(
const QDomElement &e );
00151
00152
void parseConfigEntryPath(
const QString &path,
QString &file,
00153
QString &group,
QString &entry );
00154
00155
private:
00156 KConfigSkeleton *mSkeleton;
00157
QString mKcfgFile;
00158
00159 Rule::List mRules;
00160 Change::List mChanges;
00161 };
00162
00163
#endif