Improve the playlists-choose dialog
This commit is contained in:
parent
d93f2ee188
commit
4c7317f71d
8 changed files with 191 additions and 52 deletions
|
@ -74,7 +74,7 @@ XClient::XClient (QObject *parent, const std::string &name) : QObject (parent),
|
|||
m_client = NULL;
|
||||
m_isconnected = false;
|
||||
m_cache = new XClientCache (this, this);
|
||||
m_config = new XConfig (this, this);
|
||||
m_config = new XConfig (this);
|
||||
m_collection = new XCollection (this);
|
||||
m_name = name;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,11 @@ XCollection::on_connect (XClient *client)
|
|||
client->collection ()->list ("Playlists")
|
||||
(Xmms::bind (&XCollection::handle_playlists_list, this));
|
||||
|
||||
client->playlist ()->currentActive ()
|
||||
(Xmms::bind (&XCollection::handle_active_pls_changed, this));
|
||||
client->playlist ()->broadcastLoaded ()
|
||||
(Xmms::bind (&XCollection::handle_active_pls_changed, this));
|
||||
|
||||
m_client = client;
|
||||
}
|
||||
|
||||
|
@ -93,6 +98,19 @@ XCollection::on_collection_modified (const Xmms::Dict &value)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XCollection::remove (QString name, QString ns) {
|
||||
if (!m_client->isConnected ()) return false;
|
||||
|
||||
m_client->collection ()->remove (name.toStdString (), ns.toAscii ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* idList (Playlist) stuff
|
||||
*/
|
||||
|
||||
bool
|
||||
XCollection::handle_playlists_list (const Xmms::List< std::string > &list)
|
||||
{
|
||||
|
@ -125,6 +143,16 @@ XCollection::setActivePlaylist (QString name) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XCollection::handle_active_pls_changed (const std::string &name) {
|
||||
QString tmp = m_activePlaylist;
|
||||
m_activePlaylist = XClient::stdToQ (name);
|
||||
|
||||
emit activePlaylistChanged (m_activePlaylist, tmp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: should be done in a more generic way
|
||||
bool
|
||||
XCollection::addIdlist (QString name) {
|
||||
|
@ -134,12 +162,3 @@ XCollection::addIdlist (QString name) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XCollection::remove (QString name, QString ns) {
|
||||
if (!m_client->isConnected ()) return false;
|
||||
|
||||
m_client->collection ()->remove (name.toStdString (), ns.toAscii ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,22 +30,30 @@ class XCollection : public QObject
|
|||
XCollection (XClient *client);
|
||||
QStringList list (QString ns = "Playlists");
|
||||
|
||||
bool setActivePlaylist (QString name);
|
||||
bool addIdlist (QString name);
|
||||
bool remove (QString name, QString ns);
|
||||
// idlist specific
|
||||
bool setActivePlaylist (QString name);
|
||||
QString activePlaylist () {return m_activePlaylist;}
|
||||
bool addIdlist (QString name);
|
||||
|
||||
signals:
|
||||
void collectionModified (QString collection, QString ns, int type,
|
||||
QString newname);
|
||||
|
||||
void activePlaylistChanged (QString newActive, QString oldActive);
|
||||
|
||||
protected slots:
|
||||
void on_connect (XClient *);
|
||||
|
||||
private:
|
||||
bool on_collection_modified (const Xmms::Dict &value);
|
||||
bool handle_playlists_list (const Xmms::List< std::string > &list);
|
||||
bool handle_active_pls_changed (const std::string &name);
|
||||
|
||||
XClient *m_client;
|
||||
QStringList m_playlists;
|
||||
|
||||
QString m_activePlaylist;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,18 +20,18 @@
|
|||
|
||||
#include <QList>
|
||||
|
||||
XConfig::XConfig (QObject *parent, XClient *client) : QObject (parent)
|
||||
XConfig::XConfig (XClient *parent) : QObject (parent)
|
||||
{
|
||||
m_ready = false;
|
||||
|
||||
connect (client, SIGNAL (gotConnection (XClient *)),
|
||||
connect (parent, SIGNAL (gotConnection (XClient *)),
|
||||
this, SLOT (on_connect (XClient *)));
|
||||
|
||||
connect (client, SIGNAL (disconnected (XClient *)),
|
||||
connect (parent, SIGNAL (disconnected (XClient *)),
|
||||
this, SLOT (on_disconnect (XClient *)));
|
||||
|
||||
if (client->isConnected ()) {
|
||||
on_connect (client);
|
||||
if (parent->isConnected ()) {
|
||||
on_connect (parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class XConfig : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
XConfig (QObject *parent, XClient *client);
|
||||
XConfig (XClient *parent);
|
||||
|
||||
QString value_get (QString key);
|
||||
bool value_set (QString key, QString value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue