-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add an option to replace the autoDJ queue with the selected tracks #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,26 @@ bool PlaylistDAO::isPlaylistLocked(const int playlistId) const { | |
| return false; | ||
| } | ||
|
|
||
| // TODO: Deduplicate with deletePlaylist? | ||
| bool PlaylistDAO::clearPlaylist(const int playlistId) { | ||
| ScopedTransaction transaction(m_database); | ||
| QSqlQuery query(m_database); | ||
| query.prepare("DELETE FROM PlaylistTracks WHERE playlist_id = :id"); | ||
| query.bindValue(":id", playlistId); | ||
| if (!query.exec()) { | ||
| LOG_FAILED_QUERY(query); | ||
| return false; | ||
| } | ||
| transaction.commit(); | ||
| emit(changed(playlistId)); | ||
| return true; | ||
| } | ||
|
|
||
| bool PlaylistDAO::replaceTracksInPlaylist(const QList<TrackId>& trackIds, const int playlistId) { | ||
| return clearPlaylist(playlistId) | ||
| && appendTracksToPlaylist(trackIds, playlistId); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happen if clearPlaylist() fails? |
||
| } | ||
|
|
||
| bool PlaylistDAO::appendTracksToPlaylist(const QList<TrackId>& trackIds, const int playlistId) { | ||
| // qDebug() << "PlaylistDAO::appendTracksToPlaylist" | ||
| // << QThread::currentThread() << m_database.connectionName(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,8 +44,9 @@ class WTrackTableView : public WLibraryTableView { | |
| void slotPurge(); | ||
| void onSearchStarting(); | ||
| void onSearchCleared(); | ||
| void slotSendToAutoDJ() override; | ||
| void slotSendToAutoDJBottom() override; | ||
| void slotSendToAutoDJTop() override; | ||
| void slotSendToAutoDJReplace() override; | ||
|
|
||
| private slots: | ||
| void slotRemove(); | ||
|
|
@@ -79,7 +80,13 @@ class WTrackTableView : public WLibraryTableView { | |
| void slotTagFetcherClosed(); | ||
|
|
||
| private: | ||
| void sendToAutoDJ(bool bTop); | ||
| enum AutoDJSendLoc { | ||
| SEND_TOP, | ||
| SEND_BOTTOM, | ||
| SEND_REPLACE, | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I should have done it earlier ..
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to use a strongly typed C++11 scoped enumeration: -> AutoDJSendLoc::TOP, ... |
||
|
|
||
| void sendToAutoDJ(AutoDJSendLoc loc); | ||
| void showTrackInfo(QModelIndex index); | ||
| void showDlgTagFetcher(QModelIndex index); | ||
| void createActions(); | ||
|
|
@@ -128,8 +135,9 @@ class WTrackTableView : public WLibraryTableView { | |
| QAction* m_pAddToPreviewDeck; | ||
|
|
||
| // Send to Auto-DJ Action | ||
| QAction *m_pAutoDJAct; | ||
| QAction *m_pAutoDJBottomAct; | ||
| QAction *m_pAutoDJTopAct; | ||
| QAction *m_pAutoDJReplaceAct; | ||
|
|
||
| // Remove from table | ||
| QAction *m_pRemoveAct; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this would be nice. This will also allow to clan up the double transaction and emit(changed(playlistId)) in the new replaceTracksInPlaylist.