[prev in list] [next in list] [prev in thread] [next in thread]
List: amarok
Subject: Re: Script - writeConfig with QVariant
From: El boulangero <elboulangero () gmail ! com>
Date: 2013-03-20 22:29:06
Message-ID: CALGUdm9OaFspz45uVBRuHS_HY9thNAx8a7uOy_YshL3G74CETw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
> if you look at [1] you can see that there is no code path for
QVariant::Map.
thanks for the hint. I read that and also the KConfig tutorial [1], now I
understand better how it's supposed to work.
In the end I wrote a little serialize/deserialize function to automatically
read/write my JSON to the config file, it's very simple and it works great.
However, for each object (like QTime object or QList), I need to pass it to
Amarok.writeConfig() as a string, otherwise I get the error message
mentioned in my first mail:
> TypeError: ambiguous call of overloaded function writeConfig()
It's not a problem though, passing these objects as strings (with the JS
toString() function) gives the expected result.
Problem solved for me, thanks for the help !
Regards,
Arnaud
[1] http://techbase.kde.org/Development/Tutorials/KConfig
2013/3/17 Kevin Funk <krf@gmx.de>:
> 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
[Attachment #5 (text/html)]
Hi,<br><br>> if you look at [1] you can see that there is no code path \
for QVariant::Map.<br><br>thanks for the hint. I read that and also the \
KConfig tutorial [1], now I understand better how it's supposed to \
work.<br> <br>In the end I wrote a little serialize/deserialize function to \
automatically read/write my JSON to the config file, it's very simple \
and it works great.<br><br>However, for each object (like QTime object or \
QList), I need to pass it to Amarok.writeConfig() as a string, otherwise I \
get the error message mentioned in my first mail:<br> > TypeError: \
ambiguous call of overloaded function writeConfig()<br><br>It's not a \
problem though, passing these objects as strings (with the JS toString() \
function) gives the expected result.<br><br>Problem solved for me, thanks \
for the help !<br> <br>Regards,<br>Arnaud<br><br>[1] <a \
href="http://techbase.kde.org/Development/Tutorials/KConfig">http://techbase.kde.org/Development/Tutorials/KConfig</a><br><br>2013/3/17 \
Kevin Funk <<a href="mailto:krf@gmx.de">krf@gmx.de</a>>:<br> > On \
Friday 15 March 2013, 00:10, El boulangero wrote:<br>><br>>> Hi \
again,<br>><br>>><br>><br>>> > After that, I tried to \
hack in the writeConfig function, create a new<br>><br>>> > \
QVariant with a simple string, and feed it to the<br> ><br>>> > \
KConfigGroup::writeEntry( QString, QVariant ) function.<br>><br>>> \
><br>><br>>> > But then I got the following error from \
Amarok:<br>><br>>> >> KConfigGroup::writeEntry: \
KConfigGroup::writeEntry - unhandled type<br> ><br>>> >> \
QVariantMap in group "Good Morning"<br>><br>>> My bad, I \
messed up, I launched the wrong binary.<br>><br>>> So, let me \
start again.<br>><br>>><br>><br>>> If I hack the \
writeConfig, and do something like that:<br> ><br>>> > void \
AmarokScriptConfig::writeConfig( const QString &name, \
const<br>><br>>> > QVariant &content, int dummy ) \
{<br>><br>>> ><br>><br>>> > QVariant \
v("yop");<br> ><br>>> > KGlobal::config()->group( \
m_name ).writeEntry( name, v );<br>><br>>> \
><br>><br>>> > }<br>><br>>><br>><br>>> It \
works just fine, I got the expected result.<br> \
><br>>><br>><br>>> But if I let function as it is, \
ie:<br>><br>>> > void AmarokScriptConfig::writeConfig( const \
QString &name, const<br>><br>>> > QVariant &content, \
int dummy ) {<br> ><br>>> ><br>><br>>> > \
KGlobal::config()->group( m_name ).writeEntry( name, content \
);<br>><br>>> ><br>><br>>> > \
}<br>><br>>><br>><br>>> I get the error:<br> \
><br>>> > KConfigGroup::writeEntry: KConfigGroup::writeEntry - \
unhandled type<br>><br>>> > QVariantMap in group "Good \
Morning"<br>><br>>> I guess it means my javascript object is \
converted to a QVariantMap by<br> ><br>>> the binding. And \
KConfigGroup::writeEntry is unabled to interpret<br>><br>>> \
that.<br>><br>>> Am I correct \
?<br>><br>>><br>><br>>> Regards<br>><br>> \
<br>><br> > I think so,<br>><br>> <br>><br>> if you look \
at [1] you can see that there is no code path for \
QVariant::Map.<br>><br>> Just restructure your config data so it can \
be properly (de)serialized.<br>> Lists are supported in KConfigGroup, so \
try to use them.<br> ><br>> <br>><br>> Greets<br>><br>> \
<br>><br>> [1]<br>> <a \
href="http://api.kde.org/4.10-api/kdelibs-apidocs/kdecore/html/kconfiggroup_ \
8cpp_source.html">http://api.kde.org/4.10-api/kdelibs-apidocs/kdecore/html/kconfiggroup_8cpp_source.html</a><br>
><br>> <br>><br>> --<br>><br>> Kevin Funk<br>
_______________________________________________
Amarok mailing list
Amarok@kde.org
https://mail.kde.org/mailman/listinfo/amarok
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic