X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d7d291938c45893e28715fb12ae5b83d334084e9..defa1a765f48ec880b36b14a247b89649553c2ec:/lib/service/listboxservice.cpp diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp index 881047df..24090f73 100644 --- a/lib/service/listboxservice.cpp +++ b/lib/service/listboxservice.cpp @@ -3,6 +3,7 @@ void eListboxServiceContent::setRoot(const eServiceReference &root) { + m_list.clear(); m_root = root; assert(m_service_center); @@ -16,6 +17,9 @@ void eListboxServiceContent::setRoot(const eServiceReference &root) m_size = m_list.size(); cursorHome(); + + if (m_listbox) + m_listbox->entryReset(); } void eListboxServiceContent::getCurrent(eServiceReference &ref) @@ -26,6 +30,56 @@ void eListboxServiceContent::getCurrent(eServiceReference &ref) ref = eServiceReference(); } +void eListboxServiceContent::initMarked() +{ + m_marked.clear(); +} + +void eListboxServiceContent::addMarked(const eServiceReference &ref) +{ + m_marked.insert(ref); + if (m_listbox) + m_listbox->entryChanged(lookupService(ref)); +} + +void eListboxServiceContent::removeMarked(const eServiceReference &ref) +{ + m_marked.erase(ref); + if (m_listbox) + m_listbox->entryChanged(lookupService(ref)); +} + +int eListboxServiceContent::isMarked(const eServiceReference &ref) +{ + return m_marked.find(ref) != m_marked.end(); +} + +void eListboxServiceContent::markedQueryStart() +{ + m_marked_iterator = m_marked.begin(); +} + +int eListboxServiceContent::markedQueryNext(eServiceReference &ref) +{ + if (m_marked_iterator == m_marked.end()) + return -1; + ref = *m_marked_iterator++; + return 0; +} + +int eListboxServiceContent::lookupService(const eServiceReference &ref) +{ + /* shortcut for cursor */ + if (ref == *m_cursor) + return m_cursor_number; + /* otherwise, search in the list.. */ + int index = 0; + for (list::const_iterator i(m_list.begin()); i != m_list.end(); ++i, ++index); + + /* this is ok even when the index was not found. */ + return index; +} + DEFINE_REF(eListboxServiceContent); eListboxServiceContent::eListboxServiceContent() @@ -114,7 +168,10 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const { ePtr fnt = new gFont("Arial", 14); painter.clip(eRect(offset, m_itemsize)); - style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal); + if (cursorValid() && isMarked(*m_cursor)) + style.setStyle(painter, eWindowStyle::styleListboxMarked); + else + style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal); painter.clear(); if (cursorValid())