diff options
author | Owen Williams <owilliams@mixxx.org> | 2020-11-17 22:49:05 -0500 |
---|---|---|
committer | Owen Williams <owilliams@mixxx.org> | 2020-11-17 22:49:05 -0500 |
commit | b4d297a6fd7c4bd3f558132b553ff2cd33f60197 (patch) | |
tree | 9cc27f298800a9de65c8c686ca0b9051a6715837 | |
parent | b878d36feb2b8eded824bf6ff33d2b22afd210ab (diff) |
Column Cache: address notes
-rw-r--r-- | src/library/dao/trackschema.cpp | 56 | ||||
-rw-r--r-- | src/library/dao/trackschema.h | 49 | ||||
-rw-r--r-- | src/library/mixxxlibraryfeature.cpp | 11 |
3 files changed, 55 insertions, 61 deletions
diff --git a/src/library/dao/trackschema.cpp b/src/library/dao/trackschema.cpp index ef948c4bca..7f89e9a839 100644 --- a/src/library/dao/trackschema.cpp +++ b/src/library/dao/trackschema.cpp @@ -1,51 +1,13 @@ #include "library/dao/trackschema.h" -//static -QStringList TrackSchema::GetColumnNames() { - QStringList columns; - - // This is the canonical ordering of columns. Changing this order can break things, so always - // add new columns to the bottom of the list. - columns << LIBRARYTABLE_ID - << LIBRARYTABLE_PLAYED - << LIBRARYTABLE_TIMESPLAYED - //has to be up here otherwise Played and TimesPlayed are not shown - << LIBRARYTABLE_ALBUMARTIST - << LIBRARYTABLE_ALBUM - << LIBRARYTABLE_ARTIST - << LIBRARYTABLE_TITLE - << LIBRARYTABLE_YEAR - << LIBRARYTABLE_RATING - << LIBRARYTABLE_GENRE - << LIBRARYTABLE_COMPOSER - << LIBRARYTABLE_GROUPING - << LIBRARYTABLE_TRACKNUMBER - << LIBRARYTABLE_KEY - << LIBRARYTABLE_KEY_ID - << LIBRARYTABLE_BPM - << LIBRARYTABLE_BPM_LOCK - << LIBRARYTABLE_DURATION - << LIBRARYTABLE_BITRATE - << LIBRARYTABLE_REPLAYGAIN - << LIBRARYTABLE_FILETYPE - << LIBRARYTABLE_DATETIMEADDED - << TRACKLOCATIONSTABLE_LOCATION - << TRACKLOCATIONSTABLE_FSDELETED - << LIBRARYTABLE_COMMENT - << LIBRARYTABLE_MIXXXDELETED - << LIBRARYTABLE_COLOR - << LIBRARYTABLE_COVERART_SOURCE - << LIBRARYTABLE_COVERART_TYPE - << LIBRARYTABLE_COVERART_LOCATION - << LIBRARYTABLE_COVERART_HASH; - return columns; -} - -// static -QString TrackSchema::TableForColumn(const QString& columnName){ - if (columnName == "location" || columnName == "fs_deleted") { - return "track_locations"; +namespace mixxx { +namespace TrackSchema { +QString tableForColumn(const QString& columnName) { + if (columnName == TRACKLOCATIONSTABLE_FSDELETED || columnName == TRACKLOCATIONSTABLE_LOCATION) { + return QStringLiteral(TRACKLOCATIONS_TABLE); } // This doesn't detect unknown columns, but that's not really important here. - return "library"; -}
\ No newline at end of file + return QStringLiteral(LIBRARY_TABLE); +} +} // namespace TrackSchema +} // namespace mixxx diff --git a/src/library/dao/trackschema.h b/src/library/dao/trackschema.h index f423f9a016..0284b4fc6a 100644 --- a/src/library/dao/trackschema.h +++ b/src/library/dao/trackschema.h @@ -5,6 +5,7 @@ #include <QStringList> #define LIBRARY_TABLE "library" +#define TRACKLOCATIONS_TABLE "track_locations" const QString LIBRARYTABLE_ID = "id"; const QString LIBRARYTABLE_ARTIST = "artist"; @@ -55,15 +56,45 @@ const QString TRACKLOCATIONSTABLE_NEEDSVERIFICATION = "needs_verification"; const QString REKORDBOX_ANALYZE_PATH = "analyze_path"; -// Simple static-only class for getting the ordered subset of columns used in the track headers. -class TrackSchema { -public: - // GetColumns returns a QStringList of all the relevant columns that can be displayed to the - // user. - static QStringList GetColumnNames(); +const QStringList DEFAULT_COLUMNS = { + LIBRARYTABLE_ID, + LIBRARYTABLE_PLAYED, + LIBRARYTABLE_TIMESPLAYED, + //has to be up here otherwise Played and TimesPlayed are not shown + LIBRARYTABLE_ALBUMARTIST, + LIBRARYTABLE_ALBUM, + LIBRARYTABLE_ARTIST, + LIBRARYTABLE_TITLE, + LIBRARYTABLE_YEAR, + LIBRARYTABLE_RATING, + LIBRARYTABLE_GENRE, + LIBRARYTABLE_COMPOSER, + LIBRARYTABLE_GROUPING, + LIBRARYTABLE_TRACKNUMBER, + LIBRARYTABLE_KEY, + LIBRARYTABLE_KEY_ID, + LIBRARYTABLE_BPM, + LIBRARYTABLE_BPM_LOCK, + LIBRARYTABLE_DURATION, + LIBRARYTABLE_BITRATE, + LIBRARYTABLE_REPLAYGAIN, + LIBRARYTABLE_FILETYPE, + LIBRARYTABLE_DATETIMEADDED, + TRACKLOCATIONSTABLE_LOCATION, + TRACKLOCATIONSTABLE_FSDELETED, + LIBRARYTABLE_COMMENT, + LIBRARYTABLE_MIXXXDELETED, + LIBRARYTABLE_COLOR, + LIBRARYTABLE_COVERART_SOURCE, + LIBRARYTABLE_COVERART_TYPE, + LIBRARYTABLE_COVERART_LOCATION, + LIBRARYTABLE_COVERART_HASH}; - // TableForColumn returns the name of the table that contains the named column. - static QString TableForColumn(const QString& columnName); -}; +namespace mixxx { +namespace TrackSchema { +// TableForColumn returns the name of the table that contains the named column. +QString tableForColumn(const QString& columnName); +} // namespace TrackSchema +} // namespace mixxx #endif //MIXXX_TRACKSCHEMA_H diff --git a/src/library/mixxxlibraryfeature.cpp b/src/library/mixxxlibraryfeature.cpp index d51cc5abde..8fd8e11c2d 100644 --- a/src/library/mixxxlibraryfeature.cpp +++ b/src/library/mixxxlibraryfeature.cpp @@ -32,12 +32,13 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary, m_pLibraryTableModel(nullptr), m_pMissingView(nullptr), m_pHiddenView(nullptr) { - QStringList columns = TrackSchema::GetColumnNames(); - QStringList columnsWithTables; + QStringList columns = DEFAULT_COLUMNS; + QStringList qualifiedTableColumns; qDebug() << "THIS PART----------------------"; for (const auto& col : columns) { - qDebug() << QString("%1.%2").arg(TrackSchema::TableForColumn(col), col); - columnsWithTables.append(QString("%1.%2").arg(TrackSchema::TableForColumn(col), col)); + qDebug() << (mixxx::TrackSchema::tableForColumn(col) + QLatin1Char('.') + col); + qualifiedTableColumns.append(mixxx::TrackSchema::tableForColumn(col) + + QLatin1Char('.') + col); } QSqlQuery query(m_pTrackCollection->database()); @@ -46,7 +47,7 @@ MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary, "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " "SELECT %2 FROM library " "INNER JOIN track_locations ON library.location = track_locations.id") - .arg(tableName, columnsWithTables.join(",")); + .arg(tableName, qualifiedTableColumns.join(",")); qDebug() << "and well" << queryString; query.prepare(queryString); if (!query.exec()) { |