#include <QSettings>
#include "configdialog.h"
#include "aboutdialog.h"
-#include "accountdialog.h"
+#include "appsettings.h"
#include "vlcstatus.h"
PlayListMainWindow::PlayListMainWindow(QWidget *parent) :
}
void PlayListMainWindow::init() // CALL WHEN CONFIG CHANGES
{
- mIp = AccountDialog::currentIp();
+ mIp = AppSettings::getCurrentIp(); // AccountDialog::currentIp();
}
void PlayListMainWindow::showPlayList() // CALL WHEN SHOWN
{
QDomNodeList nodes = docElem.elementsByTagName("node");
int depth = 0;
+ int currentLeafId = 0;
+ bool hasArt = false;
+ QString extension = "";
+
int ct = nodes.count();
for (int idx = 0; idx < ct; ++idx) {
QDomNode node = nodes.at(idx);
QDomNodeList leafs = node.childNodes();
int leafct = leafs.count();
if (0 < leafct) {
+ depth = 1;
for (int jdx = 0; jdx < leafct; ++jdx) {
QDomNode leaf = leafs.at(jdx);
+ parsePlayListItem(&leaf, &extension, &hasArt, ¤tLeafId, 1);
+ /*
VlcPlayListElementSimple* el = new VlcPlayListElementSimple();
el->id = leaf.attributes().namedItem("id").nodeValue().toInt();
el->path = leaf.attributes().namedItem("uri").nodeValue();
el->name = leaf.attributes().namedItem("name").nodeValue().replace("\\\\", "\\");
current = leaf.attributes().namedItem("current").nodeValue();
el->playing = (0 < current.length());
- el->depth = 1;
+ el->depth = depth;
if (0 == QString::compare(leaf.nodeName(), "node")) {
el->type = "node";
el->extension = getExtension(el->path, NULL);
QDomNodeList items = leaf.childNodes();
int itemct = items.count();
if (0 < itemct) {
+ depth = 2;
for (int kdx = 0; kdx < itemct; ++kdx) {
QDomNode item = items.at(kdx);
VlcPlayListElementSimple* it = new VlcPlayListElementSimple();
it->type = "leaf";
current = item.attributes().namedItem("current").nodeValue();
it->playing = (0 < current.length());
+ if (it->playing) {
+ currentLeafId = it->id;
+ QString art = item.toElement().namedItem("art_url").toElement().text();
+ hasArt = (!art.isNull() && !art.isEmpty());
+ extension = getExtension(it->path, NULL);
+ }
this->mContents->append(*it);
delete it;
}
else {
el->type = "leaf";
el->extension = getExtension(el->path, NULL);
+ if (el->playing) {
+ currentLeafId = el->id;
+ QString art = leaf.toElement().namedItem("art_url").toElement().text();
+ hasArt = (!art.isNull() && !art.isEmpty());
+ extension = getExtension(el->path, NULL);
+ }
this->mContents->append(*el);
}
delete el;
+ */
}
}
}
mResponse.clear();
+ emit this->idUpdated(currentLeafId, hasArt, extension);
this->updateList();
+
+}
+
+
+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);
+ }
+ }
+ }
+ }
+ }
}
QString PlayListMainWindow::getExtension(QString path, QString extension) {
QIcon icon_image = QIcon::fromTheme("general_image");
QIcon icon_flash = QIcon::fromTheme("filemanager_flash_file");
QIcon icon_media = QIcon::fromTheme("filemanager_media_folder");
+ QIcon icon_real = QIcon::fromTheme("filemanager_real_music");
+ QIcon icon_unknown= QIcon::fromTheme("filemanager_unknown_file");
for (int idx = 0; idx < ct; ++idx) {
VlcPlayListElementSimple el = mContents->at(idx);
QListWidgetItem* item;
0 == QString::compare(el.extension, "mpg") ||
0 == QString::compare(el.extension, "mov") ||
0 == QString::compare(el.extension, "mp4") ||
+ 0 == QString::compare(el.extension, "m4v") ||
0 == QString::compare(el.extension, "wmv") ||
0 == QString::compare(el.extension, "mkv") ||
0 == QString::compare(el.extension, "ogv") ) {
- item = new QListWidgetItem(icon_video, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id); // .avi, .mpg, .mpeg, .mov, .mp4, .wmv, .mkv, .ogv
+ item = new QListWidgetItem(icon_video, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id); // .avi, .mpg, .mpeg, .mov, .m4v, .mp4, .wmv, .mkv, .ogv
+ }
+ else if ( 0 == QString::compare(el.extension, "rm") ||
+ 0 == QString::compare(el.extension, "ra") ||
+ 0 == QString::compare(el.extension, "ram") ) {
+ item = new QListWidgetItem(icon_real, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id); // .ram, 'rm, 'ra
}
else if ( 0 == QString::compare(el.extension, "flv") ) {
item = new QListWidgetItem(icon_flash, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id); // .flv
}
+ else if ( 0 == QString::compare(el.extension, "") ) {
+ item = new QListWidgetItem(icon_unknown, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id); // .flv
+ }
else {
if (el.name.contains("Flash")) {
item = new QListWidgetItem(icon_flash, el.name, ui->listWidget, LIST_ITEM_TYPE_OFFSET + el.id);