CMenuOptionChooser: Add alphanumeric sort option

- default is false
- Activate by OptionsSort = true
This commit is contained in:
M. Liebmann
2014-01-04 01:18:15 +01:00
parent 621a712e81
commit 8832b803bd
2 changed files with 71 additions and 13 deletions

View File

@@ -313,6 +313,26 @@ private:
void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; }
};
class CMenuOptionChooserOptions
{
public:
int key;
std::string valname;
};
struct CMenuOptionChooserCompareItem: public std::binary_function <const CMenuOptionChooserOptions * const, const CMenuOptionChooserOptions * const, bool>
{
static bool cmpToLower(const char a, const char b)
{
return tolower(a) < tolower(b);
};
bool operator() (const CMenuOptionChooserOptions * const c1, CMenuOptionChooserOptions * const c2)
{
return std::lexicographical_compare(c1->valname.begin(), c1->valname.end(), c2->valname.begin(), c2->valname.end(), cmpToLower);
};
};
class CMenuOptionChooser : public CAbstractMenuOptionChooser
{
public:
@@ -331,28 +351,32 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
private:
std::vector<keyval_ext> options;
std::vector<CMenuOptionChooserOptions*> option_chooser_options_v;
unsigned number_of_options;
CChangeObserver * observ;
std::string optionNameString;
bool pulldown;
bool pulldown;
bool optionsSort;
void clearChooserOptions();
public:
CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "",
bool Pulldown = false);
bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "",
bool Pulldown = false);
bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "",
bool Pulldown = false);
bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "",
bool Pulldown = false);
bool Pulldown = false, bool OptionsSort = false);
~CMenuOptionChooser();
void setOptionValue(const int newvalue);