X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ae3bc8673d79edecb8fcb918d83db011535b0955..e5a909e610fcd24a0bb6d7b1a586a14cd9767512:/lib/service/listboxservice.cpp diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp index 284776fd..32b9007f 100644 --- a/lib/service/listboxservice.cpp +++ b/lib/service/listboxservice.cpp @@ -5,9 +5,32 @@ #include #include -void eListboxServiceContent::addService(const eServiceReference &service) +void eListboxServiceContent::addService(const eServiceReference &service, bool beforeCurrent) { - m_list.push_back(service); + if (beforeCurrent && m_size) + { + m_list.insert(m_cursor, service); + ++m_size; + --m_cursor; + } + else + m_list.push_back(service); +} + +void eListboxServiceContent::removeCurrent() +{ + if (m_size && m_listbox) + { + if (m_cursor_number == m_size-1) + { + m_list.erase(m_cursor--); + --m_cursor_number; + } + else + m_list.erase(m_cursor++); + --m_size; + m_listbox->entryRemoved(m_cursor_number); + } } void eListboxServiceContent::FillFinished() @@ -87,6 +110,38 @@ int eListboxServiceContent::getNextBeginningWithChar(char c) return 0; } +int eListboxServiceContent::getPrevMarkerPos() +{ + if (!m_listbox) + return 0; + list::iterator i(m_cursor); + int index = m_cursor_number; + while (index) + { + --i; + --index; + if (i->flags & eServiceReference::isMarker) + break; + } + return index; +} + +int eListboxServiceContent::getNextMarkerPos() +{ + if (!m_listbox) + return 0; + list::iterator i(m_cursor); + int index = m_cursor_number; + while (index < (m_size-1)) + { + ++i; + ++index; + if (i->flags & eServiceReference::isMarker) + break; + } + return index; +} + void eListboxServiceContent::initMarked() { m_marked.clear(); @@ -377,7 +432,7 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const if (m_is_playable_ignore.valid() && service_info && !service_info->isPlayable(*m_cursor, m_is_playable_ignore)) painter.setForegroundColor(gRGB(0xbbbbbb)); - int xoffset=0; // used as offset when painting the folder symbol + int xoffset=0; // used as offset when painting the folder/marker symbol for (int e = 0; e < celElements; ++e) { @@ -394,8 +449,21 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const { case celServiceNumber: { + if (m_cursor->flags & eServiceReference::isMarker) + continue; char bla[10]; - sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1); + /* how we can do this better? :) */ + int markers_before=0; + { + list::iterator tmp=m_cursor; + while(tmp != m_list.begin()) + { + --tmp; + if (tmp->flags & eServiceReference::isMarker) + ++markers_before; + } + } + sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1 - markers_before); text = bla; flags|=gPainter::RT_HALIGN_RIGHT; break; @@ -455,17 +523,23 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const painter.renderPara(para, offset+ePoint(xoffs, yoffs)); } - else if (e == celServiceTypePixmap || e == celFolderPixmap) + else if (e == celServiceTypePixmap || e == celFolderPixmap || e == celMarkerPixmap) { int orbpos = m_cursor->getUnsignedData(4) >> 16; ePtr &pixmap = (e == celFolderPixmap) ? m_pixmaps[picFolder] : + (e == celMarkerPixmap) ? m_pixmaps[picMarker] : (orbpos == 0xFFFF) ? m_pixmaps[picDVB_C] : (orbpos == 0xEEEE) ? m_pixmaps[picDVB_T] : m_pixmaps[picDVB_S]; if (pixmap) { eSize pixmap_size = pixmap->size(); - eRect area = m_element_position[e == celFolderPixmap ? celServiceName : celServiceInfo]; + int p = celServiceInfo; + if (e == celFolderPixmap) + p = celServiceName; + else if (e == celMarkerPixmap) + p = celServiceNumber; + eRect area = m_element_position[p]; int correction = (area.height() - pixmap_size.height()) / 2; if (m_cursor->flags & eServiceReference::flagDirectory) @@ -474,6 +548,11 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const continue; xoffset = pixmap_size.width() + 8; } + else if (m_cursor->flags & eServiceReference::isMarker) + { + if (e != celMarkerPixmap) + continue; + } else { if (e != celServiceTypePixmap)