From 124dd4bd63093bcd4f91c6f56e626568f5473912 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 3 Sep 2008 23:33:57 +0000 Subject: [PATCH] various fixes i've come across while working on services stuff today svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=856868 --- configxml.cpp | 25 +++++++++++-------------- configxml.h | 8 ++++++++ service.cpp | 1 + servicejob.cpp | 6 ++++++ servicejob.h | 2 ++ 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/configxml.cpp b/configxml.cpp index 64b00aec8..a1feec536 100644 --- a/configxml.cpp +++ b/configxml.cpp @@ -308,18 +308,18 @@ bool ConfigXmlHandler::endElement(const QString &namespaceURI, const QString &lo resetState(); } else if (tag == "label") { if (m_inChoice) { - m_choice.label = m_cdata; + m_choice.label = m_cdata.trimmed(); } else { - m_label = m_cdata; + m_label = m_cdata.trimmed(); } } else if (tag == "whatsthis") { if (m_inChoice) { - m_choice.whatsThis = m_cdata; + m_choice.whatsThis = m_cdata.trimmed(); } else { - m_whatsThis = m_cdata; + m_whatsThis = m_cdata.trimmed(); } } else if (tag == "default") { - m_default = m_cdata; + m_default = m_cdata.trimmed(); } else if (tag == "min") { m_min = m_cdata.toInt(&m_haveMin); } else if (tag == "max") { @@ -361,16 +361,17 @@ void ConfigXmlHandler::addItem() } else if (m_type == "font") { item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); } else if (m_type == "int") { - KConfigSkeleton::ItemInt* intItem = m_config->addItemInt(m_name, - *d->newInt(), - m_default.toInt(), - m_key); + KConfigSkeleton::ItemInt* intItem = m_config->addItemInt(m_name, *d->newInt(), + m_default.toInt(), m_key); + if (m_haveMin) { intItem->setMinValue(m_min); } + if (m_haveMax) { intItem->setMaxValue(m_max); } + item = intItem; } else if (m_type == "password") { item = m_config->addItemPassword(m_name, *d->newString(), m_default, m_key); @@ -504,11 +505,7 @@ ConfigXml::ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent) : KConfigSkeleton(configFile, parent), d(new ConfigXmlPrivate) { - QXmlInputSource source(xml); - QXmlSimpleReader reader; - ConfigXmlHandler handler(this, d); - reader.setContentHandler(&handler); - reader.parse(&source, false); + d->parse(this, xml); } ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent) diff --git a/configxml.h b/configxml.h index 97685f275..42e8a2ec7 100644 --- a/configxml.h +++ b/configxml.h @@ -108,6 +108,13 @@ public: ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0); ~ConfigXml(); + /** + * 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 + */ KConfigSkeletonItem* findItem(const QString &group, const QString &key); /** @@ -122,6 +129,7 @@ public: * @return the list of groups defined by the XML */ QStringList groupList() const; + private: ConfigXmlPrivate * const d; }; diff --git a/service.cpp b/service.cpp index 0f68b4c87..e156463c6 100644 --- a/service.cpp +++ b/service.cpp @@ -125,6 +125,7 @@ KConfigGroup Service::operationDescription(const QString &operationName) return KConfigGroup(); } + d->config->writeConfig(); KConfigGroup params(d->config->config(), operationName); return params; } diff --git a/servicejob.cpp b/servicejob.cpp index 9588dceb7..e3bb09862 100644 --- a/servicejob.cpp +++ b/servicejob.cpp @@ -35,6 +35,12 @@ public: parameters(params) { } + + void slotStart() + { + q->start(); + } + ServiceJob* q; QString destination; QString operation; diff --git a/servicejob.h b/servicejob.h index 2c51efa5b..07ad2389c 100644 --- a/servicejob.h +++ b/servicejob.h @@ -110,6 +110,8 @@ protected: void setResult(const QVariant &result); private: + Q_PRIVATE_SLOT(d, void slotStart()) + ServiceJobPrivate * const d; };