diff --git a/PlaylistList.cpp b/PlaylistList.cpp index 2323d12..fa8f294 100644 --- a/PlaylistList.cpp +++ b/PlaylistList.cpp @@ -143,6 +143,8 @@ PlaylistList::playlistChanged (QHash h) } } + doResize (); + } break; case XMMS_PLAYLIST_CHANGED_MOVE: @@ -151,12 +153,18 @@ PlaylistList::playlistChanged (QHash h) case XMMS_PLAYLIST_CHANGED_SHUFFLE: case XMMS_PLAYLIST_CHANGED_SORT: { + while (!m_items->isEmpty()) { + PlaylistItem *item = m_items->takeFirst(); + m_items->removeAll (item); + delete item; + } + m_itemmap->clear (); - while (!m_items->isEmpty()) - delete m_items->takeFirst(); if (signal != XMMS_PLAYLIST_CHANGED_CLEAR) { xmmsh->requestPlaylistList (); + } else { + doResize (); } } break; @@ -597,6 +605,21 @@ PlaylistList::paintEvent (QPaintEvent *event) } +void +PlaylistList::doResize (void) +{ + QWidget *w = dynamic_cast(parent()); + QSize s = w->size (); + + if (m_items->count()*getFontH () > s.height ()) { + resize (size().width(), m_items->count ()*getFontH ()); + } else { + resize (size().width(), s.height()); + setOffset (0); + } + emit sizeChanged (size()); +} + void PlaylistList::addItem (PlaylistItem *i) { @@ -604,10 +627,7 @@ PlaylistList::addItem (PlaylistItem *i) if (!m_itemmap->contains (i->getID())) { m_itemmap->insert (i->getID(), i); } - if (m_items->count()*getFontH () > size().height()) { - resize (size().width(), m_items->count ()*getFontH ()); - emit sizeChanged (size()); - } + doResize (); } int diff --git a/PlaylistList.h b/PlaylistList.h index 78b0992..eff7e09 100644 --- a/PlaylistList.h +++ b/PlaylistList.h @@ -20,6 +20,7 @@ class PlaylistList : public QWidget { void addItem (PlaylistItem *i); void setOffset (int i) { m_offset = i; } uint getOffset (void) const { return m_offset; } + void doResize (void); public slots: void setPixmaps (Skin *skin); diff --git a/TODO b/TODO index c59a4f2..d0fd52d 100644 --- a/TODO +++ b/TODO @@ -10,9 +10,7 @@ Todo: * CloseButton * ShadeButton * Add files / folders - * Redo paintEvent in PlaylistWindow class to not be slow. * Jump entry to dialog - * Reposition sliderbar on resize * move viewport when walking outside it with keyboard * drag and drop outside viewport * jump to entry when it's played.