[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>&gt; 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&#39;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&#39;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> &gt; TypeError: \
ambiguous call of overloaded function writeConfig()<br><br>It&#39;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 &lt;<a href="mailto:krf@gmx.de">krf@gmx.de</a>&gt;:<br> &gt; On \
Friday 15 March 2013, 00:10, El boulangero wrote:<br>&gt;<br>&gt;&gt; Hi \
again,<br>&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; &gt; After that, I tried to \
hack in the writeConfig function, create a new<br>&gt;<br>&gt;&gt; &gt; \
QVariant with a simple string, and feed it to the<br> &gt;<br>&gt;&gt; &gt; \
KConfigGroup::writeEntry( QString, QVariant ) function.<br>&gt;<br>&gt;&gt; \
&gt;<br>&gt;<br>&gt;&gt; &gt; But then I got the following error from \
Amarok:<br>&gt;<br>&gt;&gt; &gt;&gt; KConfigGroup::writeEntry: \
KConfigGroup::writeEntry - unhandled type<br> &gt;<br>&gt;&gt; &gt;&gt; \
QVariantMap in group &quot;Good Morning&quot;<br>&gt;<br>&gt;&gt; My bad, I \
messed up, I launched the wrong binary.<br>&gt;<br>&gt;&gt; So, let me \
start again.<br>&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; If I hack the \
writeConfig, and do something like that:<br> &gt;<br>&gt;&gt; &gt; void \
AmarokScriptConfig::writeConfig( const QString &amp;name, \
const<br>&gt;<br>&gt;&gt; &gt; QVariant &amp;content, int dummy ) \
{<br>&gt;<br>&gt;&gt; &gt;<br>&gt;<br>&gt;&gt; &gt; QVariant \
v(&quot;yop&quot;);<br> &gt;<br>&gt;&gt; &gt; KGlobal::config()-&gt;group( \
m_name ).writeEntry( name, v );<br>&gt;<br>&gt;&gt; \
&gt;<br>&gt;<br>&gt;&gt; &gt; }<br>&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; It \
works just fine, I got the expected result.<br> \
&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; But if I let function as it is, \
ie:<br>&gt;<br>&gt;&gt; &gt; void AmarokScriptConfig::writeConfig( const \
QString &amp;name, const<br>&gt;<br>&gt;&gt; &gt; QVariant &amp;content, \
int dummy ) {<br> &gt;<br>&gt;&gt; &gt;<br>&gt;<br>&gt;&gt; &gt; \
KGlobal::config()-&gt;group( m_name ).writeEntry( name, content \
);<br>&gt;<br>&gt;&gt; &gt;<br>&gt;<br>&gt;&gt; &gt; \
}<br>&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; I get the error:<br> \
&gt;<br>&gt;&gt; &gt; KConfigGroup::writeEntry: KConfigGroup::writeEntry - \
unhandled type<br>&gt;<br>&gt;&gt; &gt; QVariantMap in group &quot;Good \
Morning&quot;<br>&gt;<br>&gt;&gt; I guess it means my javascript object is \
converted to a QVariantMap by<br> &gt;<br>&gt;&gt; the binding. And \
KConfigGroup::writeEntry is unabled to interpret<br>&gt;<br>&gt;&gt; \
that.<br>&gt;<br>&gt;&gt; Am I correct \
?<br>&gt;<br>&gt;&gt;<br>&gt;<br>&gt;&gt; Regards<br>&gt;<br>&gt;  \
<br>&gt;<br> &gt; I think so,<br>&gt;<br>&gt;  <br>&gt;<br>&gt; if you look \
at [1] you can see that there is no code path for \
QVariant::Map.<br>&gt;<br>&gt; Just restructure your config data so it can \
be properly (de)serialized.<br>&gt; Lists are supported in KConfigGroup, so \
try to use them.<br> &gt;<br>&gt;  <br>&gt;<br>&gt; Greets<br>&gt;<br>&gt;  \
<br>&gt;<br>&gt; [1]<br>&gt; <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>
 &gt;<br>&gt;  <br>&gt;<br>&gt; --<br>&gt;<br>&gt; 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