Commit 993d1bbe authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

more fixes suggested by clazy

parent f5b99ebf
......@@ -41,6 +41,12 @@ class LocalFileListingTests: public QObject
{
Q_OBJECT
public:
LocalFileListingTests(QObject *parent = nullptr) : QObject(parent)
{
}
private:
QHash<QString, QVector<MusicAudioTrack>> mNewTracks;
......
......@@ -51,7 +51,7 @@ Q_SIGNALS:
void databaseReady();
void newTrackFile(MusicAudioTrack newTrack);
void newTrackFile(const MusicAudioTrack &newTrack);
public Q_SLOTS:
......
......@@ -80,7 +80,7 @@ void AbstractFileListing::databaseIsReady()
refreshContent();
}
void AbstractFileListing::newTrackFile(MusicAudioTrack partialTrack)
void AbstractFileListing::newTrackFile(const MusicAudioTrack &partialTrack)
{
const auto &newTrack = scanOneFile(partialTrack.resourceURI());
......@@ -212,7 +212,7 @@ void AbstractFileListing::refreshContent()
triggerRefreshOfContent();
}
MusicAudioTrack AbstractFileListing::scanOneFile(QUrl scanFile)
MusicAudioTrack AbstractFileListing::scanOneFile(const QUrl &scanFile)
{
MusicAudioTrack newTrack;
......
......@@ -44,7 +44,7 @@ public:
Q_SIGNALS:
void tracksList(QList<MusicAudioTrack> tracks, const QHash<QString, QUrl> &covers, QString musicSource);
void tracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers, const QString &musicSource);
void removedTracksList(const QList<QUrl> &removedTracks);
......@@ -58,7 +58,7 @@ public Q_SLOTS:
void databaseIsReady();
void newTrackFile(MusicAudioTrack partialTrack);
void newTrackFile(const MusicAudioTrack &partialTrack);
protected Q_SLOTS:
......@@ -76,7 +76,7 @@ protected:
const QString &sourceName() const;
virtual MusicAudioTrack scanOneFile(QUrl scanFile);
virtual MusicAudioTrack scanOneFile(const QUrl &scanFile);
void watchPath(const QString &pathName);
......
......@@ -40,7 +40,7 @@ int AlbumFilterProxyModel::filterRating() const
return mFilterRating;
}
void AlbumFilterProxyModel::setFilterText(QString filterText)
void AlbumFilterProxyModel::setFilterText(const QString &filterText)
{
if (mFilterText == filterText)
return;
......
......@@ -50,13 +50,13 @@ public:
public Q_SLOTS:
void setFilterText(QString filterText);
void setFilterText(const QString &filterText);
void setFilterRating(int filterRating);
Q_SIGNALS:
void filterTextChanged(QString filterText);
void filterTextChanged(const QString &filterText);
void filterRatingChanged(int filterRating);
......
......@@ -246,7 +246,7 @@ QString AlbumModel::author() const
return d->mAuthor;
}
void AlbumModel::setAlbumData(MusicAlbum album)
void AlbumModel::setAlbumData(const MusicAlbum &album)
{
if (d->mCurrentAlbum == album) {
return;
......@@ -265,7 +265,7 @@ void AlbumModel::setAlbumData(MusicAlbum album)
Q_EMIT albumDataChanged();
}
void AlbumModel::setTitle(QString title)
void AlbumModel::setTitle(const QString &title)
{
if (d->mTitle == title)
return;
......@@ -274,7 +274,7 @@ void AlbumModel::setTitle(QString title)
emit titleChanged();
}
void AlbumModel::setAuthor(QString author)
void AlbumModel::setAuthor(const QString &author)
{
if (d->mAuthor == author)
return;
......@@ -283,7 +283,7 @@ void AlbumModel::setAuthor(QString author)
emit authorChanged();
}
void AlbumModel::albumModified(MusicAlbum modifiedAlbum)
void AlbumModel::albumModified(const MusicAlbum &modifiedAlbum)
{
if (modifiedAlbum.databaseId() != d->mCurrentAlbum.databaseId()) {
return;
......@@ -330,7 +330,7 @@ void AlbumModel::albumModified(MusicAlbum modifiedAlbum)
}
}
void AlbumModel::albumRemoved(MusicAlbum modifiedAlbum)
void AlbumModel::albumRemoved(const MusicAlbum &modifiedAlbum)
{
if (modifiedAlbum.databaseId() != d->mCurrentAlbum.databaseId()) {
return;
......@@ -341,7 +341,7 @@ void AlbumModel::albumRemoved(MusicAlbum modifiedAlbum)
}
}
void AlbumModel::trackAdded(MusicAudioTrack newTrack)
void AlbumModel::trackAdded(const MusicAudioTrack &newTrack)
{
if (newTrack.albumName() != d->mCurrentAlbum.title()) {
return;
......@@ -373,7 +373,7 @@ void AlbumModel::trackAdded(MusicAudioTrack newTrack)
}
}
void AlbumModel::trackModified(MusicAudioTrack modifiedTrack)
void AlbumModel::trackModified(const MusicAudioTrack &modifiedTrack)
{
if (modifiedTrack.albumName() != d->mCurrentAlbum.title()) {
return;
......@@ -389,7 +389,7 @@ void AlbumModel::trackModified(MusicAudioTrack modifiedTrack)
Q_EMIT dataChanged(index(trackIndex, 0), index(trackIndex, 0));
}
void AlbumModel::trackRemoved(MusicAudioTrack removedTrack)
void AlbumModel::trackRemoved(const MusicAudioTrack &removedTrack)
{
if (removedTrack.albumName() != d->mCurrentAlbum.title()) {
return;
......
......@@ -115,23 +115,23 @@ Q_SIGNALS:
public Q_SLOTS:
void setAlbumData(MusicAlbum album);
void setAlbumData(const MusicAlbum &album);
void setTitle(QString title);
void setTitle(const QString &title);
void setAuthor(QString author);
void setAuthor(const QString &author);
void albumModified(MusicAlbum modifiedAlbum);
void albumModified(const MusicAlbum &modifiedAlbum);
void albumRemoved(MusicAlbum modifiedAlbum);
void albumRemoved(const MusicAlbum &modifiedAlbum);
private:
void trackAdded(MusicAudioTrack newTrack);
void trackAdded(const MusicAudioTrack &newTrack);
void trackModified(MusicAudioTrack modifiedTrack);
void trackModified(const MusicAudioTrack &modifiedTrack);
void trackRemoved(MusicAudioTrack removedTrack);
void trackRemoved(const MusicAudioTrack &removedTrack);
QVariant internalDataTrack(const MusicAudioTrack &track, int role, int rowIndex) const;
......
......@@ -205,7 +205,7 @@ int AllAlbumsModel::columnCount(const QModelIndex &parent) const
return 1;
}
void AllAlbumsModel::albumAdded(MusicAlbum newAlbum)
void AllAlbumsModel::albumAdded(const MusicAlbum &newAlbum)
{
if (newAlbum.isValid()) {
beginInsertRows({}, d->mAllAlbums.size(), d->mAllAlbums.size());
......@@ -215,7 +215,7 @@ void AllAlbumsModel::albumAdded(MusicAlbum newAlbum)
}
}
void AllAlbumsModel::albumRemoved(MusicAlbum removedAlbum)
void AllAlbumsModel::albumRemoved(const MusicAlbum &removedAlbum)
{
auto removedAlbumIterator = std::find(d->mAllAlbums.begin(), d->mAllAlbums.end(), removedAlbum);
......@@ -231,7 +231,7 @@ void AllAlbumsModel::albumRemoved(MusicAlbum removedAlbum)
endRemoveRows();
}
void AllAlbumsModel::albumModified(MusicAlbum modifiedAlbum)
void AllAlbumsModel::albumModified(const MusicAlbum &modifiedAlbum)
{
auto modifiedAlbumIterator = std::find(d->mAllAlbums.begin(), d->mAllAlbums.end(), modifiedAlbum);
......
......@@ -73,11 +73,11 @@ public:
public Q_SLOTS:
void albumAdded(MusicAlbum newAlbum);
void albumAdded(const MusicAlbum &newAlbum);
void albumRemoved(MusicAlbum removedAlbum);
void albumRemoved(const MusicAlbum &removedAlbum);
void albumModified(MusicAlbum modifiedAlbum);
void albumModified(const MusicAlbum &modifiedAlbum);
private:
......
......@@ -167,7 +167,7 @@ int AllArtistsModel::columnCount(const QModelIndex &parent) const
return 1;
}
void AllArtistsModel::artistAdded(MusicArtist newArtist)
void AllArtistsModel::artistAdded(const MusicArtist &newArtist)
{
if (newArtist.isValid()) {
beginInsertRows({}, d->mAllArtists.size(), d->mAllArtists.size());
......@@ -177,7 +177,7 @@ void AllArtistsModel::artistAdded(MusicArtist newArtist)
}
}
void AllArtistsModel::artistRemoved(MusicArtist removedArtist)
void AllArtistsModel::artistRemoved(const MusicArtist &removedArtist)
{
auto removedArtistIterator = std::find(d->mAllArtists.begin(), d->mAllArtists.end(), removedArtist);
......@@ -193,7 +193,7 @@ void AllArtistsModel::artistRemoved(MusicArtist removedArtist)
endRemoveRows();
}
void AllArtistsModel::artistModified(MusicArtist modifiedArtist)
void AllArtistsModel::artistModified(const MusicArtist &modifiedArtist)
{
Q_UNUSED(modifiedArtist);
}
......
......@@ -65,11 +65,11 @@ public:
public Q_SLOTS:
void artistAdded(MusicArtist newArtist);
void artistAdded(const MusicArtist &newArtist);
void artistRemoved(MusicArtist removedArtist);
void artistRemoved(const MusicArtist &removedArtist);
void artistModified(MusicArtist modifiedArtist);
void artistModified(const MusicArtist &modifiedArtist);
private:
......
......@@ -112,7 +112,7 @@ void AudioWrapper::setVolume(int volume)
d->mPlayer.setVolume(volume);
}
void AudioWrapper::setSource(QUrl source)
void AudioWrapper::setSource(const QUrl &source)
{
d->mPlayer.setMedia({source});
}
......
......@@ -136,7 +136,7 @@ public Q_SLOTS:
void setVolume(int volume);
void setSource(QUrl source);
void setSource(const QUrl &source);
void setPosition(qint64 position);
......
......@@ -64,7 +64,7 @@ LocalBalooFileListing::~LocalBalooFileListing()
{
}
void LocalBalooFileListing::newBalooFile(QString fileName)
void LocalBalooFileListing::newBalooFile(const QString &fileName)
{
auto newFile = QUrl::fromLocalFile(fileName);
......@@ -120,7 +120,7 @@ void LocalBalooFileListing::triggerRefreshOfContent()
}
}
MusicAudioTrack LocalBalooFileListing::scanOneFile(QUrl scanFile)
MusicAudioTrack LocalBalooFileListing::scanOneFile(const QUrl &scanFile)
{
auto newTrack = MusicAudioTrack();
......
......@@ -50,7 +50,7 @@ public Q_SLOTS:
private Q_SLOTS:
void newBalooFile(QString fileName);
void newBalooFile(const QString &fileName);
private:
......@@ -58,7 +58,7 @@ private:
void triggerRefreshOfContent() override;
MusicAudioTrack scanOneFile(QUrl scanFile) override;
MusicAudioTrack scanOneFile(const QUrl &scanFile) override;
std::unique_ptr<LocalBalooFileListingPrivate> d;
......
......@@ -37,7 +37,7 @@ class DatabaseInterfacePrivate
{
public:
DatabaseInterfacePrivate(QSqlDatabase tracksDatabase)
DatabaseInterfacePrivate(const QSqlDatabase &tracksDatabase)
: mTracksDatabase(tracksDatabase), mSelectAlbumQuery(mTracksDatabase),
mSelectTrackQuery(mTracksDatabase), mSelectAlbumIdFromTitleQuery(mTracksDatabase),
mInsertAlbumQuery(mTracksDatabase), mSelectTrackIdFromTitleAlbumIdArtistQuery(mTracksDatabase),
......@@ -180,7 +180,7 @@ void DatabaseInterface::init(const QString &dbName, const QString &databaseFileN
}
}
MusicAlbum DatabaseInterface::albumFromTitle(QString title)
MusicAlbum DatabaseInterface::albumFromTitle(const QString &title)
{
auto result = MusicAlbum();
......@@ -252,7 +252,7 @@ QList<MusicAudioTrack> DatabaseInterface::allTracks() const
return result;
}
QList<MusicAudioTrack> DatabaseInterface::allTracksFromSource(QString musicSource) const
QList<MusicAudioTrack> DatabaseInterface::allTracksFromSource(const QString &musicSource) const
{
auto result = QList<MusicAudioTrack>();
......@@ -308,7 +308,7 @@ QList<MusicAudioTrack> DatabaseInterface::allTracksFromSource(QString musicSourc
return result;
}
QList<MusicAudioTrack> DatabaseInterface::allInvalidTracksFromSource(QString musicSource) const
QList<MusicAudioTrack> DatabaseInterface::allInvalidTracksFromSource(const QString &musicSource) const
{
auto result = QList<MusicAudioTrack>();
......@@ -490,7 +490,7 @@ QList<MusicArtist> DatabaseInterface::allArtists() const
return result;
}
QList<MusicAudioTrack> DatabaseInterface::tracksFromAuthor(QString artistName) const
QList<MusicAudioTrack> DatabaseInterface::tracksFromAuthor(const QString &artistName) const
{
auto allTracks = QList<MusicAudioTrack>();
......@@ -589,7 +589,7 @@ MusicAudioTrack DatabaseInterface::trackFromDatabaseId(qulonglong id)
return result;
}
qulonglong DatabaseInterface::trackIdFromTitleAlbumArtist(QString title, QString album, QString artist) const
qulonglong DatabaseInterface::trackIdFromTitleAlbumArtist(const QString &title, const QString &album, const QString &artist) const
{
auto result = qulonglong(0);
......@@ -612,7 +612,7 @@ qulonglong DatabaseInterface::trackIdFromTitleAlbumArtist(QString title, QString
return result;
}
void DatabaseInterface::insertTracksList(QList<MusicAudioTrack> tracks, const QHash<QString, QUrl> &covers, QString musicSource)
void DatabaseInterface::insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers, const QString &musicSource)
{
auto transactionResult = startTransaction();
if (!transactionResult) {
......@@ -661,7 +661,7 @@ void DatabaseInterface::insertTracksList(QList<MusicAudioTrack> tracks, const QH
}
}
void DatabaseInterface::removeTracksList(const QList<QUrl> removedTracks)
void DatabaseInterface::removeTracksList(const QList<QUrl> &removedTracks)
{
auto transactionResult = startTransaction();
if (!transactionResult) {
......@@ -1602,7 +1602,7 @@ void DatabaseInterface::initRequest()
Q_EMIT requestsInitDone();
}
qulonglong DatabaseInterface::insertAlbum(QString title, QString albumArtist, QUrl albumArtURI, int tracksCount, bool isSingleDiscAlbum)
qulonglong DatabaseInterface::insertAlbum(const QString &title, const QString &albumArtist, const QUrl &albumArtURI, int tracksCount, bool isSingleDiscAlbum)
{
auto result = qulonglong(0);
......@@ -1684,7 +1684,7 @@ void DatabaseInterface::updateIsSingleDiscAlbumFromId(qulonglong albumId) const
d->mUpdateIsSingleDiscAlbumFromIdQuery.finish();
}
qulonglong DatabaseInterface::insertArtist(QString name)
qulonglong DatabaseInterface::insertArtist(const QString &name)
{
auto result = qulonglong(0);
......@@ -1742,7 +1742,7 @@ qulonglong DatabaseInterface::insertArtist(QString name)
return result;
}
void DatabaseInterface::insertTrackOrigin(QUrl fileNameURI, qulonglong discoverId)
void DatabaseInterface::insertTrackOrigin(const QUrl &fileNameURI, qulonglong discoverId)
{
d->mInsertTrackMapping.bindValue(QStringLiteral(":discoverId"), discoverId);
d->mInsertTrackMapping.bindValue(QStringLiteral(":fileName"), fileNameURI);
......@@ -1763,7 +1763,7 @@ void DatabaseInterface::insertTrackOrigin(QUrl fileNameURI, qulonglong discoverI
d->mInsertTrackMapping.finish();
}
void DatabaseInterface::updateTrackOrigin(qulonglong trackId, QUrl fileName)
void DatabaseInterface::updateTrackOrigin(qulonglong trackId, const QUrl &fileName)
{
d->mUpdateTrackMapping.bindValue(QStringLiteral(":trackId"), trackId);
d->mUpdateTrackMapping.bindValue(QStringLiteral(":fileName"), fileName);
......@@ -1784,7 +1784,7 @@ void DatabaseInterface::updateTrackOrigin(qulonglong trackId, QUrl fileName)
d->mInsertTrackMapping.finish();
}
int DatabaseInterface::computeTrackPriority(qulonglong trackId, QUrl fileName)
int DatabaseInterface::computeTrackPriority(qulonglong trackId, const QUrl &fileName)
{
auto result = int(0);
......@@ -1875,7 +1875,7 @@ void DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrack, con
}
}
qulonglong DatabaseInterface::internalArtistIdFromName(QString name)
qulonglong DatabaseInterface::internalArtistIdFromName(const QString &name)
{
auto result = qulonglong(0);
......@@ -1992,7 +1992,7 @@ void DatabaseInterface::reloadExistingDatabase()
++d->mTrackId;
}
qulonglong DatabaseInterface::insertMusicSource(QString name)
qulonglong DatabaseInterface::insertMusicSource(const QString &name)
{
qulonglong result = 0;
......@@ -2194,7 +2194,7 @@ MusicAlbum DatabaseInterface::internalAlbumFromId(qulonglong albumId)
return retrievedAlbum;
}
MusicAlbum DatabaseInterface::internalAlbumFromTitle(QString title)
MusicAlbum DatabaseInterface::internalAlbumFromTitle(const QString &title)
{
auto result = MusicAlbum();
......@@ -2226,7 +2226,7 @@ MusicAlbum DatabaseInterface::internalAlbumFromTitle(QString title)
return result;
}
qulonglong DatabaseInterface::internalAlbumIdFromTitle(QString title)
qulonglong DatabaseInterface::internalAlbumIdFromTitle(const QString &title)
{
auto result = qulonglong(0);
......@@ -2304,7 +2304,7 @@ MusicAudioTrack DatabaseInterface::internalTrackFromDatabaseId(qulonglong id)
return result;
}
qulonglong DatabaseInterface::internalTrackIdFromTitleAlbumArtist(QString title, QString album, QString artist) const
qulonglong DatabaseInterface::internalTrackIdFromTitleAlbumArtist(const QString &title, const QString &album, const QString &artist) const
{
auto result = qulonglong(0);
......@@ -2337,7 +2337,7 @@ qulonglong DatabaseInterface::internalTrackIdFromTitleAlbumArtist(QString title,
return result;
}
qulonglong DatabaseInterface::internalTrackIdFromFileName(const QUrl fileName) const
qulonglong DatabaseInterface::internalTrackIdFromFileName(const QUrl &fileName) const
{
auto result = qulonglong(0);
......@@ -2403,7 +2403,7 @@ QVariant DatabaseInterface::internalAlbumDataFromId(qulonglong albumId, Database
return result;
}
QList<MusicAudioTrack> DatabaseInterface::internalTracksFromAuthor(QString artistName) const
QList<MusicAudioTrack> DatabaseInterface::internalTracksFromAuthor(const QString &artistName) const
{
auto allTracks = QList<MusicAudioTrack>();
......
......@@ -54,41 +54,41 @@ public:
Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {});
MusicAlbum albumFromTitle(QString title);
MusicAlbum albumFromTitle(const QString &title);
QList<MusicAudioTrack> allTracks() const;
QList<MusicAudioTrack> allTracksFromSource(QString musicSource) const;
QList<MusicAudioTrack> allTracksFromSource(const QString &musicSource) const;
QList<MusicAudioTrack> allInvalidTracksFromSource(QString musicSource) const;
QList<MusicAudioTrack> allInvalidTracksFromSource(const QString &musicSource) const;
QList<MusicAlbum> allAlbums();
QList<MusicArtist> allArtists() const;
QList<MusicAudioTrack> tracksFromAuthor(QString artistName) const;
QList<MusicAudioTrack> tracksFromAuthor(const QString &artistName) const;
MusicAudioTrack trackFromDatabaseId(qulonglong id);
qulonglong trackIdFromTitleAlbumArtist(QString title, QString album, QString artist) const;
qulonglong trackIdFromTitleAlbumArtist(const QString &title, const QString &album, const QString &artist) const;
Q_SIGNALS:
void artistAdded(MusicArtist newArtist);
void artistAdded(const MusicArtist &newArtist);
void albumAdded(MusicAlbum newAlbum);
void albumAdded(const MusicAlbum &newAlbum);
void trackAdded(qulonglong id);
void artistRemoved(MusicArtist removedArtist);
void artistRemoved(const MusicArtist &removedArtist);
void albumRemoved(MusicAlbum removedAlbum);
void albumRemoved(const MusicAlbum &removedAlbum);
void trackRemoved(qulonglong id);
void artistModified(MusicArtist modifiedArtist);
void artistModified(const MusicArtist &modifiedArtist);
void albumModified(MusicAlbum modifiedAlbum);
void albumModified(const MusicAlbum &modifiedAlbum);
void trackModified(qulonglong id);
......@@ -96,9 +96,9 @@ Q_SIGNALS:
public Q_SLOTS:
void insertTracksList(QList<MusicAudioTrack> tracks, const QHash<QString, QUrl> &covers, QString musicSource);
void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers, const QString &musicSource);
void removeTracksList(const QList<QUrl> removedTracks);
void removeTracksList(const QList<QUrl> &removedTracks);
void modifyTracksList(const QList<MusicAudioTrack> &modifiedTracks, const QHash<QString, QUrl> &covers);
......@@ -118,31 +118,31 @@ private:
MusicAlbum internalAlbumFromId(qulonglong albumId);
MusicAlbum internalAlbumFromTitle(QString title);
MusicAlbum internalAlbumFromTitle(const QString &title);
qulonglong internalAlbumIdFromTitle(QString title);
qulonglong internalAlbumIdFromTitle(const QString &title);
MusicAudioTrack internalTrackFromDatabaseId(qulonglong id);
qulonglong internalTrackIdFromTitleAlbumArtist(QString title, QString album, QString artist) const;
qulonglong internalTrackIdFromTitleAlbumArtist(const QString &title, const QString &album, const QString &artist) const;
qulonglong internalTrackIdFromFileName(const QUrl fileName) const;
qulonglong internalTrackIdFromFileName(const QUrl &fileName) const;
QVariant internalAlbumDataFromId(qulonglong albumId, AlbumData dataType);
QList<MusicAudioTrack> internalTracksFromAuthor(QString artistName) const;
QList<MusicAudioTrack> internalTracksFromAuthor(const QString &artistName) const;
void initDatabase() const;
void initRequest();
qulonglong insertAlbum(QString title, QString albumArtist, QUrl albumArtURI, int tracksCount, bool isSingleDiscAlbum);
qulonglong insertAlbum(const QString &title, const QString &albumArtist, const QUrl &albumArtURI, int tracksCount, bool isSingleDiscAlbum);
void updateIsSingleDiscAlbumFromId(qulonglong albumId) const;
qulonglong insertArtist(QString name);
qulonglong insertArtist(const QString &name);
qulonglong internalArtistIdFromName(QString name);
qulonglong internalArtistIdFromName(const QString &name);
void removeTrackInDatabase(qulonglong trackId);
......@@ -152,13 +152,13 @@ private:
void reloadExistingDatabase();