<div dir="ltr">The cons don't seem very problematic, any other reasons why you don't like the approach? I guess the only other thing you can do is use strings, and that would suck even more :P<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, May 10, 2013 at 11:14 PM, Marco Martin <span dir="ltr"><<a href="mailto:notmart@gmail.com" target="_blank">notmart@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
After many experiments in varuious failing directions, i have the branch<br>
PlasmaTypesClass of palsma-framework<br>
<br>
The problem:<br>
we need a way to expose the enums used in libplasma such as FormFactor,<br>
Location, Constraints etc in some way accessible to QML, for applet bindings,<br>
and any possible future qml plugin that needs to use them as properties.<br>
<br>
we used to have a duplication of most of enums in AppletInterface in the<br>
script engine, that works fine-ish but you still have to pass them by numeric<br>
value (the name of the enum doesn't seem to be accessible, but at least the<br>
parameters are assed when invoking methods or setting properties)<br>
and of course you can use it only in plasmoids, and not within qml plugins.<br>
<br>
In the branch, I have now in libplasma a class called Types that contains all<br>
the enums, this makes possible to use them in qml, (or even in old qtscript if<br>
one wants). Is exactly how is done for the global Qt namespace (Qt:: is<br>
actually not a namespace, but a QObject)<br>
<br>
in QML they would be accessed by name with something like<br>
PlasmaCore.Types.TopEdge<br>
(they weren't accessible byu name at all in qml1 so no mandatory porting<br>
involved from qml part, accessing by number still works)<br>
<br>
pros:<br>
* used directly<br>
* removes duplicate definitions<br>
* typecasts--<br>
<br>
cons:<br>
* Types name (or any other for what matters) is not particularly pretty<br>
* in c++ all Plasma::Foo must be changed in Plasma::Types::Foo<br>
<br>
So.<br>
I can't really get to like this approach, but i think is the only one that can<br>
work in any way...<br>
<br>
Cheers,<br>
Marco Martin<br>
_______________________________________________<br>
Plasma-devel mailing list<br>
<a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Shantanu Tushar (UTC +0530)<br><a href="http://www.shantanutushar.com" target="_blank">http://www.shantanutushar.com</a>
</div>