(svn r13286) -Codechange: GUIList Sort returns now if the list sequence has been altered

This commit is contained in:
skidd13 2008-05-27 10:27:30 +00:00
parent e42690b381
commit 6d46851b61
2 changed files with 11 additions and 7 deletions

View File

@ -188,18 +188,19 @@ public:
* sorted data. * sorted data.
* *
* @param compare The function to compare two list items * @param compare The function to compare two list items
* @return true if the list sequence has been altered
* */ * */
FORCEINLINE void Sort(SortFunction *compare) FORCEINLINE bool Sort(SortFunction *compare)
{ {
/* Do not sort if the resort bit is not set */ /* Do not sort if the resort bit is not set */
if (!HASBITS(this->flags, VL_RESORT)) return; if (!HASBITS(this->flags, VL_RESORT)) return false;
CLRBITS(this->flags, VL_RESORT); CLRBITS(this->flags, VL_RESORT);
this->ResetResortTimer(); this->ResetResortTimer();
/* Do not sort when the list is not sortable */ /* Do not sort when the list is not sortable */
if (!this->IsSortable()) return; if (!this->IsSortable()) return false;
const bool desc = HASBITS(this->flags, VL_DESC); const bool desc = HASBITS(this->flags, VL_DESC);
@ -207,7 +208,7 @@ public:
qsort(this->data, this->items, sizeof(T), (int (CDECL *)(const void *, const void *))compare); qsort(this->data, this->items, sizeof(T), (int (CDECL *)(const void *, const void *))compare);
if (desc) this->Reverse(); if (desc) this->Reverse();
return; return true;
} }
T *a = this->data; T *a = this->data;
@ -238,6 +239,7 @@ public:
} }
} }
} }
return true;
} }
/** /**
@ -253,11 +255,13 @@ public:
/** /**
* Overload of Sort() * Overload of Sort()
* Overloaded to reduce external code * Overloaded to reduce external code
*
* @return true if the list sequence has been altered
*/ */
void Sort() bool Sort()
{ {
assert(this->func_list != NULL); assert(this->func_list != NULL);
this->Sort(this->func_list[this->sort_type]); return this->Sort(this->func_list[this->sort_type]);
} }
/** /**

View File

@ -197,7 +197,7 @@ protected:
/** Sort the stations list */ /** Sort the stations list */
void SortStationsList() void SortStationsList()
{ {
this->stations.Sort(); if (!this->stations.Sort()) return;
/* Reset name sorter sort cache */ /* Reset name sorter sort cache */
this->last_station = NULL; this->last_station = NULL;