diff options
author | xerus2000 <27jf@pm.me> | 2020-04-26 14:02:29 +0200 |
---|---|---|
committer | xerus2000 <27jf@pm.me> | 2020-04-26 14:02:29 +0200 |
commit | d31825b985bad72e467b1b69ab4267dda888e335 (patch) | |
tree | 79ee21ebdbe17d3ff46807250b124e359e2f0250 /src/library | |
parent | e566faeff0256ba2f53987e7344b7f81300caa5f (diff) |
Clean up CapabilitiesFlags and apply clang format
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/banshee/bansheeplaylistmodel.cpp | 193 | ||||
-rw-r--r-- | src/library/baseexternalplaylistmodel.cpp | 72 | ||||
-rw-r--r-- | src/library/baseexternaltrackmodel.cpp | 42 | ||||
-rw-r--r-- | src/library/basetracktablemodel.cpp | 4 | ||||
-rw-r--r-- | src/library/basetracktablemodel.h | 2 | ||||
-rw-r--r-- | src/library/browse/browsetablemodel.cpp | 63 | ||||
-rw-r--r-- | src/library/hiddentablemodel.cpp | 33 | ||||
-rw-r--r-- | src/library/librarytablemodel.cpp | 48 | ||||
-rw-r--r-- | src/library/missingtablemodel.cpp | 2 | ||||
-rw-r--r-- | src/library/playlisttablemodel.cpp | 60 | ||||
-rw-r--r-- | src/library/proxytrackmodel.cpp | 13 | ||||
-rw-r--r-- | src/library/trackmodel.h | 43 | ||||
-rw-r--r-- | src/library/trackset/crate/cratetablemodel.cpp | 14 |
13 files changed, 292 insertions, 297 deletions
diff --git a/src/library/banshee/bansheeplaylistmodel.cpp b/src/library/banshee/bansheeplaylistmodel.cpp index d3c6a44cd4..16d8fe7129 100644 --- a/src/library/banshee/bansheeplaylistmodel.cpp +++ b/src/library/banshee/bansheeplaylistmodel.cpp @@ -1,14 +1,14 @@ +#include "library/banshee/bansheeplaylistmodel.h" + #include <QtDebug> -#include "library/banshee/bansheeplaylistmodel.h" #include "library/banshee/bansheedbconnection.h" #include "library/queryutil.h" #include "library/starrating.h" -#include "library/previewbuttondelegate.h" #include "library/trackcollectionmanager.h" +#include "mixer/playermanager.h" #include "track/beatfactory.h" #include "track/beats.h" -#include "mixer/playermanager.h" #define BANSHEE_TABLE "banshee" #define CLM_TRACK_ID "track_id" @@ -75,71 +75,75 @@ void BansheePlaylistModel::setTableModel(int playlistId) { m_playlistId = playlistId; QSqlQuery query(m_database); - QString strQuery("CREATE TEMP TABLE IF NOT EXISTS %1" - " (" CLM_TRACK_ID " INTEGER, " - CLM_VIEW_ORDER " INTEGER, " - CLM_ARTIST " TEXT, " - CLM_TITLE " TEXT, " - CLM_DURATION " INTEGER, " - CLM_URI " TEXT, " - CLM_ALBUM " TEXT, " - CLM_ALBUM_ARTIST " TEXT, " - CLM_YEAR " INTEGER, " - CLM_RATING " INTEGER, " - CLM_GENRE " TEXT, " - CLM_GROUPING " TEXT, " - CLM_TRACKNUMBER " INTEGER, " - CLM_DATEADDED " INTEGER, " - CLM_BPM " INTEGER, " - CLM_BITRATE " INTEGER, " - CLM_COMMENT " TEXT, " - CLM_PLAYCOUNT" INTEGER, " - CLM_COMPOSER " TEXT, " - CLM_PREVIEW " TEXT)"); + QString strQuery( + "CREATE TEMP TABLE IF NOT EXISTS %1" + " (" CLM_TRACK_ID + " INTEGER, " CLM_VIEW_ORDER + " INTEGER, " CLM_ARTIST + " TEXT, " CLM_TITLE + " TEXT, " CLM_DURATION + " INTEGER, " CLM_URI + " TEXT, " CLM_ALBUM + " TEXT, " CLM_ALBUM_ARTIST + " TEXT, " CLM_YEAR + " INTEGER, " CLM_RATING + " INTEGER, " CLM_GENRE + " TEXT, " CLM_GROUPING + " TEXT, " CLM_TRACKNUMBER + " INTEGER, " CLM_DATEADDED + " INTEGER, " CLM_BPM + " INTEGER, " CLM_BITRATE + " INTEGER, " CLM_COMMENT + " TEXT, " CLM_PLAYCOUNT + " INTEGER, " CLM_COMPOSER + " TEXT, " CLM_PREVIEW + " TEXT)"); if (!query.exec(strQuery.arg(m_tempTableName))) { LOG_FAILED_QUERY(query); } - QString strQuery2("INSERT INTO %1" - " (" CLM_TRACK_ID ", " - CLM_VIEW_ORDER ", " - CLM_ARTIST ", " - CLM_TITLE ", " - CLM_DURATION ", " - CLM_URI ", " - CLM_ALBUM ", " - CLM_ALBUM_ARTIST ", " - CLM_YEAR ", " - CLM_RATING ", " - CLM_GENRE ", " - CLM_GROUPING ", " - CLM_TRACKNUMBER ", " - CLM_DATEADDED ", " - CLM_BPM ", " - CLM_BITRATE ", " - CLM_COMMENT ", " - CLM_PLAYCOUNT ", " - CLM_COMPOSER ") " - "VALUES (:" - CLM_TRACK_ID ", :" - CLM_VIEW_ORDER ", :" - CLM_ARTIST ", :" - CLM_TITLE ", :" - CLM_DURATION ", :" - CLM_URI ", :" - CLM_ALBUM ", :" - CLM_ALBUM_ARTIST ", :" - CLM_YEAR ", :" - CLM_RATING ", :" - CLM_GENRE ", :" - CLM_GROUPING ", :" - CLM_TRACKNUMBER ", :" - CLM_DATEADDED ", :" - CLM_BPM ", :" - CLM_BITRATE ", :" - CLM_COMMENT ", :" - CLM_PLAYCOUNT ", :" - CLM_COMPOSER ") "); + QString strQuery2( + "INSERT INTO %1" + " (" CLM_TRACK_ID + ", " CLM_VIEW_ORDER + ", " CLM_ARTIST + ", " CLM_TITLE + ", " CLM_DURATION + ", " CLM_URI + ", " CLM_ALBUM + ", " CLM_ALBUM_ARTIST + ", " CLM_YEAR + ", " CLM_RATING + ", " CLM_GENRE + ", " CLM_GROUPING + ", " CLM_TRACKNUMBER + ", " CLM_DATEADDED + ", " CLM_BPM + ", " CLM_BITRATE + ", " CLM_COMMENT + ", " CLM_PLAYCOUNT + ", " CLM_COMPOSER + ") " + "VALUES (:" CLM_TRACK_ID + ", :" CLM_VIEW_ORDER + ", :" CLM_ARTIST + ", :" CLM_TITLE + ", :" CLM_DURATION + ", :" CLM_URI + ", :" CLM_ALBUM + ", :" CLM_ALBUM_ARTIST + ", :" CLM_YEAR + ", :" CLM_RATING + ", :" CLM_GENRE + ", :" CLM_GROUPING + ", :" CLM_TRACKNUMBER + ", :" CLM_DATEADDED + ", :" CLM_BPM + ", :" CLM_BITRATE + ", :" CLM_COMMENT + ", :" CLM_PLAYCOUNT + ", :" CLM_COMPOSER + ") "); query.prepare(strQuery2.arg(m_tempTableName)); @@ -186,34 +190,33 @@ void BansheePlaylistModel::setTableModel(int playlistId) { QStringList tableColumns; tableColumns - << CLM_TRACK_ID // 0 - << CLM_VIEW_ORDER - << CLM_PREVIEW; // 3 + << CLM_TRACK_ID // 0 + << CLM_VIEW_ORDER + << CLM_PREVIEW; // 3 QStringList trackSourceColumns; trackSourceColumns - << CLM_TRACK_ID // 0 - << CLM_ARTIST - << CLM_TITLE - << CLM_DURATION - << CLM_URI - << CLM_ALBUM - << CLM_ALBUM_ARTIST - << CLM_YEAR - << CLM_RATING - << CLM_GENRE - << CLM_GROUPING - << CLM_TRACKNUMBER - << CLM_DATEADDED - << CLM_BPM - << CLM_BITRATE - << CLM_COMMENT - << CLM_PLAYCOUNT - << CLM_COMPOSER; + << CLM_TRACK_ID // 0 + << CLM_ARTIST + << CLM_TITLE + << CLM_DURATION + << CLM_URI + << CLM_ALBUM + << CLM_ALBUM_ARTIST + << CLM_YEAR + << CLM_RATING + << CLM_GENRE + << CLM_GROUPING + << CLM_TRACKNUMBER + << CLM_DATEADDED + << CLM_BPM + << CLM_BITRATE + << CLM_COMMENT + << CLM_PLAYCOUNT + << CLM_COMPOSER; QSharedPointer<BaseTrackCache> trackSource( - new BaseTrackCache(m_pTrackCollectionManager->internalCollection(), m_tempTableName, CLM_TRACK_ID, - trackSourceColumns, false)); + new BaseTrackCache(m_pTrackCollectionManager->internalCollection(), m_tempTableName, CLM_TRACK_ID, trackSourceColumns, false)); setTable(m_tempTableName, CLM_TRACK_ID, tableColumns, trackSource); setSearch(""); @@ -222,15 +225,14 @@ void BansheePlaylistModel::setTableModel(int playlistId) { } TrackModel::CapabilitiesFlags BansheePlaylistModel::getCapabilities() const { - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_ADDTOPLAYLIST - | TRACKMODELCAPS_ADDTOCRATE - | TRACKMODELCAPS_ADDTOAUTODJ - | TRACKMODELCAPS_LOADTODECK - | TRACKMODELCAPS_LOADTOSAMPLER; + return TRACKMODELCAPS_ADDTOPLAYLIST | + TRACKMODELCAPS_ADDTOCRATE | + TRACKMODELCAPS_ADDTOAUTODJ | + TRACKMODELCAPS_LOADTODECK | + TRACKMODELCAPS_LOADTOSAMPLER; } -Qt::ItemFlags BansheePlaylistModel::flags(const QModelIndex &index) const { +Qt::ItemFlags BansheePlaylistModel::flags(const QModelIndex& index) const { return readOnlyFlags(index); } @@ -297,7 +299,6 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const { mixxx::BeatsPointer pBeats = BeatFactory::makeBeatGrid(*pTrack, bpm, 0.0); pTrack->setBeats(pBeats); } - } return pTrack; } @@ -348,5 +349,5 @@ QString BansheePlaylistModel::getTrackLocation(const QModelIndex& index) const { bool BansheePlaylistModel::isColumnInternal(int column) { return (column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))); + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))); } diff --git a/src/library/baseexternalplaylistmodel.cpp b/src/library/baseexternalplaylistmodel.cpp index 0a2b17807c..2df2d879a4 100644 --- a/src/library/baseexternalplaylistmodel.cpp +++ b/src/library/baseexternalplaylistmodel.cpp @@ -7,13 +7,12 @@ #include "mixer/playermanager.h" BaseExternalPlaylistModel::BaseExternalPlaylistModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace, - const QString& playlistsTable, - const QString& playlistTracksTable, - QSharedPointer<BaseTrackCache> trackSource) - : BaseSqlTableModel(parent, pTrackCollectionManager, - settingsNamespace), + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace, + const QString& playlistsTable, + const QString& playlistTracksTable, + QSharedPointer<BaseTrackCache> trackSource) + : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace), m_playlistsTable(playlistsTable), m_playlistTracksTable(playlistTracksTable), m_trackSource(trackSource) { @@ -23,8 +22,7 @@ BaseExternalPlaylistModel::~BaseExternalPlaylistModel() { } TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const { - QString nativeLocation = index.sibling( - index.row(), fieldIndex("location")).data().toString(); + QString nativeLocation = index.sibling(index.row(), fieldIndex("location")).data().toString(); QString location = QDir::fromNativeSeparators(nativeLocation); if (location.isEmpty()) { @@ -41,28 +39,22 @@ TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const // saved with the metadata from iTunes. If it was already in the library // then we do not touch it so that we do not over-write the user's metadata. if (pTrack && !track_already_in_library) { - QString artist = index.sibling( - index.row(), fieldIndex("artist")).data().toString(); + QString artist = index.sibling(index.row(), fieldIndex("artist")).data().toString(); pTrack->setArtist(artist); - QString title = index.sibling( - index.row(), fieldIndex("title")).data().toString(); + QString title = index.sibling(index.row(), fieldIndex("title")).data().toString(); pTrack->setTitle(title); - QString album = index.sibling( - index.row(), fieldIndex("album")).data().toString(); + QString album = index.sibling(index.row(), fieldIndex("album")).data().toString(); pTrack->setAlbum(album); - QString year = index.sibling( - index.row(), fieldIndex("year")).data().toString(); + QString year = index.sibling(index.row(), fieldIndex("year")).data().toString(); pTrack->setYear(year); - QString genre = index.sibling( - index.row(), fieldIndex("genre")).data().toString(); + QString genre = index.sibling(index.row(), fieldIndex("genre")).data().toString(); pTrack->setGenre(genre); - float bpm = index.sibling( - index.row(), fieldIndex("bpm")).data().toString().toFloat(); + float bpm = index.sibling(index.row(), fieldIndex("bpm")).data().toString().toFloat(); pTrack->setBpm(bpm); } return pTrack; @@ -80,13 +72,13 @@ TrackId BaseExternalPlaylistModel::getTrackId(const QModelIndex& index) const { bool BaseExternalPlaylistModel::isColumnInternal(int column) { if (column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { return true; } return false; } -Qt::ItemFlags BaseExternalPlaylistModel::flags(const QModelIndex &index) const { +Qt::ItemFlags BaseExternalPlaylistModel::flags(const QModelIndex& index) const { return readOnlyFlags(index); } @@ -104,8 +96,7 @@ void BaseExternalPlaylistModel::setPlaylist(QString playlist_path) { int playlistId = -1; QSqlRecord finder_query_record = finder_query.record(); while (finder_query.next()) { - playlistId = finder_query.value( - finder_query_record.indexOf("id")).toInt(); + playlistId = finder_query.value(finder_query_record.indexOf("id")).toInt(); } if (playlistId == -1) { @@ -114,23 +105,22 @@ void BaseExternalPlaylistModel::setPlaylist(QString playlist_path) { } QString playlistViewTable = QString("%1_%2").arg(m_playlistTracksTable, - QString::number(playlistId)); + QString::number(playlistId)); QStringList columns; columns << "track_id"; columns << "position"; columns << "'' AS " + LIBRARYTABLE_PREVIEW; - QSqlQuery query(m_database); FieldEscaper f(m_database); QString queryString = QString( - "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " - "SELECT %2 FROM %3 WHERE playlist_id = %4") - .arg(f.escapeString(playlistViewTable), - columns.join(","), - m_playlistTracksTable, - QString::number(playlistId)); + "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " + "SELECT %2 FROM %3 WHERE playlist_id = %4") + .arg(f.escapeString(playlistViewTable), + columns.join(","), + m_playlistTracksTable, + QString::number(playlistId)); query.prepare(queryString); if (!query.exec()) { @@ -141,7 +131,7 @@ void BaseExternalPlaylistModel::setPlaylist(QString playlist_path) { columns[2] = LIBRARYTABLE_PREVIEW; setTable(playlistViewTable, columns[0], columns, m_trackSource); setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), - Qt::AscendingOrder); + Qt::AscendingOrder); setSearch(""); } @@ -161,12 +151,10 @@ TrackId BaseExternalPlaylistModel::doGetTrackId(const TrackPointer& pTrack) cons } TrackModel::CapabilitiesFlags BaseExternalPlaylistModel::getCapabilities() const { - // See src/library/trackmodel.h for the list of TRACKMODELCAPS - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_ADDTOPLAYLIST - | TRACKMODELCAPS_ADDTOCRATE - | TRACKMODELCAPS_ADDTOAUTODJ - | TRACKMODELCAPS_LOADTODECK - | TRACKMODELCAPS_LOADTOPREVIEWDECK - | TRACKMODELCAPS_LOADTOSAMPLER; + return TRACKMODELCAPS_ADDTOPLAYLIST | + TRACKMODELCAPS_ADDTOCRATE | + TRACKMODELCAPS_ADDTOAUTODJ | + TRACKMODELCAPS_LOADTODECK | + TRACKMODELCAPS_LOADTOPREVIEWDECK | + TRACKMODELCAPS_LOADTOSAMPLER; } diff --git a/src/library/baseexternaltrackmodel.cpp b/src/library/baseexternaltrackmodel.cpp index 68f2aa8794..e8dbc5ef54 100644 --- a/src/library/baseexternaltrackmodel.cpp +++ b/src/library/baseexternaltrackmodel.cpp @@ -1,14 +1,15 @@ #include "library/baseexternaltrackmodel.h" + #include "library/dao/trackschema.h" -#include "library/trackcollectionmanager.h" #include "library/queryutil.h" +#include "library/trackcollectionmanager.h" #include "mixer/playermanager.h" BaseExternalTrackModel::BaseExternalTrackModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace, - const QString& trackTable, - QSharedPointer<BaseTrackCache> trackSource) + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace, + const QString& trackTable, + QSharedPointer<BaseTrackCache> trackSource) : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace) { QString viewTable = trackTable + "_view"; QStringList columns; @@ -18,16 +19,15 @@ BaseExternalTrackModel::BaseExternalTrackModel(QObject* parent, QSqlQuery query(m_database); FieldEscaper f(m_database); QString queryString = QString( - "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " - "SELECT %2 FROM %3") - .arg(f.escapeString(viewTable), - columns.join(","), - f.escapeString(trackTable)); + "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " + "SELECT %2 FROM %3") + .arg(f.escapeString(viewTable), + columns.join(","), + f.escapeString(trackTable)); query.prepare(queryString); if (!query.exec()) { - LOG_FAILED_QUERY(query) << - "Error creating temporary view for" << trackTable; + LOG_FAILED_QUERY(query) << "Error creating temporary view for" << trackTable; return; } @@ -107,23 +107,21 @@ bool BaseExternalTrackModel::isColumnInternal(int column) { // Used for preview deck widgets. if (column == fieldIndex(LIBRARYTABLE_ID) || (PlayerManager::numPreviewDecks() == 0 && - column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { + column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { return true; } return false; } -Qt::ItemFlags BaseExternalTrackModel::flags(const QModelIndex &index) const { +Qt::ItemFlags BaseExternalTrackModel::flags(const QModelIndex& index) const { return readOnlyFlags(index); } TrackModel::CapabilitiesFlags BaseExternalTrackModel::getCapabilities() const { - // See src/library/trackmodel.h for the list of TRACKMODELCAPS - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_ADDTOPLAYLIST - | TRACKMODELCAPS_ADDTOCRATE - | TRACKMODELCAPS_ADDTOAUTODJ - | TRACKMODELCAPS_LOADTODECK - | TRACKMODELCAPS_LOADTOPREVIEWDECK - | TRACKMODELCAPS_LOADTOSAMPLER; + return TRACKMODELCAPS_ADDTOPLAYLIST | + TRACKMODELCAPS_ADDTOCRATE | + TRACKMODELCAPS_ADDTOAUTODJ | + TRACKMODELCAPS_LOADTODECK | + TRACKMODELCAPS_LOADTOPREVIEWDECK | + TRACKMODELCAPS_LOADTOSAMPLER; } diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 81e7c186e6..189219a402 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -796,6 +796,6 @@ TrackPointer BaseTrackTableModel::getTrackByRef( } bool BaseTrackTableModel::hasCapabilities( - TrackModel::CapabilitiesFlags capabilities) const { - return (getCapabilities() & capabilities) == capabilities; + TrackModel::CapabilitiesFlags caps) const { + return (getCapabilities() & caps) == caps; } diff --git a/src/library/basetracktablemodel.h b/src/library/basetracktablemodel.h index bf40a595d4..a0a5599050 100644 --- a/src/library/basetracktablemodel.h +++ b/src/library/basetracktablemodel.h @@ -90,7 +90,7 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { const TrackRef& trackRef) const override; bool hasCapabilities( - TrackModel::CapabilitiesFlags capabilities) const final; + TrackModel::CapabilitiesFlags caps) const final; protected: static constexpr int defaultColumnWidth() { diff --git a/src/library/browse/browsetablemodel.cpp b/src/library/browse/browsetablemodel.cpp index 13ea7d4d2d..39111e2060 100644 --- a/src/library/browse/browsetablemodel.cpp +++ b/src/library/browse/browsetablemodel.cpp @@ -1,13 +1,13 @@ -#include <QtSql> -#include <QStringList> -#include <QtConcurrentRun> -#include <QMetaType> +#include "library/browse/browsetablemodel.h" + #include <QMessageBox> -#include <QUrl> +#include <QMetaType> +#include <QStringList> #include <QTableView> +#include <QUrl> +#include <QtConcurrentRun> +#include <QtSql> -#include "control/controlobject.h" -#include "library/browse/browsetablemodel.h" #include "library/browse/browsethread.h" #include "library/previewbuttondelegate.h" #include "library/trackcollection.h" @@ -17,10 +17,10 @@ #include "widget/wlibrarytableview.h" BrowseTableModel::BrowseTableModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - RecordingManager* pRecordingManager) + TrackCollectionManager* pTrackCollectionManager, + RecordingManager* pRecordingManager) : TrackModel(pTrackCollectionManager->internalCollection()->database(), - "mixxx.db.model.browse"), + "mixxx.db.model.browse"), QStandardItemModel(parent), m_pTrackCollectionManager(pTrackCollectionManager), m_pRecordingManager(pRecordingManager), @@ -100,8 +100,8 @@ BrowseTableModel::BrowseTableModel(QObject* parent, setHorizontalHeaderLabels(header_data); // register the QList<T> as a metatype since we use QueuedConnection below - qRegisterMetaType< QList< QList<QStandardItem*> > >( - "QList< QList<QStandardItem*> >"); + qRegisterMetaType<QList<QList<QStandardItem*> > >( + "QList< QList<QStandardItem*> >"); qRegisterMetaType<BrowseTableModel*>("BrowseTableModel*"); m_pBrowseThread = BrowseThread::getInstanceRef(); @@ -129,7 +129,7 @@ BrowseTableModel::~BrowseTableModel() { int BrowseTableModel::columnIndexFromSortColumnId(TrackModel::SortColumnId column) { if (column == TrackModel::SortColumnId::SORTCOLUMN_INVALID || - column >= TrackModel::SortColumnId::NUM_SORTCOLUMNIDS) { + column >= TrackModel::SortColumnId::NUM_SORTCOLUMNIDS) { return -1; } @@ -160,10 +160,9 @@ TrackPointer BrowseTableModel::getTrack(const QModelIndex& index) const { TrackPointer BrowseTableModel::getTrackByRef(const TrackRef& trackRef) const { if (m_pRecordingManager->getRecordingLocation() == trackRef.getLocation()) { QMessageBox::critical( - 0, tr("Mixxx Library"), - tr("Could not load the following file because" - " it is in use by Mixxx or another application.") - + "\n" + trackRef.getLocation()); + 0, + tr("Mixxx Library"), + tr("Could not load the following file because it is in use by Mixxx or another application.") + "\n" + trackRef.getLocation()); return TrackPointer(); } // NOTE(uklotzde, 2015-12-08): Accessing tracks from the browse view @@ -237,8 +236,8 @@ void BrowseTableModel::moveTrack(const QModelIndex&, const QModelIndex&) { void BrowseTableModel::removeTracks(const QModelIndexList&) { } -QMimeData* BrowseTableModel::mimeData(const QModelIndexList &indexes) const { - QMimeData *mimeData = new QMimeData(); +QMimeData* BrowseTableModel::mimeData(const QModelIndexList& indexes) const { + QMimeData* mimeData = new QMimeData(); QList<QUrl> urls; // Ok, so the list of indexes we're given contains separates indexes for @@ -269,8 +268,8 @@ void BrowseTableModel::slotClear(BrowseTableModel* caller_object) { } } -void BrowseTableModel::slotInsert(const QList< QList<QStandardItem*> >& rows, - BrowseTableModel* caller_object) { +void BrowseTableModel::slotInsert(const QList<QList<QStandardItem*> >& rows, + BrowseTableModel* caller_object) { // There exists more than one BrowseTableModel in Mixxx We only want to // receive items here, this object has 'ordered' by the BrowserThread // (singleton) @@ -283,17 +282,15 @@ void BrowseTableModel::slotInsert(const QList< QList<QStandardItem*> >& rows, } TrackModel::CapabilitiesFlags BrowseTableModel::getCapabilities() const { - // See src/library/trackmodel.h for the list of TRACKMODELCAPS - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_ADDTOPLAYLIST - | TRACKMODELCAPS_ADDTOCRATE - | TRACKMODELCAPS_ADDTOAUTODJ - | TRACKMODELCAPS_LOADTODECK - | TRACKMODELCAPS_LOADTOPREVIEWDECK - | TRACKMODELCAPS_LOADTOSAMPLER; + return TRACKMODELCAPS_ADDTOPLAYLIST | + TRACKMODELCAPS_ADDTOCRATE | + TRACKMODELCAPS_ADDTOAUTODJ | + TRACKMODELCAPS_LOADTODECK | + TRACKMODELCAPS_LOADTOPREVIEWDECK | + TRACKMODELCAPS_LOADTOSAMPLER; } -Qt::ItemFlags BrowseTableModel::flags(const QModelIndex &index) const { +Qt::ItemFlags BrowseTableModel::flags(const QModelIndex& index) const { Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); // Enable dragging songs from this data model to elsewhere (like the @@ -330,8 +327,8 @@ bool BrowseTableModel::setData( TrackPointer pTrack(getTrack(index)); if (!pTrack) { qWarning() << "BrowseTableModel::setData():" - << "Failed to resolve track" - << getTrackLocation(index); + << "Failed to resolve track" + << getTrackLocation(index); // restore previous item content item->setText(index.data().toString()); item->setToolTip(item->text()); @@ -379,7 +376,7 @@ bool BrowseTableModel::setData( break; default: qWarning() << "BrowseTableModel::setData():" - << "No tagger column"; + << "No tagger column"; // restore previous item context item->setText(index.data().toString()); item->setToolTip(item->text()); diff --git a/src/library/hiddentablemodel.cpp b/src/library/hiddentablemodel.cpp index 7bc955e08e..85c201630f 100644 --- a/src/library/hiddentablemodel.cpp +++ b/src/library/hiddentablemodel.cpp @@ -1,12 +1,11 @@ #include "library/hiddentablemodel.h" +#include "library/dao/trackschema.h" #include "library/trackcollection.h" #include "library/trackcollectionmanager.h" -#include "library/dao/trackschema.h" - HiddenTableModel::HiddenTableModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager) + TrackCollectionManager* pTrackCollectionManager) : BaseSqlTableModel(parent, pTrackCollectionManager, "mixxx.db.model.missing") { setTableModel(); } @@ -22,13 +21,16 @@ void HiddenTableModel::setTableModel(int id) { QStringList columns; columns << "library." + LIBRARYTABLE_ID; QString filter("mixxx_deleted=1"); - query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS " - "SELECT " - + columns.join(",") + - " FROM library " - "INNER JOIN track_locations " - "ON library.location=track_locations.id " - "WHERE " + filter); + query.prepare( + "CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + + " AS " + "SELECT " + + columns.join(",") + + " FROM library " + "INNER JOIN track_locations " + "ON library.location=track_locations.id " + "WHERE " + + filter); if (!query.exec()) { qDebug() << query.executedQuery() << query.lastError(); } @@ -40,8 +42,7 @@ void HiddenTableModel::setTableModel(int id) { QStringList tableColumns; tableColumns << LIBRARYTABLE_ID; - setTable(tableName, LIBRARYTABLE_ID, tableColumns, - m_pTrackCollectionManager->internalCollection()->getTrackSource()); + setTable(tableName, LIBRARYTABLE_ID, tableColumns, m_pTrackCollectionManager->internalCollection()->getTrackSource()); setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder); setSearch(""); } @@ -73,7 +74,7 @@ bool HiddenTableModel::isColumnInternal(int column) { 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) || @@ -85,12 +86,10 @@ bool HiddenTableModel::isColumnInternal(int column) { } // Override flags from BaseSqlModel since we don't want edit this model -Qt::ItemFlags HiddenTableModel::flags(const QModelIndex &index) const { +Qt::ItemFlags HiddenTableModel::flags(const QModelIndex& index) const { return readOnlyFlags(index); } TrackModel::CapabilitiesFlags HiddenTableModel::getCapabilities() const { - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_PURGE - | TRACKMODELCAPS_UNHIDE; + return TRACKMODELCAPS_PURGE | TRACKMODELCAPS_UNHIDE; } diff --git a/src/library/librarytablemodel.cpp b/src/library/librarytablemodel.cpp index 336ac3bb61..d2813a8d92 100644 --- a/src/library/librarytablemodel.cpp +++ b/src/library/librarytablemodel.cpp @@ -1,10 +1,9 @@ #include "library/librarytablemodel.h" #include "library/dao/trackschema.h" +#include "library/queryutil.h" #include "library/trackcollection.h" #include "library/trackcollectionmanager.h" -#include "library/queryutil.h" - #include "mixer/playermanager.h" namespace { @@ -15,8 +14,8 @@ const QString kDefaultLibraryFilter = } // anonymous namespace LibraryTableModel::LibraryTableModel(QObject* parent, - TrackCollectionManager* pTrackCollectionManager, - const char* settingsNamespace) + TrackCollectionManager* pTrackCollectionManager, + const char* settingsNamespace) : BaseSqlTableModel(parent, pTrackCollectionManager, settingsNamespace) { setTableModel(); } @@ -36,11 +35,15 @@ void LibraryTableModel::setTableModel(int id) { const QString tableName = "library_view"; QSqlQuery query(m_database); - QString queryString = "CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS " - "SELECT " + columns.join(", ") + + QString queryString = + "CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + + " AS " + "SELECT " + + columns.join(", ") + " FROM library INNER JOIN track_locations " "ON library.location = track_locations.id " - "WHERE (" + kDefaultLibraryFilter + ")"; + "WHERE (" + + kDefaultLibraryFilter + ")"; query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query); @@ -50,8 +53,7 @@ void LibraryTableModel::setTableModel(int id) { tableColumns << LIBRARYTABLE_ID; tableColumns << LIBRARYTABLE_PREVIEW; tableColumns << LIBRARYTABLE_COVERART; - setTable(tableName, LIBRARYTABLE_ID, tableColumns, - m_pTrackCollectionManager->internalCollection()->getTrackSource()); + setTable(tableName, LIBRARYTABLE_ID, tableColumns, m_pTrackCollectionManager->internalCollection()->getTrackSource()); setSearch(""); set |