Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4094 from Black09/directoryprovider
Load art for directory content in static lists
  • Loading branch information
t-nelson committed Feb 18, 2014
2 parents 143f249 + be7ea17 commit b1a0a01
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions xbmc/listproviders/DirectoryProvider.cpp
Expand Up @@ -29,13 +29,25 @@
#include "threads/SingleLock.h"
#include "ApplicationMessenger.h"
#include "FileItem.h"
#include "video/VideoThumbLoader.h"
#include "music/MusicThumbLoader.h"
#include "pictures/PictureThumbLoader.h"
#include "boost/make_shared.hpp"

using namespace std;
using namespace XFILE;

class CDirectoryJob : public CJob
{
public:
typedef enum
{
VIDEO,
AUDIO,
PICTURE,
PROGRAM
} InfoTagType;

CDirectoryJob(const std::string &url, int parentID) : m_url(url), m_parentID(parentID) { };
virtual ~CDirectoryJob() {};

Expand Down Expand Up @@ -63,20 +75,56 @@ class CDirectoryJob : public CJob
CGUIStaticItemPtr item(new CGUIStaticItem(*items[i]));
if (item->HasProperty("node.visible"))
item->SetVisibleCondition(item->GetProperty("node.visible").asString(), m_parentID);

getThumbLoader(item)->LoadItem(item.get());

m_items.push_back(item);
}
m_target = items.GetProperty("node.target").asString();
}
return true;
}

boost::shared_ptr<CThumbLoader> getThumbLoader(CGUIStaticItemPtr &item)
{
if (item->IsVideo())
{
initThumbLoader<CVideoThumbLoader>(VIDEO);
return m_thumbloaders[VIDEO];
}
if (item->IsAudio())
{
initThumbLoader<CMusicThumbLoader>(AUDIO);
return m_thumbloaders[AUDIO];
}
if (item->IsPicture())
{
initThumbLoader<CPictureThumbLoader>(PICTURE);
return m_thumbloaders[PICTURE];
}
initThumbLoader<CProgramThumbLoader>(PROGRAM);
return m_thumbloaders[PROGRAM];
}

template<class CThumbLoaderClass>
void initThumbLoader(InfoTagType type)
{
if (!m_thumbloaders.count(type))
{
boost::shared_ptr<CThumbLoader> thumbLoader = boost::make_shared<CThumbLoaderClass>();
thumbLoader->OnLoaderStart();
m_thumbloaders.insert(make_pair(type, thumbLoader));
}
}

const std::vector<CGUIStaticItemPtr> &GetItems() const { return m_items; }
const std::string &GetTarget() const { return m_target; }
private:
std::string m_url;
std::string m_target;
int m_parentID;
std::vector<CGUIStaticItemPtr> m_items;
std::map<InfoTagType, boost::shared_ptr<CThumbLoader> > m_thumbloaders;
};

CDirectoryProvider::CDirectoryProvider(const TiXmlElement *element, int parentID)
Expand Down

0 comments on commit b1a0a01

Please sign in to comment.