From 6dd6589dd5029a516e49f3d4bd1e3649f0afae60 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sat, 25 Apr 2020 19:08:04 +0200 Subject: [PATCH 1/7] Reformat Crate- & PlaylistTableModel --- src/library/crate/crateid.h | 8 +------- src/library/crate/cratetablemodel.h | 17 +++++------------ src/library/playlisttablemodel.h | 17 +++++++---------- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/library/crate/crateid.h b/src/library/crate/crateid.h index be7f210b52e..137dc7baf3a 100644 --- a/src/library/crate/crateid.h +++ b/src/library/crate/crateid.h @@ -1,10 +1,7 @@ -#ifndef MIXXX_CRATEID_H -#define MIXXX_CRATEID_H - +#pragma once #include "util/db/dbid.h" - class CrateId: public DbId { public: // Inherit constructors from base class @@ -13,6 +10,3 @@ class CrateId: public DbId { Q_DECLARE_TYPEINFO(CrateId, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(CrateId) - - -#endif // MIXXX_CRATEID_H diff --git a/src/library/crate/cratetablemodel.h b/src/library/crate/cratetablemodel.h index 43665d8b27a..dcc1443a923 100644 --- a/src/library/crate/cratetablemodel.h +++ b/src/library/crate/cratetablemodel.h @@ -1,12 +1,8 @@ -#ifndef MIXXX_CRATETABLEMODEL_H -#define MIXXX_CRATETABLEMODEL_H - +#pragma once #include "library/basesqltablemodel.h" - #include "library/crate/crateid.h" - class CrateTableModel : public BaseSqlTableModel { Q_OBJECT @@ -14,24 +10,21 @@ class CrateTableModel : public BaseSqlTableModel { CrateTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager); ~CrateTableModel() final; - void selectCrate( - CrateId crateId = CrateId()); + void selectCrate(CrateId crateId = CrateId()); CrateId selectedCrate() const { return m_selectedCrate; } - bool addTrack(const QModelIndex &index, QString location); + bool addTrack(const QModelIndex& index, QString location); // From TrackModel bool isColumnInternal(int column) final; void removeTracks(const QModelIndexList& indices) final; - // Returns the number of unsuccessful track additions + /// Returns the number of unsuccessful additions. int addTracks(const QModelIndex& index, const QList& locations) final; + CapabilitiesFlags getCapabilities() const final; private: CrateId m_selectedCrate; }; - - -#endif // MIXXX_CRATETABLEMODEL_H diff --git a/src/library/playlisttablemodel.h b/src/library/playlisttablemodel.h index ec2bc79d27f..ee4a8b30b67 100644 --- a/src/library/playlisttablemodel.h +++ b/src/library/playlisttablemodel.h @@ -1,13 +1,12 @@ -#ifndef PLAYLISTTABLEMODEL_H -#define PLAYLISTTABLEMODEL_H +#pragma once #include "library/basesqltablemodel.h" class PlaylistTableModel : public BaseSqlTableModel { Q_OBJECT + public: - PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace, bool showAll = false); + PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, bool showAll = false); ~PlaylistTableModel() final = default; void setTableModel(int playlistId = -1); @@ -17,18 +16,18 @@ class PlaylistTableModel : public BaseSqlTableModel { bool appendTrack(TrackId trackId); void moveTrack(const QModelIndex& sourceIndex, - const QModelIndex& destIndex) override; + const QModelIndex& destIndex) override; void removeTrack(const QModelIndex& index); void shuffleTracks(const QModelIndexList& shuffle, const QModelIndex& exclude); bool isColumnInternal(int column) final; bool isColumnHiddenByDefault(int column) final; - // This function should only be used by AUTODJ + /// This function should only be used by AUTODJ void removeTracks(const QModelIndexList& indices) final; - // Adding multiple tracks at one to a playlist. Returns the number of - // successful additions. + /// Returns the number of successful additions. int addTracks(const QModelIndex& index, const QList& locations) final; bool isLocked() final; + CapabilitiesFlags getCapabilities() const final; private slots: @@ -40,5 +39,3 @@ class PlaylistTableModel : public BaseSqlTableModel { int m_iPlaylistId; bool m_showAll; }; - -#endif From 4d4b07d32e58c791a2eab3f62f25ea5f89be1564 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sun, 26 Apr 2020 10:52:33 +0200 Subject: [PATCH 2/7] Rename showAll parameter to keepDeletedTracks --- src/library/playlisttablemodel.cpp | 8 ++++---- src/library/playlisttablemodel.h | 4 ++-- src/library/setlogfeature.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index 3fc58d55708..2e998561485 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -11,10 +11,10 @@ PlaylistTableModel::PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, - bool showAll) + bool keepDeletedTracks) : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace), m_iPlaylistId(-1), - m_showAll(showAll) { + m_keepDeletedTracks(keepDeletedTracks) { } void PlaylistTableModel::initSortColumnMapping() { @@ -62,10 +62,10 @@ void PlaylistTableModel::setTableModel(int playlistId) { m_iPlaylistId = playlistId; - if (!m_showAll) { + if (!m_keepDeletedTracks) { // From Mixxx 2.1 we drop tracks that have been explicitly deleted // in the library (mixxx_deleted = 0) from playlists. - // These invisible tracks, consuming a playlist position number where + // These invisible tracks, consuming a playlist position number were // a source user of confusion in the past. m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().removeHiddenTracks(m_iPlaylistId); } diff --git a/src/library/playlisttablemodel.h b/src/library/playlisttablemodel.h index ee4a8b30b67..2a0e1fee0da 100644 --- a/src/library/playlisttablemodel.h +++ b/src/library/playlisttablemodel.h @@ -6,7 +6,7 @@ class PlaylistTableModel : public BaseSqlTableModel { Q_OBJECT public: - PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, bool showAll = false); + PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, bool keepDeletedTracks = false); ~PlaylistTableModel() final = default; void setTableModel(int playlistId = -1); @@ -37,5 +37,5 @@ class PlaylistTableModel : public BaseSqlTableModel { void initSortColumnMapping() override; int m_iPlaylistId; - bool m_showAll; + bool m_keepDeletedTracks; }; diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index 3101b47139e..5cbf6f1bab8 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -27,7 +27,7 @@ SetlogFeature::SetlogFeature( nullptr, pLibrary->trackCollections(), "mixxx.db.model.setlog", - /*show-all-tracks*/ true), + true), QStringLiteral("SETLOGHOME")), m_playlistId(-1), m_libraryWidget(nullptr), From 6092d8afee15cd8dbc4f27a6f41b0a6977d025db Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sun, 26 Apr 2020 10:53:04 +0200 Subject: [PATCH 3/7] Create TrackSetTableModel --- CMakeLists.txt | 1 + build/depends.py | 1 + src/library/tracksettablemodel.cpp | 1 + src/library/tracksettablemodel.h | 8 ++++++++ 4 files changed, 11 insertions(+) create mode 100644 src/library/tracksettablemodel.cpp create mode 100644 src/library/tracksettablemodel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 013ece64834..0fc08752f7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -441,6 +441,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/library/trackcollection.cpp src/library/trackcollectionmanager.cpp src/library/trackloader.cpp + src/library/tracksettablemodel.cpp src/library/traktor/traktorfeature.cpp src/library/treeitem.cpp src/library/treeitemmodel.cpp diff --git a/build/depends.py b/build/depends.py index e855b4eca4f..410a6ae8d5c 100644 --- a/build/depends.py +++ b/build/depends.py @@ -1053,6 +1053,7 @@ def sources(self, build): "src/library/crate/cratetablemodel.cpp", "src/library/playlisttablemodel.cpp", + "src/library/tracksettablemodel.cpp", "src/library/libraryfeature.cpp", "src/library/analysisfeature.cpp", "src/library/autodj/autodjfeature.cpp", diff --git a/src/library/tracksettablemodel.cpp b/src/library/tracksettablemodel.cpp new file mode 100644 index 00000000000..e3552c31fe1 --- /dev/null +++ b/src/library/tracksettablemodel.cpp @@ -0,0 +1 @@ +#include "tracksettablemodel.h" diff --git a/src/library/tracksettablemodel.h b/src/library/tracksettablemodel.h new file mode 100644 index 00000000000..0b74e89960b --- /dev/null +++ b/src/library/tracksettablemodel.h @@ -0,0 +1,8 @@ +#pragma once + +#include "library/basesqltablemodel.h" + +class TrackSetTableModel : public BaseSqlTableModel { + Q_OBJECT + +}; From 73b6d0355e1a71286f1626d495e224708c493cf1 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sun, 26 Apr 2020 15:07:52 +0200 Subject: [PATCH 4/7] Make TrackSetTableModel the common ancestor of Playlist- & CrateTableModel --- src/library/basesqltablemodel.cpp | 18 ++++++------------ src/library/basetracktablemodel.cpp | 9 ++------- src/library/basetracktablemodel.h | 4 ++-- src/library/crate/cratetablemodel.cpp | 6 ++---- src/library/crate/cratetablemodel.h | 3 ++- src/library/playlisttablemodel.cpp | 2 +- src/library/playlisttablemodel.h | 3 ++- src/library/tracksettablemodel.cpp | 4 ++++ src/library/tracksettablemodel.h | 2 ++ 9 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp index 03035310fb3..eb921d1ab14 100644 --- a/src/library/basesqltablemodel.cpp +++ b/src/library/basesqltablemodel.cpp @@ -39,18 +39,12 @@ const QString kEmptyString = QStringLiteral(""); } // anonymous namespace -BaseSqlTableModel::BaseSqlTableModel( - QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace) - : BaseTrackTableModel( - settingsNamespace, - pTrackCollectionManager, - parent), - m_pTrackCollectionManager(pTrackCollectionManager), - m_database(pTrackCollectionManager->internalCollection()->database()), - m_bInitialized(false), - m_currentSearch(kEmptyString) { +BaseSqlTableModel::BaseSqlTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) + : BaseTrackTableModel(parent, pTrackCollectionManager, settingsNamespace), + m_pTrackCollectionManager(pTrackCollectionManager), + m_database(pTrackCollectionManager->internalCollection()->database()), + m_bInitialized(false), + m_currentSearch(kEmptyString) { } BaseSqlTableModel::~BaseSqlTableModel() { diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 81e7c186e67..4121a436a69 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -88,14 +88,9 @@ QStringList BaseTrackTableModel::defaultTableColumns() { return kDefaultTableColumns; } -BaseTrackTableModel::BaseTrackTableModel( - const char* settingsNamespace, - TrackCollectionManager* pTrackCollectionManager, - QObject* parent) +BaseTrackTableModel::BaseTrackTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) : QAbstractTableModel(parent), - TrackModel( - cloneDatabase(pTrackCollectionManager), - settingsNamespace), + TrackModel(cloneDatabase(pTrackCollectionManager), settingsNamespace), m_pTrackCollectionManager(pTrackCollectionManager), m_previewDeckGroup(PlayerManager::groupForPreviewDeck(0)), m_backgroundColorOpacity(WLibrary::kDefaultTrackTableBackgroundColorOpacity) { diff --git a/src/library/basetracktablemodel.h b/src/library/basetracktablemodel.h index bf40a595d43..a3277735825 100644 --- a/src/library/basetracktablemodel.h +++ b/src/library/basetracktablemodel.h @@ -18,9 +18,9 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { public: explicit BaseTrackTableModel( - const char* settingsNamespace, + QObject* parent, TrackCollectionManager* const pTrackCollectionManager, - QObject* parent); + const char* settingsNamespace); ~BaseTrackTableModel() override = default; /////////////////////////////////////////////////////// diff --git a/src/library/crate/cratetablemodel.cpp b/src/library/crate/cratetablemodel.cpp index d2763c8be87..6c337efd4c1 100644 --- a/src/library/crate/cratetablemodel.cpp +++ b/src/library/crate/cratetablemodel.cpp @@ -1,4 +1,3 @@ - #include "library/crate/cratetablemodel.h" #include "library/dao/trackschema.h" @@ -9,9 +8,8 @@ #include -CrateTableModel::CrateTableModel(QObject* pParent, - TrackCollectionManager* pTrackCollectionManager) - : BaseSqlTableModel(pParent, pTrackCollectionManager, +CrateTableModel::CrateTableModel(QObject* pParent, TrackCollectionManager* pTrackCollectionManager) + : TrackSetTableModel(pParent, pTrackCollectionManager, "mixxx.db.model.crate") { } diff --git a/src/library/crate/cratetablemodel.h b/src/library/crate/cratetablemodel.h index dcc1443a923..f5ced816d03 100644 --- a/src/library/crate/cratetablemodel.h +++ b/src/library/crate/cratetablemodel.h @@ -2,8 +2,9 @@ #include "library/basesqltablemodel.h" #include "library/crate/crateid.h" +#include "library/tracksettablemodel.h" -class CrateTableModel : public BaseSqlTableModel { +class CrateTableModel : public TrackSetTableModel { Q_OBJECT public: diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index 2e998561485..f2a93489537 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -12,7 +12,7 @@ PlaylistTableModel::PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, bool keepDeletedTracks) - : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace), + : TrackSetTableModel(parent, pTrackCollectionManager, settingsNamespace), m_iPlaylistId(-1), m_keepDeletedTracks(keepDeletedTracks) { } diff --git a/src/library/playlisttablemodel.h b/src/library/playlisttablemodel.h index 2a0e1fee0da..79049e3f8b7 100644 --- a/src/library/playlisttablemodel.h +++ b/src/library/playlisttablemodel.h @@ -1,8 +1,9 @@ #pragma once #include "library/basesqltablemodel.h" +#include "library/tracksettablemodel.h" -class PlaylistTableModel : public BaseSqlTableModel { +class PlaylistTableModel : public TrackSetTableModel { Q_OBJECT public: diff --git a/src/library/tracksettablemodel.cpp b/src/library/tracksettablemodel.cpp index e3552c31fe1..3ba5e150037 100644 --- a/src/library/tracksettablemodel.cpp +++ b/src/library/tracksettablemodel.cpp @@ -1 +1,5 @@ #include "tracksettablemodel.h" + +TrackSetTableModel::TrackSetTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) + : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace) { +} diff --git a/src/library/tracksettablemodel.h b/src/library/tracksettablemodel.h index 0b74e89960b..1ada516706a 100644 --- a/src/library/tracksettablemodel.h +++ b/src/library/tracksettablemodel.h @@ -5,4 +5,6 @@ class TrackSetTableModel : public BaseSqlTableModel { Q_OBJECT + public: + TrackSetTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace); }; From 37290c6e983e1bb35384019f34408fb3506f470d Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sun, 26 Apr 2020 15:29:11 +0200 Subject: [PATCH 5/7] Clean up & refactor isColumnInternal methods --- src/library/baseexternalplaylistmodel.cpp | 7 ++-- src/library/baseexternaltrackmodel.cpp | 8 ++--- src/library/crate/cratetablemodel.cpp | 18 ---------- src/library/crate/cratetablemodel.h | 4 +-- src/library/hiddentablemodel.cpp | 9 ++--- src/library/librarytablemodel.cpp | 38 ++++++++++------------ src/library/missingtablemodel.cpp | 9 ++--- src/library/playlisttablemodel.cpp | 18 ++-------- src/library/playlisttablemodel.h | 3 +- src/library/rekordbox/rekordboxfeature.cpp | 5 +-- src/library/tracksettablemodel.cpp | 17 ++++++++++ src/library/tracksettablemodel.h | 2 ++ 12 files changed, 51 insertions(+), 87 deletions(-) diff --git a/src/library/baseexternalplaylistmodel.cpp b/src/library/baseexternalplaylistmodel.cpp index 0a2b17807cb..9549274dd31 100644 --- a/src/library/baseexternalplaylistmodel.cpp +++ b/src/library/baseexternalplaylistmodel.cpp @@ -78,12 +78,9 @@ TrackId BaseExternalPlaylistModel::getTrackId(const QModelIndex& index) const { } bool BaseExternalPlaylistModel::isColumnInternal(int column) { - if (column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || + return column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { - return true; - } - return false; + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)); } Qt::ItemFlags BaseExternalPlaylistModel::flags(const QModelIndex &index) const { diff --git a/src/library/baseexternaltrackmodel.cpp b/src/library/baseexternaltrackmodel.cpp index 68f2aa87948..1fa1f2b267a 100644 --- a/src/library/baseexternaltrackmodel.cpp +++ b/src/library/baseexternaltrackmodel.cpp @@ -104,13 +104,9 @@ TrackId BaseExternalTrackModel::doGetTrackId(const TrackPointer& pTrack) const { } bool BaseExternalTrackModel::isColumnInternal(int column) { - // Used for preview deck widgets. - if (column == fieldIndex(LIBRARYTABLE_ID) || + return column == fieldIndex(LIBRARYTABLE_ID) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { - return true; - } - return false; + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)); } Qt::ItemFlags BaseExternalTrackModel::flags(const QModelIndex &index) const { diff --git a/src/library/crate/cratetablemodel.cpp b/src/library/crate/cratetablemodel.cpp index 6c337efd4c1..e47d4743cd2 100644 --- a/src/library/crate/cratetablemodel.cpp +++ b/src/library/crate/cratetablemodel.cpp @@ -13,9 +13,6 @@ CrateTableModel::CrateTableModel(QObject* pParent, TrackCollectionManager* pTrac "mixxx.db.model.crate") { } -CrateTableModel::~CrateTableModel() { -} - void CrateTableModel::selectCrate(CrateId crateId) { //qDebug() << "CrateTableModel::setCrate()" << crateId; if (crateId == m_selectedCrate) { @@ -125,21 +122,6 @@ TrackModel::CapabilitiesFlags CrateTableModel::getCapabilities() const { return caps; } -bool CrateTableModel::isColumnInternal(int column) { - return column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID)|| - column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || - (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH);; -} - int CrateTableModel::addTracks(const QModelIndex& index, const QList& locations) { Q_UNUSED(index); diff --git a/src/library/crate/cratetablemodel.h b/src/library/crate/cratetablemodel.h index f5ced816d03..e0ac155a375 100644 --- a/src/library/crate/cratetablemodel.h +++ b/src/library/crate/cratetablemodel.h @@ -9,7 +9,7 @@ class CrateTableModel : public TrackSetTableModel { public: CrateTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager); - ~CrateTableModel() final; + ~CrateTableModel() final = default; void selectCrate(CrateId crateId = CrateId()); CrateId selectedCrate() const { @@ -18,8 +18,6 @@ class CrateTableModel : public TrackSetTableModel { bool addTrack(const QModelIndex& index, QString location); - // From TrackModel - bool isColumnInternal(int column) final; void removeTracks(const QModelIndexList& indices) final; /// Returns the number of unsuccessful additions. int addTracks(const QModelIndex& index, const QList& locations) final; diff --git a/src/library/hiddentablemodel.cpp b/src/library/hiddentablemodel.cpp index 7bc955e08e3..207aec4dea6 100644 --- a/src/library/hiddentablemodel.cpp +++ b/src/library/hiddentablemodel.cpp @@ -69,19 +69,16 @@ void HiddenTableModel::unhideTracks(const QModelIndexList& indices) { } bool HiddenTableModel::isColumnInternal(int column) { - if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || + return column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID)|| + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID) || column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH)) { - return true; - } - return false; + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH); } // Override flags from BaseSqlModel since we don't want edit this model diff --git a/src/library/librarytablemodel.cpp b/src/library/librarytablemodel.cpp index 336ac3bb61f..73dde3b9023 100644 --- a/src/library/librarytablemodel.cpp +++ b/src/library/librarytablemodel.cpp @@ -71,28 +71,24 @@ int LibraryTableModel::addTracks(const QModelIndex& index, } bool LibraryTableModel::isColumnInternal(int column) { - if ((column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_URL)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_CUEPOINT)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_WAVESUMMARYHEX)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_SAMPLERATE)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_HEADERPARSED)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID))|| - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_CHANNELS)) || - (column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED)) || + return column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_URL) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_CUEPOINT) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_WAVESUMMARYHEX) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_SAMPLERATE) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_HEADERPARSED) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_CHANNELS) || + column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION)) || - (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH))) { - return true; - } - - return false; + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH); } TrackModel::CapabilitiesFlags LibraryTableModel::getCapabilities() const { diff --git a/src/library/missingtablemodel.cpp b/src/library/missingtablemodel.cpp index 933f016063f..c091db310a2 100644 --- a/src/library/missingtablemodel.cpp +++ b/src/library/missingtablemodel.cpp @@ -66,19 +66,16 @@ void MissingTableModel::purgeTracks(const QModelIndexList& indices) { bool MissingTableModel::isColumnInternal(int column) { - if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || + return column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID)|| + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH)) { - return true; - } - return false; + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH); } // Override flags from BaseSqlModel since we don't want edit this model diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index f2a93489537..e56e782cf06 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -244,22 +244,8 @@ void PlaylistTableModel::shuffleTracks(const QModelIndexList& shuffle, const QMo } bool PlaylistTableModel::isColumnInternal(int column) { - if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || - column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID)|| - column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || - (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH)) { - return true; - } - return false; + return column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || + TrackSetTableModel::isColumnInternal(column); } bool PlaylistTableModel::isColumnHiddenByDefault(int column) { diff --git a/src/library/playlisttablemodel.h b/src/library/playlisttablemodel.h index 79049e3f8b7..e3e2fdf13de 100644 --- a/src/library/playlisttablemodel.h +++ b/src/library/playlisttablemodel.h @@ -16,8 +16,7 @@ class PlaylistTableModel : public TrackSetTableModel { } bool appendTrack(TrackId trackId); - void moveTrack(const QModelIndex& sourceIndex, - const QModelIndex& destIndex) override; + void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex) override; void removeTrack(const QModelIndex& index); void shuffleTracks(const QModelIndexList& shuffle, const QModelIndex& exclude); diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index fa310b88e9a..c2ef77205d5 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -1155,10 +1155,7 @@ bool RekordboxPlaylistModel::isColumnHiddenByDefault(int column) { } bool RekordboxPlaylistModel::isColumnInternal(int column) { - if (column == fieldIndex(ColumnCache::COLUMN_REKORDBOX_ANALYZE_PATH)) { - return true; - } - return BaseExternalPlaylistModel::isColumnInternal(column); + return column == fieldIndex(ColumnCache::COLUMN_REKORDBOX_ANALYZE_PATH) || BaseExternalPlaylistModel::isColumnInternal(column); } RekordboxFeature::RekordboxFeature( diff --git a/src/library/tracksettablemodel.cpp b/src/library/tracksettablemodel.cpp index 3ba5e150037..6e6aefd8e3f 100644 --- a/src/library/tracksettablemodel.cpp +++ b/src/library/tracksettablemodel.cpp @@ -1,5 +1,22 @@ #include "tracksettablemodel.h" +#include "mixer/playermanager.h" + TrackSetTableModel::TrackSetTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace) { } + +bool TrackSetTableModel::isColumnInternal(int column) { + return column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ID) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_MIXXXDELETED) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID)|| + column == fieldIndex(ColumnCache::COLUMN_TRACKLOCATIONSTABLE_FSDELETED) || + (PlayerManager::numPreviewDecks() == 0 && + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_SOURCE) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_TYPE) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_LOCATION) || + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART_HASH);; +} diff --git a/src/library/tracksettablemodel.h b/src/library/tracksettablemodel.h index 1ada516706a..bb569e6e93c 100644 --- a/src/library/tracksettablemodel.h +++ b/src/library/tracksettablemodel.h @@ -7,4 +7,6 @@ class TrackSetTableModel : public BaseSqlTableModel { public: TrackSetTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace); + + bool isColumnInternal(int column) override; }; From 1afd4babd93416d223be76fe113ecfae01553111 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Tue, 19 May 2020 13:03:37 +0200 Subject: [PATCH 6/7] Reformat constructors --- src/library/basesqltablemodel.cpp | 13 ++++++++----- src/library/basetracktablemodel.cpp | 5 ++++- src/library/crate/cratetablemodel.cpp | 9 ++++----- src/library/playlisttablemodel.cpp | 11 +++++------ src/library/tracksettablemodel.cpp | 5 ++++- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp index eb921d1ab14..db94bbae611 100644 --- a/src/library/basesqltablemodel.cpp +++ b/src/library/basesqltablemodel.cpp @@ -39,12 +39,15 @@ const QString kEmptyString = QStringLiteral(""); } // anonymous namespace -BaseSqlTableModel::BaseSqlTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) +BaseSqlTableModel::BaseSqlTableModel( + QObject* parent, + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace) : BaseTrackTableModel(parent, pTrackCollectionManager, settingsNamespace), - m_pTrackCollectionManager(pTrackCollectionManager), - m_database(pTrackCollectionManager->internalCollection()->database()), - m_bInitialized(false), - m_currentSearch(kEmptyString) { + m_pTrackCollectionManager(pTrackCollectionManager), + m_database(pTrackCollectionManager->internalCollection()->database()), + m_bInitialized(false), + m_currentSearch(kEmptyString) { } BaseSqlTableModel::~BaseSqlTableModel() { diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 4121a436a69..b3d401fff6d 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -88,7 +88,10 @@ QStringList BaseTrackTableModel::defaultTableColumns() { return kDefaultTableColumns; } -BaseTrackTableModel::BaseTrackTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) +BaseTrackTableModel::BaseTrackTableModel( + QObject* parent, + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace) : QAbstractTableModel(parent), TrackModel(cloneDatabase(pTrackCollectionManager), settingsNamespace), m_pTrackCollectionManager(pTrackCollectionManager), diff --git a/src/library/crate/cratetablemodel.cpp b/src/library/crate/cratetablemodel.cpp index e47d4743cd2..588a453dd27 100644 --- a/src/library/crate/cratetablemodel.cpp +++ b/src/library/crate/cratetablemodel.cpp @@ -6,11 +6,10 @@ #include "mixer/playermanager.h" #include "util/db/fwdsqlquery.h" -#include - -CrateTableModel::CrateTableModel(QObject* pParent, TrackCollectionManager* pTrackCollectionManager) - : TrackSetTableModel(pParent, pTrackCollectionManager, - "mixxx.db.model.crate") { +CrateTableModel::CrateTableModel( + QObject* pParent, + TrackCollectionManager* pTrackCollectionManager) + : TrackSetTableModel(pParent, pTrackCollectionManager, "mixxx.db.model.crate") { } void CrateTableModel::selectCrate(CrateId crateId) { diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index e56e782cf06..5c1e477ef9c 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -6,12 +6,11 @@ #include "library/trackcollection.h" #include "library/trackcollectionmanager.h" -#include "mixer/playermanager.h" - -PlaylistTableModel::PlaylistTableModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace, - bool keepDeletedTracks) +PlaylistTableModel::PlaylistTableModel( + QObject* parent, + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace, + bool keepDeletedTracks) : TrackSetTableModel(parent, pTrackCollectionManager, settingsNamespace), m_iPlaylistId(-1), m_keepDeletedTracks(keepDeletedTracks) { diff --git a/src/library/tracksettablemodel.cpp b/src/library/tracksettablemodel.cpp index 6e6aefd8e3f..cbed3978ac5 100644 --- a/src/library/tracksettablemodel.cpp +++ b/src/library/tracksettablemodel.cpp @@ -2,7 +2,10 @@ #include "mixer/playermanager.h" -TrackSetTableModel::TrackSetTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace) +TrackSetTableModel::TrackSetTableModel( + QObject* parent, + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace) : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace) { } From cbc2153366e2170434165cff9bab3374a97628c9 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Thu, 21 May 2020 11:50:29 +0200 Subject: [PATCH 7/7] Add parameter comment back --- src/library/setlogfeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index 5cbf6f1bab8..436eff37e96 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -27,7 +27,7 @@ SetlogFeature::SetlogFeature( nullptr, pLibrary->trackCollections(), "mixxx.db.model.setlog", - true), + /*keep deleted tracks*/true), QStringLiteral("SETLOGHOME")), m_playlistId(-1), m_libraryWidget(nullptr),