Fixed problem with switching between name and date column.

Now everything should work properly.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13629 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
deveee 2013-09-04 16:43:52 +00:00
parent 0588b4252e
commit b078633eb0
4 changed files with 33 additions and 24 deletions

View File

@ -300,8 +300,8 @@ void ListWidget::elementRemoved()
}
m_header_elements.clearAndDeleteAll();
m_selected_column = NULL;
m_sort_desc = 1;
m_sort_default = 1;
m_sort_desc = true;
m_sort_default = true;
}
// -----------------------------------------------------------------------------
@ -371,18 +371,22 @@ EventPropagation ListWidget::transmitEvent(Widget* w,
if (originator.find(m_properties[PROP_ID] + "_column_") != std::string::npos)
{
int col = originator[ (m_properties[PROP_ID] + "_column_").size() ] - '0';
m_selected_column = m_header_elements.get(col);
/** \brief Allows sort icon to change depending on sort order **/
if (m_sort_desc && !m_sort_default)
m_sort_default = true;
else
if (m_sort_col != originator[(m_properties[PROP_ID] + "_column_").size()] - '0')
{
m_sort_desc = !m_sort_desc;
m_sort_desc = false;
m_sort_default = false;
}
else
{
m_sort_default = m_sort_desc && !m_sort_default;
if (!m_sort_default) m_sort_desc = !m_sort_desc;
}
m_sort_col = originator[(m_properties[PROP_ID] + "_column_").size()] - '0';
m_selected_column = m_header_elements.get(m_sort_col);
/** \brief Allows sort icon to change depending on sort order **/
/*
for (int n=0; n<m_header_elements.size(); n++)
{
@ -391,7 +395,7 @@ EventPropagation ListWidget::transmitEvent(Widget* w,
m_header_elements[col].getIrrlichtElement<IGUIButton>()->setPressed(true);
*/
if (m_listener) m_listener->onColumnClicked(col);
if (m_listener) m_listener->onColumnClicked(m_sort_col);
return EVENT_BLOCK;
}

View File

@ -73,6 +73,9 @@ namespace GUIEngine
/** true when deault sorting is enabled */
bool m_sort_default;
/** index of column*/
int m_sort_col;
struct Column
{
irr::core::stringw m_text;

View File

@ -138,6 +138,7 @@ void AddonsScreen::init()
m_sort_desc = true;
m_sort_default = true;
m_sort_col = 0;
getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();
@ -381,27 +382,26 @@ void AddonsScreen::loadList()
// ----------------------------------------------------------------------------
void AddonsScreen::onColumnClicked(int column_id)
{
if (m_sort_desc && !m_sort_default)
m_sort_default = true;
else
if (m_sort_col != column_id)
{
m_sort_desc = !m_sort_desc;
m_sort_desc = false;
m_sort_default = false;
}
else
{
m_sort_default = m_sort_desc && !m_sort_default;
if (!m_sort_default) m_sort_desc = !m_sort_desc;
}
m_sort_col = column_id;
switch(column_id)
{
case 0:
if (!m_sort_default)
Addon::setSortOrder(Addon::SO_NAME);
else
Addon::setSortOrder(Addon::SO_DEFAULT);
Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_NAME);
break;
case 1:
if (!m_sort_default)
Addon::setSortOrder(Addon::SO_DATE);
else
Addon::setSortOrder(Addon::SO_DEFAULT);
Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_DATE);
break;
default: assert(0);
} // switch

View File

@ -78,6 +78,8 @@ private:
bool m_sort_desc;
bool m_sort_default;
int m_sort_col;
/** List of date filters **/
std::vector<DateFilter> m_date_filters;