Commit 978de1a7 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

fix some issues reported by clazy static analyser

Summary: fix other issues reported by Clazy

Test Plan: tests are OK

Reviewers: #elisa, ngraham, astippich, jguidon

Reviewed By: #elisa, astippich

Differential Revision: https://phabricator.kde.org/D23541
parent 2ccf0082
...@@ -5170,7 +5170,7 @@ private Q_SLOTS: ...@@ -5170,7 +5170,7 @@ private Q_SLOTS:
QCOMPARE(newAlbum.artist(), QStringLiteral("Various Artists")); QCOMPARE(newAlbum.artist(), QStringLiteral("Various Artists"));
QCOMPARE(newAlbum[DatabaseInterface::ColumnsRoles::SecondaryTextRole], QStringLiteral("Various Artists")); QCOMPARE(newAlbum[DatabaseInterface::ColumnsRoles::SecondaryTextRole], QStringLiteral("Various Artists"));
const auto oneAlbum = musicDb.allAlbumsData()[0]; const auto oneAlbum = musicDb.allAlbumsData().at(0);
QCOMPARE(oneAlbum.title(), QStringLiteral("album3")); QCOMPARE(oneAlbum.title(), QStringLiteral("album3"));
QCOMPARE(oneAlbum.artist(), QStringLiteral("Various Artists")); QCOMPARE(oneAlbum.artist(), QStringLiteral("Various Artists"));
QCOMPARE(oneAlbum[DatabaseInterface::ColumnsRoles::SecondaryTextRole], QStringLiteral("Various Artists")); QCOMPARE(oneAlbum[DatabaseInterface::ColumnsRoles::SecondaryTextRole], QStringLiteral("Various Artists"));
......
...@@ -122,7 +122,7 @@ Q_SIGNALS: ...@@ -122,7 +122,7 @@ Q_SIGNALS:
void positionChanged(qint64 position); void positionChanged(qint64 position);
void currentPlayingForRadiosChanged(QString title, QString nowPlaying); void currentPlayingForRadiosChanged(const QString &title, const QString &nowPlaying);
void seekableChanged(bool seekable); void seekableChanged(bool seekable);
......
...@@ -238,8 +238,7 @@ void AudioWrapper::setSource(const QUrl &source) ...@@ -238,8 +238,7 @@ void AudioWrapper::setSource(const QUrl &source)
d->mMedia = libvlc_media_new_path(d->mInstance, QDir::toNativeSeparators(source.toLocalFile()).toUtf8().constData()); d->mMedia = libvlc_media_new_path(d->mInstance, QDir::toNativeSeparators(source.toLocalFile()).toUtf8().constData());
} else { } else {
qCDebug(orgKdeElisaPlayerVlc) << "AudioWrapper::setSource reading remote resource"; qCDebug(orgKdeElisaPlayerVlc) << "AudioWrapper::setSource reading remote resource";
const char * charUrl = source.url().toUtf8().constData(); d->mMedia = libvlc_media_new_location(d->mInstance, source.url().toUtf8().constData());
d->mMedia = libvlc_media_new_location(d->mInstance, charUrl);
} }
if (!d->mMedia) { if (!d->mMedia) {
...@@ -337,6 +336,7 @@ void AudioWrapper::seek(qint64 position) ...@@ -337,6 +336,7 @@ void AudioWrapper::seek(qint64 position)
void AudioWrapper::setAudioRole(QAudio::Role audioRole) void AudioWrapper::setAudioRole(QAudio::Role audioRole)
{ {
Q_UNUSED(audioRole)
// d->mPlayer.setAudioRole(audioRole); // d->mPlayer.setAudioRole(audioRole);
} }
......
...@@ -6147,8 +6147,6 @@ qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrac ...@@ -6147,8 +6147,6 @@ qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrac
resultId = existingTrackId; resultId = existingTrackId;
const auto &albumData = internalOneAlbumPartialData(albumId);
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackId"), existingTrackId); d->mInsertTrackQuery.bindValue(QStringLiteral(":trackId"), existingTrackId);
d->mInsertTrackQuery.bindValue(QStringLiteral(":fileName"), oneTrack.resourceURI()); d->mInsertTrackQuery.bindValue(QStringLiteral(":fileName"), oneTrack.resourceURI());
d->mInsertTrackQuery.bindValue(QStringLiteral(":priority"), priority); d->mInsertTrackQuery.bindValue(QStringLiteral(":priority"), priority);
......
...@@ -423,7 +423,7 @@ Q_SIGNALS: ...@@ -423,7 +423,7 @@ Q_SIGNALS:
void databaseError(); void databaseError();
void restoredTracks(QHash<QUrl, QDateTime> allFiles); void restoredTracks(const QHash<QUrl, QDateTime> &allFiles);
void cleanedDatabase(); void cleanedDatabase();
...@@ -431,9 +431,9 @@ Q_SIGNALS: ...@@ -431,9 +431,9 @@ Q_SIGNALS:
void finishRemovingTracksList(); void finishRemovingTracksList();
void radioAdded(const DatabaseInterface::TrackDataType radio); void radioAdded(const DatabaseInterface::TrackDataType &radio);
void radioModified(const DatabaseInterface::TrackDataType radio); void radioModified(const DatabaseInterface::TrackDataType &radio);
void radioRemoved(qulonglong radioId); void radioRemoved(qulonglong radioId);
...@@ -449,7 +449,7 @@ public Q_SLOTS: ...@@ -449,7 +449,7 @@ public Q_SLOTS:
void clearData(); void clearData();
void insertRadio(const TrackDataType &oneTrack); void insertRadio(const DatabaseInterface::TrackDataType &oneTrack);
void removeRadio(qulonglong radioId); void removeRadio(qulonglong radioId);
......
...@@ -413,7 +413,8 @@ void ManageAudioPlayer::setPlayerPosition(qint64 playerPosition) ...@@ -413,7 +413,8 @@ void ManageAudioPlayer::setPlayerPosition(qint64 playerPosition)
QTimer::singleShot(0, [this]() {Q_EMIT playControlPositionChanged();}); QTimer::singleShot(0, [this]() {Q_EMIT playControlPositionChanged();});
} }
void ManageAudioPlayer::setCurrentPlayingForRadios(const QString title, const QString nowPlaying){ void ManageAudioPlayer::setCurrentPlayingForRadios(QString title, QString nowPlaying)
{
if (mPlayListModel && mCurrentTrack.isValid()) { if (mPlayListModel && mCurrentTrack.isValid()) {
Q_EMIT currentPlayingForRadiosChanged(title, MediaPlayList::TitleRole); Q_EMIT currentPlayingForRadiosChanged(title, MediaPlayList::TitleRole);
Q_EMIT currentPlayingForRadiosChanged(nowPlaying, MediaPlayList::ArtistRole); Q_EMIT currentPlayingForRadiosChanged(nowPlaying, MediaPlayList::ArtistRole);
......
...@@ -239,7 +239,7 @@ public Q_SLOTS: ...@@ -239,7 +239,7 @@ public Q_SLOTS:
void setPlayerPosition(qint64 playerPosition); void setPlayerPosition(qint64 playerPosition);
void setCurrentPlayingForRadios(const QString title, const QString nowPlaying); void setCurrentPlayingForRadios(QString title, QString nowPlaying);
void setPlayControlPosition(int playerPosition); void setPlayControlPosition(int playerPosition);
......
...@@ -279,8 +279,6 @@ private: ...@@ -279,8 +279,6 @@ private:
bool mOldIsValid = false; bool mOldIsValid = false;
int mOldRemainingTracks = 0;
}; };
......
...@@ -207,11 +207,11 @@ Q_SIGNALS: ...@@ -207,11 +207,11 @@ Q_SIGNALS:
void tracksCountChanged(); void tracksCountChanged();
void previousTrackChanged(QPersistentModelIndex previousTrack); void previousTrackChanged(const QPersistentModelIndex &previousTrack);
void currentTrackChanged(QPersistentModelIndex currentTrack); void currentTrackChanged(const QPersistentModelIndex &currentTrack);
void nextTrackChanged(QPersistentModelIndex nextTrack); void nextTrackChanged(const QPersistentModelIndex &nextTrack);
void clearPlayListPlayer(); void clearPlayListPlayer();
......
...@@ -462,7 +462,7 @@ void ModelDataLoader::databaseAlbumModified(const AlbumDataType &modifiedAlbum) ...@@ -462,7 +462,7 @@ void ModelDataLoader::databaseAlbumModified(const AlbumDataType &modifiedAlbum)
Q_EMIT albumModified(modifiedAlbum); Q_EMIT albumModified(modifiedAlbum);
} }
void ModelDataLoader::updateRadioData(TrackDataType trackDataType) void ModelDataLoader::updateRadioData(const TrackDataType &trackDataType)
{ {
Q_EMIT saveRadioModified(trackDataType); Q_EMIT saveRadioModified(trackDataType);
} }
......
...@@ -65,33 +65,33 @@ Q_SIGNALS: ...@@ -65,33 +65,33 @@ Q_SIGNALS:
void allRadiosData(const ModelDataLoader::ListRadioDataType &radiosData); void allRadiosData(const ModelDataLoader::ListRadioDataType &radiosData);
void radioAdded(const ModelDataLoader::TrackDataType radiosData); void radioAdded(const ModelDataLoader::TrackDataType &radiosData);
void radioModified(const ModelDataLoader::TrackDataType radiosData); void radioModified(const ModelDataLoader::TrackDataType &radiosData);
void allTrackData(const ModelDataLoader::TrackDataType &allData); void allTrackData(const ModelDataLoader::TrackDataType &allData);
void allRadioData(const ModelDataLoader::TrackDataType &allData); void allRadioData(const ModelDataLoader::TrackDataType &allData);
void tracksAdded(ModelDataLoader::ListTrackDataType newData); void tracksAdded(const ModelDataLoader::ListTrackDataType &newData);
void trackModified(const ModelDataLoader::TrackDataType &modifiedTrack); void trackModified(const ModelDataLoader::TrackDataType &modifiedTrack);
void trackRemoved(qulonglong removedTrackId); void trackRemoved(qulonglong removedTrackId);
void genresAdded(ModelDataLoader::ListGenreDataType newData); void genresAdded(const ModelDataLoader::ListGenreDataType &newData);
void artistsAdded(ModelDataLoader::ListArtistDataType newData); void artistsAdded(const ModelDataLoader::ListArtistDataType &newData);
void artistRemoved(qulonglong removedDatabaseId); void artistRemoved(qulonglong removedDatabaseId);
void albumsAdded(ModelDataLoader::ListAlbumDataType newData); void albumsAdded(const ModelDataLoader::ListAlbumDataType &newData);
void albumRemoved(qulonglong removedDatabaseId); void albumRemoved(qulonglong removedDatabaseId);
void albumModified(const ModelDataLoader::AlbumDataType &modifiedAlbum); void albumModified(const ModelDataLoader::AlbumDataType &modifiedAlbum);
void saveRadioModified(const ModelDataLoader::TrackDataType trackDataType); void saveRadioModified(const ModelDataLoader::TrackDataType &trackDataType);
void removeRadio(qulonglong radioId); void removeRadio(qulonglong radioId);
...@@ -122,7 +122,7 @@ public Q_SLOTS: ...@@ -122,7 +122,7 @@ public Q_SLOTS:
void loadFrequentlyPlayedData(ElisaUtils::PlayListEntryType dataType); void loadFrequentlyPlayedData(ElisaUtils::PlayListEntryType dataType);
void updateRadioData(ModelDataLoader::TrackDataType trackDataType); void updateRadioData(const ModelDataLoader::TrackDataType &trackDataType);
void deleteRadioData(qulonglong radioId); void deleteRadioData(qulonglong radioId);
......
...@@ -23,15 +23,6 @@ ...@@ -23,15 +23,6 @@
#include <QtConcurrent> #include <QtConcurrent>
const QList<DatabaseInterface::ColumnsRoles> mFieldsForClassicTrack({DatabaseInterface::TitleRole, DatabaseInterface::ArtistRole, DatabaseInterface::AlbumRole,
DatabaseInterface::AlbumArtistRole, DatabaseInterface::TrackNumberRole, DatabaseInterface::DiscNumberRole,
DatabaseInterface::RatingRole, DatabaseInterface::GenreRole, DatabaseInterface::LyricistRole,
DatabaseInterface::ComposerRole, DatabaseInterface::CommentRole, DatabaseInterface::YearRole,
DatabaseInterface::LastPlayDate, DatabaseInterface::PlayCounter});
const QList mFieldsForRadioTrack({DatabaseInterface::TitleRole,DatabaseInterface::ResourceRole, DatabaseInterface::CommentRole, DatabaseInterface::DatabaseIdRole,
DatabaseInterface::ArtistRole, DatabaseInterface::AlbumRole});
TrackMetadataModel::TrackMetadataModel(QObject *parent) TrackMetadataModel::TrackMetadataModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
...@@ -340,6 +331,7 @@ QVariant TrackMetadataModel::dataRadio(const QModelIndex &index, int role) const ...@@ -340,6 +331,7 @@ QVariant TrackMetadataModel::dataRadio(const QModelIndex &index, int role) const
case DatabaseInterface::FirstPlayDate: case DatabaseInterface::FirstPlayDate:
case DatabaseInterface::PlayFrequency: case DatabaseInterface::PlayFrequency:
case DatabaseInterface::ElementTypeRole: case DatabaseInterface::ElementTypeRole:
case DatabaseInterface::IsValidAlbumArtistRole:
break; break;
} }
break; break;
...@@ -391,6 +383,7 @@ QVariant TrackMetadataModel::dataRadio(const QModelIndex &index, int role) const ...@@ -391,6 +383,7 @@ QVariant TrackMetadataModel::dataRadio(const QModelIndex &index, int role) const
case DatabaseInterface::FirstPlayDate: case DatabaseInterface::FirstPlayDate:
case DatabaseInterface::PlayFrequency: case DatabaseInterface::PlayFrequency:
case DatabaseInterface::ElementTypeRole: case DatabaseInterface::ElementTypeRole:
case DatabaseInterface::IsValidAlbumArtistRole:
break; break;
} }
break; break;
...@@ -464,6 +457,15 @@ void TrackMetadataModel::trackData(const TrackMetadataModel::TrackDataType &trac ...@@ -464,6 +457,15 @@ void TrackMetadataModel::trackData(const TrackMetadataModel::TrackDataType &trac
void TrackMetadataModel::fillDataFromTrackData(const TrackMetadataModel::TrackDataType &trackData) void TrackMetadataModel::fillDataFromTrackData(const TrackMetadataModel::TrackDataType &trackData)
{ {
const QList<DatabaseInterface::ColumnsRoles> mFieldsForClassicTrack({DatabaseInterface::TitleRole, DatabaseInterface::ArtistRole, DatabaseInterface::AlbumRole,
DatabaseInterface::AlbumArtistRole, DatabaseInterface::TrackNumberRole, DatabaseInterface::DiscNumberRole,
DatabaseInterface::RatingRole, DatabaseInterface::GenreRole, DatabaseInterface::LyricistRole,
DatabaseInterface::ComposerRole, DatabaseInterface::CommentRole, DatabaseInterface::YearRole,
DatabaseInterface::LastPlayDate, DatabaseInterface::PlayCounter});
const QList mFieldsForRadioTrack({DatabaseInterface::TitleRole,DatabaseInterface::ResourceRole, DatabaseInterface::CommentRole, DatabaseInterface::DatabaseIdRole,
DatabaseInterface::ArtistRole, DatabaseInterface::AlbumRole});
beginResetModel(); beginResetModel();
mFullData = trackData; mFullData = trackData;
mTrackData.clear(); mTrackData.clear();
...@@ -630,7 +632,7 @@ void TrackMetadataModel::fillDataForNewRadio() ...@@ -630,7 +632,7 @@ void TrackMetadataModel::fillDataForNewRadio()
mTrackData[role] = -1; mTrackData[role] = -1;
Q_EMIT hideDeleteButton(); Q_EMIT hideDeleteButton();
} else { } else {
mTrackData[role] = QStringLiteral(""); mTrackData[role] = QString();
} }
} }
...@@ -657,6 +659,8 @@ void TrackMetadataModel::setManager(MusicListenersManager *newManager) ...@@ -657,6 +659,8 @@ void TrackMetadataModel::setManager(MusicListenersManager *newManager)
void TrackMetadataModel::setIsRadio(bool isRadio){ void TrackMetadataModel::setIsRadio(bool isRadio){
this->mIsRadio = isRadio; this->mIsRadio = isRadio;
Q_EMIT isRadioChanged();
} }
void TrackMetadataModel::setDatabase(DatabaseInterface *trackDatabase) void TrackMetadataModel::setDatabase(DatabaseInterface *trackDatabase)
...@@ -680,7 +684,7 @@ void TrackMetadataModel::deleteRadio() ...@@ -680,7 +684,7 @@ void TrackMetadataModel::deleteRadio()
} }
} }
void TrackMetadataModel::radioAdded(TrackDataType radiosData){ void TrackMetadataModel::radioAdded(const TrackDataType &radiosData){
mTrackData[DatabaseInterface::DatabaseIdRole] = radiosData[DatabaseInterface::DatabaseIdRole]; mTrackData[DatabaseInterface::DatabaseIdRole] = radiosData[DatabaseInterface::DatabaseIdRole];
Q_EMIT showDeleteButton(); Q_EMIT showDeleteButton();
radioModified(); radioModified();
......
...@@ -55,7 +55,8 @@ class ELISALIB_EXPORT TrackMetadataModel : public QAbstractListModel ...@@ -55,7 +55,8 @@ class ELISALIB_EXPORT TrackMetadataModel : public QAbstractListModel
Q_PROPERTY(bool isRadio Q_PROPERTY(bool isRadio
READ isRadio READ isRadio
WRITE setIsRadio) WRITE setIsRadio
NOTIFY isRadioChanged)
public: public:
...@@ -115,7 +116,7 @@ Q_SIGNALS: ...@@ -115,7 +116,7 @@ Q_SIGNALS:
void lyricsChanged(); void lyricsChanged();
void saveRadioData(DatabaseInterface::TrackDataType trackDataType); void saveRadioData(const DatabaseInterface::TrackDataType &trackDataType);
void deleteRadioData(qulonglong radioId); void deleteRadioData(qulonglong radioId);
...@@ -127,6 +128,8 @@ Q_SIGNALS: ...@@ -127,6 +128,8 @@ Q_SIGNALS:
void closeWindow(); void closeWindow();
void isRadioChanged();
public Q_SLOTS: public Q_SLOTS:
void trackData(const TrackMetadataModel::TrackDataType &trackData); void trackData(const TrackMetadataModel::TrackDataType &trackData);
...@@ -147,7 +150,7 @@ public Q_SLOTS: ...@@ -147,7 +150,7 @@ public Q_SLOTS:
void deleteRadio(); void deleteRadio();
void radioAdded(TrackMetadataModel::TrackDataType radiosData); void radioAdded(const TrackMetadataModel::TrackDataType &radiosData);
void radioModified(); void radioModified();
......
...@@ -110,7 +110,7 @@ Q_SIGNALS: ...@@ -110,7 +110,7 @@ Q_SIGNALS:
void elisaApplicationChanged(); void elisaApplicationChanged();
void removeTracksInError(QList<QUrl> tracks); void removeTracksInError(const QList<QUrl> &tracks);
void displayTrackError(const QString &fileName); void displayTrackError(const QString &fileName);
......
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