servicem2ts.cpp: resync on corrupt data
[enigma2.git] / lib / service / listboxservice.cpp
index 9de88c145258ea4e9565c7f02c31e0be628c34fc..cc8c32b50e64c6123fd4f58761f0f6eea059b9e9 100644 (file)
@@ -528,14 +528,18 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                eServiceReference ref = *m_cursor;
                bool isMarker = ref.flags & eServiceReference::isMarker;
                bool isPlayable = !(ref.flags & eServiceReference::isDirectory || isMarker);
+               bool paintProgress = false;
                ePtr<eServiceEvent> evt;
 
+               bool serviceAvail = true;
+
                if (!marked && isPlayable && service_info && m_is_playable_ignore.valid() && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
                {
                        if (m_color_set[serviceNotAvail])
                                painter.setForegroundColor(m_color[serviceNotAvail]);
                        else
                                painter.setForegroundColor(gRGB(0xbbbbbb));
+                       serviceAvail = false;
                }
 
                if (selected && local_style && local_style->m_selection)
@@ -585,12 +589,19 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                                }
                                case celServiceInfo:
                                {
-                                       if ( isPlayable && (evt || !service_info->getEvent(*m_cursor, evt)) )
+                                       if ( isPlayable && !service_info->getEvent(*m_cursor, evt) )
                                        {
                                                std::string name = evt->getEventName();
                                                if (!name.length())
                                                        continue;
                                                text = '(' + evt->getEventName() + ')';
+                                               if (serviceAvail)
+                                               {
+                                                       if (!selected && m_color_set[serviceDescriptionColor])
+                                                               painter.setForegroundColor(m_color[serviceDescriptionColor]);
+                                                       else if (selected && m_color_set[serviceDescriptionColorSelected])
+                                                               painter.setForegroundColor(m_color[serviceDescriptionColorSelected]);
+                                               }
                                        }
                                        else
                                                continue;
@@ -681,59 +692,60 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                        }
                        else if (e == celServiceEventProgressbar)
                        {
-                               int p = celServiceEventProgressbar;
-                               eRect area = m_element_position[p];
+                               eRect area = m_element_position[celServiceEventProgressbar];
                                if (area.width() > 0 && (isPlayable || isMarker))
                                {
-                                       if ( isPlayable && service_info && !service_info->getEvent(*m_cursor, evt) )
-                                       {
-                                               if (!selected && m_color_set[serviceEventProgressbarBorderColor])
-                                                       painter.setForegroundColor(m_color[serviceEventProgressbarBorderColor]);
-                                               else if (selected && m_color_set[serviceEventProgressbarBorderColorSelected])
-                                                       painter.setForegroundColor(m_color[serviceEventProgressbarBorderColorSelected]);
-
-                                               int border = 1;
-                                               int progressH = 6;
-                                               int progressX = area.left() + offset.x();
-                                               int progressW = area.width() - 2 * border;
-                                               int progressT = offset.y() + (m_itemsize.height() - progressH - 2*border) / 2;
-
-                                               // paint progressbar frame
-                                               painter.fill(eRect(progressX, progressT, area.width(), border));
-                                               painter.fill(eRect(progressX, progressT + border, border, progressH));
-                                               painter.fill(eRect(progressX, progressT + progressH + border, area.width(), border));
-                                               painter.fill(eRect(progressX + area.width() - border, progressT + border, border, progressH));
-
-                                               // calculate value
-                                               time_t now = time(0);
-                                               int value = progressW * (now - evt->getBeginTime()) / evt->getDuration();
-
-                                               eRect tmp = eRect(progressX + border, progressT + border, value, progressH);
-                                               ePtr<gPixmap> &pixmap = m_pixmaps[picServiceEventProgressbar];
-                                               if (pixmap)
-                                               {
-                                                       area.moveBy(offset);
-                                                       painter.clip(area);
-                                                       painter.blit(pixmap, ePoint(progressX + border, progressT + border), tmp, gPainter::BT_ALPHATEST);
-                                                       painter.clippop();
-                                               }
-                                               else
-                                               {
-                                                       if (!selected && m_color_set[serviceEventProgressbarColor])
-                                                               painter.setForegroundColor(m_color[serviceEventProgressbarColor]);
-                                                       else if (selected && m_color_set[serviceEventProgressbarColorSelected])
-                                                               painter.setForegroundColor(m_color[serviceEventProgressbarColorSelected]);
-                                                       painter.fill(tmp);
-                                               }
-                                       }
+                                       // we schedule it to paint it as last element.. so we dont need to reset fore/background color
+                                       paintProgress = isPlayable;
                                        xoffset = area.width() + 10;
                                }
                        }
                }
                if (selected && (!local_style || !local_style->m_selection))
                        style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
+               if (paintProgress && evt)
+               {
+                       eRect area = m_element_position[celServiceEventProgressbar];
+                       if (!selected && m_color_set[serviceEventProgressbarBorderColor])
+                               painter.setForegroundColor(m_color[serviceEventProgressbarBorderColor]);
+                       else if (selected && m_color_set[serviceEventProgressbarBorderColorSelected])
+                               painter.setForegroundColor(m_color[serviceEventProgressbarBorderColorSelected]);
+
+                       int border = 1;
+                       int progressH = 6;
+                       int progressX = area.left() + offset.x();
+                       int progressW = area.width() - 2 * border;
+                       int progressT = offset.y() + (m_itemsize.height() - progressH - 2*border) / 2;
+
+                       // paint progressbar frame
+                       painter.fill(eRect(progressX, progressT, area.width(), border));
+                       painter.fill(eRect(progressX, progressT + border, border, progressH));
+                       painter.fill(eRect(progressX, progressT + progressH + border, area.width(), border));
+                       painter.fill(eRect(progressX + area.width() - border, progressT + border, border, progressH));
+
+                       // calculate value
+                       time_t now = time(0);
+                       int value = progressW * (now - evt->getBeginTime()) / evt->getDuration();
+
+                       eRect tmp = eRect(progressX + border, progressT + border, value, progressH);
+                       ePtr<gPixmap> &pixmap = m_pixmaps[picServiceEventProgressbar];
+                       if (pixmap)
+                       {
+                               area.moveBy(offset);
+                               painter.clip(area);
+                               painter.blit(pixmap, ePoint(progressX + border, progressT + border), tmp, gPainter::BT_ALPHATEST);
+                               painter.clippop();
+                       }
+                       else
+                       {
+                               if (!selected && m_color_set[serviceEventProgressbarColor])
+                                       painter.setForegroundColor(m_color[serviceEventProgressbarColor]);
+                               else if (selected && m_color_set[serviceEventProgressbarColorSelected])
+                                       painter.setForegroundColor(m_color[serviceEventProgressbarColorSelected]);
+                               painter.fill(tmp);
+                       }
+               }
        }
-       
        painter.clippop();
 }