From c1ea8a35f5d845999c3ba212f3e09e101cf7721a Mon Sep 17 00:00:00 2001 From: Elias Woods Date: Thu, 17 Jun 2010 00:45:07 -0400 Subject: [PATCH] Start adding support for playlist and progress on downloading songs --- Groove.pro | 6 ++++-- Makefile | 2 +- groove.cpp | 16 +++++++++++++--- gscom.cpp | 23 +++++++++++++++++++++++ gscom.h | 1 + playlist.cpp | 6 ++++++ playlist.h | 23 +++++++++++++++++++++++ 7 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 playlist.cpp create mode 100644 playlist.h diff --git a/Groove.pro b/Groove.pro index 2762e5f..4b36e10 100644 --- a/Groove.pro +++ b/Groove.pro @@ -25,10 +25,12 @@ SOURCES += main.cpp \ groove.cpp \ gscom.cpp \ splayer.cpp \ - streamio.cpp + streamio.cpp \ + playlist.cpp HEADERS += \ groove.h \ gscom.h \ splayer.h \ - streamio.h + streamio.h \ + playlist.h diff --git a/Makefile b/Makefile index eec5371..ef443ed 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: groove -# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Jun 4 15:49:00 2010 +# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Jun 16 21:13:23 2010 # Project: Groove.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile Groove.pro diff --git a/groove.cpp b/groove.cpp index 46da9d3..02bda40 100644 --- a/groove.cpp +++ b/groove.cpp @@ -12,16 +12,19 @@ groove::groove(QWidget *parent) : player = new sPlayer(); QHBoxLayout *layout = new QHBoxLayout(); QVBoxLayout *vlayout = new QVBoxLayout(); + QHBoxLayout *bottomLayout = new QHBoxLayout(); button = new QPushButton("Search"); QPushButton *dButton = new QPushButton("Play"); + QPushButton *stopButton = new QPushButton("Stop"); + QPushButton *moreButton = new QPushButton(); resultView = new QTableView(); QMenu *pushMenu = new QMenu(); //showFullScreen(); lineEdit->insert(""); lineEdit->setDisabled(true); pushMenu->addAction("Song:"); - pushMenu->addAction("Artist:"); - pushMenu->addAction("Album:"); + //pushMenu->addAction("Artist:"); + //pushMenu->addAction("Album:"); //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum); sMethod->setMaximumWidth(sMethod->sizeHint().rwidth()); @@ -37,14 +40,21 @@ groove::groove(QWidget *parent) : resultView->setSelectionMode(QAbstractItemView::SingleSelection); resultView->setEditTriggers(QAbstractItemView::NoEditTriggers); resultView->setColumnHidden(2,true); + resultView->setColumnHidden(3,true); resultView->setAutoScroll(false); + /*QPalette pal = resultView->palette(); + pal.setBrush(QPalette::Highlight,QBrush(Qt::transparent,Qt::NoBrush)); + resultView->setPalette(pal);*/ layout->addWidget(sMethod); layout->addWidget(lineEdit); layout->addWidget(button); vlayout->addLayout(layout); vlayout->addWidget(resultView); - vlayout->addWidget(dButton); + vlayout->addLayout(bottomLayout); + bottomLayout->addWidget(dButton); + bottomLayout->addWidget(stopButton); + bottomLayout->addWidget(moreButton); vlayout->setMenuBar(mBar); setLayout(vlayout); setWindowTitle("GrooveShark"); diff --git a/gscom.cpp b/gscom.cpp index 69f7497..1e6d055 100644 --- a/gscom.cpp +++ b/gscom.cpp @@ -19,6 +19,7 @@ gscom::gscom() model->setHorizontalHeaderLabels( QStringList() << "Online"); addDebugMsg("You may now search for a song"); + addProgressbar("test"); //getSessionKey(); } @@ -261,6 +262,28 @@ void gscom::addDebugMsg(QString debug) } return; } +void gscom::addProgressbar(QString debug) +{ + QList rows = QList() + << (QStringList() << debug); + foreach (QStringList row, rows) { + QList items; + foreach (QString text, row) + { + QLinearGradient gradient(0,0,250,0); + gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1)); + gradient.setColorAt(0.9, QColor::fromRgbF(0, 1, 0, 1)); + gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0)); + QBrush brush(gradient); + QStandardItem *pBar = new QStandardItem(text); + pBar->setBackground(brush); + pBar->setSelectable(false); + items.append(pBar); + } + model->appendRow(items); + } + return; +} QString* gscom::getToken(gMETHOD meth) { QCryptographicHash *hasher = new QCryptographicHash(QCryptographicHash::Sha1); diff --git a/gscom.h b/gscom.h index f39e9a0..42bc5ef 100644 --- a/gscom.h +++ b/gscom.h @@ -49,6 +49,7 @@ private: QNetworkAccessManager *manager; QNetworkCookieJar *cookies; void addDebugMsg(QString debug); + void addProgressbar(QString debug); bool firstR; QByteArray *postdata; }; diff --git a/playlist.cpp b/playlist.cpp new file mode 100644 index 0000000..6c0cb7f --- /dev/null +++ b/playlist.cpp @@ -0,0 +1,6 @@ +#include "playlist.h" + +playlist::playlist(QObject *parent) : + QObject(parent) +{ +} diff --git a/playlist.h b/playlist.h new file mode 100644 index 0000000..d33386b --- /dev/null +++ b/playlist.h @@ -0,0 +1,23 @@ +#ifndef PLAYLIST_H +#define PLAYLIST_H + +#include +#include + +class playlist : public QObject +{ + Q_OBJECT +public: + explicit playlist(QObject *parent = 0); + void addSong(QStandardItem item); + QList getPlaylist(); + void removeSong(int position); + + +signals: + +public slots: + +}; + +#endif // PLAYLIST_H -- 1.7.9.5