forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved filters into a dialog and get them working!
- Loading branch information
Tobias Hieta
committed
Jan 10, 2013
1 parent
7738125
commit e894b98
Showing
9 changed files
with
366 additions
and
159 deletions.
There are no files selected for viewing
Submodule skin.plex
updated
from e5490a to 5de96a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// GUIDialogFilterSort.cpp | ||
// Plex | ||
// | ||
// Created by Tobias Hieta <tobias@plexapp.com> on 2012-11-26. | ||
// Copyright 2012 Plex Inc. All rights reserved. | ||
// | ||
|
||
#include "GUIDialogFilterSort.h" | ||
#include "plex/PlexTypes.h" | ||
#include "guilib/GUIControlGroupList.h" | ||
#include "guilib/GUILabelControl.h" | ||
#include "GUIWindowManager.h" | ||
|
||
CGUIDialogFilterSort::CGUIDialogFilterSort() | ||
: CGUIDialog(WINDOW_DIALOG_FILTER_SORT, "DialogFilters.xml") | ||
{ | ||
m_loadType = LOAD_ON_GUI_INIT; | ||
} | ||
|
||
void CGUIDialogFilterSort::SetFilter(CPlexFilterPtr filter) | ||
{ | ||
m_filter = filter; | ||
m_filterIdMap.clear(); | ||
m_itemIdMap.clear(); | ||
|
||
CFileItemList sublist; | ||
if (!filter->GetSublist(sublist)) | ||
return; | ||
|
||
CGUIControlGroupList* list = (CGUIControlGroupList*)GetControl(FILTER_SUBLIST); | ||
if (!list) | ||
return; | ||
|
||
list->ClearAll(); | ||
|
||
CGUIRadioButtonControl* radioButton = (CGUIRadioButtonControl*)GetControl(FILTER_SUBLIST_BUTTON); | ||
if (!radioButton) | ||
return; | ||
radioButton->SetVisible(false); | ||
|
||
CGUILabelControl* headerLabel = (CGUILabelControl*)GetControl(FILTER_SUBLIST_LABEL); | ||
if (headerLabel) | ||
headerLabel->SetLabel(filter->GetFilterString()); | ||
|
||
for (int i = 0; i < sublist.Size(); i++) | ||
{ | ||
CFileItemPtr item = sublist.Get(i); | ||
CGUIRadioButtonControl* sublistItem = new CGUIRadioButtonControl(*radioButton); | ||
sublistItem->SetLabel(item->GetLabel()); | ||
sublistItem->SetVisible(true); | ||
sublistItem->AllocResources(); | ||
sublistItem->SetID(FILTER_SUBLIST_BUTTONS_START + i); | ||
|
||
if (filter->HasCurrentValue(item->GetProperty("unprocessedKey").asString())) | ||
sublistItem->SetSelected(true); | ||
|
||
m_filterIdMap[FILTER_SUBLIST_BUTTONS_START + i] = sublistItem; | ||
m_itemIdMap[FILTER_SUBLIST_BUTTONS_START + i] = item; | ||
list->AddControl(sublistItem); | ||
} | ||
|
||
} | ||
|
||
bool CGUIDialogFilterSort::OnMessage(CGUIMessage &message) | ||
{ | ||
switch (message.GetMessage()) | ||
{ | ||
case GUI_MSG_CLICKED: | ||
{ | ||
int senderId = message.GetSenderId(); | ||
if (m_filterIdMap.find(senderId) != m_filterIdMap.end()) | ||
{ | ||
CGUIRadioButtonControl *filterCtrl = m_filterIdMap[senderId]; | ||
CFileItemPtr item = m_itemIdMap[senderId]; | ||
if (filterCtrl->IsSelected()) | ||
{ | ||
m_filter->AddCurrentValue(item->GetProperty("unprocessedKey").asString()); | ||
} | ||
else | ||
{ | ||
m_filter->RemoveCurrentValue(item->GetProperty("unprocessedKey").asString()); | ||
} | ||
|
||
CGUIMessage msg(GUI_MSG_UPDATE_FILTERS, GetID(), WINDOW_VIDEO_NAV); | ||
g_windowManager.SendThreadMessage(msg); | ||
} | ||
} | ||
|
||
} | ||
return CGUIDialog::OnMessage(message); | ||
} | ||
|
||
void CGUIDialogFilterSort::DoModal(int iWindowID, const CStdString ¶m) | ||
{ | ||
CGUIDialog::DoModal(iWindowID, param); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// GUIDialogFilterSort.h | ||
// Plex | ||
// | ||
// Created by Tobias Hieta <tobias@plexapp.com> on 2012-11-26. | ||
// Copyright 2012 Plex Inc. All rights reserved. | ||
// | ||
|
||
#ifndef GUIDIALOGFILTERSORT_H | ||
#define GUIDIALOGFILTERSORT_H | ||
|
||
#define FILTER_SUBLIST 19020 | ||
#define FILTER_SUBLIST_BUTTON 19021 | ||
#define FILTER_SUBLIST_LABEL 19029 | ||
#define FILTER_SUBLIST_BUTTONS_START -300 | ||
|
||
#include "guilib/GUIDialog.h" | ||
#include "GUI/PlexFilter.h" | ||
#include "FileItem.h" | ||
#include <map> | ||
|
||
class CGUIDialogFilterSort : public CGUIDialog | ||
{ | ||
public: | ||
CGUIDialogFilterSort(); | ||
|
||
void SetFilter(CPlexFilterPtr filter); | ||
void DoModal(int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); | ||
bool OnMessage(CGUIMessage &message); | ||
|
||
private: | ||
CPlexFilterPtr m_filter; | ||
std::map<int, CGUIRadioButtonControl*> m_filterIdMap; | ||
std::map<int, CFileItemPtr> m_itemIdMap; | ||
}; | ||
|
||
#endif // GUIDIALOGFILTERSORT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.