diff --git a/PlaylistList.cpp b/PlaylistList.cpp index a4de1dc..56ac41c 100644 --- a/PlaylistList.cpp +++ b/PlaylistList.cpp @@ -17,6 +17,15 @@ PlaylistItem::PlaylistItem (PlaylistList *pl, uint id) pl->addItem (this); } +PlaylistItem::PlaylistItem (PlaylistList *pl, uint id, uint pos) +{ + m_pl = pl; + m_id = id; + m_req = false; + m_duration = QString ("00:00"); + pl->addItem (this, pos); +} + QString PlaylistItem::text (void) { @@ -119,6 +128,17 @@ PlaylistList::playlistChanged (const QHash &h) } break; case XMMS_PLAYLIST_CHANGED_INSERT: + { + uint id = h.value("id").toUInt (); + uint pos = h.value("position").toUInt (); + + if (m_itemmap->contains (id)) { + addItem (m_itemmap->value (id)); + } else { + new PlaylistItem (this, id, pos); + } + + } break; case XMMS_PLAYLIST_CHANGED_REMOVE: { @@ -635,6 +655,16 @@ PlaylistList::doResize (void) emit sizeChanged (size()); } +void +PlaylistList::addItem (PlaylistItem *i, uint pos) +{ + m_items->insert (pos, i); + if (!m_itemmap->contains (i->getID())) { + m_itemmap->insert (i->getID(), i); + } + doResize (); +} + void PlaylistList::addItem (PlaylistItem *i) { diff --git a/PlaylistList.h b/PlaylistList.h index e078ad3..9fe2fa0 100644 --- a/PlaylistList.h +++ b/PlaylistList.h @@ -18,6 +18,7 @@ class PlaylistList : public QWidget { void setSize (int, int); void addItem (PlaylistItem *i); + void addItem (PlaylistItem *i, uint pos); void setOffset (int i) { m_offset = i; } uint getOffset (void) const { return m_offset; } void doResize (void); @@ -74,6 +75,7 @@ class PlaylistList : public QWidget { class PlaylistItem { public: + PlaylistItem (PlaylistList *pl, uint, uint); PlaylistItem (PlaylistList *pl, uint); ~PlaylistItem () {}