Permalink
Browse files

CSmartPlaylist: store SortOrder instead of a boolean to be able to le…

…ave the sort order unset i.e. SortOrderNone (fixes #13429)
  • Loading branch information...
1 parent a350439 commit 3d6cc48bd796858d46b455f9d28ef4aaddb7bcd5 @Montellese Montellese committed Oct 19, 2012
View
7 xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
@@ -233,7 +233,10 @@ void CGUIDialogSmartPlaylistEditor::OnOrder()
void CGUIDialogSmartPlaylistEditor::OnOrderDirection()
{
- m_playlist.m_orderAscending = !m_playlist.m_orderAscending;
+ if (m_playlist.m_orderDirection == SortOrderDescending)
+ m_playlist.m_orderDirection = SortOrderAscending;
+ else
+ m_playlist.m_orderDirection = SortOrderDescending;
UpdateButtons();
}
@@ -275,7 +278,7 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
OnMessage(msg);
SendMessage(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_RULE_LIST, currentItem);
- if (m_playlist.m_orderAscending)
+ if (m_playlist.m_orderDirection != SortOrderDescending)
{
CONTROL_SELECT(CONTROL_ORDER_DIRECTION);
}
View
12 xbmc/playlists/SmartPlayList.cpp
@@ -1226,7 +1226,7 @@ bool CSmartPlaylist::Load(const CVariant &obj)
if (obj.isMember("order") && obj["order"].isMember("method") && obj["order"]["method"].isString())
{
if (obj["order"].isMember("direction") && obj["order"]["direction"].isString())
- m_orderAscending = strcmpi(obj["order"]["direction"].asString().c_str(), "ascending") == 0;
+ m_orderDirection = strcmpi(obj["order"]["direction"].asString().c_str(), "ascending") == 0 ? SortOrderAscending : SortOrderDescending;
m_orderField = CSmartPlaylistRule::TranslateOrder(obj["order"]["method"].asString().c_str());
}
@@ -1285,7 +1285,7 @@ bool CSmartPlaylist::LoadFromXML(TiXmlElement *root, const CStdString &encoding)
{
const char *direction = order->Attribute("direction");
if (direction)
- m_orderAscending = strcmpi(direction, "ascending") == 0;
+ m_orderDirection = strcmpi(direction, "ascending") == 0 ? SortOrderAscending : SortOrderDescending;
m_orderField = CSmartPlaylistRule::TranslateOrder(order->FirstChild()->Value());
}
return true;
@@ -1344,7 +1344,7 @@ bool CSmartPlaylist::Save(const CStdString &path) const
{
TiXmlText order(CSmartPlaylistRule::TranslateOrder(m_orderField).c_str());
TiXmlElement nodeOrder("order");
- nodeOrder.SetAttribute("direction", m_orderAscending ? "ascending" : "descending");
+ nodeOrder.SetAttribute("direction", m_orderDirection == SortOrderDescending ? "descending" : "ascending");
nodeOrder.InsertEndChild(order);
pRoot->InsertEndChild(nodeOrder);
}
@@ -1374,7 +1374,7 @@ bool CSmartPlaylist::Save(CVariant &obj, bool full /* = true */) const
{
obj["order"] = CVariant(CVariant::VariantTypeObject);
obj["order"]["method"] = CSmartPlaylistRule::TranslateOrder(m_orderField);
- obj["order"]["direction"] = m_orderAscending ? "ascending" : "descending";
+ obj["order"]["direction"] = m_orderDirection == SortOrderDescending ? "descending" : "ascending";
}
return true;
@@ -1397,7 +1397,7 @@ void CSmartPlaylist::Reset()
m_ruleCombination.SetType(CSmartPlaylistRuleCombination::CombinationAnd);
m_limit = 0;
m_orderField = SortByNone;
- m_orderAscending = true;
+ m_orderDirection = SortOrderNone;
m_playlistType = "songs"; // sane default
}
@@ -1449,7 +1449,7 @@ bool CSmartPlaylist::IsEmpty(bool ignoreSortAndLimit /* = true */) const
{
bool empty = m_ruleCombination.m_rules.empty() && m_ruleCombination.m_combinations.empty();
if (empty && !ignoreSortAndLimit)
- empty = m_limit <= 0 && m_orderField == SortByNone && m_orderAscending;
+ empty = m_limit <= 0 && m_orderField == SortByNone && m_orderDirection == SortOrderNone;
return empty;
}
View
7 xbmc/playlists/SmartPlayList.h
@@ -177,8 +177,9 @@ class CSmartPlaylist
void SetOrder(SortBy order) { m_orderField = order; };
SortBy GetOrder() const { return m_orderField; };
- void SetOrderAscending(bool orderAscending) { m_orderAscending = orderAscending; };
- bool GetOrderAscending() const { return m_orderAscending; };
+ void SetOrderAscending(bool orderAscending) { m_orderDirection = orderAscending ? SortOrderAscending : SortOrderDescending; };
+ bool GetOrderAscending() const { return m_orderDirection != SortOrderDescending; };
+ SortOrder GetOrderDirection() const { return m_orderDirection; }
/*! \brief get the where clause for a playlist
We handle playlists inside playlists separately in order to ensure we don't introduce infinite loops
@@ -211,7 +212,7 @@ class CSmartPlaylist
// order information
unsigned int m_limit;
SortBy m_orderField;
- bool m_orderAscending;
+ SortOrder m_orderDirection;
CXBMCTinyXML m_xmlDoc;
};
View
3 xbmc/video/VideoDatabase.cpp
@@ -9363,7 +9363,8 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription
sorting.limitEnd = xsp.GetLimit();
if (xsp.GetOrder() != SortByNone)
sorting.sortBy = xsp.GetOrder();
- sorting.sortOrder = xsp.GetOrderAscending() ? SortOrderAscending : SortOrderDescending;
+ if (xsp.GetOrderDirection() != SortOrderNone)
+ sorting.sortOrder = xsp.GetOrderDirection();
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
sorting.sortAttributes = SortAttributeIgnoreArticle;
}

0 comments on commit 3d6cc48

Please sign in to comment.