void NetTree::buildGenericTree(MythGenericTree *dst, QStringList paths, QString dirthumb, QList<ResultItem*> videos) { MythGenericTree *folder = NULL; // A little loop to determine what path of the provided path might // already exist in the tree. while (folder == NULL && paths.size()) { QString curPath = paths.takeFirst(); curPath.replace("|", "/"); MythGenericTree *tmp = dst->getChildByName(curPath); if (tmp) dst = tmp; else folder = new MythGenericTree( curPath, kSubFolder, false); } if (!folder) return; folder->SetData(dirthumb); dst->addNode(folder); // Add an upfolder if (m_type != DLG_TREE) { folder->addNode(QString(tr("Back")), kUpFolder, true, false); } if (paths.size()) buildGenericTree(folder, paths, dirthumb, videos); else { // File Handling for (QList<ResultItem*>::iterator it = videos.begin(); it != videos.end(); ++it) AddFileNode(folder, *it); } }
void NetTree::fillTree() { // First let's add all the RSS m_rssGeneric = new MythGenericTree( RSSNode, kSubFolder, false); // Add an upfolder if (m_type != DLG_TREE) { m_rssGeneric->addNode(QString(tr("Back")), kUpFolder, true, false); } m_rssGeneric->SetData(QString("%1/mythnetvision/icons/rss.png") .arg(GetShareDir())); RSSSite::rssList::iterator i = m_rssList.begin(); for (; i != m_rssList.end(); ++i) { ResultItem::resultList items = getRSSArticles((*i)->GetTitle(), VIDEO_PODCAST); MythGenericTree *ret = new MythGenericTree( (*i)->GetTitle(), kSubFolder, false); ret->SetData(qVariantFromValue(*i)); m_rssGeneric->addNode(ret); // Add an upfolder if (m_type != DLG_TREE) { ret->addNode(QString(tr("Back")), kUpFolder, true, false); } ResultItem::resultList::iterator it = items.begin(); for (; it != items.end(); ++it) { AddFileNode(ret, *it); } } if (m_rssList.count() > 0) m_siteGeneric->addNode(m_rssGeneric); else { delete m_rssGeneric; m_rssGeneric = NULL; } // Now let's add all the grabber trees for (GrabberScript::scriptList::iterator i = m_grabberList.begin(); i != m_grabberList.end(); ++i) { QMultiMap<QPair<QString,QString>, ResultItem*> treePathsNodes = getTreeArticles((*i)->GetTitle(), VIDEO_FILE); QList< QPair<QString,QString> > paths = treePathsNodes.uniqueKeys(); MythGenericTree *ret = new MythGenericTree( (*i)->GetTitle(), kSubFolder, false); QString thumb = QString("%1mythnetvision/icons/%2").arg(GetShareDir()) .arg((*i)->GetImage()); ret->SetData(qVariantFromValue(thumb)); // Add an upfolder if (m_type != DLG_TREE) { ret->addNode(QString(tr("Back")), kUpFolder, true, false); } for (QList<QPair<QString, QString> >::iterator i = paths.begin(); i != paths.end(); ++i) { QStringList curPaths = (*i).first.split("/"); QString dirthumb = (*i).second; QList<ResultItem*> videos = treePathsNodes.values(*i); buildGenericTree(ret, curPaths, dirthumb, videos); } m_siteGeneric->addNode(ret); } }