diff --git a/mythtv/libs/libmythui/mythuispinbox.cpp b/mythtv/libs/libmythui/mythuispinbox.cpp index 11777815983..6635954abf3 100644 --- a/mythtv/libs/libmythui/mythuispinbox.cpp +++ b/mythtv/libs/libmythui/mythuispinbox.cpp @@ -83,6 +83,41 @@ void MythUISpinBox::SetRange(int low, int high, int step, uint pageMultiple) CalculateArrowStates(); } + +/** + * \brief Add a special label for a value of the spinbox, it does not need to be in the range + * + * \param label The text displayed + * \param value The value associated to this label + */ +void MythUISpinBox::AddSelection(int value, const QString &label) +{ + MythUIButtonListItem *item; + if (!label.isEmpty()) + { + item = GetItemByData(value); + if (item) + item->SetText(label); + return; + } + + int insertPos=-1; + + for (int pos = 0; pos < m_itemList.size(); pos++) + { + item = m_itemList.at(pos); + if (item->GetData().toInt() > value) + { + insertPos = pos; + break; + } + } + + item = new MythUIButtonListItem(this, + label.isEmpty() ? QString(value) : label, + qVariantFromValue(value), insertPos); +} + /** * \copydoc MythUIType::ParseElement() */ diff --git a/mythtv/libs/libmythui/mythuispinbox.h b/mythtv/libs/libmythui/mythuispinbox.h index 451530f78c4..27a72c100cf 100644 --- a/mythtv/libs/libmythui/mythuispinbox.h +++ b/mythtv/libs/libmythui/mythuispinbox.h @@ -24,6 +24,7 @@ class MUI_PUBLIC MythUISpinBox : public MythUIButtonList void SetValue(int val) { SetValueByData(val); } void SetValue(const QString &val) { SetValueByData(val.toInt()); } + void AddSelection (int value, const QString &label = ""); QString GetValue(void) const { return GetDataValue().toString(); } int GetIntValue(void) const { return GetDataValue().toInt(); }