<div dir="ltr">Well, like you put it, you need KTp::Presence anyway, so it seems to me that you have already decided you want KTp::Presence as a QObject.<div><br></div><div style>I don't think it would be much of a problem, since there aren't this much Presence instance anyway, so that it has a memory impact, no?</div>

<div style><br></div><div style>Aleix</div><div style><br></div><div style>PS: note that I don't know what I'm talking about</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 29, 2013 at 1:10 AM, David Edmundson <span dir="ltr"><<a href="mailto:david@davidedmundson.co.uk" target="_blank">david@davidedmundson.co.uk</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I plan to convert the presence applet to QML for 0.7.<br>
We need to do this before Plasma Workspace 5, otherwise it won't run.<br>
So we may as well do it now. It also allows us to show a better<br>
tooltip with account state via the AccountsModel.<br>
Should be pretty trivial.<br>
<br>
I need to expose the GlobalPresence class to QML, however I'm unsure<br>
on how to do this well.<br>
<br>
The problem:<br>
 - GlobalPresence deals with KTp::Presence objects for retrieving and<br>
setting current presence<br>
 - QML cannot read KTp::Presence objects as they don't inherit from QObject.<br>
<br>
Possible solutions:<br>
<br>
- Change KTp::Presence to inherit from QObject.<br>
 KTp::Presence stores data. Data has no clear parent so should always<br>
be stored with shared pointers, otherwise you get in crazy situations<br>
and things breaking all over the place. QObjects also have a lot of<br>
overhead in creation and should be avoided when we don't need to.<br>
<br>
- Make a wrapper class around GlobalPresence that converts<br>
KTp::Presence objects to QVariantMaps<br>
Arbitrary QVariantMaps don't make for very readable code in the QML.<br>
You have to read the C++ code to know how to use an object in QML.<br>
<br>
- Use a dataengine / serviceprovider<br>
  Basically exactly the same as above, but with 10 times as much code.<br>
We used to have one, it made nwoki go insane and rewrite the whole<br>
thing in C++.<br>
<br>
- Modify GlobalPresence to deal with the individual properties.<br>
i.e<br>
setPresenceType(Tp::ConnectionStatus)<br>
setPresenceMessage(QString)<br>
<br>
KTp::Presence has convenient methods for i18n'ing words like "online"<br>
and finding the right icon and such. This would lose that, we also<br>
lose a 1-1 mapping with our C++ code, that we're moving towards (a<br>
bit)<br>
<br>
- Any opinions/other ideas?<br>
<br>
<br>
<br>
Related:<br>
 - I'm also going to need to add methods to open the accounts KCM,<br>
start chats and add contacts to the TelepathyManager QML class. Any<br>
objections?<br>
_______________________________________________<br>
KDE-Telepathy mailing list<br>
<a href="mailto:KDE-Telepathy@kde.org">KDE-Telepathy@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kde-telepathy" target="_blank">https://mail.kde.org/mailman/listinfo/kde-telepathy</a><br>
</blockquote></div><br></div>