diff options
author | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-10-25 22:39:12 -0700 |
---|---|---|
committer | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-10-26 00:14:38 -0700 |
commit | 10ec4cb3d6c5d6a3d7727ef74a16c7c3526ed30f (patch) | |
tree | 033cc4304a434c024d3ffde5450ac0d51908ee26 /src/library | |
parent | 398b533a847db24ddb6f3d30e1d2964f62308cbf (diff) |
Fix some issues identified by clazy.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/baseplaylistfeature.cpp | 16 | ||||
-rw-r--r-- | src/library/basetrackcache.cpp | 5 | ||||
-rw-r--r-- | src/library/browse/foldertreemodel.cpp | 4 | ||||
-rw-r--r-- | src/library/dao/analysisdao.cpp | 1 | ||||
-rw-r--r-- | src/library/dao/playlistdao.cpp | 7 | ||||
-rw-r--r-- | src/library/dao/trackdao.cpp | 4 | ||||
-rw-r--r-- | src/library/proxytrackmodel.cpp | 2 |
7 files changed, 17 insertions, 22 deletions
diff --git a/src/library/baseplaylistfeature.cpp b/src/library/baseplaylistfeature.cpp index 0971edbcfb..d2f77e26a4 100644 --- a/src/library/baseplaylistfeature.cpp +++ b/src/library/baseplaylistfeature.cpp @@ -623,8 +623,8 @@ QModelIndex BasePlaylistFeature::constructChildModel(int selected_id) { int selected_row = -1; int row = 0; - for (QList<QPair<int, QString> >::const_iterator it = m_playlistList.begin(); - it != m_playlistList.end(); ++it, ++row) { + for (auto it = m_playlistList.constBegin(); + it != m_playlistList.constEnd(); ++it, ++row) { int playlist_id = it->first; QString playlist_name = it->second; @@ -654,8 +654,8 @@ void BasePlaylistFeature::updateChildModel(int selected_id) { buildPlaylistList(); int row = 0; - for (QList<QPair<int, QString> >::const_iterator it = m_playlistList.begin(); - it != m_playlistList.end(); ++it, ++row) { + for (auto it = m_playlistList.constBegin(); + it != m_playlistList.constEnd(); ++it, ++row) { int playlist_id = it->first; QString playlist_name = it->second; @@ -680,8 +680,8 @@ void BasePlaylistFeature::clearChildModel() { QModelIndex BasePlaylistFeature::indexFromPlaylistId(int playlistId) { int row = 0; - for (QList<QPair<int, QString> >::const_iterator it = m_playlistList.begin(); - it != m_playlistList.end(); ++it, ++row) { + for (auto it = m_playlistList.constBegin(); + it != m_playlistList.constEnd(); ++it, ++row) { int current_id = it->first; QString playlist_name = it->second; @@ -708,8 +708,8 @@ void BasePlaylistFeature::slotTrackSelected(TrackPointer pTrack) { // Set all playlists the track is in bold (or if there is no track selected, // clear all the bolding). int row = 0; - for (QList<QPair<int, QString> >::const_iterator it = m_playlistList.begin(); - it != m_playlistList.end(); ++it, ++row) { + for (auto it = m_playlistList.constBegin(); + it != m_playlistList.constEnd(); ++it, ++row) { TreeItem* playlist = rootItem->child(row); if (playlist == nullptr) { continue; diff --git a/src/library/basetrackcache.cpp b/src/library/basetrackcache.cpp index c11060d766..fcceaec9d3 100644 --- a/src/library/basetrackcache.cpp +++ b/src/library/basetrackcache.cpp @@ -452,9 +452,8 @@ QVariant BaseTrackCache::data(TrackId trackId, int column) const { // metadata. Currently the upper-levels will not delegate row-specific // columns to this method, but there should still be a check here I think. if (!result.isValid()) { - QHash<TrackId, QVector<QVariant> >::const_iterator it = - m_trackInfo.find(trackId); - if (it != m_trackInfo.end()) { + auto it = m_trackInfo.constFind(trackId); + if (it != m_trackInfo.constEnd()) { const QVector<QVariant>& fields = it.value(); result = fields.value(column, result); } diff --git a/src/library/browse/foldertreemodel.cpp b/src/library/browse/foldertreemodel.cpp index a91cb8eae0..03738bed54 100644 --- a/src/library/browse/foldertreemodel.cpp +++ b/src/library/browse/foldertreemodel.cpp @@ -50,8 +50,8 @@ bool FolderTreeModel::hasChildren(const QModelIndex& parent) const { } bool FolderTreeModel::directoryHasChildren(const QString& path) const { - QHash<QString, bool>::const_iterator it = m_directoryCache.find(path); - if (it != m_directoryCache.end()) { + auto it = m_directoryCache.constFind(path); + if (it != m_directoryCache.constEnd()) { return it.value(); } diff --git a/src/library/dao/analysisdao.cpp b/src/library/dao/analysisdao.cpp index 58121296e8..f1a43c2810 100644 --- a/src/library/dao/analysisdao.cpp +++ b/src/library/dao/analysisdao.cpp @@ -125,7 +125,6 @@ bool AnalysisDao::saveAnalysis(AnalysisDao::AnalysisInfo* info) { "VALUES (:trackId,:type,:description,:version,:data_checksum)") .arg(s_analysisTableName)); - QByteArray waveformBytes; query.bindValue(":trackId", info->trackId.toVariant()); query.bindValue(":type", info->type); query.bindValue(":description", info->description); diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index e05a524420..dd206a7ca8 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -457,7 +457,6 @@ void PlaylistDAO::removeTracksFromPlaylist(const int playlistId, QList<int>& pos //qDebug() << "PlaylistDAO::removeTrackFromPlaylist" // << QThread::currentThread() << m_database.connectionName(); ScopedTransaction transaction(m_database); - QSqlQuery query(m_database); foreach (int position , positions) { removeTracksFromPlaylistInner(playlistId, position); } @@ -856,7 +855,7 @@ void PlaylistDAO::shuffleTracks(const int playlistId, const QList<int>& position ScopedTransaction transaction(m_database); QSqlQuery query(m_database); - int seed = QDateTime::currentDateTime().toTime_t(); + int seed = QDateTime::currentDateTimeUtc().toTime_t(); qsrand(seed); QHash<int,TrackId> trackPositionIds = allIds; QList<int> newPositions = positions; @@ -1004,8 +1003,8 @@ bool PlaylistDAO::isTrackInPlaylist(TrackId trackId, const int playlistId) const void PlaylistDAO::getPlaylistsTrackIsIn(TrackId trackId, QSet<int>* playlistSet) const { playlistSet->clear(); - for (QHash<TrackId, int>::const_iterator it = m_playlistsTrackIsIn.find(trackId); - it != m_playlistsTrackIsIn.end() && it.key() == trackId; ++it) { + for (auto it = m_playlistsTrackIsIn.constFind(trackId); + it != m_playlistsTrackIsIn.constEnd() && it.key() == trackId; ++it) { playlistSet->insert(it.value()); } } diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index 90315c805c..773d172a89 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -1800,7 +1800,7 @@ void TrackDAO::detectCoverArtForTracksWithoutCover(volatile const bool* pCancel, "WHERE coverart_source IS NULL or coverart_source = 0 " "ORDER BY track_locations.directory"); - QList<TrackWithoutCover> tracksWithoutCover; + QVector<TrackWithoutCover> tracksWithoutCover; if (!query.exec()) { LOG_FAILED_QUERY(query) @@ -1842,8 +1842,6 @@ void TrackDAO::detectCoverArtForTracksWithoutCover(volatile const bool* pCancel, "WHERE id=:track_id"); - QRegExp coverArtFilenames(CoverArtUtils::supportedCoverArtExtensionsRegex(), - Qt::CaseInsensitive); QString currentDirectoryPath; MDir currentDirectory; QLinkedList<QFileInfo> possibleCovers; diff --git a/src/library/proxytrackmodel.cpp b/src/library/proxytrackmodel.cpp index 61d41bd736..3504557b1a 100644 --- a/src/library/proxytrackmodel.cpp +++ b/src/library/proxytrackmodel.cpp @@ -117,7 +117,7 @@ bool ProxyTrackModel::filterAcceptsRow(int sourceRow, QModelIndex index = itemModel->index(sourceRow, i, sourceParent); QVariant data = itemModel->data(index); if (data.canConvert(QMetaType::QString)) { - QString strData = data.value<QString>(); + QString strData = data.toString(); if (strData.contains(filter)) rowMatches = true; } |