more pid cache stuff
[enigma2.git] / lib / service / listboxservice.cpp
index 011c96c..24090f7 100644 (file)
@@ -3,6 +3,7 @@
 
 void eListboxServiceContent::setRoot(const eServiceReference &root)
 {
+       m_list.clear();
        m_root = root;
        
        assert(m_service_center);
@@ -16,6 +17,67 @@ void eListboxServiceContent::setRoot(const eServiceReference &root)
 
        m_size = m_list.size();
        cursorHome();
+       
+       if (m_listbox)
+               m_listbox->entryReset();
+}
+
+void eListboxServiceContent::getCurrent(eServiceReference &ref)
+{
+       if (cursorValid())
+               ref = *m_cursor;
+       else
+               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);
@@ -106,7 +168,10 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
 {
        ePtr<gFont> 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())