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>
31 class KConfigSkeleton
;
32 class KConfigSkeletonItem
;
36 class KDEPIM_EXPORT KConfigPropagator
41 Create KConfigPropagator object without associated source configuration.
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.
60 class KDEPIM_EXPORT Condition
63 Condition() : isValid( false ) {}
73 class KDEPIM_EXPORT Rule
76 typedef QList
<Rule
> List
;
78 Rule() : hideValue( false ) {}
93 class KDEPIM_EXPORT Change
96 typedef Q3PtrList
<Change
> List
;
98 Change( const QString
&title
) : mTitle( title
) {}
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;
113 class KDEPIM_EXPORT ChangeConfig
: public Change
119 QString
arg1() const;
120 QString
arg2() const;
132 void updateChanges();
134 Change::List
changes();
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
* );
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
);
160 KConfigSkeleton
*mSkeleton
;
164 Change::List mChanges
;