[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: QML/Data Engine Part 2
From:       Eric Mesa <ericsbinaryworld () gmail ! com>
Date:       2012-01-24 15:12:14
Message-ID: CAKYHq8K+pX39CPf8E_UhmTCKkAhCSEJ=bDDVUDQ+FK-3wFGPCg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>

[Attachment #5 (text/html)]

Sorry it was late and I was a little out of it.  <br><br>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&#39;m back home I&#39;ll have to \
match up this email and your previous email with my code to see what I&#39;m doing.  \
(Because I think I already have the dataSource.connectSource(bla))<br>

<br>Actually, if I can look into what I sent the mailing list \
recently....<br><br>here&#39;s the engine part of what I have right now in the QML \
part of my code:<br><br> PlasmaCore.DataSource {<br><br>         id: viewsSource<br>

<br>         engine: &quot;flickrviewsengine&quot;<br><br>         interval: \
0<br><br>         Component.onCompleted: connectedSources = sources<br><br>         \
onSourceAdded: connectSource(source)<br><br>     }<br><br><br>

So is that not enough to connect to the source?  <br><br>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.<br>

<br>If you remove the python code that&#39;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&#39;s no data inside.  I know it&#39;s connected because \
viewsSource.valid gives true.  <br>

<br>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&#39;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 <br>

<br>text: viewsSource.data[&quot;1500&quot;][&quot;Group 1500&quot;]<br><br>And I can \
see the contents of my data Engine.  <br><br>So it works!  yay!  So why come to the \
mailing list?  Because I want to make sure I&#39;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.<br \
                clear="all">
--<br>Eric Mesa<br><a href="http://www.ericsbinaryworld.com" \
target="_blank">http://www.ericsbinaryworld.com</a><br>

<br><br><div class="gmail_quote">On Tue, Jan 24, 2012 at 5:20 AM, Sebastian Kügler \
<span dir="ltr">&lt;<a href="mailto:sebas@kde.org" \
target="_blank">sebas@kde.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">

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



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic