OpenTTD
|
List template of 'things' T
to sort in a GUI.
More...
#include <sortlist_type.h>
Public Types | |
typedef bool | SortFunction(const T &, const T &) |
Signature of sort function. | |
typedef bool CDECL | FilterFunction(const T *, F) |
Signature of filter function. | |
Public Member Functions | |
uint8 | SortType () const |
Get the sorttype of the list. More... | |
void | SetSortType (uint8 n_type) |
Set the sorttype of the list. More... | |
Listing | GetListing () const |
Export current sort conditions. More... | |
void | SetListing (Listing l) |
Import sort conditions. More... | |
uint8 | FilterType () const |
Get the filtertype of the list. More... | |
void | SetFilterType (uint8 n_type) |
Set the filtertype of the list. More... | |
Filtering | GetFiltering () const |
Export current filter conditions. More... | |
void | SetFiltering (Filtering f) |
Import filter conditions. More... | |
bool | NeedResort () |
Check if a resort is needed next loop If used the resort timer will decrease every call till 0. More... | |
void | ForceResort () |
Force a resort next Sort call Reset the resort timer if used too. | |
bool | IsDescSortOrder () const |
Check if the sort order is descending. More... | |
void | ToggleSortOrder () |
Toggle the sort order Since that is the worst condition for the sort function reverse the list here. | |
bool | Sort (SortFunction *compare) |
Sort the list. More... | |
void | SetSortFuncs (SortFunction *const *n_funcs) |
Hand the array of sort function pointers to the sort list. More... | |
bool | Sort () |
Overload of Sort(SortFunction *compare) Overloaded to reduce external code. More... | |
bool | IsFilterEnabled () const |
Check if the filter is enabled. More... | |
void | SetFilterState (bool state) |
Enable or disable the filter. More... | |
bool | Filter (FilterFunction *decide, F filter_data) |
Filter the list. More... | |
void | SetFilterFuncs (FilterFunction *const *n_funcs) |
Hand the array of filter function pointers to the sort list. More... | |
bool | Filter (F filter_data) |
Filter the data with the currently selected filter. More... | |
bool | NeedRebuild () const |
Check if a rebuild is needed. More... | |
void | ForceRebuild () |
Force that a rebuild is needed. | |
void | RebuildDone () |
Notify the sortlist that the rebuild is done. More... | |
Protected Member Functions | |
bool | IsSortable () const |
Check if the list is sortable. More... | |
void | ResetResortTimer () |
Reset the resort timer. | |
Protected Attributes | |
SortFunction *const * | sort_func_list |
the sort criteria functions | |
FilterFunction *const * | filter_func_list |
the filter criteria functions | |
SortListFlags | flags |
used to control sorting/resorting/etc. | |
uint8 | sort_type |
what criteria to sort on | |
uint8 | filter_type |
what criteria to filter on | |
uint16 | resort_timer |
resort list after a given amount of ticks if set | |
List template of 'things' T
to sort in a GUI.
T | Type of data stored in the list to represent each item. |
F | Type of data fed as additional value to the filter function. |
Definition at line 47 of file sortlist_type.h.
|
inline |
Filter the list.
decide | The function to decide about an item |
filter_data | Additional data passed to the filter function |
Definition at line 331 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), NetworkContentListWindow::FilterContentList(), BuildVehicleWindow::FilterEngineList(), SignList::FilterSignList(), and NewGRFWindow::TagNameFilter().
|
inline |
Filter the data with the currently selected filter.
filter_data | Additional data passed to the filter function. |
Definition at line 365 of file sortlist_type.h.
|
inline |
Get the filtertype of the list.
Definition at line 148 of file sortlist_type.h.
|
inline |
Export current filter conditions.
Definition at line 170 of file sortlist_type.h.
Referenced by NetworkContentListWindow::UpdateFilterState().
Export current sort conditions.
Definition at line 117 of file sortlist_type.h.
Referenced by TownDirectoryWindow::OnClick(), TownDirectoryWindow::OnDropdownSelect(), BuildBridgeWindow::SortBridgeList(), and CompanyStationsWindow::SortStationsList().
|
inline |
Check if the sort order is descending.
Definition at line 226 of file sortlist_type.h.
Referenced by BuildBridgeWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), VehicleListWindow::DrawWidget(), and NetworkContentListWindow::OnPaint().
|
inline |
Check if the filter is enabled.
Definition at line 305 of file sortlist_type.h.
|
inlineprotected |
Check if the list is sortable.
Definition at line 65 of file sortlist_type.h.
|
inline |
Check if a rebuild is needed.
Definition at line 375 of file sortlist_type.h.
Referenced by CompanyLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), BuildVehicleWindow::FilterSingleEngine(), GetUnitNumberDigits(), NetworkContentListWindow::OnInvalidateData(), NetworkGameWindow::OnPaint(), NetworkContentListWindow::OnPaint(), TownDirectoryWindow::OnPaint(), IndustryDirectoryWindow::OnPaint(), SignList::SignList(), and NewGRFWindow::TagNameFilter().
|
inline |
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
If 0 reached the resort bit will be set and the timer will be reset.
Definition at line 202 of file sortlist_type.h.
Referenced by CompanyStationsWindow::OnGameTick(), VehicleGroupWindow::OnGameTick(), CompanyLeagueWindow::OnGameTick(), VehicleListWindow::OnGameTick(), NetworkGameWindow::OnPaint(), CompanyLeagueWindow::PerformanceSorter(), BuildBridgeWindow::SortBridgeList(), and CompanyStationsWindow::SortStationsList().
|
inline |
Notify the sortlist that the rebuild is done.
Definition at line 393 of file sortlist_type.h.
Referenced by CompanyLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), ReplaceVehicleWindow::GenerateLists(), GetUnitNumberDigits(), SignList::SignList(), and NewGRFWindow::TagNameFilter().
|
inline |
Hand the array of filter function pointers to the sort list.
n_funcs | The pointer to the first filter func |
Definition at line 354 of file sortlist_type.h.
Referenced by BuildVehicleWindow::SetCargoFilterArray().
|
inline |
Import filter conditions.
f | The filter conditions we want to use |
Definition at line 184 of file sortlist_type.h.
|
inline |
Enable or disable the filter.
state | If filtering should be enabled or disabled |
Definition at line 315 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), BuildVehicleWindow::OnDropdownSelect(), NewGRFWindow::OnEditboxChanged(), SignList::SignList(), and NetworkContentListWindow::UpdateFilterState().
|
inline |
Set the filtertype of the list.
n_type | the new filter type |
Definition at line 158 of file sortlist_type.h.
Referenced by NetworkContentListWindow::FilterContentList().
Import sort conditions.
l | The sort conditions we want to use |
Definition at line 131 of file sortlist_type.h.
Referenced by TownDirectoryWindow::OnClick(), BuildBridgeWindow::SortBridgeList(), CompanyStationsWindow::SortStationsList(), and TownDirectoryWindow::TownRatingSorter().
|
inline |
Hand the array of sort function pointers to the sort list.
n_funcs | The pointer to the first sort func |
Definition at line 283 of file sortlist_type.h.
Referenced by BuildBridgeWindow::SortBridgeList(), CompanyStationsWindow::SortStationsList(), and TownDirectoryWindow::TownRatingSorter().
|
inline |
Set the sorttype of the list.
n_type | the new sort type |
Definition at line 104 of file sortlist_type.h.
Referenced by BuildBridgeWindow::OnDropdownSelect(), CompanyStationsWindow::OnDropdownSelect(), VehicleGroupWindow::OnDropdownSelect(), TownDirectoryWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), and VehicleListWindow::OnDropdownSelect().
|
inline |
Sort the list.
For the first sorting we use quick sort since it is faster for irregular sorted data. After that we use gsort.
compare | The function to compare two list items |
Definition at line 253 of file sortlist_type.h.
Referenced by VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), TownDirectoryWindow::OnClick(), CompanyLeagueWindow::OnPaint(), SignList::SignNameSorter(), BuildBridgeWindow::SortBridgeList(), NetworkContentListWindow::SortContentList(), NetworkGameWindow::SortNetworkGameList(), CompanyStationsWindow::SortStationsList(), and NewGRFWindow::TagNameFilter().
|
inline |
Overload of Sort(SortFunction *compare) Overloaded to reduce external code.
Definition at line 294 of file sortlist_type.h.
|
inline |
Get the sorttype of the list.
Definition at line 94 of file sortlist_type.h.
Referenced by BuildBridgeWindow::OnClick(), VehicleGroupWindow::OnClick(), NetworkGameWindow::OnClick(), TownDirectoryWindow::OnClick(), IndustryDirectoryWindow::OnClick(), VehicleListWindow::OnClick(), BuildBridgeWindow::OnDropdownSelect(), CompanyStationsWindow::OnDropdownSelect(), TownDirectoryWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), NetworkContentListWindow::OnPaint(), TownDirectoryWindow::SetStringParameters(), IndustryDirectoryWindow::SetStringParameters(), BuildBridgeWindow::SortBridgeList(), and CompanyStationsWindow::SortStationsList().