From 9277680c902cc6fcf05aeda3773ecec792a9930e Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Sun, 17 May 2015 11:11:53 +0200 Subject: [PATCH] More const references everywhere --- src/aggregatevideosource.h | 2 +- src/database.cpp | 4 ++-- src/database.h | 4 ++-- src/iconutils.cpp | 4 ++-- src/loadingwidget.cpp | 2 +- src/loadingwidget.h | 2 +- src/mainwindow.cpp | 10 +++++----- src/mainwindow.h | 10 +++++----- src/mediaview.cpp | 4 ++-- src/mediaview.h | 4 ++-- src/painterutils.cpp | 2 +- src/painterutils.h | 2 +- src/playlistmodel.cpp | 6 +++--- src/playlistmodel.h | 2 +- src/refinesearchwidget.cpp | 12 ++++++------ src/refinesearchwidget.h | 4 ++-- src/searchparams.cpp | 2 +- src/searchparams.h | 2 +- src/searchview.cpp | 27 ++++++++++++--------------- src/searchview.h | 4 ++-- src/sidebarheader.cpp | 4 ++-- src/sidebarheader.h | 4 ++-- src/sidebarwidget.cpp | 2 +- src/standardfeedsview.cpp | 3 +-- src/standardfeedsview.h | 2 +- src/temporary.cpp | 2 +- src/video.cpp | 8 ++++---- src/video.h | 2 +- src/videoareawidget.cpp | 2 +- src/videoareawidget.h | 2 +- src/videosource.cpp | 2 +- src/videosource.h | 2 +- src/ytregions.cpp | 8 ++++---- src/ytregions.h | 8 ++++---- src/ytsearch.cpp | 2 +- src/ytsearch.h | 2 +- src/ytsinglevideosource.h | 2 +- src/ytstandardfeed.h | 10 +++++----- 38 files changed, 86 insertions(+), 90 deletions(-) diff --git a/src/aggregatevideosource.h b/src/aggregatevideosource.h index 55aa730..6263c43 100644 --- a/src/aggregatevideosource.h +++ b/src/aggregatevideosource.h @@ -35,7 +35,7 @@ public: 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: diff --git a/src/database.cpp b/src/database.cpp index e49133b..0e1059f 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -144,7 +144,7 @@ QSqlDatabase Database::getConnection() { } } -QVariant Database::getAttribute(QString name) { +QVariant Database::getAttribute(const QString &name) { QSqlQuery query("select value from attributes where name=?", getConnection()); query.bindValue(0, name); @@ -155,7 +155,7 @@ QVariant Database::getAttribute(QString 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); diff --git a/src/database.h b/src/database.h index e5133fc..3012a0f 100644 --- a/src/database.h +++ b/src/database.h @@ -42,8 +42,8 @@ private: 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(); diff --git a/src/iconutils.cpp b/src/iconutils.cpp index de75631..6b0f61e 100644 --- a/src/iconutils.cpp +++ b/src/iconutils.cpp @@ -52,7 +52,7 @@ QIcon IconUtils::icon(const QString &name) { 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; } @@ -63,7 +63,7 @@ QIcon IconUtils::tintedIcon(const QString &name, const QColor &color, QListsetText(tr("Error")); descriptionLabel->setText(message); // progressBar->hide(); diff --git a/src/loadingwidget.h b/src/loadingwidget.h index 4c7a2d3..21f0f19 100644 --- a/src/loadingwidget.h +++ b/src/loadingwidget.h @@ -34,7 +34,7 @@ class LoadingWidget : public QWidget { public: LoadingWidget(QWidget *parent); void setVideo(Video *video); - void setError(QString message); + void setError(const QString &message); void clear(); public slots: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5ddaf12..65d3627 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1461,7 +1461,7 @@ void MainWindow::volumeMutedChanged(bool muted) { #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()) @@ -1520,7 +1520,7 @@ void MainWindow::setManualPlay(bool enabled) { showActionInStatusBar(The::globalActions()->value("manualplay"), enabled); } -void MainWindow::updateDownloadMessage(QString message) { +void MainWindow::updateDownloadMessage(const QString &message) { The::globalActions()->value("downloads")->setText(message); } @@ -1609,7 +1609,7 @@ void MainWindow::checkForUpdate() { settings.setValue(updateCheckKey, unixTime); } -void MainWindow::gotNewVersion(QString version) { +void MainWindow::gotNewVersion(const QString &version) { if (updateChecker) { delete updateChecker; updateChecker = 0; @@ -1629,7 +1629,7 @@ void MainWindow::gotNewVersion(QString version) { #endif } -void MainWindow::simpleUpdateDialog(QString version) { +void MainWindow::simpleUpdateDialog(const QString &version) { QMessageBox msgBox(this); msgBox.setIconPixmap( QPixmap(":/images/app.png") @@ -1718,7 +1718,7 @@ void MainWindow::printHelp() { std::cout << msg.toLocal8Bit().data(); } -void MainWindow::showMessage(QString message) { +void MainWindow::showMessage(const QString &message) { statusBar()->showMessage(message, 60000); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 1c76171..7e593a0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -76,7 +76,7 @@ public slots: 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(); @@ -97,7 +97,7 @@ protected: private slots: void lazyInit(); void checkForUpdate(); - void gotNewVersion(QString version); + void gotNewVersion(const QString &version); void visitSite(); void donate(); void reportIssue(); @@ -112,7 +112,7 @@ private slots: void searchFocus(); void tick(qint64 time); void totalTimeChanged(qint64 time); - void setDefinitionMode(QString definitionName); + void setDefinitionMode(const QString &definitionName); void toggleDefinitionMode(); void clearRecentKeywords(); @@ -128,7 +128,7 @@ private slots: void showFullscreenPlaylist(bool show); void setManualPlay(bool enabled); - void updateDownloadMessage(QString); + void updateDownloadMessage(const QString &); void downloadsFinished(); void toggleDownloads(bool show); @@ -152,7 +152,7 @@ private: void showWidget(QWidget*, bool transition = true); static QString formatTime(qint64 time); bool confirmQuit(); - void simpleUpdateDialog(QString version); + void simpleUpdateDialog(const QString &version); UpdateChecker *updateChecker; diff --git a/src/mediaview.cpp b/src/mediaview.cpp index 4d191fd..f3837fd 100644 --- a/src/mediaview.cpp +++ b/src/mediaview.cpp @@ -307,7 +307,7 @@ void MediaView::disappear() { } -void MediaView::handleError(QString message) { +void MediaView::handleError(const QString &message) { qWarning() << __PRETTY_FUNCTION__ << message; #ifdef APP_PHONON_SEEK mediaObject->play(); @@ -341,7 +341,7 @@ void MediaView::pause() { #endif } -QRegExp MediaView::wordRE(QString s) { +QRegExp MediaView::wordRE(const QString &s) { return QRegExp("\\W" + s + "\\W?", Qt::CaseInsensitive); } diff --git a/src/mediaview.h b/src/mediaview.h index 84146d7..b46bfd7 100644 --- a/src/mediaview.h +++ b/src/mediaview.h @@ -113,7 +113,7 @@ private slots: void activeRowChanged(int); void selectVideos(QList 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); @@ -137,7 +137,7 @@ private: MediaView(QWidget *parent = 0); SearchParams* getSearchParams(); - static QRegExp wordRE(QString s); + static QRegExp wordRE(const QString &s); QSplitter *splitter; SidebarWidget *sidebar; diff --git a/src/painterutils.cpp b/src/painterutils.cpp index 54f4cbd..097eac2 100644 --- a/src/painterutils.cpp +++ b/src/painterutils.cpp @@ -23,7 +23,7 @@ $END_LICENSE */ 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)); diff --git a/src/painterutils.h b/src/painterutils.h index 26bdbab..2ff86f2 100644 --- a/src/painterutils.h +++ b/src/painterutils.h @@ -29,7 +29,7 @@ $END_LICENSE */ 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); diff --git a/src/playlistmodel.cpp b/src/playlistmodel.cpp index eb8a2dd..264f6ec 100644 --- a/src/playlistmodel.cpp +++ b/src/playlistmodel.cpp @@ -232,7 +232,7 @@ void PlaylistModel::searchFinished(int total) { 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 ) ); @@ -340,7 +340,7 @@ bool PlaylistModel::removeRows(int position, int rows, const QModelIndex & /*par void PlaylistModel::removeIndexes(QModelIndexList &indexes) { QList originalList(videos); QList 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); @@ -464,7 +464,7 @@ QModelIndex PlaylistModel::indexForVideo(Video* video) { void PlaylistModel::move(QModelIndexList &indexes, bool up) { QList movedVideos; - foreach (QModelIndex index, indexes) { + foreach (const QModelIndex &index, indexes) { int row = index.row(); if (row >= videos.size()) continue; // qDebug() << "index row" << row; diff --git a/src/playlistmodel.h b/src/playlistmodel.h index 2123bd2..82ffcf6 100644 --- a/src/playlistmodel.h +++ b/src/playlistmodel.h @@ -90,7 +90,7 @@ public slots: void searchNeeded(); void addVideos(QList newVideos); void searchFinished(int total); - void searchError(QString message); + void searchError(const QString &message); void updateVideoSender(); void emitDataChanged(); diff --git a/src/refinesearchwidget.cpp b/src/refinesearchwidget.cpp index cba9079..3518d71 100644 --- a/src/refinesearchwidget.cpp +++ b/src/refinesearchwidget.cpp @@ -57,7 +57,7 @@ void RefineSearchWidget::setup() { << 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()); @@ -78,7 +78,7 @@ void RefineSearchWidget::setup() { << 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()); @@ -104,7 +104,7 @@ void RefineSearchWidget::setup() { << 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); @@ -127,7 +127,7 @@ void RefineSearchWidget::setup() { << "" << 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); @@ -151,7 +151,7 @@ void RefineSearchWidget::setup() { 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); @@ -181,7 +181,7 @@ void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString pa 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); diff --git a/src/refinesearchwidget.h b/src/refinesearchwidget.h index 809d388..efed109 100644 --- a/src/refinesearchwidget.h +++ b/src/refinesearchwidget.h @@ -53,8 +53,8 @@ private slots: 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 bars; bool dirty; diff --git a/src/searchparams.cpp b/src/searchparams.cpp index 17a8dfa..47ab4de 100644 --- a/src/searchparams.cpp +++ b/src/searchparams.cpp @@ -29,7 +29,7 @@ SearchParams::SearchParams(QObject *parent) : QObject(parent) { 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(); } diff --git a/src/searchparams.h b/src/searchparams.h index f55dceb..c408c89 100644 --- a/src/searchparams.h +++ b/src/searchparams.h @@ -91,7 +91,7 @@ public: } public slots: - void setParam(QString name, QVariant value); + void setParam(const QString &name, const QVariant &value); private: QString m_keywords; diff --git a/src/searchview.cpp b/src/searchview.cpp index a0037a3..1e6e5a2 100644 --- a/src/searchview.cpp +++ b/src/searchview.cpp @@ -223,7 +223,7 @@ void SearchView::updateRecentKeywords() { 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://")) { @@ -271,7 +271,7 @@ void SearchView::updateRecentChannels() { 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('|'); @@ -304,24 +304,22 @@ void SearchView::textChanged(const QString &text) { 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); } @@ -348,9 +346,8 @@ void SearchView::watchChannel(const QString &channelId) { 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) { @@ -359,12 +356,12 @@ void SearchView::watchKeywords(QString query) { } 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); diff --git a/src/searchview.h b/src/searchview.h index a8022b6..f069d44 100644 --- a/src/searchview.h +++ b/src/searchview.h @@ -45,9 +45,9 @@ public: 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*); diff --git a/src/sidebarheader.cpp b/src/sidebarheader.cpp index ea8c14d..b4ab622 100644 --- a/src/sidebarheader.cpp +++ b/src/sidebarheader.cpp @@ -98,12 +98,12 @@ void SidebarHeader::updateInfo() { 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(); diff --git a/src/sidebarheader.h b/src/sidebarheader.h index 0ac551e..c0713f1 100644 --- a/src/sidebarheader.h +++ b/src/sidebarheader.h @@ -39,11 +39,11 @@ protected: 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; diff --git a/src/sidebarwidget.cpp b/src/sidebarwidget.cpp index fd5fd40..3149b47 100644 --- a/src/sidebarwidget.cpp +++ b/src/sidebarwidget.cpp @@ -163,7 +163,7 @@ void SidebarWidget::showSuggestions(const QStringList &suggestions) { QString message = tr("Did you mean: %1"); QString suggestionLinks; - foreach (QString suggestion, suggestions) { + foreach (const QString &suggestion, suggestions) { suggestionLinks += "" + suggestion + " "; } message = message.arg(suggestionLinks); diff --git a/src/standardfeedsview.cpp b/src/standardfeedsview.cpp index 0f03564..7f62c32 100644 --- a/src/standardfeedsview.cpp +++ b/src/standardfeedsview.cpp @@ -114,8 +114,7 @@ QList StandardFeedsView::getMainFeeds() { 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); diff --git a/src/standardfeedsview.h b/src/standardfeedsview.h index 94a2be4..066035c 100644 --- a/src/standardfeedsview.h +++ b/src/standardfeedsview.h @@ -57,7 +57,7 @@ private slots: private: void addVideoSourceWidget(VideoSource *videoSource); QList getMainFeeds(); - YTStandardFeed* buildStardardFeed(QString feedId, QString label, QString time = QString()); + YTStandardFeed* buildStardardFeed(const QString &feedId, const QString &label, QString time = QString()); QGridLayout *layout; }; diff --git a/src/temporary.cpp b/src/temporary.cpp index 7fd978c..9c00215 100644 --- a/src/temporary.cpp +++ b/src/temporary.cpp @@ -64,7 +64,7 @@ QString Temporary::filename() { } 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; } diff --git a/src/video.cpp b/src/video.cpp index 4e2192d..41e8c01 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -201,7 +201,7 @@ void Video::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) { // qDebug() << "fmtUrlMap" << fmtUrlMap; const QStringList formatUrls = fmtUrlMap.split(',', QString::SkipEmptyParts); QHash urlMap; - foreach(QString formatUrl, formatUrls) { + foreach(const QString &formatUrl, formatUrls) { // qDebug() << "formatUrl" << formatUrl; const QStringList urlParams = formatUrl.split('&', QString::SkipEmptyParts); // qDebug() << "urlParams" << urlParams; @@ -209,7 +209,7 @@ void Video::parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage) { 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("="); @@ -449,12 +449,12 @@ void Video::captureObject(const QString &name, const QString &js) { 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(); diff --git a/src/video.h b/src/video.h index de2c1b5..d502cb2 100644 --- a/src/video.h +++ b/src/video.h @@ -82,7 +82,7 @@ public: 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; } diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp index 2c6b055..7999bce 100644 --- a/src/videoareawidget.cpp +++ b/src/videoareawidget.cpp @@ -76,7 +76,7 @@ void VideoAreaWidget::showVideo() { loadingWidget->clear(); } -void VideoAreaWidget::showError(QString message) { +void VideoAreaWidget::showError(const QString &message) { // loadingWidget->setError(message); messageLabel->setText(message); messageLabel->show(); diff --git a/src/videoareawidget.h b/src/videoareawidget.h index e40d38f..866c903 100644 --- a/src/videoareawidget.h +++ b/src/videoareawidget.h @@ -41,7 +41,7 @@ public: 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; diff --git a/src/videosource.cpp b/src/videosource.cpp index 6f08656..6ca33cf 100644 --- a/src/videosource.cpp +++ b/src/videosource.cpp @@ -20,7 +20,7 @@ $END_LICENSE */ #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(); } diff --git a/src/videosource.h b/src/videosource.h index 458d120..e2da4d4 100644 --- a/src/videosource.h +++ b/src/videosource.h @@ -40,7 +40,7 @@ public: virtual QList getActions() { return QList(); } public slots: - void setParam(QString name, QVariant value); + void setParam(const QString &name, const QVariant &value); signals: void gotVideos(QList videos); diff --git a/src/ytregions.cpp b/src/ytregions.cpp index b05cf6c..ed5dc46 100644 --- a/src/ytregions.cpp +++ b/src/ytregions.cpp @@ -126,7 +126,7 @@ const QList & YTRegions::list() { return list; } -YTRegion YTRegions::r(QString name, QString id) { +YTRegion YTRegions::r(const QString &name, const QString &id) { YTRegion r = {id, name}; return r; } @@ -149,7 +149,7 @@ const YTRegion & YTRegions::worldwideRegion() { return region; } -void YTRegions::setRegion(QString regionId) { +void YTRegions::setRegion(const QString ®ionId) { QSettings settings; settings.setValue("regionId", regionId); } @@ -163,7 +163,7 @@ YTRegion YTRegions::currentRegion() { 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()) @@ -175,7 +175,7 @@ YTRegion YTRegions::regionById(QString id) { 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"); } diff --git a/src/ytregions.h b/src/ytregions.h index 1ea5e89..c0d7e4e 100644 --- a/src/ytregions.h +++ b/src/ytregions.h @@ -42,14 +42,14 @@ public: static const QList & 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(); }; diff --git a/src/ytsearch.cpp b/src/ytsearch.cpp index 30e7852..7274d89 100644 --- a/src/ytsearch.cpp +++ b/src/ytsearch.cpp @@ -281,7 +281,7 @@ void YTSearch::requestError(QNetworkReply *reply) { 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("^.*://.*/([^&#\\?]+).*$"); diff --git a/src/ytsearch.h b/src/ytsearch.h index be2a0c1..dae1638 100644 --- a/src/ytsearch.h +++ b/src/ytsearch.h @@ -39,7 +39,7 @@ public: QString getName(); QList 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(); diff --git a/src/ytsinglevideosource.h b/src/ytsinglevideosource.h index dc869a6..caf23b5 100644 --- a/src/ytsinglevideosource.h +++ b/src/ytsinglevideosource.h @@ -35,7 +35,7 @@ public: 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: diff --git a/src/ytstandardfeed.h b/src/ytstandardfeed.h index b1b64e9..4bd4721 100644 --- a/src/ytstandardfeed.h +++ b/src/ytstandardfeed.h @@ -32,19 +32,19 @@ public: 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(); -- 2.39.5