mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
CMenuOptionChooser: Add alphanumeric sort option
- default is false - Activate by OptionsSort = true
This commit is contained in:
@@ -1269,7 +1269,7 @@ int CMenuOptionNumberChooser::getWidth(void)
|
||||
return width + 10; /* min 10 pixels between option name and value. enough? */
|
||||
}
|
||||
|
||||
CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
|
||||
CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionNameString = g_Locale->getText(OptionName);
|
||||
@@ -1280,7 +1280,8 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int *
|
||||
observ = Observ;
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
pulldown = Pulldown;
|
||||
pulldown = Pulldown;
|
||||
optionsSort = OptionsSort;
|
||||
for (unsigned int i = 0; i < number_of_options; i++)
|
||||
{
|
||||
struct keyval_ext opt;
|
||||
@@ -1291,7 +1292,7 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int *
|
||||
}
|
||||
}
|
||||
|
||||
CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
|
||||
CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionNameString = OptionName;
|
||||
@@ -1302,7 +1303,8 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio
|
||||
observ = Observ;
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
pulldown = Pulldown;
|
||||
pulldown = Pulldown;
|
||||
optionsSort = OptionsSort;
|
||||
for (unsigned int i = 0; i < number_of_options; i++)
|
||||
{
|
||||
struct keyval_ext opt;
|
||||
@@ -1315,7 +1317,7 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio
|
||||
|
||||
CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options,
|
||||
const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ,
|
||||
const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
|
||||
const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionNameString = g_Locale->getText(OptionName);
|
||||
@@ -1326,14 +1328,15 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int *
|
||||
observ = Observ;
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
pulldown = Pulldown;
|
||||
pulldown = Pulldown;
|
||||
optionsSort = OptionsSort;
|
||||
for (unsigned int i = 0; i < number_of_options; i++)
|
||||
options.push_back(Options[i]);
|
||||
}
|
||||
|
||||
CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options,
|
||||
const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ,
|
||||
const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
|
||||
const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionNameString = OptionName;
|
||||
@@ -1344,7 +1347,8 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio
|
||||
observ = Observ;
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
pulldown = Pulldown;
|
||||
pulldown = Pulldown;
|
||||
optionsSort = OptionsSort;
|
||||
for (unsigned int i = 0; i < number_of_options; i++)
|
||||
options.push_back(Options[i]);
|
||||
}
|
||||
@@ -1352,6 +1356,7 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio
|
||||
CMenuOptionChooser::~CMenuOptionChooser()
|
||||
{
|
||||
options.clear();
|
||||
clearChooserOptions();
|
||||
}
|
||||
|
||||
void CMenuOptionChooser::setOptionValue(const int newvalue)
|
||||
@@ -1364,12 +1369,41 @@ int CMenuOptionChooser::getOptionValue(void) const
|
||||
return *optionValue;
|
||||
}
|
||||
|
||||
void CMenuOptionChooser::clearChooserOptions()
|
||||
{
|
||||
for (std::vector<CMenuOptionChooserOptions*>::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
option_chooser_options_v.clear();
|
||||
}
|
||||
|
||||
int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
{
|
||||
bool wantsRepaint = false;
|
||||
int ret = menu_return::RETURN_NONE;
|
||||
|
||||
if (optionsSort) {
|
||||
clearChooserOptions();
|
||||
unsigned int i1;
|
||||
for (i1 = 0; i1 < number_of_options; i1++)
|
||||
{
|
||||
CMenuOptionChooserOptions* co = new CMenuOptionChooserOptions();
|
||||
co->key = options[i1].key;
|
||||
co->valname = (options[i1].valname != 0) ? options[i1].valname : g_Locale->getText(options[i1].value);
|
||||
option_chooser_options_v.push_back(co);
|
||||
}
|
||||
|
||||
sort(option_chooser_options_v.begin(), option_chooser_options_v.end(), CMenuOptionChooserCompareItem());
|
||||
|
||||
i1 = 0;
|
||||
for (std::vector<CMenuOptionChooserOptions*>::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end() && i1 < number_of_options; ++it) {
|
||||
options[i1].key = (*it)->key;
|
||||
options[i1].value = NONEXISTANT_LOCALE;
|
||||
options[i1].valname = (*it)->valname.c_str();
|
||||
i1++;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg == CRCInput::RC_ok) && pulldown) {
|
||||
int select = -1;
|
||||
char cnt[5];
|
||||
|
Reference in New Issue
Block a user