QML/Data Engine Part 2

Sebastian Kügler sebas at kde.org
Tue Jan 24 10:20:52 UTC 2012


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


More information about the Plasma-devel mailing list