QML/Data Engine Part 2

Eric Mesa ericsbinaryworld at gmail.com
Tue Jan 24 15:12:14 UTC 2012


Sorry it was late and I was a little out of it.

Basically, in my data Engine - which is written in Python, if I add in that
block, then when my plasmoid runs it will cause the data Engine to get that
data.  When I'm back home I'll have to match up this email and your
previous email with my code to see what I'm doing.  (Because I think I
already have the dataSource.connectSource(bla))

Actually, if I can look into what I sent the mailing list recently....

here's the engine part of what I have right now in the QML part of my code:

PlasmaCore.DataSource {

id: viewsSource

engine: "flickrviewsengine"

interval: 0

Component.onCompleted: connectedSources = sources

onSourceAdded: connectSource(source)

}


So is that not enough to connect to the source?

To try and clarify things as much as possible - because I was posting as I
was debugging things in a mad fit of inspiration at 0200 local time - let
me try and sum up here.

If you remove the python code that's in this email chain from the data
engine code, but leave everything else about my QML the same, then my
plasmoid connects to the dataEngine, but there's no data inside.  I know
it's connected because viewsSource.valid gives true.

Now, I add that python code, uninstall and reinstall the engine.  When I
run my plasmoid THIS time, I can see all the debug statements that I've put
into my engine code.  I see the engine is working and then I get data out.
I know this because I did a

text: viewsSource.data["1500"]["Group 1500"]

And I can see the contents of my data Engine.

So it works!  yay!  So why come to the mailing list?  Because I want to
make sure I'm doing this correctly since adding in all my sources would
cause this plasmoid to take forever to load.  It takes 15 minutes or more
for all the data to be pulled off the internet and put into the engine for
all the data sources.  If it has to be that way, then it has to be that
way.  But I was hoping that by using a data engine I could have the data
engine just grab the sources in parallel.  Then, in the plasmoid, you could
click on buttons for each of the sources - 25, 50, 1500, etc and whichever
ones already have data in them would allow you to interact with them while
the other ones downloaded.
--
Eric Mesa
http://www.ericsbinaryworld.com


On Tue, Jan 24, 2012 at 5:20 AM, Sebastian Kügler <sebas at kde.org> wrote:

> On Tuesday, January 24, 2012 09:46:21 Sebastian Kügler wrote:
> > On Tuesday, January 24, 2012 08:43:49 Eric Mesa wrote:
> > >  Here's an interesting little tidbit that might make this all finally
> > >  work
> > >
> > > correctly.
> > >
> > > If I add this in:
> > >
> > > def sources(self):
> > >     sources = ["1500"]
> > >     return sources
>
> That looks a lot like Python syntax... :)
>
> sources() is just an accessor though, instead use setData(...) or
> addSource(...) if you want to put data into your engine.
>
> > > to my engine - then whenever it's connected to, it grabs the data into
> > > the engine.  So it looks like the data was empty otherwise, even if I
> > > used plasmaengineexplorer to make sure data was in there first.  The
> > > question is - is this the right thing to do?  Or is there a way of
> > > telling it to grab the data as it's requested by my plasmoid?  When I
> > > add i the rest of my sources it will take a while for the data to be
> > > available.
> >
> > plasmaengineexplorer starts a different process, so what happens in there
> > doesn't happen in your plasmoid, they're entirely different things. You
> > have to populate the dataengine from your plasmoid, using
> > dataSource.connectSource(bla).
>
> Also useful, in order to debug in your code:
>
> if (dataSource["mysource"]) { print(dataSource["mysource"]); }
>
> or if (typeof(dataSource["mySource"]) ...
>
> You can also check what you're connected to:
>
> or print(dataSource.connectedSources)
>
> In your DataSource:
>
> DataSource {
>    id: ds
>         [...]
>        onNewData: {
>                print(source, data);
>        }
> }
>
> this should make it a bit easier to do basic print-level debugging.
>
> Cheers,
> --
> sebas
>
> http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120124/11656d43/attachment.html>


More information about the Plasma-devel mailing list