[PATCH] Allow KConfigGroup to write any QVariant wrapped type

Andreas Pakulat apaku at gmx.de
Mon Mar 19 18:26:07 GMT 2007


Hi,

while revisiting my KConfigXT patch I came across a problem, because
KConfigGroup uses the QVariant() constructor. This makes it (AFAICS)
impossible to use KUrl::List (for example) with writeEntry<> or
readEntry<>, at least I get a bunch of errors because there's no
QVariant constructor for that.

I think the attached patch is the proper fix for that and it would be
cool if somebody could comment soon so I may commit it until bic monday
is over.

Andreas

-- 
You definitely intend to start living sometime soon.
-------------- next part --------------
Index: kdecore/config/kconfiggroup.h
===================================================================
--- kdecore/config/kconfiggroup.h	(Revision 642947)
+++ kdecore/config/kconfiggroup.h	(Arbeitskopie)
@@ -662,7 +662,7 @@ inline T KConfigGroup::readEntry( const 
 #if KCONFIG_QVARIANT_CHECK
   ConversionCheck::to_QVariant<T>();
 #endif
-  return qvariant_cast<T>(readEntry(pKey, QVariant(aDefault)));
+  return qvariant_cast<T>(readEntry(pKey, qVariantFromValue(aDefault)));
 }
 
 template <typename T>
@@ -693,7 +693,7 @@ inline void KConfigGroup::writeEntry( co
 #if KCONFIG_QVARIANT_CHECK
   ConversionCheck::to_QVariant<T>();
 #endif
-  writeEntry( pKey, QVariant(value), pFlags );
+  writeEntry( pKey, qVariantFromValue(value), pFlags );
 }
 
 #endif // KCONFIGGROUP_H


More information about the kde-core-devel mailing list