virtual void abort();
virtual const QStringList & getSuggestions();
QString getName() { return name; }
- void setName(QString name) { this->name = name; }
+ void setName(const QString &value) { name = value; }
void setUnwatched(bool enable) { unwatched = enable; }
private:
}
}
-QVariant Database::getAttribute(QString name) {
+QVariant Database::getAttribute(const QString &name) {
QSqlQuery query("select value from attributes where name=?", getConnection());
query.bindValue(0, name);
return QVariant();
}
-void Database::setAttribute(QString name, QVariant value) {
+void Database::setAttribute(const QString &name, const QVariant &value) {
QSqlQuery query(getConnection());
query.prepare("insert or replace into attributes (name, value) values (?,?)");
query.bindValue(0, name);
Database();
static QString getDbLocation();
void createDatabase();
- QVariant getAttribute(QString name);
- void setAttribute(QString name, QVariant value);
+ QVariant getAttribute(const QString &name);
+ void setAttribute(const QString &name, const QVariant &value);
void fixChannelIds();
QIcon IconUtils::icon(const QStringList &names) {
QIcon icon;
- foreach (QString name, names) {
+ foreach (const QString &name, names) {
icon = IconUtils::icon(name);
if (!icon.availableSizes().isEmpty()) break;
}
QIcon i = IconUtils::icon(name);
QIcon t;
if (sizes.isEmpty()) sizes = i.availableSizes();
- foreach (QSize size, sizes) {
+ foreach (const QSize &size, sizes) {
QPixmap pixmap = i.pixmap(size);
QImage tintedImage = tinted(pixmap.toImage(), color);
t.addPixmap(QPixmap::fromImage(tintedImage));
startTime.start();
}
-void LoadingWidget::setError(QString message) {
+void LoadingWidget::setError(const QString &message) {
titleLabel->setText(tr("Error"));
descriptionLabel->setText(message);
// progressBar->hide();
public:
LoadingWidget(QWidget *parent);
void setVideo(Video *video);
- void setError(QString message);
+ void setError(const QString &message);
void clear();
public slots:
#endif
}
-void MainWindow::setDefinitionMode(QString definitionName) {
+void MainWindow::setDefinitionMode(const QString &definitionName) {
QAction *definitionAct = The::globalActions()->value("definition");
definitionAct->setText(definitionName);
definitionAct->setStatusTip(tr("Maximum video definition set to %1").arg(definitionAct->text())
showActionInStatusBar(The::globalActions()->value("manualplay"), enabled);
}
-void MainWindow::updateDownloadMessage(QString message) {
+void MainWindow::updateDownloadMessage(const QString &message) {
The::globalActions()->value("downloads")->setText(message);
}
settings.setValue(updateCheckKey, unixTime);
}
-void MainWindow::gotNewVersion(QString version) {
+void MainWindow::gotNewVersion(const QString &version) {
if (updateChecker) {
delete updateChecker;
updateChecker = 0;
#endif
}
-void MainWindow::simpleUpdateDialog(QString version) {
+void MainWindow::simpleUpdateDialog(const QString &version) {
QMessageBox msgBox(this);
msgBox.setIconPixmap(
QPixmap(":/images/app.png")
std::cout << msg.toLocal8Bit().data();
}
-void MainWindow::showMessage(QString message) {
+void MainWindow::showMessage(const QString &message) {
statusBar()->showMessage(message, 60000);
}
void suggestionAccepted(Suggestion *suggestion);
void search(const QString &query);
void goBack();
- void showMessage(QString message);
+ void showMessage(const QString &message);
#ifdef APP_ACTIVATION
void showActivationView(bool transition = true);
void showActivationDialog();
private slots:
void lazyInit();
void checkForUpdate();
- void gotNewVersion(QString version);
+ void gotNewVersion(const QString &version);
void visitSite();
void donate();
void reportIssue();
void searchFocus();
void tick(qint64 time);
void totalTimeChanged(qint64 time);
- void setDefinitionMode(QString definitionName);
+ void setDefinitionMode(const QString &definitionName);
void toggleDefinitionMode();
void clearRecentKeywords();
void showFullscreenPlaylist(bool show);
void setManualPlay(bool enabled);
- void updateDownloadMessage(QString);
+ void updateDownloadMessage(const QString &);
void downloadsFinished();
void toggleDownloads(bool show);
void showWidget(QWidget*, bool transition = true);
static QString formatTime(qint64 time);
bool confirmQuit();
- void simpleUpdateDialog(QString version);
+ void simpleUpdateDialog(const QString &version);
UpdateChecker *updateChecker;
}
-void MediaView::handleError(QString message) {
+void MediaView::handleError(const QString &message) {
qWarning() << __PRETTY_FUNCTION__ << message;
#ifdef APP_PHONON_SEEK
mediaObject->play();
#endif
}
-QRegExp MediaView::wordRE(QString s) {
+QRegExp MediaView::wordRE(const QString &s) {
return QRegExp("\\W" + s + "\\W?", Qt::CaseInsensitive);
}
void activeRowChanged(int);
void selectVideos(QList<Video*> videos);
void gotStreamUrl(QUrl streamUrl);
- void handleError(QString message);
+ void handleError(const QString &message);
// phonon
#ifdef APP_PHONON
void stateChanged(Phonon::State newState, Phonon::State oldState);
MediaView(QWidget *parent = 0);
SearchParams* getSearchParams();
- static QRegExp wordRE(QString s);
+ static QRegExp wordRE(const QString &s);
QSplitter *splitter;
SidebarWidget *sidebar;
PainterUtils::PainterUtils() { }
-void PainterUtils::centeredMessage(QString message, QWidget* widget) {
+void PainterUtils::centeredMessage(const QString &message, QWidget* widget) {
QPainter painter(widget);
painter.setFont(FontUtils::big());
QSize textSize(QFontMetrics(painter.font()).size(Qt::TextSingleLine, message));
class PainterUtils {
public:
- static void centeredMessage(QString message, QWidget* widget);
+ static void centeredMessage(const QString &message, QWidget* widget);
static void topShadow(QWidget *widget);
static void paintBadge(QPainter *painter, const QString &text, bool center = false);
handleFirstVideo(videos.first());
}
-void PlaylistModel::searchError(QString message) {
+void PlaylistModel::searchError(const QString &message) {
errorMessage = message;
// update the message item
emit dataChanged( createIndex( maxItems, 0 ), createIndex( maxItems, columnCount() - 1 ) );
void PlaylistModel::removeIndexes(QModelIndexList &indexes) {
QList<Video*> originalList(videos);
QList<Video*> delitems;
- foreach (QModelIndex index, indexes) {
+ foreach (const QModelIndex &index, indexes) {
if (index.row() >= originalList.size()) continue;
Video* video = originalList.at(index.row());
int idx = videos.indexOf(video);
void PlaylistModel::move(QModelIndexList &indexes, bool up) {
QList<Video*> movedVideos;
- foreach (QModelIndex index, indexes) {
+ foreach (const QModelIndex &index, indexes) {
int row = index.row();
if (row >= videos.size()) continue;
// qDebug() << "index row" << row;
void searchNeeded();
void addVideos(QList<Video*> newVideos);
void searchFinished(int total);
- void searchError(QString message);
+ void searchError(const QString &message);
void updateVideoSender();
void emitDataChanged();
<< tr("View Count")
<< tr("Rating");
int i = 0;
- foreach (QString actionName, sortOptions) {
+ foreach (const QString &actionName, sortOptions) {
QAction *action = new QAction(actionName, sortBar);
action->setCheckable(true);
action->setFont(FontUtils::medium());
<< tr("7 Days")
<< tr("30 Days");
i = 0;
- foreach (QString actionName, timeSpans) {
+ foreach (const QString &actionName, timeSpans) {
QAction *action = new QAction(actionName, timeBar);
action->setCheckable(true);
action->setFont(FontUtils::medium());
<< tr("Between 4 and 20 minutes")
<< tr("Longer than 20 minutes");
i = 0;
- foreach (QString actionName, lengthOptions) {
+ foreach (const QString &actionName, lengthOptions) {
QAction *action = new QAction(actionName, timeBar);
action->setStatusTip(tips.at(i));
action->setCheckable(true);
<< ""
<< tr("720p or higher");
i = 0;
- foreach (QString actionName, qualityOptions) {
+ foreach (const QString &actionName, qualityOptions) {
QAction *action = new QAction(actionName, timeBar);
action->setStatusTip(tips.at(i));
action->setCheckable(true);
layout->addWidget(doneButton, 0, Qt::AlignLeft);
}
-void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString paramName) {
+void RefineSearchWidget::setupLabel(const QString &text, QBoxLayout *layout, const QString ¶mName) {
QBoxLayout* hLayout = new QHBoxLayout();
hLayout->setSpacing(8);
hLayout->setMargin(0);
layout->addLayout(hLayout);
}
-QToolBar* RefineSearchWidget::setupBar(QString paramName) {
+QToolBar* RefineSearchWidget::setupBar(const QString ¶mName) {
QToolBar* bar = new QToolBar(this);
bar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// bar->setProperty("segmented", true);
private:
void setup();
- void setupLabel(QString text, QBoxLayout* layout, QString paramName);
- QToolBar *setupBar(QString paramName);
+ void setupLabel(const QString &text, QBoxLayout* layout, const QString ¶mName);
+ QToolBar *setupBar(const QString ¶mName);
QHash<QString, QToolBar*> bars;
bool dirty;
m_publishedAfter = 0;
}
-void SearchParams::setParam(QString name, QVariant value) {
+void SearchParams::setParam(const QString &name, const QVariant &value) {
bool success = setProperty(name.toUtf8(), value);
if (!success) qWarning() << "Failed to set property" << name << value.toString();
}
}
public slots:
- void setParam(QString name, QVariant value);
+ void setParam(const QString &name, const QVariant &value);
private:
QString m_keywords;
recentKeywordsLabel->setVisible(!keywords.isEmpty());
The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
- foreach (QString keyword, keywords) {
+ foreach (const QString &keyword, keywords) {
QString link = keyword;
QString display = keyword;
if (keyword.startsWith("http://") || keyword.startsWith("https://")) {
recentChannelsLabel->setVisible(!keywords.isEmpty());
// TODO The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
- foreach (QString keyword, keywords) {
+ foreach (const QString &keyword, keywords) {
QString link = keyword;
QString display = keyword;
int separator = keyword.indexOf('|');
watchButton->setEnabled(!text.simplified().isEmpty());
}
-void SearchView::watch(QString query) {
-
- query = query.simplified();
+void SearchView::watch(const QString &query) {
+ QString q = query.simplified();
// check for empty query
- if (query.length() == 0) {
+ if (q.length() == 0) {
queryEdit->setFocus(Qt::OtherFocusReason);
return;
}
SearchParams *searchParams = new SearchParams();
if (typeCombo->currentIndex() == 0)
- searchParams->setKeywords(query);
+ searchParams->setKeywords(q);
else {
// remove spaces from channel name
- query = query.simplified();
- query = query.remove(' ');
- searchParams->setChannelId(query);
+ q.remove(' ');
+ searchParams->setChannelId(q);
searchParams->setSortBy(SearchParams::SortByNewest);
}
emit search(searchParams);
}
-void SearchView::watchKeywords(QString query) {
-
- query = query.simplified();
+void SearchView::watchKeywords(const QString &query) {
+ QString q = query.simplified();
// check for empty query
if (query.length() == 0) {
}
if (typeCombo->currentIndex() == 0) {
- queryEdit->setText(query);
+ queryEdit->setText(q);
watchButton->setEnabled(true);
}
SearchParams *searchParams = new SearchParams();
- searchParams->setKeywords(query);
+ searchParams->setKeywords(q);
// go!
emit search(searchParams);
public slots:
void appear();
void disappear() { }
- void watch(QString query);
+ void watch(const QString &query);
void watchChannel(const QString &channelId);
- void watchKeywords(QString query);
+ void watchKeywords(const QString &query);
signals:
void search(SearchParams*);
setTitle(currentVideoSource->getName());
}
-void SidebarHeader::updateTitle(QString title) {
+void SidebarHeader::updateTitle(const QString &title) {
sender()->disconnect(this);
setTitle(title);
}
-void SidebarHeader::setTitle(QString title) {
+void SidebarHeader::setTitle(const QString &title) {
this->title = title;
update();
void paintEvent(QPaintEvent *event);
private slots:
- void updateTitle(QString title);
+ void updateTitle(const QString &title);
private:
void setup();
- void setTitle(QString title);
+ void setTitle(const QString &title);
QAction *backAction;
QAction * forwardAction;
QString message = tr("Did you mean: %1");
QString suggestionLinks;
- foreach (QString suggestion, suggestions) {
+ foreach (const QString &suggestion, suggestions) {
suggestionLinks += "<a href='" + suggestion + "'>" + suggestion + "</a> ";
}
message = message.arg(suggestionLinks);
return feeds;
}
-YTStandardFeed* StandardFeedsView::buildStardardFeed(
- QString feedId, QString label, QString time) {
+YTStandardFeed* StandardFeedsView::buildStardardFeed(const QString &feedId, const QString &label, QString time) {
YTStandardFeed *feed = new YTStandardFeed(this);
feed->setFeedId(feedId);
feed->setLabel(label);
private:
void addVideoSourceWidget(VideoSource *videoSource);
QList<YTStandardFeed*> getMainFeeds();
- YTStandardFeed* buildStardardFeed(QString feedId, QString label, QString time = QString());
+ YTStandardFeed* buildStardardFeed(const QString &feedId, const QString &label, QString time = QString());
QGridLayout *layout;
};
}
void Temporary::deleteAll() {
- foreach(QString path, paths) {
+ foreach(const QString &path, paths) {
if (QFile::exists(path) && !QFile::remove(path)) {
qDebug() << "Cannot remove temp file" << path;
}
// qDebug() << "fmtUrlMap" << fmtUrlMap;
const QStringList formatUrls = fmtUrlMap.split(',', QString::SkipEmptyParts);
QHash<int, QString> urlMap;
- foreach(QString formatUrl, formatUrls) {
+ foreach(const QString &formatUrl, formatUrls) {
// qDebug() << "formatUrl" << formatUrl;
const QStringList urlParams = formatUrl.split('&', QString::SkipEmptyParts);
// qDebug() << "urlParams" << urlParams;
int format = -1;
QString url;
QString sig;
- foreach(QString urlParam, urlParams) {
+ foreach(const QString &urlParam, urlParams) {
// qWarning() << urlParam;
if (urlParam.startsWith("itag=")) {
int separator = urlParam.indexOf("=");
QString Video::decryptSignature(const QString &s) {
if (sigFuncName.isEmpty()) return QString();
QScriptEngine engine;
- foreach (QString f, sigObjects.values()) {
+ foreach (const QString &f, sigObjects.values()) {
QScriptValue value = engine.evaluate(f);
if (value.isError())
qWarning() << "Error in" << f << value.toString();
}
- foreach (QString f, sigFunctions.values()) {
+ foreach (const QString &f, sigFunctions.values()) {
QScriptValue value = engine.evaluate(f);
if (value.isError())
qWarning() << "Error in" << f << value.toString();
void loadStreamUrl();
const QUrl & getStreamUrl() { return m_streamUrl; }
- void setId(QString id) { videoId = id; }
+ void setId(const QString &value) { videoId = value; }
const QString & id() const { return videoId; }
void setLicense(License license) { m_license = license; }
loadingWidget->clear();
}
-void VideoAreaWidget::showError(QString message) {
+void VideoAreaWidget::showError(const QString &message) {
// loadingWidget->setError(message);
messageLabel->setText(message);
messageLabel->show();
void setLoadingWidget(LoadingWidget *loadingWidget);
void showLoading(Video* video);
void showVideo();
- void showError(QString message);
+ void showError(const QString &message);
void clear();
void setListModel(PlaylistModel *listModel) {
this->listModel = listModel;
#include "videosource.h"
-void VideoSource::setParam(QString name, QVariant value) {
+void VideoSource::setParam(const QString &name, const QVariant &value) {
bool success = setProperty(name.toUtf8(), value);
if (!success) qWarning() << "Failed to set property" << name << value.toString();
}
virtual QList<QAction*> getActions() { return QList<QAction*>(); }
public slots:
- void setParam(QString name, QVariant value);
+ void setParam(const QString &name, const QVariant &value);
signals:
void gotVideos(QList<Video*> videos);
return list;
}
-YTRegion YTRegions::r(QString name, QString id) {
+YTRegion YTRegions::r(const QString &name, const QString &id) {
YTRegion r = {id, name};
return r;
}
return region;
}
-void YTRegions::setRegion(QString regionId) {
+void YTRegions::setRegion(const QString ®ionId) {
QSettings settings;
settings.setValue("regionId", regionId);
}
return regionById(currentRegionId());
}
-YTRegion YTRegions::regionById(QString id) {
+YTRegion YTRegions::regionById(const QString &id) {
if (id.isEmpty()) return worldwideRegion();
YTRegion region;
foreach (YTRegion r, list())
return region;
}
-QIcon YTRegions::iconForRegionId(QString regionId) {
+QIcon YTRegions::iconForRegionId(const QString ®ionId) {
if (regionId.isEmpty()) return QIcon(":images/worldwide.png");
return QIcon(":flags/" + regionId.toLower() + ".png");
}
static const QList<YTRegion> & list();
static const YTRegion & localRegion();
static const YTRegion & worldwideRegion();
- static void setRegion(QString regionId);
+ static void setRegion(const QString ®ionId);
static QString currentRegionId();
static YTRegion currentRegion();
- static QIcon iconForRegionId(QString regionId);
+ static QIcon iconForRegionId(const QString ®ionId);
private:
- static YTRegion r(QString name, QString id);
- static YTRegion regionById(QString id);
+ static YTRegion r(const QString &name, const QString &id);
+ static YTRegion regionById(const QString &id);
YTRegions();
};
emit error(reply->errorString());
}
-QString YTSearch::videoIdFromUrl(QString url) {
+QString YTSearch::videoIdFromUrl(const QString &url) {
QRegExp re = QRegExp("^.*[\\?&]v=([^&#]+).*$");
if (re.exactMatch(url)) return re.cap(1);
re = QRegExp("^.*://.*/([^&#\\?]+).*$");
QString getName();
QList<QAction*> getActions();
SearchParams* getSearchParams() const { return searchParams; }
- static QString videoIdFromUrl(QString url);
+ static QString videoIdFromUrl(const QString &url);
bool operator==(const YTSearch &other) const {
return searchParams == other.getSearchParams();
const QStringList & getSuggestions();
QString getName();
- void setVideoId(QString videoId) { this->videoId = videoId; }
+ void setVideoId(const QString &value) { videoId = value; }
void setVideo(Video *video);
private slots:
YTStandardFeed(QObject *parent = 0);
QString getFeedId() { return feedId; }
- void setFeedId(QString feedId) { this->feedId = feedId; }
+ void setFeedId(const QString &value) { feedId = value; }
QString getRegionId() { return regionId; }
- void setRegionId(QString regionId) { this->regionId = regionId; }
+ void setRegionId(const QString &value) { regionId = value; }
QString getCategory() { return category; }
- void setCategory(QString category) { this->category = category; }
+ void setCategory(const QString &value) { category = value; }
QString getLabel() { return label; }
- void setLabel(QString label) { this->label = label; }
+ void setLabel(const QString &value) { label = value; }
QString getTime() { return time; }
- void setTime(QString time) { this->time = time; }
+ void setTime(const QString &value) { time = value; }
void loadVideos(int max, int startIndex);
void abort();