#include <lib/service/listboxservice.h>
#include <lib/service/service.h>
+#include <lib/gdi/font.h>
+#include <lib/dvb/epgcache.h>
+#include <lib/dvb/pmt.h>
+#include <lib/python/connections.h>
-void eListboxServiceContent::setRoot(const eServiceReference &root)
+void eListboxServiceContent::addService(const eServiceReference &service)
+{
+ m_list.push_back(service);
+}
+
+void eListboxServiceContent::FillFinished()
+{
+ m_size = m_list.size();
+ cursorHome();
+
+ if (m_listbox)
+ m_listbox->entryReset();
+}
+
+void eListboxServiceContent::setRoot(const eServiceReference &root, bool justSet)
{
m_list.clear();
m_root = root;
-
+
+ if (justSet)
+ return;
assert(m_service_center);
ePtr<iListableService> lst;
if (lst->getContent(m_list))
eDebug("getContent failed");
- m_size = m_list.size();
- cursorHome();
-
- if (m_listbox)
- m_listbox->entryReset();
+ FillFinished();
}
void eListboxServiceContent::setCurrent(const eServiceReference &ref)
ref = eServiceReference();
}
+int eListboxServiceContent::getNextBeginningWithChar(char c)
+{
+// printf("Char: %c\n", c);
+ int index=0;
+ for (list::iterator i(m_list.begin()); i != m_list.end(); ++i, ++index)
+ {
+ std::string text;
+ ePtr<iStaticServiceInformation> service_info;
+ m_service_center->info(*i, service_info);
+ service_info->getName(*i, text);
+// printf("%c\n", text.c_str()[0]);
+ int idx=0;
+ int len=text.length();
+ while ( idx <= len )
+ {
+ char cc = text[idx++];
+ if ( cc >= 33 && cc < 127)
+ {
+ if (cc == c)
+ return index;
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
void eListboxServiceContent::initMarked()
{
m_marked.clear();
void eListboxServiceContent::sort()
{
ePtr<iListableService> lst;
- if (!m_service_center->list(m_root, lst))
- {
+ if (!m_service_center->list(m_root, lst))
+ {
m_list.sort(iListableServiceCompare(lst));
/* FIXME: is this really required or can we somehow keep the current entry? */
cursorHome();
{
cursorHome();
cursorMove(n);
-
return 0;
}
/* get service information */
ePtr<iStaticServiceInformation> service_info;
m_service_center->info(*m_cursor, service_info);
-
+
+ if (m_is_playable_ignore.valid() && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
+ painter.setForegroundColor(gRGB(0xbbbbbb));
+
for (int e = 0; e < celElements; ++e)
{
if (!m_element_font[e])
continue;
- painter.setFont(m_element_font[e]);
-
+ int flags=gPainter::RT_VALIGN_CENTER;
+
+ eRect area = m_element_position[e];
+
std::string text = "<n/a>";
-
+
switch (e)
{
- case celServiceName:
- {
- if (service_info)
- service_info->getName(*m_cursor, text);
- break;
- }
+ case celIcon:
+ // render icon here...
+ continue;
case celServiceNumber:
{
char bla[10];
sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1);
text = bla;
+ flags|=gPainter::RT_HALIGN_RIGHT;
+ break;
+ }
+ case celServiceName:
+ {
+ if (service_info)
+ service_info->getName(*m_cursor, text);
break;
}
case celServiceInfo:
{
- text = "now&next";
+ ePtr<eServiceEvent> evt;
+ if ( !service_info->getEvent(*m_cursor, evt) )
+ text = '(' + evt->getEventName() + ')';
+ else
+ continue;
break;
}
- case celIcon:
- continue;
}
-
- eRect area = m_element_position[e];
- area.moveBy(offset.x(), offset.y());
-
- painter.renderText(area, text);
+
+ eTextPara *para = new eTextPara(area);
+
+ para->setFont(m_element_font[e]);
+ para->renderString(text);
+
+ if (e == celServiceName)
+ {
+ eRect bbox = para->getBoundBox();
+ int name_width = bbox.width()+10;
+ m_element_position[celServiceInfo].setLeft(area.left()+name_width);
+ m_element_position[celServiceInfo].setTop(area.top());
+ m_element_position[celServiceInfo].setWidth(area.width()-name_width);
+ m_element_position[celServiceInfo].setHeight(area.height());
+ }
+
+ if (flags & gPainter::RT_HALIGN_RIGHT)
+ para->realign(eTextPara::dirRight);
+ else if (flags & gPainter::RT_HALIGN_CENTER)
+ para->realign(eTextPara::dirCenter);
+ else if (flags & gPainter::RT_HALIGN_BLOCK)
+ para->realign(eTextPara::dirBlock);
+
+ ePoint offs = offset;
+
+ if (flags & gPainter::RT_VALIGN_CENTER)
+ {
+ eRect bbox = para->getBoundBox();
+ int vcentered_top = (area.height() - bbox.height()) / 2;
+ int correction = vcentered_top - bbox.top();
+ offs += ePoint(0, correction);
+ }
+
+ painter.renderPara(para, offs);
}
if (selected)
painter.clippop();
}
+void eListboxServiceContent::setIgnoreService( const eServiceReference &service )
+{
+ m_is_playable_ignore=service;
+}