+
+void PlayListMainWindow::parsePlayListItem(QDomNode *node, QString *extension, bool *hasArt, int *currentLeafId, int depth) {
+ if (NULL != node) {
+ QString current;
+ VlcPlayListElementSimple* el = new VlcPlayListElementSimple();
+ el->id = node->attributes().namedItem("id").nodeValue().toInt();
+ el->path = node->attributes().namedItem("uri").nodeValue();
+ el->name = node->attributes().namedItem("name").nodeValue().replace("\\\\", "\\");
+ current = node->attributes().namedItem("current").nodeValue();
+ el->playing = (0 < current.length());
+ el->depth = depth;
+ if (0 != QString::compare(node->nodeName(), "node")) {
+ el->type = "leaf";
+ el->extension = getExtension(el->path, NULL);
+ if (el->playing) {
+ *currentLeafId = el->id;
+ QString art = node->toElement().namedItem("art_url").toElement().text();
+ *hasArt = (!art.isNull() && !art.isEmpty());
+ *extension = getExtension(el->path, NULL);
+ }
+ this->mContents->append(*el);
+ delete el;
+ }
+ else {
+ el->type = "node";
+ el->extension = getExtension(el->path, NULL);
+ this->mContents->append(*el);
+ delete el;
+ // now parse the child nodes as leaf.
+ if (node->hasChildNodes()) {
+ QDomNodeList items = node->childNodes();
+ int itemct = items.count();
+ if (0 < itemct) {
+ ++depth;
+ for (int kdx = 0; kdx < itemct; ++kdx) {
+ QDomNode item = items.at(kdx);
+ parsePlayListItem(&item, extension, hasArt, currentLeafId, depth);
+ }
+ }
+ }
+ }
+ }
+}
+