summaryrefslogtreecommitdiffstats
path: root/src/library
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-05-27 14:33:37 +0200
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-05-28 12:26:26 +0200
commit3f6f5b6169657f2b77f553024b6e4e33cbd119ae (patch)
treebc0ac7e5eb6e488efcac5e9388a644a230d5dd5d /src/library
parentdf66e41e4486753e55293d4177b4a0862bdeb3ff (diff)
Replace deprecated QLinkedList with std::list
Diffstat (limited to 'src/library')
-rw-r--r--src/library/basesqltablemodel.cpp4
-rw-r--r--src/library/basesqltablemodel.h4
-rw-r--r--src/library/basetracktablemodel.cpp4
-rw-r--r--src/library/browse/browsetablemodel.cpp4
-rw-r--r--src/library/browse/browsetablemodel.h2
-rw-r--r--src/library/proxytrackmodel.cpp4
-rw-r--r--src/library/proxytrackmodel.h7
-rw-r--r--src/library/scanner/importfilestask.cpp14
-rw-r--r--src/library/scanner/importfilestask.h28
-rw-r--r--src/library/scanner/recursivescandirectorytask.cpp14
-rw-r--r--src/library/scanner/recursivescandirectorytask.h15
-rw-r--r--src/library/setlogfeature.cpp10
-rw-r--r--src/library/setlogfeature.h3
-rw-r--r--src/library/trackmodel.h8
14 files changed, 57 insertions, 64 deletions
diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp
index 03035310fb..1923ff2b73 100644
--- a/src/library/basesqltablemodel.cpp
+++ b/src/library/basesqltablemodel.cpp
@@ -731,8 +731,8 @@ void BaseSqlTableModel::tracksChanged(QSet<TrackId> trackIds) {
const int numColumns = columnCount();
for (const auto& trackId : trackIds) {
- QLinkedList<int> rows = getTrackRows(trackId);
- foreach (int row, rows) {
+ std::list<int> rows = getTrackRows(trackId);
+ for (int row : rows) {
//qDebug() << "Row in this result set was updated. Signalling update. track:" << trackId << "row:" << row;
QModelIndex topLeft = index(row, 0);
QModelIndex bottomRight = index(row, numColumns);
diff --git a/src/library/basesqltablemodel.h b/src/library/basesqltablemodel.h
index be574d22c5..3f79551e0c 100644
--- a/src/library/basesqltablemodel.h
+++ b/src/library/basesqltablemodel.h
@@ -49,7 +49,7 @@ class BaseSqlTableModel : public BaseTrackTableModel {
TrackId getTrackId(const QModelIndex& index) const override;
QString getTrackLocation(const QModelIndex& index) const override;
- const QLinkedList<int> getTrackRows(TrackId trackId) const override {
+ const std::list<int> getTrackRows(TrackId trackId) const override {
return m_trackIdToRows.value(trackId);
}
@@ -136,7 +136,7 @@ class BaseSqlTableModel : public BaseTrackTableModel {
}
};
- typedef QHash<TrackId, QLinkedList<int>> TrackId2Rows;
+ typedef QHash<TrackId, std::list<int>> TrackId2Rows;
void clearRows();
void replaceRows(
diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp
index 81e7c186e6..53695a314c 100644
--- a/src/library/basetracktablemodel.cpp
+++ b/src/library/basetracktablemodel.cpp
@@ -709,9 +709,9 @@ void BaseTrackTableModel::slotTrackLoaded(
// preview state will update.
if (m_previewDeckTrackId.isValid()) {
const int numColumns = columnCount();
- QLinkedList<int> rows = getTrackRows(m_previewDeckTrackId);
+ std::list<int> rows = getTrackRows(m_previewDeckTrackId);
m_previewDeckTrackId = TrackId(); // invalidate
- foreach (int row, rows) {
+ for (int row : rows) {
QModelIndex topLeft = index(row, 0);
QModelIndex bottomRight = index(row, numColumns);
emit dataChanged(topLeft, bottomRight);
diff --git a/src/library/browse/browsetablemodel.cpp b/src/library/browse/browsetablemodel.cpp
index 13ea7d4d2d..2e5de46b22 100644
--- a/src/library/browse/browsetablemodel.cpp
+++ b/src/library/browse/browsetablemodel.cpp
@@ -198,10 +198,10 @@ TrackId BrowseTableModel::getTrackId(const QModelIndex& index) const {
}
}
-const QLinkedList<int> BrowseTableModel::getTrackRows(TrackId trackId) const {
+const std::list<int> BrowseTableModel::getTrackRows(TrackId trackId) const {
Q_UNUSED(trackId);
// We can't implement this as it stands.
- return QLinkedList<int>();
+ return std::list<int>();
}
void BrowseTableModel::search(const QString& searchText, const QString& extraFilter) {
diff --git a/src/library/browse/browsetablemodel.h b/src/library/browse/browsetablemodel.h
index 0b61810f5d..b36e44b089 100644
--- a/src/library/browse/browsetablemodel.h
+++ b/src/library/browse/browsetablemodel.h
@@ -56,7 +56,7 @@ class BrowseTableModel final : public QStandardItemModel, public virtual TrackMo
QString getTrackLocation(const QModelIndex& index) const override;
TrackId getTrackId(const QModelIndex& index) const override;
- const QLinkedList<int> getTrackRows(TrackId trackId) const override;
+ const std::list<int> getTrackRows(TrackId trackId) const override;
void search(const QString& searchText,const QString& extraFilter = QString()) override;
void removeTracks(const QModelIndexList& indices) override;
QMimeData* mimeData(const QModelIndexList &indexes) const override;
diff --git a/src/library/proxytrackmodel.cpp b/src/library/proxytrackmodel.cpp
index 65b3e4b73a..dcaafb413f 100644
--- a/src/library/proxytrackmodel.cpp
+++ b/src/library/proxytrackmodel.cpp
@@ -38,8 +38,8 @@ TrackId ProxyTrackModel::getTrackId(const QModelIndex& index) const {
return m_pTrackModel ? m_pTrackModel->getTrackId(indexSource) : TrackId();
}
-const QLinkedList<int> ProxyTrackModel::getTrackRows(TrackId trackId) const {
- return m_pTrackModel ? m_pTrackModel->getTrackRows(trackId) : QLinkedList<int>();
+const std::list<int> ProxyTrackModel::getTrackRows(TrackId trackId) const {
+ return m_pTrackModel ? m_pTrackModel->getTrackRows(trackId) : std::list<int>();
}
TrackPointer ProxyTrackModel::getTrack(const QModelIndex& index) const {
diff --git a/src/library/proxytrackmodel.h b/src/library/proxytrackmodel.h
index 7ed49b25fd..2830a92f2c 100644
--- a/src/library/proxytrackmodel.h
+++ b/src/library/proxytrackmodel.h
@@ -1,5 +1,4 @@
-#ifndef MIXXX_PROXYTRACKMODEL_H
-#define MIXXX_PROXYTRACKMODEL_H
+#pragma once
#include <QSortFilterProxyModel>
#include <QAbstractItemModel>
@@ -28,7 +27,7 @@ class ProxyTrackModel : public QSortFilterProxyModel, public TrackModel {
TrackPointer getTrackByRef(const TrackRef& trackRef) const final;
QString getTrackLocation(const QModelIndex& index) const final;
TrackId getTrackId(const QModelIndex& index) const final;
- const QLinkedList<int> getTrackRows(TrackId trackId) const final;
+ const std::list<int> getTrackRows(TrackId trackId) const final;
void search(const QString& searchText,const QString& extraFilter = QString()) final;
const QString currentSearch() const final;
bool isColumnInternal(int column) final;
@@ -52,5 +51,3 @@ class ProxyTrackModel : public QSortFilterProxyModel, public TrackModel {
QString m_currentSearch;
bool m_bHandleSearches;
};
-
-#endif // MIXXX_PROXYTRACKMODEL_H
diff --git a/src/library/scanner/importfilestask.cpp b/src/library/scanner/importfilestask.cpp
index 86964dffe3..7d124cb286 100644
--- a/src/library/scanner/importfilestask.cpp
+++ b/src/library/scanner/importfilestask.cpp
@@ -5,13 +5,13 @@
#include "util/timer.h"
ImportFilesTask::ImportFilesTask(LibraryScanner* pScanner,
- const ScannerGlobalPointer scannerGlobal,
- const QString& dirPath,
- const bool prevHashExists,
- const mixxx::cache_key_t newHash,
- const QLinkedList<QFileInfo>& filesToImport,
- const QLinkedList<QFileInfo>& possibleCovers,
- SecurityTokenPointer pToken)
+ const ScannerGlobalPointer scannerGlobal,
+ const QString& dirPath,
+ const bool prevHashExists,
+ const mixxx::cache_key_t newHash,
+ const std::list<QFileInfo>& filesToImport,
+ const std::list<QFileInfo>& possibleCovers,
+ SecurityTokenPointer pToken)
: ScannerTask(pScanner, scannerGlobal),
m_dirPath(dirPath),
m_prevHashExists(prevHashExists),
diff --git a/src/library/scanner/importfilestask.h b/src/library/scanner/importfilestask.h
index c4d5e58f1f..c737b4a9dd 100644
--- a/src/library/scanner/importfilestask.h
+++ b/src/library/scanner/importfilestask.h
@@ -1,25 +1,23 @@
-#ifndef IMPORTFILESTASK_H
-#define IMPORTFILESTASK_H
+#pragma once
-#include <QLinkedList>
#include <QFileInfo>
#include "util/sandbox.h"
#include "library/scanner/scannertask.h"
-// Import the provided files. Successful if the scan completed without being
-// cancelled. False if the scan was cancelled part-way through.
+/// Import the provided files. Successful if the scan completed without being
+/// cancelled. False if the scan was cancelled part-way through.
class ImportFilesTask : public ScannerTask {
Q_OBJECT
public:
ImportFilesTask(LibraryScanner* pScanner,
- const ScannerGlobalPointer scannerGlobal,
- const QString& dirPath,
- const bool prevHashExists,
- const mixxx::cache_key_t newHash,
- const QLinkedList<QFileInfo>& filesToImport,
- const QLinkedList<QFileInfo>& possibleCovers,
- SecurityTokenPointer pToken);
+ const ScannerGlobalPointer scannerGlobal,
+ const QString& dirPath,
+ const bool prevHashExists,
+ const mixxx::cache_key_t newHash,
+ const std::list<QFileInfo>& filesToImport,
+ const std::list<QFileInfo>& possibleCovers,
+ SecurityTokenPointer pToken);
virtual ~ImportFilesTask() {}
virtual void run();
@@ -28,9 +26,7 @@ class ImportFilesTask : public ScannerTask {
const QString m_dirPath;
const bool m_prevHashExists;
const mixxx::cache_key_t m_newHash;
- const QLinkedList<QFileInfo> m_filesToImport;
- const QLinkedList<QFileInfo> m_possibleCovers;
+ const std::list<QFileInfo> m_filesToImport;
+ const std::list<QFileInfo> m_possibleCovers;
SecurityTokenPointer m_pToken;
};
-
-#endif /* IMPORTFILESTASK_H */
diff --git a/src/library/scanner/recursivescandirectorytask.cpp b/src/library/scanner/recursivescandirectorytask.cpp
index dcef6e1510..a2ce203f04 100644
--- a/src/library/scanner/recursivescandirectorytask.cpp
+++ b/src/library/scanner/recursivescandirectorytask.cpp
@@ -36,9 +36,9 @@ void RecursiveScanDirectoryTask::run() {
QString currentFile;
QFileInfo currentFileInfo;
- QLinkedList<QFileInfo> filesToImport;
- QLinkedList<QFileInfo> possibleCovers;
- QLinkedList<QDir> dirsToScan;
+ std::list<QFileInfo> filesToImport;
+ std::list<QFileInfo> possibleCovers;
+ std::list<QDir> dirsToScan;
QCryptographicHash hasher(QCryptographicHash::Sha256);
@@ -57,9 +57,9 @@ void RecursiveScanDirectoryTask::run() {
const QString& fileName = currentFileInfo.fileName();
if (supportedExtensionsRegex.indexIn(fileName) != -1) {
hasher.addData(currentFile.toUtf8());
- filesToImport.append(currentFileInfo);
+ filesToImport.push_back(currentFileInfo);
} else if (supportedCoverExtensionsRegex.indexIn(fileName) != -1) {
- possibleCovers.append(currentFileInfo);
+ possibleCovers.push_back(currentFileInfo);
}
} else {
// File is a directory
@@ -69,7 +69,7 @@ void RecursiveScanDirectoryTask::run() {
continue;
}
const QDir currentDir(currentFile);
- dirsToScan.append(currentDir);
+ dirsToScan.push_back(currentDir);
}
}
@@ -89,7 +89,7 @@ void RecursiveScanDirectoryTask::run() {
if (prevHash != newHash) {
// Rescan that mofo! If importing fails then the scan was cancelled so
// we return immediately.
- if (!filesToImport.isEmpty()) {
+ if (!filesToImport.empty()) {
m_pScanner->queueTask(
new ImportFilesTask(m_pScanner, m_scannerGlobal, dirPath,
prevHashExists, newHash, filesToImport,
diff --git a/src/library/scanner/recursivescandirectorytask.h b/src/library/scanner/recursivescandirectorytask.h
index 8ed45c4ecf..5a7440cb83 100644
--- a/src/library/scanner/recursivescandirectorytask.h
+++ b/src/library/scanner/recursivescandirectorytask.h
@@ -1,16 +1,15 @@
-#ifndef RECURSIVESCANDIRECTORYTASK_H
-#define RECURSIVESCANDIRECTORYTASK_H
+#pragma once
#include <QDir>
#include "library/scanner/scannertask.h"
#include "util/sandbox.h"
-// Recursively scan a music library. Doesn't import tracks for any directories
-// that have already been scanned and have not changed. Changes are tracked by
-// performing a hash of the directory's file list, and those hashes are stored
-// in the database. Successful if the scan completed without being
-// cancelled. False if the scan was cancelled part-way through.
+/// Recursively scan a music library. Doesn't import tracks for any directories
+/// that have already been scanned and have not changed. Changes are tracked by
+/// performing a hash of the directory's file list, and those hashes are stored
+/// in the database. Successful if the scan completed without being
+/// cancelled. False if the scan was cancelled part-way through.
class RecursiveScanDirectoryTask : public ScannerTask {
Q_OBJECT
public:
@@ -29,5 +28,3 @@ class RecursiveScanDirectoryTask : public ScannerTask {
SecurityTokenPointer m_pToken;
bool m_scanUnhashed;
};
-
-#endif /* RECURSIVESCANDIRECTORYTASK_H */
diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp
index 3101b47139..d745753316 100644
--- a/src/library/setlogfeature.cpp
+++ b/src/library/setlogfeature.cpp
@@ -288,7 +288,15 @@ void SetlogFeature::slotPlayingTrackChanged(TrackPointer currentPlayingTrack) {
if (currentPlayingTrackId.isValid()) {
// Remove the track from the recent tracks list if it's present and put
// at the front of the list.
- track_played_recently = m_recentTracks.removeOne(currentPlayingTrackId);
+ auto it = std::find(std::begin(m_recentTracks),
+ std::end(m_recentTracks),
+ currentPlayingTrackId);
+ if (it == std::end(m_recentTracks)) {
+ track_played_recently = false;
+ } else {
+ track_played_recently = true;
+ m_recentTracks.erase(it);
+ }
m_recentTracks.push_front(currentPlayingTrackId);
// Keep a window of 6 tracks (inspired by 2 decks, 4 samplers)
diff --git a/src/library/setlogfeature.h b/src/library/setlogfeature.h
index 7cb5c2e541..cf7ccef933 100644
--- a/src/library/setlogfeature.h
+++ b/src/library/setlogfeature.h
@@ -1,7 +1,6 @@
#pragma once
#include <QAction>
-#include <QLinkedList>
#include <QPointer>
#include <QSqlTableModel>
@@ -42,7 +41,7 @@ class SetlogFeature : public BasePlaylistFeature {
private:
QString getRootViewHtml() const override;
- QLinkedList<TrackId> m_recentTracks;
+ std::list<TrackId> m_recentTracks;
QAction* m_pJoinWithPreviousAction;
QAction* m_pGetNewPlaylist;
int m_playlistId;
diff --git a/src/library/trackmodel.h b/src/library/trackmodel.h
index f717fe6e44..f2f2334de1 100644
--- a/src/library/trackmodel.h
+++ b/src/library/trackmodel.h
@@ -1,8 +1,6 @@
-#ifndef TRACKMODEL_H
-#define TRACKMODEL_H
+#pragma once
#include <QList>
-#include <QLinkedList>
#include <QItemDelegate>
#include <QtSql>
@@ -102,7 +100,7 @@ class TrackModel {
// Gets the rows of the track in the current result set. Returns an
// empty list if the track ID is not present in the result set.
- virtual const QLinkedList<int> getTrackRows(TrackId trackId) const = 0;
+ virtual const std::list<int> getTrackRows(TrackId trackId) const = 0;
bool isTrackModel() { return true;}
virtual void search(const QString& searchText, const QString& extraFilter=QString()) = 0;
@@ -207,5 +205,3 @@ class TrackModel {
int m_iDefaultSortColumn;
Qt::SortOrder m_eDefaultSortOrder;
};
-
-#endif