CMenuOptionChooser: clean up multiple code parts

Origin commit data
------------------
Branch: ni/coolstream
Commit: 8899660dad
Author: Thilo Graf <dbt@novatux.de>
Date: 2017-06-18 (Sun, 18 Jun 2017)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
2017-06-18 00:04:40 +02:00
parent a3d5baa1e6
commit 5f1d85300f
2 changed files with 74 additions and 102 deletions

View File

@@ -1703,74 +1703,36 @@ int CMenuOptionNumberChooser::getWidth(void)
return width; return width;
} }
CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options,
const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) const bool Active, CChangeObserver * const Observ,
: CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{
nameString = "";
name = OptionName;
optionValue = OptionValue;
number_of_options = Number_Of_Options;
observ = Observ;
pulldown = Pulldown;
optionsSort = OptionsSort;
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt = Options[i];
options.push_back(opt);
}
}
CMenuOptionChooser::CMenuOptionChooser(const std::string &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 char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{
nameString = OptionName;
name = NONEXISTANT_LOCALE;
optionValue = OptionValue;
number_of_options = Number_Of_Options;
observ = Observ;
pulldown = Pulldown;
optionsSort = OptionsSort;
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt = Options[i];
options.push_back(opt);
}
}
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 char * const IconName, bool Pulldown, bool OptionsSort) const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName) : CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{ {
nameString = ""; init("", OptionName, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort);
name = OptionName;
optionValue = OptionValue;
number_of_options = Number_Of_Options;
observ = Observ;
pulldown = Pulldown;
optionsSort = OptionsSort;
for (unsigned int i = 0; i < number_of_options; i++)
options.push_back(Options[i]);
} }
CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options,
const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const bool Active, CChangeObserver * const Observ,
const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName) : CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{ {
nameString = OptionName; init(OptionName, NONEXISTANT_LOCALE, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort);
name = NONEXISTANT_LOCALE; }
optionValue = OptionValue;
number_of_options = Number_Of_Options; CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options,
observ = Observ; const bool Active, CChangeObserver * const Observ,
pulldown = Pulldown; const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
optionsSort = OptionsSort; : CAbstractMenuOptionChooser(Active, DirectKey, IconName)
for (unsigned int i = 0; i < number_of_options; i++) {
options.push_back(Options[i]); init("", OptionName, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort);
}
CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options,
const bool Active, CChangeObserver * const Observ,
const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{
init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort);
} }
CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, std::vector<keyval_ext> &Options, CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, std::vector<keyval_ext> &Options,
@@ -1778,14 +1740,7 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int *
const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName) : CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{ {
nameString = ""; init("", OptionName, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort);
name = OptionName;
optionValue = OptionValue;
options = Options;
number_of_options = options.size();
observ = Observ;
pulldown = Pulldown;
optionsSort = OptionsSort;
} }
CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector<keyval_ext> &Options, CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector<keyval_ext> &Options,
@@ -1793,14 +1748,7 @@ CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * cons
const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort)
: CAbstractMenuOptionChooser(Active, DirectKey, IconName) : CAbstractMenuOptionChooser(Active, DirectKey, IconName)
{ {
nameString = OptionName; init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort);
name = NONEXISTANT_LOCALE;
optionValue = OptionValue;
options = Options;
number_of_options = options.size();
observ = Observ;
pulldown = Pulldown;
optionsSort = OptionsSort;
} }
CMenuOptionChooser::~CMenuOptionChooser() CMenuOptionChooser::~CMenuOptionChooser()
@@ -1808,13 +1756,14 @@ CMenuOptionChooser::~CMenuOptionChooser()
clearChooserOptions(); clearChooserOptions();
} }
void CMenuOptionChooser::initVarOptionChooser( const std::string &OptionName, void CMenuOptionChooser::init( const std::string &OptionName,
const neutrino_locale_t Name, const neutrino_locale_t Name,
int * const OptionValue, int * const OptionValue,
const bool Active, const struct keyval * const Options,
const struct keyval_ext * const OptionsExt,
std::vector<keyval_ext> * v_Options,
const size_t Number_Of_Options,
CChangeObserver * const Observ, CChangeObserver * const Observ,
neutrino_msg_t DirectKey,
const char * IconName,
bool Pulldown, bool Pulldown,
bool OptionsSort) bool OptionsSort)
{ {
@@ -1822,12 +1771,33 @@ void CMenuOptionChooser::initVarOptionChooser( const std::string &OptionName,
nameString = OptionName; nameString = OptionName;
name = Name; name = Name;
optionValue = OptionValue; optionValue = OptionValue;
active = Active; number_of_options = Number_Of_Options;
observ = Observ; observ = Observ;
directKey = DirectKey;
iconName = IconName;
pulldown = Pulldown; pulldown = Pulldown;
optionsSort = OptionsSort; optionsSort = OptionsSort;
if (Options || OptionsExt)
{
if (Options)
{
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt = Options[i];
options.push_back(opt);
}
}
if (OptionsExt)
{
for (unsigned int i = 0; i < number_of_options; i++)
options.push_back(OptionsExt[i]);
}
}
else{
if (v_Options)
options = *v_Options;
}
} }
void CMenuOptionChooser::clearChooserOptions() void CMenuOptionChooser::clearChooserOptions()

View File

@@ -386,19 +386,20 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
private: private:
std::vector<keyval_ext> options; std::vector<keyval_ext> options;
std::vector<CMenuOptionChooserOptions*> option_chooser_options_v; std::vector<CMenuOptionChooserOptions*> option_chooser_options_v;
unsigned number_of_options; size_t number_of_options;
CChangeObserver * observ; CChangeObserver * observ;
bool pulldown; bool pulldown;
bool optionsSort; bool optionsSort;
void clearChooserOptions(); void clearChooserOptions();
void initVarOptionChooser( const std::string &OptionName, void init( const std::string &OptionName,
const neutrino_locale_t Name, const neutrino_locale_t Name,
int * const OptionValue, int * const OptionValue,
const bool Active, const struct keyval * const Options,
const struct keyval_ext * const OptionsExt,
std::vector<keyval_ext> * v_Options,
const size_t Number_Of_Options,
CChangeObserver * const Observ, CChangeObserver * const Observ,
neutrino_msg_t DirectKey,
const char * IconName,
bool Pulldown, bool Pulldown,
bool OptionsSort bool OptionsSort
); );
@@ -406,19 +407,19 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
public: public:
CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options, CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL,
bool Pulldown = false, bool OptionsSort = false); bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options, CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL,
bool Pulldown = false, bool OptionsSort = false); bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options, CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL,
bool Pulldown = false, bool OptionsSort = false); bool size_t = false, bool OptionsSort = false);
CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options, CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options,
const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL,
bool Pulldown = false, bool OptionsSort = false); bool Pulldown = false, bool OptionsSort = false);
CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector<keyval_ext> &Options, CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector<keyval_ext> &Options,
@@ -429,6 +430,7 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
const bool Active = false, CChangeObserver * const Observ = NULL, const bool Active = false, CChangeObserver * const Observ = NULL,
const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL,
bool Pulldown = false, bool OptionsSort = false); bool Pulldown = false, bool OptionsSort = false);
~CMenuOptionChooser(); ~CMenuOptionChooser();
void setOption(const int newvalue); void setOption(const int newvalue);