This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to use a JSON based Datasource within QML?

Tags: None
(comma "," separated)
chausknecht
Registered Member
Posts
7
Karma
0
Hello folks,

I am new to programming QML Plasmoids and Plasmoids in general ;-) I am quite good in programming Python, so I wrote a simple DataEngine, that fetches some sport results. As there are plenty information for just "one" result, I chose JSON as data format. So my crawler produces something like this: Link

Now as it comes to "plasma", I have two different DataSources, the "live" and the "results" source. As keys I chose the kind of sports, like "football", "tennis" and so on. So the value consists of a list of different events, like special tennis tournaments or right now the football EM.

Here is a screenshot from `plasmaengineexplorer` as it shows up right now:
Image

So my problem is quite obvious: How can I use the nice structured data within a QML plasmoid? I didn't found something like a "JSONModel".. so how I can "declare" that my values consists of other structured data?

So my questions are:

- is my approach maybe wrong?
- is there a (easy) way to deal with such data?
- should I reorganize my data? And what could be a better way to provide all the informations?

If there is no good way, I would just stay with Python and write a plasmoid within it. In Python it is quite easy to deal with such data...

Last edited by chausknecht on Sun Jun 24, 2012 7:46 pm, edited 1 time in total.
chausknecht
Registered Member
Posts
7
Karma
0
Hm... not so much users around here? Or are my questions not understandable?
chausknecht
Registered Member
Posts
7
Karma
0
Ok, I started doing the Plasmoid in Python right now. Although it was quite hard to figure out all stuff, because imho there is a lack of *good* and *profound* documentation, I just got a result:
Image
Quite satisfying to see a visual result of all work :-)

Now I can start polish some stuff and add some more features... perhaps someday I can release my small piece of "plasma" to the wild ;)

But my questions above are still "alive"! I definitly want to learn more about QML; so if anybody can tell me something about, I would appreciate that.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
In my experience, questions regarding QML and Plasma Data Engines / Applets should generally be made to the plasma-devel@kde.org mailing list.

In any case, you should look at QJSON to handle JSON data.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
chausknecht
Registered Member
Posts
7
Karma
0
Thanks for your reply. `QJson` seems to be interesting :-)

Hm... I am no friend of mailinglists. In this special case perhaps I will give it a try.
chausknecht
Registered Member
Posts
7
Karma
0
Ok, I managed to improve my plasmoid; it is quite stable right now and I cleand much Code and structure smells. Right time for that, as Wimbledon starts today o)
Image

But there is at least one functionality left: After every Update the TabBars are generated new and therefor the `currentIndex` is resettet. So I have to "scroll" back to the event I wanna see:
Image

It seems I have to invest some more brain power to solve this problem :-)
ArthurTaborda
Registered Member
Posts
8
Karma
0
OS
I am having problems too with DataSources and I am right now stuck because I can't find a good documentation or somebody who could help. Could you please post the source code of your plasmoid?
chausknecht
Registered Member
Posts
7
Karma
0
Yes I will - but I am going to holidays right now for a week. So as I have to clean up the code further more, it will take some time.
chausknecht
Registered Member
Posts
7
Karma
0
I think I would better not publish my plasmoid and dataengine! I know that sounds sad, but I do not wanna risk to break legal terms of the data source. As I scrape results from a website, which explicitly enables users to copy their contents in an electronic form - nothing else I do by fetching the website - I am not shure whether it is legal to spread a software, which does that. So as long as I am not shure whether it is legal, I just use it of my own.

It works quite well - shows me Olympic results without adding / changing something to the dataengine source :-)


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient