Playlist now listen to updates.
This commit is contained in:
parent
3326962123
commit
561987527f
4 changed files with 109 additions and 3 deletions
|
@ -56,6 +56,50 @@ PlaylistList::PlaylistList (QWidget *parent) : QWidget (parent)
|
|||
connect (xmmsh, SIGNAL(currentID(uint)), this, SLOT(currentID(uint)));
|
||||
connect (xmmsh, SIGNAL(mediainfoChanged(uint, QHash<QString, QString>)),
|
||||
this, SLOT(mediainfoChanged(uint, QHash<QString, QString>)));
|
||||
connect (xmmsh, SIGNAL(playlistChanged(QHash<QString, QString>)),
|
||||
this, SLOT(playlistChanged(QHash<QString, QString>)));
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::playlistChanged (QHash<QString,QString> h)
|
||||
{
|
||||
int signal = h.value("type").toUInt();
|
||||
XMMSHandler *xmmsh = XMMSHandler::getInstance ();
|
||||
switch (signal) {
|
||||
case XMMS_PLAYLIST_CHANGED_ADD:
|
||||
new PlaylistItem (this, h.value("id").toUInt());
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_INSERT:
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_REMOVE:
|
||||
{
|
||||
int pos = h.value("position").toUInt();
|
||||
PlaylistItem *i = m_items->value (pos);
|
||||
if (!i) {
|
||||
qDebug ("no item in playlist?");
|
||||
return;
|
||||
}
|
||||
m_items->removeAt (pos);
|
||||
m_itemmap->remove (i->getID ());
|
||||
delete i;
|
||||
}
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_MOVE:
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_CLEAR:
|
||||
case XMMS_PLAYLIST_CHANGED_SHUFFLE:
|
||||
case XMMS_PLAYLIST_CHANGED_SORT:
|
||||
{
|
||||
m_itemmap->clear ();
|
||||
while (!m_items->isEmpty())
|
||||
delete m_items->takeFirst();
|
||||
|
||||
xmmsh->requestPlaylistList ();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -22,6 +22,7 @@ class PlaylistList : public QWidget {
|
|||
void setPixmaps (Skin *skin);
|
||||
void playlistList (QList<uint>);
|
||||
void mediainfoChanged (uint, QHash<QString,QString>);
|
||||
void playlistChanged (QHash<QString,QString>);
|
||||
void currentID (uint);
|
||||
|
||||
private:
|
||||
|
|
|
@ -32,6 +32,9 @@ XMMSHandler::XMMSHandler (void) : sigc::trackable ()
|
|||
XMMSResultValueList<uint> *l = m_xmmsc->playlist_list ();
|
||||
l->connect (sigc::mem_fun (this, &XMMSHandler::playlist_list));
|
||||
|
||||
XMMSResultDict *p = m_xmmsc->broadcast_playlist_changed ();
|
||||
p->connect (sigc::mem_fun (this, &XMMSHandler::playlist_changed));
|
||||
|
||||
XMMSResultValue<uint> *r = m_xmmsc->signal_playback_playtime ();
|
||||
r->connect (sigc::mem_fun (this, &XMMSHandler::playback_playtime));
|
||||
|
||||
|
@ -52,6 +55,13 @@ XMMSHandler::requestMediainfo (uint id)
|
|||
r->connect (sigc::mem_fun (this, &XMMSHandler::medialib_info));
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::requestPlaylistList (void)
|
||||
{
|
||||
XMMSResultValueList<uint> *r = m_xmmsc->playlist_list ();
|
||||
r->connect (sigc::mem_fun (this, &XMMSHandler::playlist_list));
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::playlist_list (XMMSResultValueList<uint> *res)
|
||||
{
|
||||
|
@ -118,10 +128,40 @@ XMMSHandler::setPlaytime (void)
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::medialib_info (XMMSResultDict *res)
|
||||
QHash<QString, QString>
|
||||
XMMSHandler::DictToQHash (XMMSResultDict *res)
|
||||
{
|
||||
QHash<QString, QString> h;
|
||||
std::list<const char *> l = res->getDictKeys ();
|
||||
|
||||
std::list<const char *>::const_iterator it;
|
||||
for(it=l.begin(); it!=l.end(); ++it)
|
||||
{
|
||||
if (res->getDictValueType (*it) == XMMSC_RESULT_VALUE_TYPE_UINT32) {
|
||||
uint i;
|
||||
res->getValue (*it, &i);
|
||||
QString t;
|
||||
t.setNum (i);
|
||||
h.insert (QString::fromLatin1(*it), t);
|
||||
} else if (res->getDictValueType (*it) == XMMSC_RESULT_VALUE_TYPE_INT32) {
|
||||
int i;
|
||||
res->getValue (*it, &i);
|
||||
QString t;
|
||||
t.setNum (i);
|
||||
h.insert (QString::fromLatin1(*it), t);
|
||||
} else if (res->getDictValueType (*it) == XMMSC_RESULT_VALUE_TYPE_STRING) {
|
||||
char *c;
|
||||
res->getValue (*it, &c);
|
||||
h.insert (QString::fromLatin1(*it), QString::fromUtf8 (c));
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
QHash<QString, QString>
|
||||
XMMSHandler::PropDictToQHash (XMMSResultDict *res)
|
||||
{
|
||||
int id;
|
||||
QHash<QString, QString> h;
|
||||
std::list<const char *> l = res->getPropDictKeys ();
|
||||
|
||||
|
@ -147,6 +187,22 @@ XMMSHandler::medialib_info (XMMSResultDict *res)
|
|||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::playlist_changed (XMMSResultDict *res)
|
||||
{
|
||||
QHash<QString, QString> h(DictToQHash (res));
|
||||
emit playlistChanged (h);
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::medialib_info (XMMSResultDict *res)
|
||||
{
|
||||
int id;
|
||||
QHash<QString, QString> h(PropDictToQHash (res));
|
||||
|
||||
res->getValue ("id", &id);
|
||||
|
||||
emit mediainfoChanged (id, h);
|
||||
|
|
|
@ -17,10 +17,12 @@ class XMMSHandler : public QObject, public sigc::trackable {
|
|||
void playback_playtime (XMMSResultValue<uint> *res);
|
||||
void playback_current_id (XMMSResultValue<uint> *res);
|
||||
void medialib_info (XMMSResultDict *res);
|
||||
void playlist_changed (XMMSResultDict *res);
|
||||
void playback_status (XMMSResultValue<uint> *res);
|
||||
void playlist_list (XMMSResultValueList<uint> *res);
|
||||
|
||||
void requestMediainfo (uint id);
|
||||
void requestPlaylistList (void);
|
||||
|
||||
const XMMSClient *getXMMS () { return m_xmmsc; }
|
||||
|
||||
|
@ -46,12 +48,15 @@ class XMMSHandler : public QObject, public sigc::trackable {
|
|||
void currentSong (QHash<QString, QString>);
|
||||
void playlistList (QList<uint>);
|
||||
void currentID (uint);
|
||||
void playlistChanged (QHash<QString, QString>);
|
||||
|
||||
private:
|
||||
XmmsQT4 *m_qt4;
|
||||
XMMSClient *m_xmmsc;
|
||||
static XMMSHandler *singleton;
|
||||
uint m_currentid;
|
||||
QHash<QString, QString> PropDictToQHash (XMMSResultDict *res);
|
||||
QHash<QString, QString> DictToQHash (XMMSResultDict *res);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue