Script - writeConfig with QVariant

Kevin Funk krf at gmx.de
Sun Mar 17 18:41:30 UTC 2013


On Friday 15 March 2013, 00:10, El boulangero wrote:
> Hi again,
> 
> > After that, I tried to hack in the writeConfig function, create a new
> > QVariant with a simple string, and feed it to the
> > KConfigGroup::writeEntry( QString, QVariant ) function.
> > 
> > But then I got the following error from Amarok:
> >> KConfigGroup::writeEntry: KConfigGroup::writeEntry - unhandled type
> >> QVariantMap in group "Good Morning"
> My bad, I messed up, I launched the wrong binary.
> So, let me start again.
> 
> If I hack the writeConfig, and do something like that:
> >    void AmarokScriptConfig::writeConfig( const QString &name, const
> >    QVariant &content, int dummy ) {
> >    
> >        QVariant v("yop");
> >        KGlobal::config()->group( m_name ).writeEntry( name, v );
> >    
> >    }
> 
> It works just fine, I got the expected result.
> 
> But if I let function as it is, ie:
> >    void AmarokScriptConfig::writeConfig( const QString &name, const
> >    QVariant &content, int dummy ) {
> >    
> >        KGlobal::config()->group( m_name ).writeEntry( name, content );
> >    
> >    }
> 
> I get the error:
> > KConfigGroup::writeEntry: KConfigGroup::writeEntry - unhandled type
> > QVariantMap in group "Good Morning"
> I guess it means my javascript object is converted to a QVariantMap by
> the binding. And KConfigGroup::writeEntry is unabled to interpret
> that.
> Am I correct ?
> 
> Regards

I think so,

if you look at [1] you can see that there is no code path for QVariant::Map.
Just restructure your config data so it can be properly (de)serialized. Lists are 
supported in KConfigGroup, so try to use them.

Greets

[1] http://api.kde.org/4.10-api/kdelibs-apidocs/kdecore/html/kconfiggroup_8cpp_source.html

-- 
Kevin Funk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/amarok/attachments/20130317/968e2824/attachment.html>


More information about the Amarok mailing list