Skip to content

Commit

Permalink
Clean up CapabilitiesFlags and apply clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
xeruf committed Apr 26, 2020
1 parent 2fbbe79 commit 4f840a3
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 297 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AlignOperands: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
BinPackArguments: false
BinPackParameters: false
ConstructorInitializerIndentWidth: 8
Expand Down
193 changes: 97 additions & 96 deletions src/library/banshee/bansheeplaylistmodel.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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("");
Expand All @@ -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);
}

Expand Down Expand Up @@ -297,7 +299,6 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const {
BeatsPointer pBeats = BeatFactory::makeBeatGrid(*pTrack, bpm, 0.0);
pTrack->setBeats(pBeats);
}

}
return pTrack;
}
Expand Down Expand Up @@ -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)));
}
Loading

0 comments on commit 4f840a3

Please sign in to comment.