From ad816859973708186dab66789fa0e6d7ebad5ab5 Mon Sep 17 00:00:00 2001 From: Iktwo Sh Date: Wed, 7 Jan 2015 21:39:02 -0800 Subject: [PATCH] Update to goears new website --- qml/AboutPage.qml | 4 +- qml/Arrow.qml | 2 +- qml/FakeMainPage.qml | 14 +++---- qml/FakePlaybackControls.qml | 6 +-- qml/FakeSearchPage.qml | 6 +-- qml/ImageButton.qml | 2 +- qml/MainPage.qml | 12 ++---- qml/PlaybackControls.qml | 8 ++-- qml/PlaylistDelegate.qml | 6 +-- qml/ReviewDialog.qml | 2 +- qml/SearchPage.qml | 7 ++-- qml/SongDelegate.qml | 12 +++--- qml/TutorialPage.qml | 4 +- qml/main.qml | 12 +++--- qml/testModels/TestSearchModel.qml | 18 +++------ src/downloader.cpp | 65 +++++++++++------------------- src/downloader.h | 3 +- src/musicstreamer.cpp | 15 ++----- src/musicstreamer.h | 8 ++-- src/song.cpp | 35 +--------------- src/song.h | 15 +------ 21 files changed, 85 insertions(+), 171 deletions(-) diff --git a/qml/AboutPage.qml b/qml/AboutPage.qml index e44d455..75f0e2c 100644 --- a/qml/AboutPage.qml +++ b/qml/AboutPage.qml @@ -1,5 +1,5 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 import com.iktwo.components 1.0 diff --git a/qml/Arrow.qml b/qml/Arrow.qml index 2d9c1a1..34acc10 100644 --- a/qml/Arrow.qml +++ b/qml/Arrow.qml @@ -1,4 +1,4 @@ -import QtQuick 2.3 +import QtQuick 2.4 Item { height: 100 diff --git a/qml/FakeMainPage.qml b/qml/FakeMainPage.qml index d54c3ab..bb222c9 100644 --- a/qml/FakeMainPage.qml +++ b/qml/FakeMainPage.qml @@ -1,6 +1,5 @@ -import QtQuick 2.3 -import com.iktwo.components 1.0 -import QtQuick.Controls 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 import com.iktwo.components 1.0 @@ -51,20 +50,17 @@ Item { ListElement { name: "Arrullo De Estrellas"; artist: "Zoé" - length: "4:14"; comment: "Bonita canción que me hace pensar en ti.." - code: ""; url: "xxx" + length: "4:14"; code: ""; url: "xxx" } ListElement { name: "Goodbye Lovers and Friends"; artist: "Franz Ferdinand" - length: "4:34"; comment: "I love this song!" - code: ""; url: "xxx" + length: "4:34"; code: ""; url: "xxx" } ListElement { name: "Addicted to you"; artist: "Avicii" - length: "3:24"; comment: "I am addicted to you" - code: ""; url: "xxx" + length: "3:24"; code: ""; url: "xxx" } } diff --git a/qml/FakePlaybackControls.qml b/qml/FakePlaybackControls.qml index 59318bf..033fd80 100644 --- a/qml/FakePlaybackControls.qml +++ b/qml/FakePlaybackControls.qml @@ -1,6 +1,6 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.1 +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.3 import QtQuick.Layouts 1.1 import QtMultimedia 5.1 import com.iktwo.components 1.0 diff --git a/qml/FakeSearchPage.qml b/qml/FakeSearchPage.qml index 8d2ce68..7bb40d8 100644 --- a/qml/FakeSearchPage.qml +++ b/qml/FakeSearchPage.qml @@ -1,7 +1,7 @@ -import QtQuick 2.3 +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.3 import com.iktwo.components 1.0 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 Page { id: root diff --git a/qml/ImageButton.qml b/qml/ImageButton.qml index 54e1938..bc76dd0 100644 --- a/qml/ImageButton.qml +++ b/qml/ImageButton.qml @@ -1,4 +1,4 @@ -import QtQuick 2.3 +import QtQuick 2.4 Item { id: root diff --git a/qml/MainPage.qml b/qml/MainPage.qml index fecb126..76202df 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -1,5 +1,5 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.1 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 import QtMultimedia 5.2 import com.iktwo.components 1.0 @@ -92,12 +92,12 @@ Page { if (index < playlist.count - 1) { /// Will copy next item data, no need to change index - playbackControls.song = playlist.get(index + 1).name + " - " + playlist.get(index + 1).comment + "" + playbackControls.song = playlist.get(index + 1).name + " - " + playlist.get(index + 1).artist + "" audioElement.source = playlist.get(index + 1).url audioElement.play() } else if (index - 1 >= 0) { /// Will copy previous item data, update index to -1 - playbackControls.song = playlist.get(index - 1).name + " - " + playlist.get(index - 1).comment + "" + playbackControls.song = playlist.get(index - 1).name + " - " + playlist.get(index - 1).artist + "" audioElement.source = playlist.get(index - 1).url audioElement.index = audioElement.index - 1 audioElement.play() @@ -141,8 +141,4 @@ Page { wrapMode: "Wrap" elide: "ElideRight" } - - //Component.onCompleted: playlist.append({"name" : "First Song", - //"artist" : "First Group", "length" : "3:31", "comment" : "this is a test", - //"code" : "XASDDASD", "url": "invalid", "picture": "crazytest"}) } diff --git a/qml/PlaybackControls.qml b/qml/PlaybackControls.qml index 9200f0e..66fab7d 100644 --- a/qml/PlaybackControls.qml +++ b/qml/PlaybackControls.qml @@ -1,8 +1,8 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.1 +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.3 import QtQuick.Layouts 1.1 -import QtMultimedia 5.1 +import QtMultimedia 5.2 import com.iktwo.components 1.0 import "components/style.js" as Style diff --git a/qml/PlaylistDelegate.qml b/qml/PlaylistDelegate.qml index 7bdcf39..02721de 100644 --- a/qml/PlaylistDelegate.qml +++ b/qml/PlaylistDelegate.qml @@ -1,5 +1,5 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import com.iktwo.components 1.0 import "components" as ThisComponents import "components/style.js" as Style @@ -75,7 +75,7 @@ Item { elide: Text.ElideRight color: Style.TEXT_SECONDARY_COLOR_DARK - text: model.length + " - " + model.comment + "" + text: model.length width: parent.width renderType: Text.NativeRendering } diff --git a/qml/ReviewDialog.qml b/qml/ReviewDialog.qml index a603890..72f7745 100644 --- a/qml/ReviewDialog.qml +++ b/qml/ReviewDialog.qml @@ -1,4 +1,4 @@ -import QtQuick 2.3 +import QtQuick 2.4 import com.iktwo.components 1.0 Dialog { diff --git a/qml/SearchPage.qml b/qml/SearchPage.qml index 2a1ecce..120516e 100644 --- a/qml/SearchPage.qml +++ b/qml/SearchPage.qml @@ -1,6 +1,6 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.3 import com.iktwo.components 1.0 Page { @@ -187,7 +187,6 @@ Page { playlist.append({ "name" : model.name, "artist" : model.artist, "length" : model.length, - "comment" : model.comment, "code" : model.code, "url": model.url, "picture": model.picture }) diff --git a/qml/SongDelegate.qml b/qml/SongDelegate.qml index 71a42ca..fe33e1e 100644 --- a/qml/SongDelegate.qml +++ b/qml/SongDelegate.qml @@ -1,6 +1,6 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.1 +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.3 import QtQuick.Layouts 1.1 import com.iktwo.components 1.0 import "components" as ThisComponents @@ -97,7 +97,7 @@ Item { elide: Text.ElideRight color: Style.TEXT_SECONDARY_COLOR_DARK - text: model.length + (model.comment !== "" && model.length !== "" ? " - " : "") + model.comment + text: model.artist width: parent.width renderType: Text.NativeRendering maximumLineCount: 1 @@ -124,9 +124,9 @@ Item { color: Style.TEXT_COLOR_LIGHT elide: Text.ElideRight - text: model.kbps + "kbps " //+ model.hits renderType: Text.NativeRendering maximumLineCount: 1 + text: model.kbps + "kbps" } } } @@ -140,9 +140,9 @@ Item { elide: Text.ElideRight color: Style.TEXT_SECONDARY_COLOR_DARK - text: "▶ " + model.hits width: parent.width renderType: Text.NativeRendering + text: model.length } } diff --git a/qml/TutorialPage.qml b/qml/TutorialPage.qml index cfc2030..2fa07cf 100644 --- a/qml/TutorialPage.qml +++ b/qml/TutorialPage.qml @@ -1,5 +1,5 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import com.iktwo.components 1.0 Page { diff --git a/qml/main.qml b/qml/main.qml index 9ade852..9030e53 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,7 +1,7 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick 2.4 +import QtQuick.Controls 1.3 import QtQuick.Window 2.1 -import QtMultimedia 5.1 +import QtMultimedia 5.2 import com.iktwo.components 1.0 import "." @@ -29,7 +29,7 @@ ApplicationWindow { else audio.index = 0 - playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).comment + "" + playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).artist + "" audio.source = playlist.get(audio.index).url audio.play() } @@ -40,7 +40,7 @@ ApplicationWindow { else audio.index = playlist.count - 1 - playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).comment + "" + playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).artist + "" audio.source = playlist.get(audio.index).url audio.play() } @@ -122,7 +122,7 @@ ApplicationWindow { onRowsInserted: { // If new item is first on list, play it if (count === 1) { - playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).comment + "" + playbackControls.song = playlist.get(audio.index).name + " - " + playlist.get(audio.index).artist + "" audio.source = playlist.get(audio.index).url audio.play() } else if (audio.status == Audio.EndOfMedia) { diff --git a/qml/testModels/TestSearchModel.qml b/qml/testModels/TestSearchModel.qml index ea97e0d..0fcd07b 100644 --- a/qml/testModels/TestSearchModel.qml +++ b/qml/testModels/TestSearchModel.qml @@ -2,58 +2,52 @@ import QtQuick 2.3 ListModel { id: testModel + ListElement { name: "Labios Rotos" artist: "Zoe" picture: "zoe" length: "3:40" - comment: "Bonita canción" kbps: 192 - hits: 11500 } + ListElement { name: "Yesterday" artist: "The Beatles" picture: "beatles" length: "2:58" - comment: "The yellow submarine!" kbps: 128 - hits: 25800 } + ListElement { name: "Another one bites the dust" artist: "Queen" picture: "queen" length: "3:14" - comment: "We are the champions my friend!" kbps: 320 - hits: 23160 } + ListElement { name: "hips don't lie" artist: "Shakira" picture: "shakira" length: "3:22" - comment: "Waka waka!" kbps: 98 - hits: 18231 } + ListElement { name: "Hotel Room Service" artist: "Pitbull" picture: "pitbull" length: "4:15" - comment: "Ya tu sabe!" kbps: 64 - hits: 10100 } + ListElement { name: "Song Name" artist: "Fake" picture: "crazystuff" length: "3:10" - comment: "This a long useful comment" kbps: 64 - hits: 158 } } diff --git a/src/downloader.cpp b/src/downloader.cpp index 37d0438..071c7aa 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -97,7 +97,7 @@ void Downloader::downloadFinished(QNetworkReply *reply) // if (!reply->url().toString().startsWith("http://www.goear.com/action/sound/get/")) - // qDebug() << reply->url().toString() << "Downloaded"; + // qDebug() << reply->url().toString() << "Downloaded"; QVariant redir = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); @@ -199,31 +199,37 @@ void Downloader::downloadFinished(QNetworkReply *reply) songs = songs.mid(termEnds); - searchTerm = "\">"; - closingTerm = ""; + searchTerm = "
  • "; termBegins = songs.indexOf(searchTerm) + searchTerm.length(); termEnds = songs.indexOf(closingTerm, termBegins); - QString tmp = songs.mid(termBegins, termEnds - termBegins); - QString artist = tmp.mid(0, tmp.indexOf(" -")); - QString title = tmp.mid(tmp.indexOf("- ") + 1); + QString title = songs.mid(termBegins, termEnds - termBegins); + title = title.mid(title.indexOf(">") + 1).simplified(); - if (artist == "") - artist = tmp; + songs = songs.mid(termEnds + closingTerm.length()); - if (title == "") - title = tmp; + searchTerm = "
  • <"; + closingTerm = "
  • "; + termBegins = songs.indexOf(searchTerm) + searchTerm.length(); + termEnds = songs.indexOf(closingTerm, termBegins); + + QString artist = songs.mid(termBegins, termEnds - termBegins); + artist = artist.mid(artist.indexOf(">") + 1).simplified(); - searchTerm = "
  • ") + 1); + QString length = songs.mid(termBegins, termEnds - termBegins); + + songs = songs.mid(termEnds + closingTerm.length()); searchTerm = "title=\"Kbps\">"; closingTerm = "").remove("kbps"); - searchTerm = "title=\"Plays\">"; - closingTerm = "
  • "; - - if (songs.indexOf(searchTerm) == -1) - searchTerm = "class=\"total_hits\" >"; - - termBegins = songs.indexOf(searchTerm) + searchTerm.length(); - termEnds = songs.indexOf(closingTerm, termBegins); - - QString hits = songs.mid(termBegins, termEnds - termBegins); - - searchTerm = "
  • "; - closingTerm = "
  • "; - - termBegins = songs.indexOf(searchTerm) + searchTerm.length(); - termEnds = songs.indexOf(closingTerm, termBegins); - - QString comment = songs.mid(termBegins, termEnds - termBegins); - searchTerm = ">"; closingTerm = " 1) { - emit songFound(title, artist, length, comment, kbps.toInt(), code, picture, hits.replace(",", "").toLong()); + emit songFound(title, artist, length, kbps.toInt(), code, picture); getDownloadLink(code); addedSongs++; } diff --git a/src/downloader.h b/src/downloader.h index 0de640c..24e02c6 100644 --- a/src/downloader.h +++ b/src/downloader.h @@ -47,8 +47,7 @@ public slots: signals: void songFound(const QString &title, const QString &artist, const QString &length, - const QString &comment, int kbps, const QString &code, - const QString &picture, long long hits); + int kbps, const QString &code, const QString &picture); void decodedUrl(const QString &code, const QString &url); void searchEnded(); diff --git a/src/musicstreamer.cpp b/src/musicstreamer.cpp index 6420031..7a8720d 100644 --- a/src/musicstreamer.cpp +++ b/src/musicstreamer.cpp @@ -18,8 +18,8 @@ MusicStreamer::MusicStreamer(QObject *parent) : { mDownloader = new Downloader(this); - connect(mDownloader, SIGNAL(songFound(QString, QString, QString, QString, int, QString, QString, long long)), - SLOT(songFound(QString, QString, QString, QString, int, QString, QString, long long))); + connect(mDownloader, SIGNAL(songFound(QString, QString, QString, int, QString, QString)), + SLOT(songFound(QString, QString, QString, int, QString, QString))); connect(mDownloader, SIGNAL(searchEnded()), SLOT(searchEnded())); connect(mDownloader, SIGNAL(decodedUrl(QString,QString)), SLOT(decodedUrl(QString,QString))); connect(mDownloader, SIGNAL(searchHasMoreResults(QString)), SLOT(lastSearchHasMoreResults(QString))); @@ -59,10 +59,9 @@ void MusicStreamer::search(const QString &term) } void MusicStreamer::songFound(const QString &title, const QString &artist, const QString &length, - const QString &comment, int kbps, const QString &code, - const QString &picture, long long hits) + int kbps, const QString &code, const QString &picture) { - mTempSongs.append(new Song(title, artist, length, comment, kbps, code, picture, hits, this)); + mTempSongs.append(new Song(title, artist, length, kbps, code, picture, this)); } QObjectList MusicStreamer::songs() @@ -101,8 +100,6 @@ QVariant MusicStreamer::data(const QModelIndex & index, int role) const return song->artist(); else if (role == LengthRole) return song->length(); - else if (role == CommentRole) - return song->comment(); else if (role == KbpsRole) return song->kbps(); else if (role == CodeRole) @@ -111,8 +108,6 @@ QVariant MusicStreamer::data(const QModelIndex & index, int role) const return song->url(); else if (role == PictureRole) return song->picture(); - else if (role == HitsRole) - return song->hits(); return QVariant(); } @@ -128,12 +123,10 @@ QHash MusicStreamer::roleNames() const roles[NameRole] = "name"; roles[ArtistRole] = "artist"; roles[LengthRole] = "length"; - roles[CommentRole] = "comment"; roles[KbpsRole] = "kbps"; roles[CodeRole] = "code"; roles[UrlRole] = "url"; roles[PictureRole] = "picture"; - roles[HitsRole] = "hits"; return roles; } diff --git a/src/musicstreamer.h b/src/musicstreamer.h index b6981be..f6e99c1 100644 --- a/src/musicstreamer.h +++ b/src/musicstreamer.h @@ -21,12 +21,10 @@ class MusicStreamer : public QAbstractListModel NameRole = Qt::UserRole + 1, ArtistRole, LengthRole, - CommentRole, KbpsRole, CodeRole, UrlRole, - PictureRole, - HitsRole + PictureRole }; explicit MusicStreamer(QObject *parent = 0); @@ -82,8 +80,8 @@ class MusicStreamer : public QAbstractListModel private slots: void songFound(const QString &title, const QString &artist, const QString &length, - const QString &comment, int kbps, const QString &code, - const QString &picture, long long hits); + int kbps, const QString &code, + const QString &picture); void decodedUrl(const QString &code, const QString &url); void searchEnded(); void lastSearchHasMoreResults(const QString &url); diff --git a/src/song.cpp b/src/song.cpp index 8859cde..cdde2e0 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -7,17 +7,14 @@ Song::Song(QObject *parent) } Song::Song(const QString &name, const QString &artist, const QString &length, - const QString &comment, int kbps, const QString &code, const QString &picture, - long long hits, QObject *parent) + int kbps, const QString &code, const QString &picture, QObject *parent) : QObject(parent), m_name(name), m_artist(artist), m_length(length), - m_comment(comment), m_kbps(kbps), m_code(code), - m_picture(picture), - m_hits(hits) + m_picture(picture) { } @@ -63,20 +60,6 @@ void Song::setLength(const QString &length) emit lengthChanged(); } -QString Song::comment() const -{ - return m_comment; -} - -void Song::setComment(const QString &comment) -{ - if (m_comment == comment) - return; - - m_comment = comment; - emit commentChanged(); -} - QString Song::code() const { return m_code; @@ -132,17 +115,3 @@ void Song::setPicture(const QString &picture) m_picture = picture; emit pictureChanged(); } - -long long Song::hits() const -{ - return m_hits; -} - -void Song::setHits(long long hits) -{ - if (m_hits == hits) - return; - - m_hits = hits; - emit hitsChanged(); -} diff --git a/src/song.h b/src/song.h index d44d667..c702508 100644 --- a/src/song.h +++ b/src/song.h @@ -11,23 +11,20 @@ class Song : public QObject Q_PROPERTY(QString artist READ artist NOTIFY artistChanged) Q_PROPERTY(QString length READ length NOTIFY lengthChanged) - Q_PROPERTY(QString comment READ comment NOTIFY commentChanged) Q_PROPERTY(QString code READ code NOTIFY codeChanged) Q_PROPERTY(QString url READ url NOTIFY urlChanged) Q_PROPERTY(int kbps READ kbps NOTIFY kbpsChanged) Q_PROPERTY(QString picture READ picture NOTIFY pictureChanged) - Q_PROPERTY(long long hits READ hits WRITE setHits NOTIFY hitsChanged) public: Song(QObject *parent = 0); - Song(const QString &name, const QString &artist, const QString &length, const QString &comment, - int kbps, const QString &code, const QString &picture, long long hits, QObject *parent = 0); + Song(const QString &name, const QString &artist, const QString &length, + int kbps, const QString &code, const QString &picture, QObject *parent = 0); QString name() const; QString artist() const; QString length() const; - QString comment() const; int kbps() const; QString code() const; QString url() const; @@ -35,7 +32,6 @@ class Song : public QObject void setName(const QString &name); void setArtist(const QString &artist); void setLength(const QString &length); - void setComment(const QString &comment); void setCode(const QString &code); void setUrl(const QString &url); void setKbps(int kbps); @@ -43,30 +39,23 @@ class Song : public QObject QString picture() const; void setPicture(const QString &picture); - long long hits() const; - void setHits(long long hits); - signals: void nameChanged(); void artistChanged(); void lengthChanged(); - void commentChanged(); void codeChanged(); void urlChanged(); void kbpsChanged(); void pictureChanged(); - void hitsChanged(); private: QString m_name; QString m_artist; QString m_length; - QString m_comment; int m_kbps; QString m_url; QString m_code; QString m_picture; - long long m_hits; }; #endif // SONG_H