Fix typo found by Yuri Chornoivan
[kdepim.git] / libkdepim / kconfigpropagator.h
blobc5be9c7b382d976b1a394235b4ee84aa60d63245
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #ifndef KDEPIM_KCONFIGPROPAGATOR_H
22 #define KDEPIM_KCONFIGPROPAGATOR_H
24 #include "kdepim_export.h"
26 #include <QDomElement>
27 #include <QList>
28 #include <QString>
29 #include <Q3PtrList>
31 class KConfigSkeleton;
32 class KConfigSkeletonItem;
34 namespace KPIM {
36 class KDEPIM_EXPORT KConfigPropagator
38 public:
40 /**
41 Create KConfigPropagator object without associated source configuration.
43 KConfigPropagator();
44 /**
45 Create KConfigPropagator object.
47 @param skeleton KConfigSkeleton object used as source for the propagation
48 @param kcfgFile file name of kcfg file containing the propagation rules
50 KConfigPropagator( KConfigSkeleton *skeleton, const QString &kcfgFile );
51 virtual ~KConfigPropagator() {}
53 KConfigSkeleton *skeleton() { return mSkeleton; }
56 Commit changes according to propagation rules.
58 void commit();
60 class KDEPIM_EXPORT Condition
62 public:
63 Condition() : isValid( false ) {}
65 QString file;
66 QString group;
67 QString key;
68 QString value;
70 bool isValid;
73 class KDEPIM_EXPORT Rule
75 public:
76 typedef QList<Rule> List;
78 Rule() : hideValue( false ) {}
80 QString sourceFile;
81 QString sourceGroup;
82 QString sourceEntry;
84 QString targetFile;
85 QString targetGroup;
86 QString targetEntry;
88 Condition condition;
90 bool hideValue;
93 class KDEPIM_EXPORT Change
95 public:
96 typedef Q3PtrList<Change> List;
98 Change( const QString &title ) : mTitle( title ) {}
99 virtual ~Change();
101 void setTitle( const QString &title ) { mTitle = title; }
102 QString title() const { return mTitle; }
104 virtual QString arg1() const { return QString(); }
105 virtual QString arg2() const { return QString(); }
107 virtual void apply() = 0;
109 private:
110 QString mTitle;
113 class KDEPIM_EXPORT ChangeConfig : public Change
115 public:
116 ChangeConfig();
117 ~ChangeConfig() {}
119 QString arg1() const;
120 QString arg2() const;
122 void apply();
124 QString file;
125 QString group;
126 QString name;
127 QString label;
128 QString value;
129 bool hideValue;
132 void updateChanges();
134 Change::List changes();
136 Rule::List rules();
138 protected:
139 void init();
142 Implement this function in a subclass if you want to add changes which
143 can't be expressed as propagations in the kcfg file.
145 virtual void addCustomChanges( Change::List & ) {}
147 KConfigSkeletonItem *findItem( const QString &group, const QString &name );
149 QString itemValueAsString( KConfigSkeletonItem * );
151 void readKcfgFile();
153 Rule parsePropagation( const QDomElement &e );
154 Condition parseCondition( const QDomElement &e );
156 void parseConfigEntryPath( const QString &path, QString &file,
157 QString &group, QString &entry );
159 private:
160 KConfigSkeleton *mSkeleton;
161 QString mKcfgFile;
163 Rule::List mRules;
164 Change::List mChanges;
169 #endif