diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2008-06-13 20:48:48 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2008-06-13 20:48:48 -0400 |
commit | 5e20082624170873375e6b56b377d75192ca0475 (patch) | |
tree | f9ba1fff3ab93ae54e45015b82b1cd5917bbc6cf | |
parent | Subclassed qtreeview. (diff) | |
download | zmusicplayer-5e20082624170873375e6b56b377d75192ca0475.tar.xz zmusicplayer-5e20082624170873375e6b56b377d75192ca0475.zip |
Made credentials non-static.
-rw-r--r-- | CollectionModel.cpp | 5 | ||||
-rw-r--r-- | CollectionModel.h | 4 | ||||
-rw-r--r-- | PlayerWindow.cpp | 22 | ||||
-rw-r--r-- | PlayerWindow.h | 3 |
4 files changed, 15 insertions, 19 deletions
diff --git a/CollectionModel.cpp b/CollectionModel.cpp index 2dc7f7c..dcad438 100644 --- a/CollectionModel.cpp +++ b/CollectionModel.cpp @@ -13,11 +13,12 @@ #include <QMimeData> #include <QUrl> -CollectionModel::CollectionModel(QList<Song*> songs, QObject* parent) +CollectionModel::CollectionModel(QList<Song*> songs, Credentials* credentials, QObject* parent) : QAbstractItemModel(parent) , m_songs(songs) , m_position(-1) , m_fakeBoldState(false) + , m_credentials(credentials) {} QVariant CollectionModel::data(const QModelIndex &index, int role) const @@ -117,7 +118,7 @@ QMimeData* CollectionModel::mimeData(const QModelIndexList& indexes) const Q_FOREACH(QModelIndex index, indexes) { if(index.column() == 1) - urls << PlayerWindow::credentials()->songUrl(m_songs[index.row()]->sha1()).toString(); + urls << m_credentials->songUrl(m_songs[index.row()]->sha1()).toString(); }; ret->setData("text/uri-list", urls.join("\n").toUtf8()); return ret; diff --git a/CollectionModel.h b/CollectionModel.h index d342342..32bf557 100644 --- a/CollectionModel.h +++ b/CollectionModel.h @@ -10,12 +10,13 @@ #include <QList> class Song; +class Credentials; class CollectionModel : public QAbstractItemModel { Q_OBJECT; public: - CollectionModel(QList<Song*> songs, QObject* parent = 0); + CollectionModel(QList<Song*> songs, Credentials* credentials, QObject* parent = 0); QVariant data(const QModelIndex &index, int role) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; @@ -33,5 +34,6 @@ private: QList<Song*> m_songs; int m_position; bool m_fakeBoldState; + Credentials *m_credentials; }; #endif //COLLECTIONMODEL_H diff --git a/PlayerWindow.cpp b/PlayerWindow.cpp index be53ea9..eba7138 100644 --- a/PlayerWindow.cpp +++ b/PlayerWindow.cpp @@ -20,7 +20,6 @@ #include <QSortFilterProxyModel> //BEGIN CONSTRUCT OBJECTS -Credentials *PlayerWindow::s_credentials = 0; PlayerWindow::PlayerWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) , m_model(0) @@ -87,11 +86,12 @@ void PlayerWindow::setupUi() m_downloadProgress = new QProgressBar; statusBar()->addWidget(m_downloadProgress, 1); statusBar()->hide(); - connect(credentials(), SIGNAL(receivedList(const QList<Song*>)), this, SLOT(setupTable(const QList<Song*>))); - m_treeView->setChildWidget(credentials()); - credentials()->setDownloadProgressBar(m_downloadProgress); - credentials()->setStatusBar(statusBar()); - credentials()->show(); + m_credentials = new Credentials("zx2c4.com", "/music/getlisting.php?language=xml", "music/getsong.php?hash=%1"); + connect(m_credentials, SIGNAL(receivedList(const QList<Song*>)), this, SLOT(setupTable(const QList<Song*>))); + m_treeView->setChildWidget(m_credentials); + m_credentials->setDownloadProgressBar(m_downloadProgress); + m_credentials->setStatusBar(statusBar()); + m_credentials->show(); show(); } @@ -111,19 +111,13 @@ void PlayerWindow::setupPhonon() } void PlayerWindow::setupTable(const QList<Song*> songList) { - m_model = new CollectionModel(songList, this); + m_model = new CollectionModel(songList, m_credentials, this); m_filter = new CollectionFilter(this, m_model); m_treeView->setModel(m_filter); m_searchEdit->setDisabled(false); connect(m_treeView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(songDoubleClicked(const QModelIndex&))); updateControls(); } -Credentials* PlayerWindow::credentials() -{ - if(!s_credentials) - s_credentials = new Credentials("zx2c4.com", "/music/getlisting.php?language=xml", "music/getsong.php?hash=%1"); - return s_credentials; -} //END CONSTRUCT OBJECTS //BEGIN SYNC PLAYER CONTROLS @@ -218,7 +212,7 @@ void PlayerWindow::stopTriggered() void PlayerWindow::playIndex(const QModelIndex &index) { if(index.isValid()) { - m_mediaObject->setCurrentSource(credentials()->songUrl(m_model->song(index)->sha1())); + m_mediaObject->setCurrentSource(m_credentials->songUrl(m_model->song(index)->sha1())); m_mediaObject->play(); updateControls(); } diff --git a/PlayerWindow.h b/PlayerWindow.h index 11f14c1..f1ff773 100644 --- a/PlayerWindow.h +++ b/PlayerWindow.h @@ -25,7 +25,6 @@ class PlayerWindow : public QMainWindow Q_OBJECT public: PlayerWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); - static Credentials* credentials(); private slots: void songDoubleClicked(const QModelIndex &index); @@ -62,7 +61,7 @@ private: double m_suggestedRatio2; double m_suggestedRatio3; int m_suggestedWidthTotal; - static Credentials *s_credentials; + Credentials *m_credentials; void setupUi(); void setupPhonon(); |