add movemode in channellist (later it should only useable in bouquets)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 15 Oct 2005 15:40:50 +0000 (15:40 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 15 Oct 2005 15:40:50 +0000 (15:40 +0000)
lib/python/Components/ServiceList.py
lib/python/Screens/ChannelSelection.py
lib/service/listboxservice.cpp
lib/service/listboxservice.h

index 93c79296203134cfea0b69c17fe971e8930e407a..0f71c44aaa7ca71fc74e5e82f3692b88ceadd293 100644 (file)
@@ -61,6 +61,9 @@ class ServiceList(HTMLComponent, GUIComponent):
 
                return marked
 
+       def setCurrentMarked(self, state):
+               self.l.setCurrentMarked(state)
+
        def setMode(self, mode):
                if mode == self.MODE_NORMAL:
                        self.instance.setItemHeight(20)
index 5e35a7e1b6fbd02f7043dff26f04aaaf59800d91..8b9f9b8caa6b4eea513fc131ddbe1770d9588d6a 100644 (file)
@@ -49,6 +49,7 @@ class ChannelSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
                
+               self.entry_marked = False
                self.movemode = False
                self.bouquet_mark_edit = False
                
@@ -121,9 +122,17 @@ class ChannelSelection(Screen):
        
        # ...
        def channelSelected(self):
-               self.session.nav.playService(self["list"].getCurrent())
-               print "current: " + self["list"].getCurrent().toString()
-               self.close()
+               if not (self.movemode):
+                       self.session.nav.playService(self["list"].getCurrent())
+                       print "current: " + self["list"].getCurrent().toString()
+                       self.close()
+               else:
+                       if self.entry_marked:
+                               self["list"].setCurrentMarked(False)
+                               self.entry_marked = False
+                       else:
+                               self["list"].setCurrentMarked(True)
+                               self.entry_marked = True
 
        #called from infoBar
        def zap(self):
@@ -139,7 +148,10 @@ class ChannelSelection(Screen):
                self.session.open(ChannelContextMenu, self)
 
        def setMoveMode(self, mode):
-               self.movemode = mode
+               if mode:
+                       self.movemode = False
+               else:
+                       self.movemode = True
        
        def showFavourites(self):
                l = self["list" ]
index d4cbff208a0da0f1f8077a9762156710d58dcb2a..f35c00a584e1d397e7ba4fe3fc951e40f0e1fba2 100644 (file)
@@ -124,30 +124,49 @@ void eListboxServiceContent::sort()
 DEFINE_REF(eListboxServiceContent);
 
 eListboxServiceContent::eListboxServiceContent()
+       :m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_swap(m_list.end())
 {
-       m_visual_mode = visModeSimple;
-       m_size = 0;
        cursorHome();
        eServiceCenter::getInstance(m_service_center);
 }
 
 void eListboxServiceContent::cursorHome()
 {
+       list::iterator old = m_cursor;
+
        m_cursor = m_list.begin();
        m_cursor_number = 0;
+
+       if ( m_current_marked && m_saved_cursor == m_list.end() )
+               std::iter_swap( old, m_cursor );
 }
 
 void eListboxServiceContent::cursorEnd()
 {
+       if ( m_current_marked && m_saved_cursor == m_list.end() && m_cursor != m_list.end() )
+               m_swap = m_cursor;
        m_cursor = m_list.end();
        m_cursor_number = m_size;
 }
 
+int eListboxServiceContent::setCurrentMarked(bool state)
+{
+       bool prev = m_current_marked;
+       m_current_marked = state;
+
+       if (state != prev && m_listbox)
+               m_listbox->entryChanged(m_cursor_number);
+
+       return 0;
+}
+
 int eListboxServiceContent::cursorMove(int count)
 {
+       list::iterator old = m_cursor;
+
        if (count > 0)
        {
-               while (count && (m_cursor != m_list.end()))
+               while(count && (m_cursor != m_list.end()))
                {
                        ++m_cursor;
                        ++m_cursor_number;
@@ -162,7 +181,20 @@ int eListboxServiceContent::cursorMove(int count)
                        ++count;
                }
        }
-       
+
+       if ( m_current_marked && m_saved_cursor == m_list.end() )
+       {
+               if ( m_cursor == m_list.end() )
+                       m_swap = old;
+               else if ( old == m_list.end() )
+               {
+                       std::iter_swap( m_swap, m_cursor );
+                       m_swap = m_list.end();
+               }
+               else
+                       std::iter_swap( old, m_cursor );
+       }
+
        return 0;
 }
 
@@ -194,6 +226,7 @@ void eListboxServiceContent::cursorRestore()
 {
        m_cursor = m_saved_cursor;
        m_cursor_number = m_saved_cursor_number;
+       m_saved_cursor = m_list.end();
 }
 
 int eListboxServiceContent::size()
@@ -210,7 +243,10 @@ void eListboxServiceContent::setSize(const eSize &size)
 void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
 {
        painter.clip(eRect(offset, m_itemsize));
-       if (cursorValid() && isMarked(*m_cursor))
+
+       if (m_current_marked && selected)
+               style.setStyle(painter, eWindowStyle::styleListboxMarked);
+       else if (cursorValid() && isMarked(*m_cursor))
                style.setStyle(painter, eWindowStyle::styleListboxMarked);
        else
                style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
index 4e5a8dd57ac4e381cb6371222003ad07ed2d9abe..b2fc311b7bd5fcfb4729da8b2e339f3ea6f0618b 100644 (file)
@@ -47,6 +47,8 @@ public:
        
        void sort();
        
+       int setCurrentMarked(bool);
+       
 protected:
        void cursorHome();
        void cursorEnd();
@@ -82,11 +84,15 @@ private:
        ePtr<iServiceHandler> m_service_center;
        
        eServiceReference m_root;
-       
+
                /* support for marked services */
        std::set<eServiceReference> m_marked;
        
        std::set<eServiceReference>::const_iterator m_marked_iterator;
+
+               /* support for movemode */
+       bool m_current_marked;
+       list::iterator m_swap;
 };
 
 #endif