2007-07-18 11:26:24 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
2007-07-18 11:26:24 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2007-07-18 11:26:24 +02:00
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-08-06 11:19:29 +02:00
|
|
|
#ifndef PLASMA_CONFIGXML_H
|
|
|
|
#define PLASMA_CONFIGXML_H
|
2007-07-18 11:26:24 +02:00
|
|
|
|
2007-11-25 19:17:19 +01:00
|
|
|
#include <KDE/KConfigGroup>
|
|
|
|
#include <KDE/KConfigSkeleton>
|
|
|
|
#include <KDE/KSharedConfig>
|
2007-07-18 11:26:24 +02:00
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
/**
|
2008-08-25 19:47:48 +02:00
|
|
|
* @class ConfigXml plasma/configxml.h <Plasma/ConfigXml>
|
|
|
|
*
|
|
|
|
* @short A KConfigSkeleton that populates itself based on KConfigXT XML
|
2007-07-18 11:26:24 +02:00
|
|
|
*
|
|
|
|
* This class allows one to ship an XML file and reconstitute it into a
|
|
|
|
* KConfigSkeleton object at runtime. Common usage might look like this:
|
2007-09-10 17:07:29 +02:00
|
|
|
*
|
2007-07-18 11:26:24 +02:00
|
|
|
* \code
|
|
|
|
* QFile file(xmlFilePath);
|
|
|
|
* Plasma::ConfigXml appletConfig(configFilePath, &file);
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* Alternatively, any QIODevice may be used in place of QFile in the
|
|
|
|
* example above.
|
|
|
|
*
|
|
|
|
* Currently the following data types are supported:
|
|
|
|
*
|
|
|
|
* @li bools
|
|
|
|
* @li colors
|
|
|
|
* @li datetimes
|
|
|
|
* @li enumerations
|
|
|
|
* @li fonts
|
|
|
|
* @li ints
|
|
|
|
* @li passwords
|
|
|
|
* @li paths
|
|
|
|
* @li strings
|
|
|
|
* @li stringlists
|
|
|
|
* @li uints
|
|
|
|
* @li urls
|
|
|
|
* @li doubles
|
|
|
|
* @li int lists
|
|
|
|
* @li longlongs
|
|
|
|
* @li path lists
|
|
|
|
* @li points
|
|
|
|
* @li rects
|
|
|
|
* @li sizes
|
|
|
|
* @li ulonglongs
|
|
|
|
* @li url lists
|
|
|
|
**/
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class ConfigXmlPrivate;
|
|
|
|
|
2007-07-18 11:26:24 +02:00
|
|
|
class PLASMA_EXPORT ConfigXml : public KConfigSkeleton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a KConfigSkeleton populated using the definition found in
|
|
|
|
* the XML data passed in.
|
|
|
|
*
|
|
|
|
* @param configFile path to the configuration file to use
|
|
|
|
* @param xml the xml data; must be valid KConfigXT data
|
|
|
|
* @param parent optional QObject parent
|
|
|
|
**/
|
|
|
|
ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent = 0);
|
2007-07-30 18:18:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a KConfigSkeleton populated using the definition found in
|
|
|
|
* the XML data passed in.
|
|
|
|
*
|
2007-11-25 01:14:27 +01:00
|
|
|
* @param config the configuration object to use
|
|
|
|
* @param xml the xml data; must be valid KConfigXT data
|
|
|
|
* @param parent optional QObject parent
|
|
|
|
**/
|
|
|
|
ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a KConfigSkeleton populated using the definition found in
|
|
|
|
* the XML data passed in.
|
|
|
|
*
|
|
|
|
* @param config the group to use as the root for configuration items
|
2007-07-30 18:18:27 +02:00
|
|
|
* @param xml the xml data; must be valid KConfigXT data
|
|
|
|
* @param parent optional QObject parent
|
|
|
|
**/
|
2007-11-25 01:14:27 +01:00
|
|
|
ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
|
2007-07-18 11:26:24 +02:00
|
|
|
~ConfigXml();
|
|
|
|
|
2008-09-04 01:33:57 +02:00
|
|
|
/**
|
|
|
|
* Finds the item for the given group and key.
|
|
|
|
*
|
|
|
|
* @arg group the group in the config file to look in
|
|
|
|
* @arg key the configuration key to find
|
|
|
|
* @return the associated KConfigSkeletonItem, or 0 if none
|
|
|
|
*/
|
2008-05-18 06:28:27 +02:00
|
|
|
KConfigSkeletonItem* findItem(const QString &group, const QString &key);
|
|
|
|
|
2008-08-04 09:59:32 +02:00
|
|
|
/**
|
|
|
|
* Check to see if a group exists
|
|
|
|
*
|
|
|
|
* @param group the name of the group to check for
|
|
|
|
* @return true if the group exists, or false if it does not
|
|
|
|
*/
|
|
|
|
bool hasGroup(const QString &group) const;
|
|
|
|
|
2008-09-04 00:28:10 +02:00
|
|
|
/**
|
|
|
|
* @return the list of groups defined by the XML
|
|
|
|
*/
|
|
|
|
QStringList groupList() const;
|
2008-09-04 01:33:57 +02:00
|
|
|
|
2007-07-18 11:26:24 +02:00
|
|
|
private:
|
2008-07-01 20:56:43 +02:00
|
|
|
ConfigXmlPrivate * const d;
|
2007-07-18 11:26:24 +02:00
|
|
|
};
|
|
|
|
|
2007-07-18 16:36:42 +02:00
|
|
|
} // Plasma namespace
|
2007-07-18 11:26:24 +02:00
|
|
|
|
|
|
|
#endif //multiple inclusion guard
|