Permalink
Browse files

Allow a buttonlist item position to be specified

This allows a new button list item to be inserted at any position in
the list so that a full list rebuild can be avoided.
  • Loading branch information...
1 parent bc3942b commit c64efc1b95349c40fe1db7fd817df882ca7ec0b0 @stuartm stuartm committed Jun 20, 2011
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.25.20110616-1"
+#define MYTH_BINARY_VERSION "0.25.20110620-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
@@ -1344,10 +1344,21 @@ void MythUIButtonList::ItemVisible(MythUIButtonListItem* item)
emit itemVisible(item);
}
-void MythUIButtonList::InsertItem(MythUIButtonListItem *item)
+void MythUIButtonList::InsertItem(MythUIButtonListItem *item, int listPosition)
{
bool wasEmpty = m_itemList.isEmpty();
- m_itemList.append(item);
+ if (listPosition >= 0 && listPosition <= m_itemList.count())
+ {
+ m_itemList.insert(listPosition, item);
+
+ if (listPosition <= m_selPosition)
+ m_selPosition++;
+
+ if (listPosition <= m_topPosition)
+ m_topPosition++;
+ }
+ else
+ m_itemList.append(item);
m_itemCount++;
@@ -2643,7 +2654,7 @@ bool MythUIButtonList::DoFind(bool doMove, bool searchForward)
MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList* lbtype,
const QString& text, const QString& image,
bool checkable, CheckState state,
- bool showArrow)
+ bool showArrow, int listPosition)
{
if (!lbtype)
VERBOSE(VB_IMPORTANT, "Cannot add a button to a non-existent list!");
@@ -2661,12 +2672,12 @@ MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList* lbtype,
m_checkable = true;
if (m_parent)
- m_parent->InsertItem(this);
+ m_parent->InsertItem(this, listPosition);
}
MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList* lbtype,
const QString& text,
- QVariant data)
+ QVariant data, int listPosition)
{
if (!lbtype)
VERBOSE(VB_IMPORTANT, "Cannot add a button to a non-existent list!");
@@ -2682,7 +2693,7 @@ MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList* lbtype,
m_showArrow = false;
if (m_parent)
- m_parent->InsertItem(this);
+ m_parent->InsertItem(this, listPosition);
}
MythUIButtonListItem::~MythUIButtonListItem()
@@ -32,9 +32,10 @@ class MUI_PUBLIC MythUIButtonListItem
MythUIButtonListItem(MythUIButtonList *lbtype, const QString& text,
const QString& image = "", bool checkable = false,
- CheckState state = CantCheck, bool showArrow = false);
+ CheckState state = CantCheck, bool showArrow = false,
+ int listPosition = -1);
MythUIButtonListItem(MythUIButtonList *lbtype, const QString& text,
- QVariant data);
+ QVariant data, int listPosition = -1);
virtual ~MythUIButtonListItem();
MythUIButtonList *parent() const;
@@ -197,7 +198,7 @@ class MUI_PUBLIC MythUIButtonList : public MythUIType
void Const();
virtual void Init();
- void InsertItem(MythUIButtonListItem *item);
+ void InsertItem(MythUIButtonListItem *item, int listPosition = -1);
int minButtonWidth(const MythRect & area);
int minButtonHeight(const MythRect & area);

0 comments on commit c64efc1

Please sign in to comment.