From 88a355db54b6be2f52e7790243fe1ecf51186fe0 Mon Sep 17 00:00:00 2001 From: Flavio Date: Mon, 7 Jan 2013 17:22:42 +0100 Subject: [PATCH] 2013 --- src/aboutview.cpp | 2 +- src/{listmodel.cpp => playlistmodel.cpp} | 0 src/{listmodel.h => playlistmodel.h} | 0 src/playlistwidget.cpp | 11 -- src/playlistwidget.h | 17 --- src/youtubesearch.cpp | 126 ------------------ src/youtubesearch.h | 37 ----- ...utubestreamreader.cpp => ytfeedreader.cpp} | 0 src/{youtubestreamreader.h => ytfeedreader.h} | 0 src/{youtubesuggest.cpp => ytsuggester.cpp} | 0 src/{youtubesuggest.h => ytsuggester.h} | 0 11 files changed, 1 insertion(+), 192 deletions(-) rename src/{listmodel.cpp => playlistmodel.cpp} (100%) rename src/{listmodel.h => playlistmodel.h} (100%) delete mode 100644 src/playlistwidget.cpp delete mode 100644 src/playlistwidget.h delete mode 100644 src/youtubesearch.cpp delete mode 100644 src/youtubesearch.h rename src/{youtubestreamreader.cpp => ytfeedreader.cpp} (100%) rename src/{youtubestreamreader.h => ytfeedreader.h} (100%) rename src/{youtubesuggest.cpp => ytsuggester.cpp} (100%) rename src/{youtubesuggest.h => ytsuggester.h} (100%) diff --git a/src/aboutview.cpp b/src/aboutview.cpp index 9a5e259..78d4a34 100644 --- a/src/aboutview.cpp +++ b/src/aboutview.cpp @@ -69,7 +69,7 @@ AboutView::AboutView(QWidget *parent) : QWidget(parent) { "

" + tr("Released under the GNU General Public License") .arg("http://www.gnu.org/licenses/gpl.html") + "

" #endif - "

© 2009-2012 " + Constants::ORG_NAME + "

" + "

© 2009-2013 " + Constants::ORG_NAME + "

" ""; QLabel *infoLabel = new QLabel(info, this); infoLabel->setOpenExternalLinks(true); diff --git a/src/listmodel.cpp b/src/playlistmodel.cpp similarity index 100% rename from src/listmodel.cpp rename to src/playlistmodel.cpp diff --git a/src/listmodel.h b/src/playlistmodel.h similarity index 100% rename from src/listmodel.h rename to src/playlistmodel.h diff --git a/src/playlistwidget.cpp b/src/playlistwidget.cpp deleted file mode 100644 index 1101e4d..0000000 --- a/src/playlistwidget.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "playlistwidget.h" -#include "segmentedcontrol.h" - -PlaylistWidget::PlaylistWidget (QWidget *parent, SegmentedControl *tabBar, QListView *listView) - : QWidget(parent) { - QBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(tabBar); - layout->addWidget(listView); -} diff --git a/src/playlistwidget.h b/src/playlistwidget.h deleted file mode 100644 index 5e3342c..0000000 --- a/src/playlistwidget.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef PLAYLISTWIDGET_H -#define PLAYLISTWIDGET_H - -#include - -class SegmentedControl; - -class PlaylistWidget : public QWidget { - - Q_OBJECT - -public: - PlaylistWidget(QWidget *parent, SegmentedControl *tabBar, QListView *listView); - -}; - -#endif // PLAYLISTWIDGET_H diff --git a/src/youtubesearch.cpp b/src/youtubesearch.cpp deleted file mode 100644 index 3263525..0000000 --- a/src/youtubesearch.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "youtubesearch.h" -#include "youtubestreamreader.h" -#include "constants.h" -#include "networkaccess.h" - -namespace The { - NetworkAccess* http(); -} - -YouTubeSearch::YouTubeSearch() : QObject() {} - -void YouTubeSearch::search(SearchParams *searchParams, int max, int skip) { - this->abortFlag = false; - - QUrl url("http://gdata.youtube.com/feeds/api/videos/"); - url.addQueryItem("v", "2"); - - url.addQueryItem("max-results", QString::number(max)); - url.addQueryItem("start-index", QString::number(skip)); - - if (!searchParams->keywords().isEmpty()) { - if (searchParams->keywords().startsWith("http://") || - searchParams->keywords().startsWith("https://")) { - url.addQueryItem("q", YouTubeSearch::videoIdFromUrl(searchParams->keywords())); - } else url.addQueryItem("q", searchParams->keywords()); - } - - if (!searchParams->author().isEmpty()) - url.addQueryItem("author", searchParams->author()); - - switch (searchParams->sortBy()) { - case SearchParams::SortByNewest: - url.addQueryItem("orderby", "published"); - break; - case SearchParams::SortByViewCount: - url.addQueryItem("orderby", "viewCount"); - break; - case SearchParams::SortByRating: - url.addQueryItem("orderby", "rating"); - break; - } - - switch (searchParams->duration()) { - case SearchParams::DurationShort: - url.addQueryItem("duration", "short"); - break; - case SearchParams::DurationMedium: - url.addQueryItem("duration", "medium"); - break; - case SearchParams::DurationLong: - url.addQueryItem("duration", "long"); - break; - } - - switch (searchParams->time()) { - case SearchParams::TimeToday: - url.addQueryItem("time", "today"); - break; - case SearchParams::TimeWeek: - url.addQueryItem("time", "this_week"); - break; - case SearchParams::TimeMonth: - url.addQueryItem("time", "this_month"); - break; - } - - switch (searchParams->quality()) { - case SearchParams::QualityHD: - url.addQueryItem("hd", "true"); - break; - } - - QObject *reply = The::http()->get(url); - connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResults(QByteArray))); - connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(error(QNetworkReply*))); - -} - -void YouTubeSearch::error(QNetworkReply *reply) { - emit error(reply->errorString()); -} - -void YouTubeSearch::parseResults(QByteArray data) { - - YouTubeStreamReader reader; - if (!reader.read(data)) { - qDebug() << "Error parsing XML"; - } - videos = reader.getVideos(); - suggestions = reader.getSuggestions(); - - foreach (Video *video, videos) { - // send it to the model - emit gotVideo(video); - } - - foreach (Video *video, videos) { - // preload the thumb - if (abortFlag) return; - video->preloadThumbnail(); - } - - emit finished(videos.size()); -} - -QList YouTubeSearch::getResults() { - return videos; -} - -const QStringList & YouTubeSearch::getSuggestions() const { - return suggestions; -} - -void YouTubeSearch::abort() { - this->abortFlag = true; -} - -QString YouTubeSearch::videoIdFromUrl(QString url) { - QRegExp re = QRegExp("^.*\\?v=([^&]+).*$"); - if (re.exactMatch(url)) { - QString videoId = re.cap(1); - videoId.remove('-'); - return videoId; - } - return QString(); -} diff --git a/src/youtubesearch.h b/src/youtubesearch.h deleted file mode 100644 index 254ea02..0000000 --- a/src/youtubesearch.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef YOUTUBESEARCH_H -#define YOUTUBESEARCH_H - -#include "video.h" -#include "searchparams.h" - -class YouTubeSearch : public QObject { - - Q_OBJECT - -public: - YouTubeSearch(); - void search(SearchParams *searchParams, int max, int skip); - void abort(); - QList getResults(); - const QStringList & getSuggestions() const; - static QString videoIdFromUrl(QString url); - -signals: - void gotVideo(Video*); - void finished(int total); - void error(QString message); - -private slots: - void parseResults(QByteArray data); - void error(QNetworkReply *reply); - -private: - - QList videos; - QStringList suggestions; - - bool abortFlag; - -}; - -#endif // YOUTUBESEARCH_H diff --git a/src/youtubestreamreader.cpp b/src/ytfeedreader.cpp similarity index 100% rename from src/youtubestreamreader.cpp rename to src/ytfeedreader.cpp diff --git a/src/youtubestreamreader.h b/src/ytfeedreader.h similarity index 100% rename from src/youtubestreamreader.h rename to src/ytfeedreader.h diff --git a/src/youtubesuggest.cpp b/src/ytsuggester.cpp similarity index 100% rename from src/youtubesuggest.cpp rename to src/ytsuggester.cpp diff --git a/src/youtubesuggest.h b/src/ytsuggester.h similarity index 100% rename from src/youtubesuggest.h rename to src/ytsuggester.h -- 2.39.5