if (content)
m_content->setListbox(this);
entryReset();
+ /* if oldsel != m_selected, selectionChanged was already
+ emitted in entryReset. we want it in any case, so otherwise,
+ emit it now. */
if (oldsel == m_selected)
/* emit */ selectionChanged();
}
void eListbox::moveToEnd()
{
+ if (!m_content)
+ return;
/* move to last existing one ("end" is already invalid) */
m_content->cursorEnd(); m_content->cursorMove(-1);
/* current selection invisible? */
{
m_content_changed=true;
m_prev_scrollbar_page=-1;
- m_content->setSize(eSize(size().width(), m_itemheight));
+ if (m_content)
+ m_content->setSize(eSize(size().width(), m_itemheight));
m_items_per_page = size().height() / m_itemheight;
if (m_items_per_page < 0) /* TODO: whyever - our size could be invalid, or itemheigh could be wrongly specified. */
void eListbox::entryAdded(int index)
{
- /* manage our local pointers. when the entry was added before the current position, we have to advance. */
+ if (m_content && (m_content->size() % m_items_per_page) == 1)
+ m_content_changed=true;
+ /* manage our local pointers. when the entry was added before the current position, we have to advance. */
/* we need to check <= - when the new entry has the (old) index of the cursor, the cursor was just moved down. */
if (index <= m_selected)
void eListbox::entryRemoved(int index)
{
- if (index == m_selected)
+ if (m_content && !(m_content->size() % m_items_per_page))
+ m_content_changed=true;
+
+ if (index == m_selected && m_content)
m_selected = m_content->cursorGet();
moveSelection(justCheck);