-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix playlist import of external library features #1877
Conversation
// use the data because models with nested playlists need to use the | ||
// full path/name of the playlist. | ||
*pPlaylist = m_lastRightClickedIndex.data(Qt::UserRole).toString(); | ||
*pPlaylist = m_lastRightClickedIndex.data().toString(); |
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.
I have now Idea when this was broken ...
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.
Please add at least a debug assertion before dereferencing pPlaylist:
DEBUG_ASSERT(pPlaylist);
Adding tracks from an external to an internal playlist works by drag&drop, but not when using the context menu -> missing/wrong tracks + warnings:
Currently only tested for Banshee. I also noticed that tracks in Banshee playlists are not numbered consecutively after tracks have been removed. But that doesn't seem to matter, |
OK, now the right click track context menu works as well. |
@@ -327,6 +348,15 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const { | |||
return pTrack; | |||
} | |||
|
|||
TrackId BansheePlaylistModel::getTrackId(const QModelIndex& index) const { |
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.
This is identical with the default implementation in BaseExternalPlaylistModel. Obsolete?
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.
BansheePlaylistModel does not inherit BaseExternalPlaylistModel.
We fetch the Banshee database directly.
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.
🙈
if (m_playlistId >= 0) { | ||
// Clear old playlist | ||
m_playlistId = -1; | ||
QSqlQuery query(m_pTrackCollection->database()); | ||
QString strQuery("DELETE FROM " BANSHEE_TABLE); | ||
if (!query.exec(strQuery)) { | ||
QString strQuery("DELETE FROM %1"); |
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.
The empty table remains. Please drop it entirely instead of only deleting all records:
DROP TABLE IF EXISTS %1
https://www.sqlite.org/lang_droptable.html
if (column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_TRACKID) || | ||
(PlayerManager::numPreviewDecks() == 0 && | ||
column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW))) { | ||
return true; |
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.
Avoid anti-pattern:
BAD: if (condition) { return true }
GOOD: return condition
@@ -41,9 +43,11 @@ class BansheePlaylistModel : public BaseSqlTableModel { | |||
private: | |||
QString getFieldString(const QModelIndex& index, const QString& fieldName) const; | |||
QVariant getFieldVariant(const QModelIndex& index, const QString& fieldName) const; | |||
void deleteTempTable(); |
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.
dropTempTable()
// use the data because models with nested playlists need to use the | ||
// full path/name of the playlist. | ||
*pPlaylist = m_lastRightClickedIndex.data(Qt::UserRole).toString(); | ||
*pPlaylist = m_lastRightClickedIndex.data().toString(); |
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.
Please add at least a debug assertion before dereferencing pPlaylist:
DEBUG_ASSERT(pPlaylist);
Done |
LGTM Since this affects a released version and the PR fixes multiple issues another approval is recommended. I've only tested with a small, external Banshee library created for this purpose. |
Thank you. A iTunes test would be nice. Any volunteers? |
This should also be included in 2.2.0 final! |
Installed both iTunes and the build artefact on Windows 10, works as expected. Single and multiple tracks can be selected and added to Auto DJ or playlists, order of tracks is preserved. |
Merged 2.1 into 2.2. I'm confident that I resolved all merge conflicts correctly. |
This fixes the import feature of banshee playlists.
I have added a lost select() call and privatize the temporary table for banshee data.