Bug 72298 - repaint errors in collection list
Summary: repaint errors in collection list
Status: RESOLVED FIXED
Alias: None
Product: juk
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR grave
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-10 12:21 UTC by gregormueckl
Modified: 2004-01-12 01:46 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
screenshot of redraw errors (26.10 KB, image/png)
2004-01-10 12:23 UTC, gregormueckl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gregormueckl 2004-01-10 12:21:14 UTC
Version:           1.96 (2.0 Beta 2) (using KDE 3.1.94 (3.2 Beta 2), Gentoo)
Compiler:          gcc version 3.3.2 20031201 (Gentoo Linux 3.3.2-r4, propolice)
OS:          Linux (i686) release 2.6.0-test9

On my system the collection list isn't redrawn properly. The first column is almost non-existent and may contain seemingly random contents (see screenshot).

The playlist views work. I have no idea about what could be going on. I'll append a screenshot with the next comment to this bug. Unfortunately, this won't work with the initial report.
Comment 1 gregormueckl 2004-01-10 12:23:22 UTC
Created attachment 4076 [details]
screenshot of redraw errors

This is the screenshot I mentioned in the initial report.
Comment 2 Scott Wheeler 2004-01-10 17:58:23 UTC
Yes, I've been aware of this for a while -- there are a couple of cases where it happens, most notably when importing items for the first time.  This is one that I consider a show stopper (since it has the possibility of making a really bad first impression) and I'll get it fixed before 3.2.
Comment 3 Stephan Kulow 2004-01-11 14:14:43 UTC
sorry to spoil your fun, but the release won't be delayed for that. If you fix it, fine though
Comment 4 Scott Wheeler 2004-01-12 01:46:25 UTC
Subject: kdemultimedia/juk

CVS commit by wheeler: 

Add a helper class that rations out paint events when needed (in an
effecient manner too).  This speeds up importing and also makes it not so
dang broken looking.

CCMAIL:72298-done@bugs.kde.org


  M +66 -0     playlistsplitter.cpp   1.146


--- kdemultimedia/juk/playlistsplitter.cpp  #1.145:1.146
@@ -47,4 +47,67 @@ void processEvents()
 
 ////////////////////////////////////////////////////////////////////////////////
+// helper class
+////////////////////////////////////////////////////////////////////////////////
+
+// Painting is slow, so we want to be able to ignore the fact that QListView
+// likes to do it so much.  Specifically while loading -- when without a bit of
+// hackery it takes more time to paint the new items than it does to read them.
+// This helper class operates on a Playlist while loading items and throws out
+// most of the repaint events that are issued.
+
+class PaintEater : public QObject
+{
+public:
+    PaintEater(Playlist *list) : QObject(list), m_list(list),
+                                 m_allowOne(false), m_previousHeight(0)
+    {
+        // We want to catch paint events for both the contents and the frame of
+        // our listview.
+
+        list->installEventFilter(this);
+        list->viewport()->installEventFilter(this);
+    }
+
+private:
+    virtual bool eventFilter(QObject *o, QEvent *e)
+    {
+        if(e->type() == QEvent::Paint) {
+
+            // There are two cases where we want to let our viewport repaint
+            // itself -- if the actual contents have changed as indicated by
+            // m_allowOne being true, or if the height has changed indicating
+            // that we've either scrolled or resized the widget.
+
+            if(o == m_list->viewport()) {
+                if(m_allowOne) {
+                    m_allowOne = false;
+                    return false;
+                }
+
+                int newHeight = static_cast<QPaintEvent *>(e)->rect().top();
+
+                if(m_previousHeight != newHeight) {
+                    m_previousHeight = newHeight;
+                    return false;
+                }
+            }
+            else
+                m_allowOne = true;
+
+            if(m_list->count() < 20)
+                m_list->slotWeightDirty();
+
+            return true;
+        }
+
+        return false;
+    }
+
+    Playlist *m_list;
+    bool m_allowOne;
+    int m_previousHeight;
+};
+
+////////////////////////////////////////////////////////////////////////////////
 // public methods
 ////////////////////////////////////////////////////////////////////////////////
@@ -363,4 +426,5 @@ void PlaylistSplitter::slotAddToPlaylist
 
     KApplication::setOverrideCursor(Qt::waitCursor);
+    PaintEater pe(list);
     addImpl(file, list, after);
     list->slotWeightDirty();
@@ -387,4 +451,6 @@ void PlaylistSplitter::slotAddToPlaylist
     KApplication::setOverrideCursor(Qt::waitCursor);
 
+    PaintEater pe(list);
+
     for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
         after = addImpl(*it, list, after);