mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 05:19:18 -06:00
OptionProperty: ability to get the string description by passing a value
string getDescriptionByValue(int)
This commit is contained in:
@@ -96,7 +96,7 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the list of available options.
|
||||
* /return The list of available options
|
||||
* \return The list of available options
|
||||
*/
|
||||
const std::vector<Option>& options() const;
|
||||
|
||||
@@ -107,6 +107,12 @@ public:
|
||||
*/
|
||||
void setValue(int value) override;
|
||||
|
||||
/**
|
||||
* Get the description of the option that matches <code>value</code>
|
||||
* \param value The value of the option
|
||||
*/
|
||||
std::string getDescriptionByValue(int value);
|
||||
|
||||
private:
|
||||
static const std::string OptionsKey;
|
||||
std::string generateAdditionalDescription() const;
|
||||
|
||||
@@ -103,6 +103,14 @@ void OptionProperty::setValue(int value) {
|
||||
LERROR("Could not find an option for value '" << value << "' in OptionProperty");
|
||||
}
|
||||
|
||||
std::string OptionProperty::getDescriptionByValue(int value) {
|
||||
for (auto option : _options) {
|
||||
if (option.value == value) {
|
||||
return option.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string OptionProperty::generateAdditionalDescription() const {
|
||||
// @REFACTOR from selectionproperty.cpp, possible refactoring? ---abock
|
||||
std::string result;
|
||||
|
||||
Reference in New Issue
Block a user