Model/View and plasma javascript
Thomas Fjellstrom
tfjellstrom at shaw.ca
Sat Jul 3 08:54:42 CEST 2010
On June 30, 2010, Thomas Fjellstrom wrote:
> On June 30, 2010, Marco Martin wrote:
> > On Wednesday 30 June 2010, Thomas Fjellstrom wrote:
> > > I'm wondering if its possible to use a QStandardItemModel or
> > > something similar to it with the javascript bindings. I tried
> > > QStandardItemModel, but it doesn't seem to exist.
> > >
> > > Though even if I am able to use a standard model from Qt or KDE, I
> > > don't think theres a view that I'll be happy with, so I'm planning on
> > > writing my own, and was wondering if anyone else would be interested
> > > in what I have in mind, and if it could make it into plasma's default
> > > widgets.
> > >
> > > Basically its a fancy, plasma-ish tree widget (won't look like a
> > > standard tree widget) where the top level items span the width, like
> > > a header for a "Section", and the children can collapse under the
> > > headers. I guess it would look a little like the device notifier
> > > widget, but with a lot less padding or margin around the child
> > > items.
> >
> > there are no bindings for qt models at the moment, there is a tree view
> > proxy widget in plasma widget but i don't think is usable at all in
> > javascript.
> >
> > at the moment the only way to have some kind of "fake" item view is to
> > iterate trough the data given from the dataengine and construct a
> > widget for each item. is how microblog, opendesktop etc plasmoids
> > work.
>
> The problem with that is it'll make for some neigh unreadable and
> unmaintainable javascript (imo) code. I'd like to be able to change the
> groupings at a whim, which would mean a lot of crazy add/remove code.
>
> I'm not sure I can do what I want in javascript since the bindings are
> missing a few crucial parts. I was trying it out just to learn the
> bindings. I can just as easily (or probably easier, since I'm much more
> familiar with it) do it in C++.
Yeah so after fighting with the javascript bits (I'm really not that familiar
with javascript, nor the differences between the C++ api and the js api), I
started up a C++ widget, and made some progress:
http://www.strangesoft.net/plasma-networkinfo/prototype1.png
Now I just need to make a fancy list like widget for the host items, that
allows sorting, grouping and filtering. Anyone have some tips on how to get
started with something like that? It doesn't seem like theres an existing
"plasma like" list widget. What I'm envisioning is a widget that can either
display a single list of items, or group them into several collapsible
lists, like a tree, but a maximum depth of 1 or 2. I'm not sure the
TreeWidget will work, not sure how well that blends into plasma over all (I
tried adding one to a test javascript widget and it had a white background
rather than a widget background).
Right now I imagine I'll have to write up a fully custom widget, which I
never seem to look forward to.
I'll probably start with a very simple list of "host widgets" that just
display the host name, and current status via an image or something. But I'd
really appreciate some tips or insight on how to wrangle a fully plasmified
fancy list widget.
--
Thomas Fjellstrom
tfjellstrom at shaw.ca
More information about the Plasma-devel
mailing list