Custom Tree in MusicBrowser using XML

"David Hough" <[email protected]> Sat, 08 Jan 2005 21:00:50 -0000
Newsgroups gmane.comp.audio.zinf.devel
Message-ID <[email protected]>
Hi,

I've been thinking about changing how the tree in the browser is =20
specified. At the moment its specified using a series of objects (e.g. =20
MyMusicInfo, ArtistInfo, etc.) which return each other as children. There=
 =20
are quite a few of these as each type of item, or single node needs its =20
own class written for it. Also, of course, this means the structure of th=
e =20
tree is hardcoded.

What I'm thinking of doing is ditching all the different classes for each=
 =20
of the items in the tree, and having one or two generic classes, with the=
 =20
properties and list structure specified by XML. This would in effect mean=
 =20
it would be possible for people to define their tree stucture and =20
contents, instead of our current one size fits all single fixed tree =20
structure.

This is still at an early stage, and I'm just wondering what other people=
 =20
think of the idea?

I've so far hacked together an implementation that can parse the followin=
g =20
XML to create the "My Music" node on the tree.
I seriously doubt that this is the best way to represent the tree in XML,=
 =20
anybody got any better ideas?

<node text=3D'My Music' icon=3D'zinf-music-library'>
   <node text=3D'All Tracks' icon=3D'zinf-all-tracks'>
     <list url=3D'zinf://url?type=3DF'>
       <template url=3D'@@url@@' input=3D'url' icon=3D'zinf-track' />
     </list>
   </node>
   <node text=3D'Uncatogorized Tracks' icon=3D'zinf-uncatagorised-tracks'=
>
     <list url=3D'zinf://url?artist=3D;type=3DF'>
       <template url=3D'@@url@@' input=3D'url' icon=3D'zinf-track' />
     </list>
   </node>
   <list url=3D'zinf://artist'>
     <template url=3D'zinf://album?artist=3D@@artist@@' input=3D'artist' =
=20
icon=3D'zinf-artist'>
       <template url=3D'zinf://url?artist=3D@@artist@@;album=3D@@album@@'=
 =20
input=3D'album' icon=3D'zinf-album'>
         <template url=3D'@@url@@' input=3D'url' icon=3D'zinf-track' />
       </template>"
     </template>
   </list>"
</node>

The 'node' tags represent a single node on the tree with the specified =20
text and icon.
The 'list' tags represent a list of nodes generated using the =20
readEntries(url) function in MusicDB.
The 'template' tags specify how to generate each of the nodes in the list=
. =20
By having templates within templates you specify sublists.

One obvious problem with the above XML is that there is no way to specify=
 =20
a directory in the tree as they have potentially infinate recursion, and =
=20
this requires you to specify a new template for each sub list. So how the=
 =20
XML is written will definetly need changing, I'm just not sure how yet.

Anyway, what do people think?

Cheers,
David

--=20
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt