diff options
Diffstat (limited to 'src/library/banshee')
-rw-r--r-- | src/library/banshee/bansheeplaylistmodel.cpp | 176 | ||||
-rw-r--r-- | src/library/banshee/bansheeplaylistmodel.h | 2 |
2 files changed, 81 insertions, 97 deletions
diff --git a/src/library/banshee/bansheeplaylistmodel.cpp b/src/library/banshee/bansheeplaylistmodel.cpp index 70aacfce9c..be7f8c85d3 100644 --- a/src/library/banshee/bansheeplaylistmodel.cpp +++ b/src/library/banshee/bansheeplaylistmodel.cpp @@ -78,73 +78,56 @@ 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)"); - if (!query.exec(strQuery.arg(m_tempTableName))) { + if (!query.exec(QStringLiteral( + "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)") + .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 ") "); - - query.prepare(strQuery2.arg(m_tempTableName)); + QStringList insertColumns; + insertColumns + << 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( + QStringLiteral("INSERT INTO %1 (%2) VALUES (:%3)") + .arg(m_tempTableName, insertColumns.join(", "), insertColumns.join(", :"))); QList<struct BansheeDbConnection::PlaylistEntry> list = m_pConnection->getPlaylistEntries(playlistId); @@ -189,34 +172,37 @@ 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(""); @@ -224,16 +210,14 @@ void BansheePlaylistModel::setTableModel(int playlistId) { setSort(defaultSortColumn(), defaultSortOrder()); } -TrackModel::CapabilitiesFlags BansheePlaylistModel::getCapabilities() const { - return TRACKMODELCAPS_NONE - | TRACKMODELCAPS_ADDTOPLAYLIST - | TRACKMODELCAPS_ADDTOCRATE - | TRACKMODELCAPS_ADDTOAUTODJ - | TRACKMODELCAPS_LOADTODECK - | TRACKMODELCAPS_LOADTOSAMPLER; +TrackModel::Capabilities BansheePlaylistModel::getCapabilities() const { + return Capability::AddToTrackSet | + Capability::AddToAutoDJ | + Capability::LoadToDeck | + Capability::LoadToSampler; } -Qt::ItemFlags BansheePlaylistModel::flags(const QModelIndex &index) const { +Qt::ItemFlags BansheePlaylistModel::flags(const QModelIndex& index) const { return readOnlyFlags(index); } @@ -346,5 +330,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/banshee/bansheeplaylistmodel.h b/src/library/banshee/bansheeplaylistmodel.h index e55e0f0354..04cd7d01c6 100644 --- a/src/library/banshee/bansheeplaylistmodel.h +++ b/src/library/banshee/bansheeplaylistmodel.h @@ -25,7 +25,7 @@ class BansheePlaylistModel final : public BaseSqlTableModel { bool isColumnInternal(int column) final; Qt::ItemFlags flags(const QModelIndex &index) const final; - CapabilitiesFlags getCapabilities() const final; + Capabilities getCapabilities() const final; private: TrackId doGetTrackId(const TrackPointer& pTrack) const final; |