OTHER: Replaced code for current_id handling
Now the current_id changed broadcast is handled in xclientcache, the now unused code from XMMSHandler has been removed
This commit is contained in:
parent
058e2d0987
commit
20cfdad68d
11 changed files with 82 additions and 111 deletions
|
@ -46,6 +46,11 @@ XClientCache::got_connection (XClient *client)
|
|||
|
||||
client->medialib ()->broadcastEntryChanged () (
|
||||
Xmms::bind (&XClientCache::handle_mlib_entry_changed, this));
|
||||
|
||||
client->playback ()->broadcastCurrentID () (
|
||||
Xmms::bind (&XClientCache::handle_current_id_changed, this));
|
||||
client->playback ()->currentID () (
|
||||
Xmms::bind (&XClientCache::handle_current_id_changed, this));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -60,12 +65,16 @@ XClientCache::handle_medialib_info_error (const std::string &error, uint32_t id)
|
|||
bool
|
||||
XClientCache::handle_medialib_info (const Xmms::PropDict &info)
|
||||
{
|
||||
int32_t id = info.get<int32_t> ("id");
|
||||
uint32_t id = info.get<int32_t> ("id");
|
||||
QHash<QString, QVariant> hash = XClient::convert_propdict (info);
|
||||
|
||||
m_info.insert (id, hash);
|
||||
emit entryChanged (id);
|
||||
|
||||
if (id == m_current_id) {
|
||||
emit activeEntryChanged (hash);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -165,6 +174,20 @@ XClientCache::handle_mlib_entry_changed (const uint32_t &id)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XClientCache::handle_current_id_changed (const uint32_t &id)
|
||||
{
|
||||
m_current_id = id;
|
||||
if (!m_info.contains (id)) {
|
||||
// get_info fetches the metadata from the server, and calls handle_medialib_info.
|
||||
// handle_medialib_info sends the activeEntryChanged Signal
|
||||
get_info (id);
|
||||
return true;
|
||||
}
|
||||
|
||||
emit activeEntryChanged (m_info[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XClientCache::handle_playtime (const unsigned int &tme)
|
||||
|
|
|
@ -38,6 +38,8 @@ class QIcon;
|
|||
class QPixmap;
|
||||
//#include <QPixmapCache>
|
||||
|
||||
typedef QHash<QString, QVariant> QVariantHash;
|
||||
|
||||
class XClientCache : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -45,6 +47,7 @@ class XClientCache : public QObject
|
|||
XClientCache (XClient *);
|
||||
|
||||
QHash<QString, QVariant> get_info (uint32_t id);
|
||||
QVariantHash get_current_info () {return get_info (m_current_id);}
|
||||
QIcon get_icon (uint32_t id);
|
||||
QPixmap get_pixmap (uint32_t id);
|
||||
QVariant extra_info_get (uint32_t, const QString &);
|
||||
|
@ -65,14 +68,17 @@ class XClientCache : public QObject
|
|||
void entryRemoved (uint32_t);
|
||||
void playtime (uint32_t);
|
||||
|
||||
void activeEntryChanged (QVariantHash);
|
||||
|
||||
public slots:
|
||||
void got_connection (XClient *);
|
||||
|
||||
private:
|
||||
bool handle_medialib_info (const Xmms::PropDict &info);
|
||||
bool handle_medialib_info_error (const std::string &, uint32_t);
|
||||
|
||||
|
||||
bool handle_mlib_entry_changed (const uint32_t &id);
|
||||
bool handle_current_id_changed (const uint32_t &id);
|
||||
bool handle_bindata (const Xmms::bin &, const QString &);
|
||||
|
||||
bool handle_playtime (const unsigned int &tme);
|
||||
|
@ -82,6 +88,8 @@ class XClientCache : public QObject
|
|||
QHash < QString, QList <uint32_t> > m_icon_map;
|
||||
QHash < int, QHash < QString, QVariant > > m_extra_info;
|
||||
|
||||
uint32_t m_current_id;
|
||||
|
||||
XClient *m_client;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue