Commit e1b17e32 authored by Matthieu Gallien's avatar Matthieu Gallien

correct clazy level 1 warnings from Elisa source code

parent 10e1201a
......@@ -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>())
......@@ -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("*");
......
......@@ -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,7 +410,7 @@ 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)
......@@ -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()
......
......@@ -115,12 +115,6 @@ private:
QPersistentModelIndex mNextTrack;
bool mCurrentTrackWillBeRemoved = false;
bool mSkipBackwardControlWasEnabled = false;
bool mSkipForwardControlWasEnabled = false;
bool mIsInPlayingState = false;
};
......
......@@ -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:
......
......@@ -437,10 +437,6 @@ void TrackMetadataModel::initialize(MusicListenersManager *newManager, DatabaseI
if (mManager) {
mDataLoader.setDatabase(mManager->viewDatabase());
connect(this, &TrackMetadataModel::needDataByUrl,
mManager->tracksListener(), &TracksListener::trackByFileNameInList);
connect(mManager->tracksListener(), &TracksListener::trackHasChanged,
this, &TrackMetadataModel::trackData);
} else if (trackDatabase) {
mDataLoader.setDatabase(trackDatabase);
}
......@@ -467,6 +463,8 @@ void TrackMetadataModel::initialize(MusicListenersManager *newManager, DatabaseI
this, &TrackMetadataModel::radioData);
connect(&mDataLoader, &ModelDataLoader::radioModified,
this, &TrackMetadataModel::radioData);
connect(this, &TrackMetadataModel::needDataByUrl,
&mDataLoader, &ModelDataLoader::loadDataByUrl);
}
void TrackMetadataModel::fetchLyrics()
......
......@@ -155,7 +155,7 @@ void TracksListener::trackByNameInList(const QVariant &title, const QVariant &ar
}
}
void TracksListener::trackByFileNameInList(ElisaUtils::PlayListEntryType databaseIdType, const QUrl &fileName)
void TracksListener::trackByFileNameInList(const QUrl &fileName)
{
if (fileName.isLocalFile() || fileName.scheme().isEmpty()) {
auto newTrackId = d->mDatabase->trackIdFromFileName(fileName);
......@@ -246,7 +246,7 @@ void TracksListener::newUrlInList(const QUrl &entryUrl, ElisaUtils::PlayListEntr
if (!newDatabaseId)
{
trackByFileNameInList(databaseIdType, entryUrl);
trackByFileNameInList(entryUrl);
return;
}
......
......@@ -69,7 +69,7 @@ public Q_SLOTS:
const QString &entryTitle,
ElisaUtils::PlayListEntryType databaseIdType);
void trackByFileNameInList(ElisaUtils::PlayListEntryType databaseIdType, const QUrl &fileName);
void trackByFileNameInList(const QUrl &fileName);
void newUrlInList(const QUrl &entryUrl,
ElisaUtils::PlayListEntryType databaseIdType);
......
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