update scrollbar in timerlist when a entry is removed
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 19 Nov 2007 23:58:58 +0000 (23:58 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 19 Nov 2007 23:58:58 +0000 (23:58 +0000)
lib/gui/elistbox.cpp
lib/gui/elistboxcontent.cpp
lib/gui/elistboxcontent.h
lib/python/Components/TimerList.py
lib/python/Screens/TimerEdit.py

index 383ac42..73fbff3 100644 (file)
@@ -432,7 +432,10 @@ void eListbox::entryRemoved(int index)
        if (index == m_selected && m_content)
                m_selected = m_content->cursorGet();
 
-       moveSelection(justCheck);
+       if (m_content && m_content->cursorGet() >= m_content->size())
+               moveSelection(moveUp);
+       else
+               moveSelection(justCheck);
 
        if ((m_top <= index) && (index < (m_top + m_items_per_page)))
        {
index fd7341a..191bc7e 100644 (file)
@@ -262,7 +262,8 @@ void eListboxPythonStringContent::invalidate()
                int s = size();
                if ( m_cursor >= s )
                        m_listbox->moveSelectionTo(s?s-1:0);
-               m_listbox->invalidate();
+               else
+                       m_listbox->invalidate();
        }
 }
 
@@ -1021,3 +1022,9 @@ void eListboxPythonMultiContent::updateClip(gRegion &clip)
        else
                m_old_clip = m_clip = gRegion::invalidRegion();
 }
+
+void eListboxPythonMultiContent::entryRemoved(int idx)
+{
+       if (m_listbox)
+               m_listbox->entryRemoved(idx);
+}
index 118ed30..277899e 100644 (file)
@@ -78,6 +78,7 @@ public:
        void setItemHeight(int height);
        void setSelectionClip(eRect &rect, bool update=false);
        void updateClip(gRegion &);
+       void entryRemoved(int idx);
 private:
        std::map<int, ePtr<gFont> > m_font;
 };
index d3c20ec..b1d9ba0 100644 (file)
@@ -98,3 +98,7 @@ class TimerList(HTMLComponent, GUIComponent, object):
 
        def invalidate(self):
                self.l.invalidate()
+
+       def entryRemoved(self, idx):
+               self.l.entryRemoved(idx)
+
index 8d8d9ac..5a7109f 100644 (file)
@@ -148,8 +148,15 @@ class TimerEditList(Screen):
                        self.refill()
        
        def refill(self):
+               oldsize = len(self.list)
                self.fillTimerList()
-               self["timerlist"].invalidate()
+               lst = self["timerlist"]
+               newsize = len(self.list)
+               if oldsize and oldsize != newsize:
+                       idx = lst.getCurrentIndex()
+                       lst.entryRemoved(idx)
+               else:
+                       lst.invalidate()
        
        def addCurrentTimer(self):
                event = None