Insert works.

This commit is contained in:
Tobias Rundstrom 2006-03-13 21:12:39 -04:00
parent 429cf316ed
commit d7eede1737
2 changed files with 32 additions and 0 deletions

View file

@ -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<QString,QString> &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)
{

View file

@ -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 () {}