Summary: | repaint errors in collection list | ||
---|---|---|---|
Product: | [Applications] juk | Reporter: | gregormueckl |
Component: | general | Assignee: | Scott Wheeler <wheeler> |
Status: | RESOLVED FIXED | ||
Severity: | grave | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | screenshot of redraw errors |
Description
gregormueckl
2004-01-10 12:21:14 UTC
Created attachment 4076 [details]
screenshot of redraw errors
This is the screenshot I mentioned in the initial report.
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. sorry to spoil your fun, but the release won't be delayed for that. If you fix it, fine though 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); |