You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
4.0 KiB
166 lines
4.0 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
|
||
|
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
#ifndef KCONFIGPROPAGATOR_H
|
||
|
#define KCONFIGPROPAGATOR_H
|
||
|
|
||
14 years ago
|
#include <tqstring.h>
|
||
|
#include <tqvaluelist.h>
|
||
|
#include <tqdom.h>
|
||
|
#include <tqptrlist.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
|
class KConfigSkeleton;
|
||
|
class KConfigSkeletonItem;
|
||
|
|
||
|
class KDE_EXPORT KConfigPropagator
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
Create KConfigPropagator object without associated source configuration.
|
||
|
*/
|
||
|
KConfigPropagator();
|
||
|
/**
|
||
|
Create KConfigPropagator object.
|
||
|
|
||
|
@param skeleton KConfigSkeleton object used as source for the propagation
|
||
|
@param kcfgFile file name of kcfg file containing the propagation rules
|
||
|
*/
|
||
14 years ago
|
KConfigPropagator( KConfigSkeleton *skeleton, const TQString &kcfgFile );
|
||
15 years ago
|
virtual ~KConfigPropagator() {}
|
||
|
|
||
|
KConfigSkeleton *skeleton() { return mSkeleton; }
|
||
|
|
||
|
/*
|
||
|
Commit changes according to propagation rules.
|
||
|
*/
|
||
|
void commit();
|
||
|
|
||
|
class KDE_EXPORT Condition
|
||
|
{
|
||
|
public:
|
||
|
Condition() : isValid( false ) {}
|
||
|
|
||
14 years ago
|
TQString file;
|
||
|
TQString group;
|
||
|
TQString key;
|
||
|
TQString value;
|
||
15 years ago
|
|
||
|
bool isValid;
|
||
|
};
|
||
|
|
||
|
class KDE_EXPORT Rule
|
||
|
{
|
||
|
public:
|
||
14 years ago
|
typedef TQValueList<Rule> List;
|
||
15 years ago
|
|
||
|
Rule() : hideValue( false ) {}
|
||
|
|
||
14 years ago
|
TQString sourceFile;
|
||
|
TQString sourceGroup;
|
||
|
TQString sourceEntry;
|
||
15 years ago
|
|
||
14 years ago
|
TQString targetFile;
|
||
|
TQString targetGroup;
|
||
|
TQString targetEntry;
|
||
15 years ago
|
|
||
|
Condition condition;
|
||
|
|
||
|
bool hideValue;
|
||
|
};
|
||
|
|
||
|
class KDE_EXPORT Change
|
||
|
{
|
||
|
public:
|
||
14 years ago
|
typedef TQPtrList<Change> List;
|
||
15 years ago
|
|
||
14 years ago
|
Change( const TQString &title ) : mTitle( title ) {}
|
||
15 years ago
|
virtual ~Change();
|
||
|
|
||
14 years ago
|
void setTitle( const TQString &title ) { mTitle = title; }
|
||
|
TQString title() const { return mTitle; }
|
||
15 years ago
|
|
||
14 years ago
|
virtual TQString arg1() const { return TQString(); }
|
||
|
virtual TQString arg2() const { return TQString(); }
|
||
15 years ago
|
|
||
|
virtual void apply() = 0;
|
||
|
|
||
|
private:
|
||
14 years ago
|
TQString mTitle;
|
||
15 years ago
|
};
|
||
|
|
||
|
class KDE_EXPORT ChangeConfig : public Change
|
||
|
{
|
||
|
public:
|
||
|
ChangeConfig();
|
||
|
~ChangeConfig() {}
|
||
|
|
||
14 years ago
|
TQString arg1() const;
|
||
|
TQString arg2() const;
|
||
15 years ago
|
|
||
|
void apply();
|
||
|
|
||
14 years ago
|
TQString file;
|
||
|
TQString group;
|
||
|
TQString name;
|
||
|
TQString label;
|
||
|
TQString value;
|
||
15 years ago
|
bool hideValue;
|
||
|
};
|
||
|
|
||
|
void updateChanges();
|
||
|
|
||
|
Change::List changes();
|
||
|
|
||
|
Rule::List rules();
|
||
|
|
||
|
protected:
|
||
|
void init();
|
||
|
|
||
|
/**
|
||
|
Implement this function in a subclass if you want to add changes which
|
||
|
can't be expressed as propagations in the kcfg file.
|
||
|
*/
|
||
|
virtual void addCustomChanges( Change::List & ) {}
|
||
|
|
||
14 years ago
|
KConfigSkeletonItem *findItem( const TQString &group, const TQString &name );
|
||
15 years ago
|
|
||
14 years ago
|
TQString itemValueAsString( KConfigSkeletonItem * );
|
||
15 years ago
|
|
||
|
void readKcfgFile();
|
||
|
|
||
14 years ago
|
Rule parsePropagation( const TQDomElement &e );
|
||
|
Condition parseCondition( const TQDomElement &e );
|
||
15 years ago
|
|
||
14 years ago
|
void parseConfigEntryPath( const TQString &path, TQString &file,
|
||
|
TQString &group, TQString &entry );
|
||
15 years ago
|
|
||
|
private:
|
||
|
KConfigSkeleton *mSkeleton;
|
||
14 years ago
|
TQString mKcfgFile;
|
||
15 years ago
|
|
||
|
Rule::List mRules;
|
||
|
Change::List mChanges;
|
||
|
};
|
||
|
|
||
|
#endif
|