cd65f350cee9e3f14839f48ed2e80acd3ff6a28f
[vuplus_dvbapp] / lib / service / listboxservice.cpp
1 #include <lib/service/listboxservice.h>
2 #include <lib/service/service.h>
3 #include <lib/gdi/font.h>
4 #include <lib/dvb/epgcache.h>
5 #include <lib/dvb/pmt.h>
6 #include <lib/python/connections.h>
7
8 void eListboxServiceContent::addService(const eServiceReference &service, bool beforeCurrent)
9 {
10         if (beforeCurrent && m_size)
11                 m_list.insert(m_cursor, service);
12         else
13                 m_list.push_back(service);
14         if (m_size++)
15         {
16                 ++m_cursor_number;
17                 if (m_listbox)
18                         m_listbox->entryAdded(m_cursor_number-1);
19         }
20         else
21         {
22                 m_cursor = m_list.begin();
23                 m_cursor_number=0;
24                 m_listbox->entryAdded(0);
25         }
26 }
27
28 void eListboxServiceContent::removeCurrent()
29 {
30         if (m_size && m_listbox)
31         {
32                 if (m_cursor_number == --m_size)
33                 {
34                         m_list.erase(m_cursor--);
35                         if (m_size)
36                         {
37                                 --m_cursor_number;
38                                 m_listbox->entryRemoved(m_cursor_number+1);
39                         }
40                         else
41                                 m_listbox->entryRemoved(m_cursor_number);
42                 }
43                 else
44                 {
45                         m_list.erase(m_cursor++);
46                         m_listbox->entryRemoved(m_cursor_number);
47                 }
48         }
49 }
50
51 void eListboxServiceContent::FillFinished()
52 {
53         m_size = m_list.size();
54         cursorHome();
55
56         if (m_listbox)
57                 m_listbox->entryReset();
58 }
59
60 void eListboxServiceContent::setRoot(const eServiceReference &root, bool justSet)
61 {
62         m_list.clear();
63         m_root = root;
64
65         if (justSet)
66         {
67                 m_lst=0;
68                 return;
69         }
70         ASSERT(m_service_center);
71         
72         if (m_service_center->list(m_root, m_lst))
73                 eDebug("no list available!");
74         else if (m_lst->getContent(m_list))
75                 eDebug("getContent failed");
76
77         FillFinished();
78 }
79
80 void eListboxServiceContent::setCurrent(const eServiceReference &ref)
81 {
82         int index=0;
83         for (list::iterator i(m_list.begin()); i != m_list.end(); ++i, ++index)
84                 if ( *i == ref )
85                 {
86                         m_cursor = i;
87                         m_cursor_number = index;
88                         break;
89                 }
90         if (m_listbox)
91                 m_listbox->moveSelectionTo(index);
92 }
93
94 void eListboxServiceContent::getCurrent(eServiceReference &ref)
95 {
96         if (cursorValid())
97                 ref = *m_cursor;
98         else
99                 ref = eServiceReference();
100 }
101
102 void eListboxServiceContent::getPrev(eServiceReference &ref)
103 {
104         if (cursorValid())
105         {
106                 list::iterator cursor(m_cursor);
107                 if (cursor == m_list.begin())
108                 {
109                         cursor = m_list.end();
110                 }
111                 ref = *(--cursor);
112         }
113         else
114                 ref = eServiceReference();
115 }
116
117 void eListboxServiceContent::getNext(eServiceReference &ref)
118 {
119         if (cursorValid())
120         {
121                 list::iterator cursor(m_cursor);
122                 cursor++;
123                 if (cursor == m_list.end())
124                 {
125                         cursor = m_list.begin();
126                 }
127                 ref = *(cursor);
128         }
129         else
130                 ref = eServiceReference();
131 }
132
133 int eListboxServiceContent::getNextBeginningWithChar(char c)
134 {
135 //      printf("Char: %c\n", c);
136         int index=0;
137         for (list::iterator i(m_list.begin()); i != m_list.end(); ++i, ++index)
138         {
139                 std::string text;
140                 ePtr<iStaticServiceInformation> service_info;
141                 m_service_center->info(*i, service_info);
142                 service_info->getName(*i, text);
143 //              printf("%c\n", text.c_str()[0]);
144                 int idx=0;
145                 int len=text.length();
146                 while ( idx <= len )
147                 {
148                         char cc = text[idx++];
149                         if ( cc >= 33 && cc < 127)
150                         {
151                                 if (cc == c)
152                                         return index;
153                                 break;
154                         }
155                 }
156         }
157         return 0;
158 }
159
160 int eListboxServiceContent::getPrevMarkerPos()
161 {
162         if (!m_listbox)
163                 return 0;
164         list::iterator i(m_cursor);
165         int index = m_cursor_number;
166         while (index)
167         {
168                 --i;
169                 --index;
170                 if (i->flags & eServiceReference::isMarker)
171                         break;
172         }
173         return index;
174 }
175
176 int eListboxServiceContent::getNextMarkerPos()
177 {
178         if (!m_listbox)
179                 return 0;
180         list::iterator i(m_cursor);
181         int index = m_cursor_number;
182         while (index < (m_size-1))
183         {
184                 ++i;
185                 ++index;
186                 if (i->flags & eServiceReference::isMarker)
187                         break;
188         }
189         return index;
190 }
191
192 void eListboxServiceContent::initMarked()
193 {
194         m_marked.clear();
195 }
196
197 void eListboxServiceContent::addMarked(const eServiceReference &ref)
198 {
199         m_marked.insert(ref);
200         if (m_listbox)
201                 m_listbox->entryChanged(lookupService(ref));
202 }
203
204 void eListboxServiceContent::removeMarked(const eServiceReference &ref)
205 {
206         m_marked.erase(ref);
207         if (m_listbox)
208                 m_listbox->entryChanged(lookupService(ref));
209 }
210
211 int eListboxServiceContent::isMarked(const eServiceReference &ref)
212 {
213         return m_marked.find(ref) != m_marked.end();
214 }
215
216 void eListboxServiceContent::markedQueryStart()
217 {
218         m_marked_iterator = m_marked.begin();
219 }
220
221 int eListboxServiceContent::markedQueryNext(eServiceReference &ref)
222 {
223         if (m_marked_iterator == m_marked.end())
224                 return -1;
225         ref = *m_marked_iterator++;
226         return 0;
227 }
228
229 int eListboxServiceContent::lookupService(const eServiceReference &ref)
230 {
231                 /* shortcut for cursor */
232         if (ref == *m_cursor)
233                 return m_cursor_number;
234                 /* otherwise, search in the list.. */
235         int index = 0;
236         for (list::const_iterator i(m_list.begin()); i != m_list.end(); ++i, ++index);
237         
238                 /* this is ok even when the index was not found. */
239         return index;
240 }
241
242 void eListboxServiceContent::setVisualMode(int mode)
243 {
244         for (int i=0; i < celElements; ++i)
245         {
246                 m_element_position[i] = eRect();
247                 m_element_font[i] = 0;
248         }
249
250         m_visual_mode = mode;
251
252         if (m_visual_mode == visModeSimple)
253         {
254                 m_element_position[celServiceName] = eRect(ePoint(0, 0), m_itemsize);
255                 m_element_font[celServiceName] = new gFont("Regular", 23);
256         }
257 }
258
259 void eListboxServiceContent::setElementPosition(int element, eRect where)
260 {
261         if ((element >= 0) && (element < celElements))
262                 m_element_position[element] = where;
263 }
264
265 void eListboxServiceContent::setElementFont(int element, gFont *font)
266 {
267         if ((element >= 0) && (element < celElements))
268                 m_element_font[element] = font;
269 }
270
271 void eListboxServiceContent::setPixmap(int type, ePtr<gPixmap> &pic)
272 {
273         if ((type >=0) && (type < picElements))
274                 m_pixmaps[type] = pic;
275 }
276
277 void eListboxServiceContent::sort()
278 {
279         if (!m_lst)
280                 m_service_center->list(m_root, m_lst);
281         if (m_lst)
282         {
283                 m_list.sort(iListableServiceCompare(m_lst));
284                         /* FIXME: is this really required or can we somehow keep the current entry? */
285                 cursorHome();
286                 if (m_listbox)
287                         m_listbox->entryReset();
288         }
289 }
290
291 DEFINE_REF(eListboxServiceContent);
292
293 eListboxServiceContent::eListboxServiceContent()
294         :m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0), m_itemheight(25)
295 {
296         memset(m_color_set, 0, sizeof(m_color_set));
297         cursorHome();
298         eServiceCenter::getInstance(m_service_center);
299 }
300
301 void eListboxServiceContent::setColor(int color, gRGB &col)
302 {
303         if ((color >= 0) && (color < colorElements))
304         {
305                 m_color_set[color] = true;
306                 m_color[color] = col;
307         }
308 }
309
310 void eListboxServiceContent::cursorHome()
311 {
312         if (m_current_marked && m_saved_cursor == m_list.end())
313         {
314                 if (m_cursor_number >= m_size)
315                 {
316                         m_cursor_number = m_size-1;
317                         --m_cursor;
318                 }
319                 while (m_cursor_number)
320                 {
321                         std::iter_swap(m_cursor--, m_cursor);
322                         --m_cursor_number;
323                         if (m_listbox && m_cursor_number)
324                                 m_listbox->entryChanged(m_cursor_number);
325                 }
326         }
327         else
328         {
329                 m_cursor = m_list.begin();
330                 m_cursor_number = 0;
331         }
332 }
333
334 void eListboxServiceContent::cursorEnd()
335 {
336         if (m_current_marked && m_saved_cursor == m_list.end())
337         {
338                 while (m_cursor != m_list.end())
339                 {
340                         list::iterator prev = m_cursor++;
341                         ++m_cursor_number;
342                         if ( prev != m_list.end() && m_cursor != m_list.end() )
343                         {
344                                 std::iter_swap(m_cursor, prev);
345                                 if ( m_listbox )
346                                         m_listbox->entryChanged(m_cursor_number);
347                         }
348                 }
349         }
350         else
351         {
352                 m_cursor = m_list.end();
353                 m_cursor_number = m_size;
354         }
355 }
356
357 int eListboxServiceContent::setCurrentMarked(bool state)
358 {
359         bool prev = m_current_marked;
360         m_current_marked = state;
361
362         if (state != prev && m_listbox)
363         {
364                 m_listbox->entryChanged(m_cursor_number);
365                 if (!state)
366                 {
367                         if (!m_lst)
368                                 m_service_center->list(m_root, m_lst);
369                         if (m_lst)
370                         {
371                                 ePtr<iMutableServiceList> list;
372                                 if (m_lst->startEdit(list))
373                                         eDebug("no editable list");
374                                 else
375                                 {
376                                         eServiceReference ref;
377                                         getCurrent(ref);
378                                         if(!ref)
379                                                 eDebug("no valid service selected");
380                                         else
381                                         {
382                                                 int pos = cursorGet();
383                                                 eDebugNoNewLine("move %s to %d ", ref.toString().c_str(), pos);
384                                                 if (list->moveService(ref, cursorGet()))
385                                                         eDebug("failed");
386                                                 else
387                                                         eDebug("ok");
388                                         }
389                                 }
390                         }
391                         else
392                                 eDebug("no list available!");
393                 }
394         }
395
396         return 0;
397 }
398
399 int eListboxServiceContent::cursorMove(int count)
400 {
401         int prev = m_cursor_number, last = m_cursor_number + count;
402         if (count > 0)
403         {
404                 while(count && m_cursor != m_list.end())
405                 {
406                         list::iterator prev_it = m_cursor++;
407                         if ( m_current_marked && m_cursor != m_list.end() && m_saved_cursor == m_list.end() )
408                         {
409                                 std::iter_swap(prev_it, m_cursor);
410                                 if ( m_listbox && prev != m_cursor_number && last != m_cursor_number )
411                                         m_listbox->entryChanged(m_cursor_number);
412                         }
413                         ++m_cursor_number;
414                         --count;
415         }
416         } else if (count < 0)
417         {
418                 while (count && m_cursor != m_list.begin())
419                 {
420                         list::iterator prev_it = m_cursor--;
421                         if ( m_current_marked && m_cursor != m_list.end() && prev_it != m_list.end() && m_saved_cursor == m_list.end() )
422                         {
423                                 std::iter_swap(prev_it, m_cursor);
424                                 if ( m_listbox && prev != m_cursor_number && last != m_cursor_number )
425                                         m_listbox->entryChanged(m_cursor_number);
426                         }
427                         --m_cursor_number;
428                         ++count;
429                 }
430         }
431         return 0;
432 }
433
434 int eListboxServiceContent::cursorValid()
435 {
436         return m_cursor != m_list.end();
437 }
438
439 int eListboxServiceContent::cursorSet(int n)
440 {
441         cursorHome();
442         cursorMove(n);
443         return 0;
444 }
445
446 int eListboxServiceContent::cursorGet()
447 {
448         return m_cursor_number;
449 }
450
451 void eListboxServiceContent::cursorSave()
452 {
453         m_saved_cursor = m_cursor;
454         m_saved_cursor_number = m_cursor_number;
455 }
456
457 void eListboxServiceContent::cursorRestore()
458 {
459         m_cursor = m_saved_cursor;
460         m_cursor_number = m_saved_cursor_number;
461         m_saved_cursor = m_list.end();
462 }
463
464 int eListboxServiceContent::size()
465 {
466         return m_size;
467 }
468         
469 void eListboxServiceContent::setSize(const eSize &size)
470 {
471         m_itemsize = size;
472         if (m_visual_mode == visModeSimple)
473                 setVisualMode(m_visual_mode);
474 }
475
476 void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
477 {
478         painter.clip(eRect(offset, m_itemsize));
479
480         int marked = 0;
481
482         if (m_current_marked && selected)
483                 marked = 2;
484         else if (cursorValid() && isMarked(*m_cursor))
485         {
486                 if (selected)
487                         marked = 2;
488                 else
489                         marked = 1;
490         }
491         else
492                 style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
493
494         eListboxStyle *local_style = 0;
495
496                 /* get local listbox style, if present */
497         if (m_listbox)
498                 local_style = m_listbox->getLocalStyle();
499
500         if (marked == 1)  // marked
501         {
502                 style.setStyle(painter, eWindowStyle::styleListboxMarked);
503                 if (m_color_set[markedForeground])
504                         painter.setForegroundColor(m_color[markedForeground]);
505                 if (m_color_set[markedBackground])
506                         painter.setBackgroundColor(m_color[markedBackground]);
507         }
508         else if (marked == 2) // marked and selected
509         {
510                 style.setStyle(painter, eWindowStyle::styleListboxMarkedAndSelected);
511                 if (m_color_set[markedForegroundSelected])
512                         painter.setForegroundColor(m_color[markedForegroundSelected]);
513                 if (m_color_set[markedBackgroundSelected])
514                         painter.setBackgroundColor(m_color[markedBackgroundSelected]);
515         }
516         else if (local_style)
517         {
518                 if (selected)
519                 {
520                         /* if we have a local background color set, use that. */
521                         if (local_style->m_background_color_selected_set)
522                                 painter.setBackgroundColor(local_style->m_background_color_selected);
523                         /* same for foreground */
524                         if (local_style->m_foreground_color_selected_set)
525                                 painter.setForegroundColor(local_style->m_foreground_color_selected);
526                 }
527                 else
528                 {
529                         /* if we have a local background color set, use that. */
530                         if (local_style->m_background_color_set)
531                                 painter.setBackgroundColor(local_style->m_background_color);
532                         /* same for foreground */
533                         if (local_style->m_foreground_color_set)
534                                 painter.setForegroundColor(local_style->m_foreground_color);
535                 }
536         }
537
538         if (!local_style || !local_style->m_transparent_background)
539                 /* if we have no transparent background */
540         {
541                 /* blit background picture, if available (otherwise, clear only) */
542                 if (local_style && local_style->m_background)
543                         painter.blit(local_style->m_background, offset, eRect(), 0);
544                 else
545                         painter.clear();
546         } else
547         {
548                 if (local_style->m_background)
549                         painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST);
550                 else if (selected && !local_style->m_selection)
551                         painter.clear();
552         }
553
554         if (cursorValid())
555         {
556                         /* get service information */
557                 ePtr<iStaticServiceInformation> service_info;
558                 m_service_center->info(*m_cursor, service_info);
559                 eServiceReference ref = *m_cursor;
560                 bool isMarker = ref.flags & eServiceReference::isMarker;
561                 bool isPlayable = !(ref.flags & eServiceReference::isDirectory || isMarker);
562                 bool paintProgress = false;
563                 ePtr<eServiceEvent> evt;
564
565                 bool serviceAvail = true;
566
567                 if (!marked && isPlayable && service_info && m_is_playable_ignore.valid() && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
568                 {
569                         if (m_color_set[serviceNotAvail])
570                                 painter.setForegroundColor(m_color[serviceNotAvail]);
571                         else
572                                 painter.setForegroundColor(gRGB(0xbbbbbb));
573                         serviceAvail = false;
574                 }
575
576                 if (selected && local_style && local_style->m_selection)
577                         painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);
578
579                 int xoffset=0;  // used as offset when painting the folder/marker symbol or the serviceevent progress
580
581                 for (int e = 0; e < celElements; ++e)
582                 {
583                         if (m_element_font[e])
584                         {
585                                 int flags=gPainter::RT_VALIGN_CENTER,
586                                         yoffs = 0,
587                                         xoffs = xoffset;
588                                 eRect &area = m_element_position[e];
589                                 std::string text = "<n/a>";
590                                 xoffset=0;
591
592                                 switch (e)
593                                 {
594                                 case celServiceNumber:
595                                 {
596                                         if (m_cursor->flags & eServiceReference::isMarker)
597                                                 continue;
598                                         char bla[10];
599                                 /* how we can do this better? :) */
600                                         int markers_before=0;
601                                         {
602                                                 list::iterator tmp=m_cursor;
603                                                 while(tmp != m_list.begin())
604                                                 {
605                                                         --tmp;
606                                                         if (tmp->flags & eServiceReference::isMarker)
607                                                                 ++markers_before;
608                                                 }
609                                         }
610                                         sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1 - markers_before);
611                                         text = bla;
612                                         flags|=gPainter::RT_HALIGN_RIGHT;
613                                         break;
614                                 }
615                                 case celServiceName:
616                                 {
617                                         if (service_info)
618                                                 service_info->getName(*m_cursor, text);
619                                         break;
620                                 }
621                                 case celServiceInfo:
622                                 {
623                                         if ( isPlayable && !service_info->getEvent(*m_cursor, evt) )
624                                         {
625                                                 std::string name = evt->getEventName();
626                                                 if (!name.length())
627                                                         continue;
628                                                 text = '(' + evt->getEventName() + ')';
629                                                 if (serviceAvail)
630                                                 {
631                                                         if (!selected && m_color_set[serviceDescriptionColor])
632                                                                 painter.setForegroundColor(m_color[serviceDescriptionColor]);
633                                                         else if (selected && m_color_set[serviceDescriptionColorSelected])
634                                                                 painter.setForegroundColor(m_color[serviceDescriptionColorSelected]);
635                                                 }
636                                         }
637                                         else
638                                                 continue;
639                                         break;
640                                 }
641                                 }
642
643                                 eRect tmp = area;
644                                 tmp.setWidth(tmp.width()-xoffs);
645
646                                 eTextPara *para = new eTextPara(tmp);
647                                 para->setFont(m_element_font[e]);
648                                 para->renderString(text.c_str());
649
650                                 if (e == celServiceName)
651                                 {
652                                         eRect bbox = para->getBoundBox();
653                                         int name_width = bbox.width()+8;
654                                         m_element_position[celServiceInfo].setLeft(area.left()+name_width+xoffs);
655                                         m_element_position[celServiceInfo].setTop(area.top());
656                                         m_element_position[celServiceInfo].setWidth(area.width()-(name_width+xoffs));
657                                         m_element_position[celServiceInfo].setHeight(area.height());
658                                 }
659
660                                 if (flags & gPainter::RT_HALIGN_RIGHT)
661                                         para->realign(eTextPara::dirRight);
662                                 else if (flags & gPainter::RT_HALIGN_CENTER)
663                                         para->realign(eTextPara::dirCenter);
664                                 else if (flags & gPainter::RT_HALIGN_BLOCK)
665                                         para->realign(eTextPara::dirBlock);
666
667                                 if (flags & gPainter::RT_VALIGN_CENTER)
668                                 {
669                                         eRect bbox = para->getBoundBox();
670                                         int vcentered_top = (area.height() - bbox.height()) / 2;
671                                         yoffs = vcentered_top - bbox.top();
672                                 }
673
674                                 painter.renderPara(para, offset+ePoint(xoffs, yoffs));
675                         }
676                         else if (e == celServiceTypePixmap || e == celFolderPixmap || e == celMarkerPixmap)
677                         {
678                                 int orbpos = m_cursor->getUnsignedData(4) >> 16;
679                                 ePtr<gPixmap> &pixmap =
680                                         (e == celFolderPixmap) ? m_pixmaps[picFolder] :
681                                         (e == celMarkerPixmap) ? m_pixmaps[picMarker] :
682                                         (m_cursor->flags & eServiceReference::isGroup) ? m_pixmaps[picServiceGroup] :
683                                         (orbpos == 0xFFFF) ? m_pixmaps[picDVB_C] :
684                                         (orbpos == 0xEEEE) ? m_pixmaps[picDVB_T] : m_pixmaps[picDVB_S];
685                                 if (pixmap)
686                                 {
687                                         eSize pixmap_size = pixmap->size();
688                                         int p = celServiceInfo;
689                                         if (e == celFolderPixmap)
690                                                 p = celServiceName;
691                                         else if (e == celMarkerPixmap)
692                                                 p = celServiceNumber;
693                                         eRect area = m_element_position[p];
694                                         int correction = (area.height() - pixmap_size.height()) / 2;
695
696                                         if (isPlayable)
697                                         {
698                                                 if (e != celServiceTypePixmap)
699                                                         continue;
700                                                 m_element_position[celServiceInfo] = area;
701                                                 m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + 8);
702                                                 m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - 8);
703                                         }
704                                         else if (m_cursor->flags & eServiceReference::isDirectory)
705                                         {
706                                                 if (e != celFolderPixmap)
707                                                         continue;
708                                                 xoffset = pixmap_size.width() + 8;
709                                         }
710                                         else if (m_cursor->flags & eServiceReference::isMarker)
711                                         {
712                                                 if (e != celMarkerPixmap)
713                                                         continue;
714                                         }
715                                         else
716                                                 eFatal("unknown service type in listboxservice");
717
718                                         area.moveBy(offset);
719                                         painter.clip(area);
720                                         painter.blit(pixmap, offset+ePoint(area.left(), correction), area, gPainter::BT_ALPHATEST);
721                                         painter.clippop();
722                                 }
723                         }
724                         else if (e == celServiceEventProgressbar)
725                         {
726                                 eRect area = m_element_position[celServiceEventProgressbar];
727                                 if (area.width() > 0 && (isPlayable || isMarker))
728                                 {
729                                         // we schedule it to paint it as last element.. so we dont need to reset fore/background color
730                                         paintProgress = isPlayable;
731                                         xoffset = area.width() + 10;
732                                 }
733                         }
734                 }
735                 if (selected && (!local_style || !local_style->m_selection))
736                         style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
737                 if (paintProgress && evt)
738                 {
739                         eRect area = m_element_position[celServiceEventProgressbar];
740                         if (!selected && m_color_set[serviceEventProgressbarBorderColor])
741                                 painter.setForegroundColor(m_color[serviceEventProgressbarBorderColor]);
742                         else if (selected && m_color_set[serviceEventProgressbarBorderColorSelected])
743                                 painter.setForegroundColor(m_color[serviceEventProgressbarBorderColorSelected]);
744
745                         int border = 1;
746                         int progressH = 6;
747                         int progressX = area.left() + offset.x();
748                         int progressW = area.width() - 2 * border;
749                         int progressT = offset.y() + (m_itemsize.height() - progressH - 2*border) / 2;
750
751                         // paint progressbar frame
752                         painter.fill(eRect(progressX, progressT, area.width(), border));
753                         painter.fill(eRect(progressX, progressT + border, border, progressH));
754                         painter.fill(eRect(progressX, progressT + progressH + border, area.width(), border));
755                         painter.fill(eRect(progressX + area.width() - border, progressT + border, border, progressH));
756
757                         // calculate value
758                         time_t now = time(0);
759                         int value = progressW * (now - evt->getBeginTime()) / evt->getDuration();
760
761                         eRect tmp = eRect(progressX + border, progressT + border, value, progressH);
762                         ePtr<gPixmap> &pixmap = m_pixmaps[picServiceEventProgressbar];
763                         if (pixmap)
764                         {
765                                 area.moveBy(offset);
766                                 painter.clip(area);
767                                 painter.blit(pixmap, ePoint(progressX + border, progressT + border), tmp, gPainter::BT_ALPHATEST);
768                                 painter.clippop();
769                         }
770                         else
771                         {
772                                 if (!selected && m_color_set[serviceEventProgressbarColor])
773                                         painter.setForegroundColor(m_color[serviceEventProgressbarColor]);
774                                 else if (selected && m_color_set[serviceEventProgressbarColorSelected])
775                                         painter.setForegroundColor(m_color[serviceEventProgressbarColorSelected]);
776                                 painter.fill(tmp);
777                         }
778                 }
779         }
780         painter.clippop();
781 }
782
783 void eListboxServiceContent::setIgnoreService( const eServiceReference &service )
784 {
785         m_is_playable_ignore=service;
786         if (m_listbox && m_listbox->isVisible())
787                 m_listbox->invalidate();
788 }
789
790 void eListboxServiceContent::setItemHeight(int height)
791 {
792         m_itemheight = height;
793         if (m_listbox)
794                 m_listbox->setItemHeight(height);
795 }