future proof the ConfigXml API a bit by pretending we actually know what to do with a KConfigGroup
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=741174
This commit is contained in:
parent
9c31a55b06
commit
f54dcc2cc1
@ -169,7 +169,8 @@ public:
|
|||||||
if (!xmlPath.isEmpty()) {
|
if (!xmlPath.isEmpty()) {
|
||||||
QFile file(xmlPath);
|
QFile file(xmlPath);
|
||||||
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
|
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
|
||||||
//configXml = new ConfigXml(applet->config(), &file);
|
KConfigGroup config = applet->config();
|
||||||
|
configXml = new ConfigXml(&config, &file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!package->filePath("mainconfigui").isEmpty()) {
|
if (!package->filePath("mainconfigui").isEmpty()) {
|
||||||
|
@ -174,6 +174,8 @@ class ConfigXml::Private
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parse(ConfigXml *configXml, QIODevice *xml);
|
||||||
|
|
||||||
QList<bool*> bools;
|
QList<bool*> bools;
|
||||||
QList<QString*> strings;
|
QList<QString*> strings;
|
||||||
QList<QStringList*> stringlists;
|
QList<QStringList*> stringlists;
|
||||||
@ -223,6 +225,16 @@ private:
|
|||||||
bool m_inChoice;
|
bool m_inChoice;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ConfigXml::Private::parse(ConfigXml *configXml, QIODevice *xml)
|
||||||
|
{
|
||||||
|
QXmlInputSource source(xml);
|
||||||
|
QXmlSimpleReader reader;
|
||||||
|
ConfigXmlHandler handler(configXml, this);
|
||||||
|
reader.setContentHandler(&handler);
|
||||||
|
reader.parse(&source, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<bool*> bools;
|
||||||
ConfigXmlHandler::ConfigXmlHandler(ConfigXml* config, ConfigXml::Private* d)
|
ConfigXmlHandler::ConfigXmlHandler(ConfigXml* config, ConfigXml::Private* d)
|
||||||
: QXmlDefaultHandler(),
|
: QXmlDefaultHandler(),
|
||||||
m_config(config),
|
m_config(config),
|
||||||
@ -495,15 +507,21 @@ ConfigXml::ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent)
|
|||||||
reader.parse(&source, false);
|
reader.parse(&source, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml::ConfigXml(KSharedConfig::Ptr config, QIODevice *xml, QObject *parent)
|
ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
|
||||||
: KConfigSkeleton(config, parent),
|
: KConfigSkeleton(config, parent),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
QXmlInputSource source(xml);
|
d->parse(this, xml);
|
||||||
QXmlSimpleReader reader;
|
}
|
||||||
ConfigXmlHandler handler(this, d);
|
|
||||||
reader.setContentHandler(&handler);
|
//FIXME: obviously this is broken and should be using the group as the root,
|
||||||
reader.parse(&source, false);
|
// but KConfigSkeleton does not currently support this. it will eventually though,
|
||||||
|
// at which point this can be addressed properly
|
||||||
|
ConfigXml::ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent)
|
||||||
|
: KConfigSkeleton(KSharedConfig::openConfig(config->config()->name()), parent),
|
||||||
|
d(new Private)
|
||||||
|
{
|
||||||
|
d->parse(this, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml::~ConfigXml()
|
ConfigXml::~ConfigXml()
|
||||||
|
19
configxml.h
19
configxml.h
@ -20,8 +20,9 @@
|
|||||||
#ifndef CONFIGXML_H
|
#ifndef CONFIGXML_H
|
||||||
#define CONFIGXML_H
|
#define CONFIGXML_H
|
||||||
|
|
||||||
#include <kconfigskeleton.h>
|
#include <KConfigGroup>
|
||||||
#include <ksharedconfig.h>
|
#include <KConfigSkeleton>
|
||||||
|
#include <KSharedConfig>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
|
||||||
@ -84,11 +85,21 @@ public:
|
|||||||
* Creates a KConfigSkeleton populated using the definition found in
|
* Creates a KConfigSkeleton populated using the definition found in
|
||||||
* the XML data passed in.
|
* the XML data passed in.
|
||||||
*
|
*
|
||||||
* @param configFile path to the configuration file to use
|
* @param config the configuration object to use
|
||||||
* @param xml the xml data; must be valid KConfigXT data
|
* @param xml the xml data; must be valid KConfigXT data
|
||||||
* @param parent optional QObject parent
|
* @param parent optional QObject parent
|
||||||
**/
|
**/
|
||||||
ConfigXml(KSharedConfig::Ptr config, QIODevice *xml, QObject *parent = 0);
|
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
|
||||||
|
* @param xml the xml data; must be valid KConfigXT data
|
||||||
|
* @param parent optional QObject parent
|
||||||
|
**/
|
||||||
|
ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
|
||||||
~ConfigXml();
|
~ConfigXml();
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
Loading…
Reference in New Issue
Block a user