Added description for OptionProperty

This commit is contained in:
Alexander Bock
2014-12-17 18:52:01 +01:00
parent 6336ee998a
commit 7cd1374cdb
2 changed files with 20 additions and 0 deletions

View File

@@ -87,6 +87,9 @@ public:
void setValue(int value) override;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
};

View File

@@ -30,6 +30,8 @@ namespace {
namespace openspace {
namespace properties {
const std::string OptionProperty::OptionsKey = "Options";
OptionProperty::OptionProperty(std::string identifier, std::string guiName)
: IntProperty(std::move(identifier), std::move(guiName))
@@ -73,5 +75,20 @@ void OptionProperty::setValue(int value) {
LERROR("Could not find an option for value '" << value << "' in OptionProperty");
}
std::string OptionProperty::generateAdditionalDescription() const {
// @REFACTOR from selectionproperty.cpp, possible refactoring? ---abock
std::string result;
result += OptionsKey + " = {";
for (size_t i = 0; i < _options.size(); ++i) {
const Option& o = _options[i];
result += "[\"" + std::to_string(o.value) + "\"] = \"" + o.description + "\"";
if (i != _options.size() - 1)
result += ",";
}
result += "}";
return result;
}
} // namespace properties
} // namespace openspace