Commit ba3b822e authored by Matthieu Gallien's avatar Matthieu Gallien

Merge branch 'fixClazyWarnings' into 'release/19.12'

Fix clazy warnings

See merge request !30
parents 0f8fdd57 4ec4503d
......@@ -41,6 +41,12 @@ class AllTracksProxyModelTests: public QObject, public DatabaseTestData
{
Q_OBJECT
public:
explicit AllTracksProxyModelTests(QObject *aParent = nullptr) : QObject(aParent)
{
}
private Q_SLOTS:
void initTestCase()
......
......@@ -44,7 +44,11 @@ class DatabaseInterfaceTests: public QObject, public DatabaseTestData
{
Q_OBJECT
private:
public:
explicit DatabaseInterfaceTests(QObject *aParent = nullptr) : QObject(aParent)
{
}
private Q_SLOTS:
......
......@@ -41,6 +41,12 @@ class DataModelTests: public QObject, public DatabaseTestData
{
Q_OBJECT
public:
explicit DataModelTests(QObject *aParent = nullptr) : QObject(aParent)
{
}
private Q_SLOTS:
void initTestCase()
......
......@@ -34,7 +34,13 @@ class FileScannerTest: public QObject
public:
QString createTrackUrl(QString subpath) {
explicit FileScannerTest(QObject *aParent = nullptr) : QObject(aParent)
{
}
public:
QString createTrackUrl(const QString &subpath) {
return QStringLiteral(LOCAL_FILE_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/cover_art") + subpath;
}
......
......@@ -28,6 +28,12 @@ class TrackMetadataModelTests: public QObject, public DatabaseTestData
{
Q_OBJECT
public:
explicit TrackMetadataModelTests(QObject *aParent = nullptr) : QObject(aParent)
{
}
private Q_SLOTS:
void initTestCase()
......
......@@ -25,7 +25,11 @@ class ViewManagerTests: public QObject
{
Q_OBJECT
private:
public:
explicit ViewManagerTests(QObject *aParent = nullptr) : QObject(aParent)
{
}
private Q_SLOTS:
......
......@@ -96,15 +96,15 @@ public:
QString aAlbumArtist, int aTrackNumber, int aDiscNumber, QTime aDuration, QUrl aResourceURI,
const QDateTime &fileModificationTime, QUrl aAlbumCover, int rating, bool aIsSingleDiscAlbum,
QString aGenre, QString aComposer, QString aLyricist, bool aHasEmbeddedCover)
: DataType({{key_type::TitleRole, aTitle}, {key_type::AlbumRole, aAlbumName},
{key_type::ArtistRole, aArtist}, {key_type::AlbumArtistRole, aAlbumArtist},
{key_type::IdRole, aId}, {key_type::ParentIdRole, aParentId},
: DataType({{key_type::TitleRole, std::move(aTitle)}, {key_type::AlbumRole, std::move(aAlbumName)},
{key_type::ArtistRole, std::move(aArtist)}, {key_type::AlbumArtistRole, std::move(aAlbumArtist)},
{key_type::IdRole, std::move(aId)}, {key_type::ParentIdRole, std::move(aParentId)},
{key_type::TrackNumberRole, aTrackNumber}, {key_type::DiscNumberRole, aDiscNumber},
{key_type::DurationRole, aDuration}, {key_type::ResourceRole, aResourceURI},
{key_type::FileModificationTime, fileModificationTime}, {key_type::ImageUrlRole, aAlbumCover},
{key_type::DurationRole, aDuration}, {key_type::ResourceRole, std::move(aResourceURI)},
{key_type::FileModificationTime, fileModificationTime}, {key_type::ImageUrlRole, std::move(aAlbumCover)},
{key_type::RatingRole, rating}, {key_type::IsSingleDiscAlbumRole, aIsSingleDiscAlbum},
{key_type::GenreRole, aGenre}, {key_type::ComposerRole, aComposer},
{key_type::LyricistRole, aLyricist}, {key_type::HasEmbeddedCover, aHasEmbeddedCover},})
{key_type::GenreRole, std::move(aGenre)}, {key_type::ComposerRole, std::move(aComposer)},
{key_type::LyricistRole, std::move(aLyricist)}, {key_type::HasEmbeddedCover, aHasEmbeddedCover},})
{
Q_UNUSED(aValid)
}
......
......@@ -78,6 +78,11 @@
#include <QQmlEngine>
#include <QQmlContext>
ElisaQmlTestPlugin::ElisaQmlTestPlugin(QObject *aParent)
: QQmlExtensionPlugin(aParent)
{
}
void ElisaQmlTestPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
......
......@@ -28,6 +28,8 @@ class ElisaQmlTestPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
explicit ElisaQmlTestPlugin(QObject *aParent = nullptr);
void initializeEngine(QQmlEngine *engine, const char *uri) override;
void registerTypes(const char *uri) override;
};
......
......@@ -25,7 +25,7 @@ class AsyncImageResponse : public QQuickImageResponse, public QRunnable
{
public:
AsyncImageResponse(QString id, QSize requestedSize)
: mId(std::move(id)), mRequestedSize(requestedSize)
: QQuickImageResponse(), mId(std::move(id)), mRequestedSize(requestedSize)
{
setAutoDelete(false);
}
......
......@@ -45,29 +45,6 @@
#include <QHash>
#include <QMimeDatabase>
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
static const QHash<KFileMetaData::Property::Property, DataTypes::ColumnsRoles> propertyTranslation = {
{KFileMetaData::Property::Artist, DataTypes::ColumnsRoles::ArtistRole},
{KFileMetaData::Property::AlbumArtist, DataTypes::ColumnsRoles::AlbumArtistRole},
{KFileMetaData::Property::Genre, DataTypes::ColumnsRoles::GenreRole},
{KFileMetaData::Property::Composer, DataTypes::ColumnsRoles::ComposerRole},
{KFileMetaData::Property::Lyricist, DataTypes::ColumnsRoles::LyricistRole},
{KFileMetaData::Property::Title, DataTypes::ColumnsRoles::TitleRole},
{KFileMetaData::Property::Album, DataTypes::ColumnsRoles::AlbumRole},
{KFileMetaData::Property::TrackNumber, DataTypes::ColumnsRoles::TrackNumberRole},
{KFileMetaData::Property::DiscNumber, DataTypes::ColumnsRoles::DiscNumberRole},
{KFileMetaData::Property::ReleaseYear, DataTypes::ColumnsRoles::YearRole},
{KFileMetaData::Property::Lyrics, DataTypes::ColumnsRoles::LyricsRole},
{KFileMetaData::Property::Comment, DataTypes::ColumnsRoles::CommentRole},
{KFileMetaData::Property::Rating, DataTypes::ColumnsRoles::RatingRole},
{KFileMetaData::Property::Channels, DataTypes::ColumnsRoles::ChannelsRole},
{KFileMetaData::Property::SampleRate, DataTypes::ColumnsRoles::SampleRateRole},
{KFileMetaData::Property::BitRate, DataTypes::ColumnsRoles::BitRateRole},
{KFileMetaData::Property::Duration, DataTypes::ColumnsRoles::DurationRole},
};
#endif
class FileScannerPrivate
{
public:
......@@ -80,15 +57,37 @@ public:
#endif
QMimeDatabase mMimeDb;
};
static const QStringList constSearchStrings = {
QStringLiteral("*[Cc]over*.jpg"),
QStringLiteral("*[Cc]over*.png"),
QStringLiteral("*[Ff]older*.jpg"),
QStringLiteral("*[Ff]older*.png"),
QStringLiteral("*[Ff]ront*.jpg"),
QStringLiteral("*[Ff]ront*.png")
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
const QHash<KFileMetaData::Property::Property, DataTypes::ColumnsRoles> propertyTranslation = {
{KFileMetaData::Property::Artist, DataTypes::ColumnsRoles::ArtistRole},
{KFileMetaData::Property::AlbumArtist, DataTypes::ColumnsRoles::AlbumArtistRole},
{KFileMetaData::Property::Genre, DataTypes::ColumnsRoles::GenreRole},
{KFileMetaData::Property::Composer, DataTypes::ColumnsRoles::ComposerRole},
{KFileMetaData::Property::Lyricist, DataTypes::ColumnsRoles::LyricistRole},
{KFileMetaData::Property::Title, DataTypes::ColumnsRoles::TitleRole},
{KFileMetaData::Property::Album, DataTypes::ColumnsRoles::AlbumRole},
{KFileMetaData::Property::TrackNumber, DataTypes::ColumnsRoles::TrackNumberRole},
{KFileMetaData::Property::DiscNumber, DataTypes::ColumnsRoles::DiscNumberRole},
{KFileMetaData::Property::ReleaseYear, DataTypes::ColumnsRoles::YearRole},
{KFileMetaData::Property::Lyrics, DataTypes::ColumnsRoles::LyricsRole},
{KFileMetaData::Property::Comment, DataTypes::ColumnsRoles::CommentRole},
{KFileMetaData::Property::Rating, DataTypes::ColumnsRoles::RatingRole},
{KFileMetaData::Property::Channels, DataTypes::ColumnsRoles::ChannelsRole},
{KFileMetaData::Property::SampleRate, DataTypes::ColumnsRoles::SampleRateRole},
{KFileMetaData::Property::BitRate, DataTypes::ColumnsRoles::BitRateRole},
{KFileMetaData::Property::Duration, DataTypes::ColumnsRoles::DurationRole},
};
#endif
const QStringList constSearchStrings = {
QStringLiteral("*[Cc]over*.jpg"),
QStringLiteral("*[Cc]over*.png"),
QStringLiteral("*[Ff]older*.jpg"),
QStringLiteral("*[Ff]older*.png"),
QStringLiteral("*[Ff]ront*.jpg"),
QStringLiteral("*[Ff]ront*.png")
};
};
FileScanner::FileScanner() : d(std::make_unique<FileScannerPrivate>())
......@@ -183,13 +182,13 @@ void FileScanner::scanProperties(const QString &localFileName, DataTypes::TrackD
auto key = (*rangeBegin).first;
auto rangeEnd = std::find_if(rangeBegin, d->mAllProperties.constKeyValueEnd(),
[key](const entry& e) { return e.first != key; });
[key](entry e) { return e.first != key; });
auto distance = std::distance(rangeBegin, rangeEnd);
if (distance > 1) {
QStringList list;
list.reserve(static_cast<int>(distance));
std::for_each(rangeBegin, rangeEnd, [&list](const entry& s) { list.append(s.second.toString()); });
std::for_each(rangeBegin, rangeEnd, [&list](entry s) { list.append(s.second.toString()); });
value = QLocale().createSeparatedList(list);
} else {
value = (*rangeBegin).second;
......@@ -197,10 +196,10 @@ void FileScanner::scanProperties(const QString &localFileName, DataTypes::TrackD
value = QLocale().createSeparatedList(value.toStringList());
}
}
auto translatedKey = propertyTranslation.find(key);
auto translatedKey = d->propertyTranslation.find(key);
if (translatedKey.value() == DataTypes::DurationRole) {
trackData.insert(translatedKey.value(), QTime::fromMSecsSinceStartOfDay(int(1000 * (*rangeBegin).second.toDouble())));
} else if (translatedKey != propertyTranslation.end()) {
} else if (translatedKey != d->propertyTranslation.end()) {
trackData.insert(translatedKey.value(), (*rangeBegin).second);
}
rangeBegin = rangeEnd;
......@@ -230,7 +229,7 @@ QUrl FileScanner::searchForCoverFile(const QString &localFileName)
QFileInfo trackFilePath(localFileName);
QDir trackFileDir = trackFilePath.absoluteDir();
trackFileDir.setFilter(QDir::Files);
trackFileDir.setNameFilters(constSearchStrings);
trackFileDir.setNameFilters(d->constSearchStrings);
QFileInfoList coverFiles = trackFileDir.entryInfoList();
if (coverFiles.isEmpty()) {
QString dirNamePattern = QLatin1String("*") + trackFileDir.dirName() + QLatin1String("*");
......
......@@ -81,7 +81,7 @@ void KCMElisaLocalFile::save()
Elisa::ElisaConfiguration::self()->save();
}
void KCMElisaLocalFile::setRootPath(QStringList rootPath)
void KCMElisaLocalFile::setRootPath(const QStringList &rootPath)
{
if (mRootPath == rootPath && !mRootPath.isEmpty()) {
return;
......
......@@ -42,7 +42,7 @@ public:
Q_SIGNALS:
void rootPathChanged(QStringList rootPath);
void rootPathChanged(const QStringList &rootPath);
public Q_SLOTS:
......@@ -52,7 +52,7 @@ public Q_SLOTS:
void save() override final;
void setRootPath(QStringList rootPath);
void setRootPath(const QStringList &rootPath);
private Q_SLOTS:
......
......@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
auto arguments = ElisaUtils::EntryDataList{};
auto realArgumentsList = parser.positionalArguments();
for (auto oneArgument : realArgumentsList) {
for (const auto &oneArgument : realArgumentsList) {
arguments.push_back(ElisaUtils::EntryData{{}, {}, QUrl(oneArgument)});
}
......
......@@ -410,10 +410,10 @@ void ManageAudioPlayer::setPlayerPosition(qint64 playerPosition)
mPlayerPosition = playerPosition;
Q_EMIT playerPositionChanged();
QTimer::singleShot(0, [this]() {Q_EMIT playControlPositionChanged();});
QTimer::singleShot(0, this, [this]() {Q_EMIT playControlPositionChanged();});
}
void ManageAudioPlayer::setCurrentPlayingForRadios(QString title, QString nowPlaying)
void ManageAudioPlayer::setCurrentPlayingForRadios(const QString &title, const QString &nowPlaying)
{
if (mPlayListModel && mCurrentTrack.isValid()) {
Q_EMIT currentPlayingForRadiosChanged(title, MediaPlayList::TitleRole);
......@@ -532,22 +532,22 @@ void ManageAudioPlayer::notifyPlayerSourceProperty()
void ManageAudioPlayer::triggerPlay()
{
QTimer::singleShot(0, [this]() {Q_EMIT playerPlay();});
QTimer::singleShot(0, this, [this]() {Q_EMIT playerPlay();});
}
void ManageAudioPlayer::triggerPause()
{
QTimer::singleShot(0, [this]() {Q_EMIT playerPause();});
QTimer::singleShot(0, this, [this]() {Q_EMIT playerPause();});
}
void ManageAudioPlayer::triggerStop()
{
QTimer::singleShot(0, [this]() {Q_EMIT playerStop();});
QTimer::singleShot(0, this, [this]() {Q_EMIT playerStop();});
}
void ManageAudioPlayer::triggerSkipNextTrack()
{
QTimer::singleShot(0, [this]() {Q_EMIT skipNextTrack();});
QTimer::singleShot(0, this, [this]() {Q_EMIT skipNextTrack();});
}
void ManageAudioPlayer::restorePreviousState()
......
......@@ -155,7 +155,7 @@ Q_SIGNALS:
void playListModelChanged();
void playerSourceChanged(QUrl url);
void playerSourceChanged(const QUrl &url);
void urlRoleChanged();
......@@ -197,7 +197,7 @@ Q_SIGNALS:
void albumNameRoleChanged();
void sourceInError(QUrl source, QMediaPlayer::Error playerError);
void sourceInError(const QUrl &source, QMediaPlayer::Error playerError);
void displayTrackError(const QString &fileName);
......@@ -239,7 +239,7 @@ public Q_SLOTS:
void setPlayerPosition(qint64 playerPosition);
void setCurrentPlayingForRadios(QString title, QString nowPlaying);
void setCurrentPlayingForRadios(const QString &title, const QString &nowPlaying);
void setPlayControlPosition(int playerPosition);
......
......@@ -115,12 +115,6 @@ private:
QPersistentModelIndex mNextTrack;
bool mCurrentTrackWillBeRemoved = false;
bool mSkipBackwardControlWasEnabled = false;
bool mSkipForwardControlWasEnabled = false;
bool mIsInPlayingState = false;
};
......
......@@ -354,14 +354,18 @@ public:
explicit MediaPlayListEntry(qulonglong id) : mId(id), mIsValid(true) {
}
MediaPlayListEntry(QString title, QString artist, QString album, int trackNumber, int discNumber, ElisaUtils::PlayListEntryType entryType = ElisaUtils::Unknown)
MediaPlayListEntry(QString title, QString artist,
QString album, int trackNumber,
int discNumber, ElisaUtils::PlayListEntryType entryType = ElisaUtils::Unknown)
: mTitle(std::move(title)), mAlbum(std::move(album)), mArtist(std::move(artist)),
mTrackNumber(trackNumber), mDiscNumber(discNumber), mEntryType(entryType) {
}
MediaPlayListEntry(qulonglong id, QVariant title, QVariant artist, QVariant album, QVariant trackNumber, QVariant discNumber, ElisaUtils::PlayListEntryType entryType = ElisaUtils::Unknown)
MediaPlayListEntry(qulonglong id, QVariant title, QVariant artist, QVariant album,
QVariant trackNumber, QVariant discNumber,
ElisaUtils::PlayListEntryType entryType = ElisaUtils::Unknown)
: mTitle(std::move(title)), mAlbum(std::move(album)), mArtist(std::move(artist)),
mTrackNumber(trackNumber), mDiscNumber(discNumber), mId(id), mEntryType(entryType) {
mTrackNumber(std::move(trackNumber)), mDiscNumber(std::move(discNumber)), mId(id), mEntryType(entryType) {
}
explicit MediaPlayListEntry(const MediaPlayList::TrackDataType &track)
......
......@@ -127,11 +127,11 @@ public Q_SLOTS:
private Q_SLOTS:
void databaseTracksAdded(const ListTrackDataType &newData);
void databaseTracksAdded(const ModelDataLoader::ListTrackDataType &newData);
void databaseArtistsAdded(const ListArtistDataType &newData);
void databaseArtistsAdded(const ModelDataLoader::ListArtistDataType &newData);
void databaseAlbumsAdded(const ListAlbumDataType &newData);
void databaseAlbumsAdded(const ModelDataLoader::ListAlbumDataType &newData);
private:
......
......@@ -677,7 +677,7 @@ void DataModel::radioRemoved(qulonglong removedRadioId)
endRemoveRows();
}
void DataModel::radioAdded(const DataModel::TrackDataType radioData)
void DataModel::radioAdded(const DataModel::TrackDataType &radioData)
{
if (d->mModelType != ElisaUtils::Radio) {
return;
......
......@@ -149,7 +149,7 @@ private Q_SLOTS:
private:
void radioAdded(const DataModel::TrackDataType radiosData);
void radioAdded(const TrackDataType &radiosData);
void radioModified(const DataModel::TrackDataType &modifiedRadio);
......
......@@ -64,7 +64,7 @@ void Mpris2::initDBusService()
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/mpris/MediaPlayer2"), this, QDBusConnection::ExportAdaptors);
connect(m_mp2.get(), SIGNAL(raisePlayer()), this, SIGNAL(raisePlayer()));
connect(m_mp2.get(), &MediaPlayer2::raisePlayer, this, &Mpris2::raisePlayer);
}
}
......
......@@ -329,7 +329,8 @@ void MusicListenersManager::configChanged()
//resolve symlinks
QStringList allRootPaths;
for (const auto &onePath : currentConfiguration->rootPath()) {
auto inputRootPath = currentConfiguration->rootPath();
for (const auto &onePath : inputRootPath) {
auto workPath = onePath;
if (workPath.startsWith(QLatin1String("file:/"))) {
auto urlPath = QUrl{workPath};
......
......@@ -155,8 +155,10 @@ void TracksListener::trackByNameInList(const QVariant &title, const QVariant &ar
}
}
void TracksListener::trackByFileNameInList(ElisaUtils::PlayListEntryType databaseIdType, const QUrl &fileName)
void TracksListener::trackByFileNameInList(ElisaUtils::PlayListEntryType type, const QUrl &fileName)
{
Q_UNUSED(type)
if (fileName.isLocalFile() || fileName.scheme().isEmpty()) {
auto newTrackId = d->mDatabase->trackIdFromFileName(fileName);
if (newTrackId == 0) {
......
......@@ -69,7 +69,7 @@ public Q_SLOTS:
const QString &entryTitle,
ElisaUtils::PlayListEntryType databaseIdType);
void trackByFileNameInList(ElisaUtils::PlayListEntryType databaseIdType, const QUrl &fileName);
void trackByFileNameInList(ElisaUtils::PlayListEntryType type, const QUrl &fileName);
void newUrlInList(const QUrl &entryUrl,
ElisaUtils::PlayListEntryType databaseIdType);
......
......@@ -87,7 +87,7 @@ Q_SIGNALS:
void openListView(ViewManager::ViewsType viewType, ElisaUtils::FilterType filterType, int expectedDepth,
const QString &mainTitle, const QString &secondaryTitle, qulonglong databaseId,
const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, QVariant sortRole,
const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QVariant &sortRole,
ViewManager::SortOrder sortOrder, bool displaySingleAlbum, ViewManager::AlbumViewStyle showDiscHeaders,
ViewManager::RadioSpecificStyle radioCase);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment