Skip to content

Commit

Permalink
Merge pull request #9309 from phil65/container_viewcount
Browse files Browse the repository at this point in the history
[gui] add container.viewcount
  • Loading branch information
phil65 committed Mar 11, 2016
2 parents 11912ea + ad3f874 commit 1b8404d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
9 changes: 8 additions & 1 deletion xbmc/GUIInfoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
{ "foldername", CONTAINER_FOLDERNAME },
{ "pluginname", CONTAINER_PLUGINNAME },
{ "viewmode", CONTAINER_VIEWMODE },
{ "viewcount", CONTAINER_VIEWCOUNT },
{ "totaltime", CONTAINER_TOTALTIME },
{ "totalwatched", CONTAINER_TOTALWATCHED },
{ "totalunwatched", CONTAINER_TOTALUNWATCHED },
Expand Down Expand Up @@ -1997,14 +1998,20 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *
}
break;
}
case CONTAINER_VIEWCOUNT:
case CONTAINER_VIEWMODE:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIControl *control = window->GetControl(window->GetViewContainerID());
if (control && control->IsContainer())
strLabel = ((IGUIContainer *)control)->GetLabel();
{
if (info == CONTAINER_VIEWMODE)
strLabel = ((IGUIContainer *)control)->GetLabel();
else if (info == CONTAINER_VIEWCOUNT)
strLabel = StringUtils::Format("%i", window->GetViewCount());
}
}
break;
}
Expand Down
15 changes: 8 additions & 7 deletions xbmc/guiinfo/GUIInfoLabels.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@
#define CONTAINER_SORT_ORDER 378
#define CONTAINER_TOTALWATCHED 379
#define CONTAINER_TOTALUNWATCHED 380
#define MUSICPM_ENABLED 381
#define MUSICPM_SONGSPLAYED 382
#define MUSICPM_MATCHINGSONGS 383
#define MUSICPM_MATCHINGSONGSPICKED 384
#define MUSICPM_MATCHINGSONGSLEFT 385
#define MUSICPM_RELAXEDSONGSPICKED 386
#define MUSICPM_RANDOMSONGSPICKED 387
#define CONTAINER_VIEWCOUNT 381
#define MUSICPM_ENABLED 382
#define MUSICPM_SONGSPLAYED 383
#define MUSICPM_MATCHINGSONGS 384
#define MUSICPM_MATCHINGSONGSPICKED 385
#define MUSICPM_MATCHINGSONGSLEFT 386
#define MUSICPM_RELAXEDSONGSPICKED 387
#define MUSICPM_RANDOMSONGSPICKED 388

#define PLAYLIST_LENGTH 390
#define PLAYLIST_POSITION 391
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/GUIWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class CGUIWindow : public CGUIControlGroup, protected CCriticalSection
virtual bool IsSoundEnabled() const { return true; };
virtual CFileItemPtr GetCurrentListItem(int offset = 0) { return CFileItemPtr(); };
virtual int GetViewContainerID() const { return 0; };
virtual int GetViewCount() const { return 0; };
virtual bool CanBeActivated() const { return true; };
virtual bool IsActive() const;
void SetCoordsRes(const RESOLUTION_INFO &res) { m_coordsRes = res; };
Expand Down
6 changes: 6 additions & 0 deletions xbmc/view/GUIViewControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ int CGUIViewControl::GetViewModeNumber(int number) const
return 0; // no view modes :(
}

// returns the amount of visible views
int CGUIViewControl::GetViewModeCount() const
{
return static_cast<int>(m_visibleViews.size());
}

int CGUIViewControl::GetViewModeByID(int id) const
{
for (unsigned int i = 0; i < m_visibleViews.size(); ++i)
Expand Down
1 change: 1 addition & 0 deletions xbmc/view/GUIViewControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CGUIViewControl
bool HasControl(int controlID) const;
int GetNextViewMode(int direction = 1) const;
int GetViewModeNumber(int number) const;
int GetViewModeCount() const;
int GetViewModeByID(int id) const;

int GetCurrentControl() const;
Expand Down
1 change: 1 addition & 0 deletions xbmc/windows/GUIMediaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CGUIMediaWindow : public CGUIWindow
virtual void OnInitWindow();
virtual bool IsMediaWindow() const { return true; }
int GetViewContainerID() const { return m_viewControl.GetCurrentControl(); }
int GetViewCount() const { return m_viewControl.GetViewModeCount(); };
virtual bool HasListItems() const { return true; }
virtual CFileItemPtr GetCurrentListItem(int offset = 0);

Expand Down

0 comments on commit 1b8404d

Please sign in to comment.