Commit Graph

20 Commits

Author SHA1 Message Date
Anna Schumaker 8f26cf9fee db: Fix random next_track() on playlists with only one track
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-09 17:51:02 -05:00
Anna Schumaker 574d03bad6 db: Make it easy to know if we can delete tracks from playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-05 13:49:22 -05:00
Anna Schumaker 2e57e1fe0a db: Preserve the current track when removing tracks
Again, we have to be careful not to check positions against playlists
where current == -1 for performance reasons.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 2f747ccaa6 db: Preserve the current track when adding tracks
We have to be careful not to check track positions against playlists
where current == -1, because this could drastically slow down adding new
tracks because SQLite would need to find the position for every track

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker e94a737718 db: Provide a passthrough for playlist_state.rowid
So the audio layer can easily access it when saving the current
playlist.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 7a46ffdf47 db: Give playlists a next_track() function
For picking the next track (with or without random enabled)

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 8a4590f0ed db: Preserve the current track when sorting
Implements: #39 (Preserve current track when sorting)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 23699a601d db: Have playlists clamp the current track value
And add a get_current_track() function to make it easier to get the
currently selected track. Clamping behaves differently if random or loop
are enabled to ensure a track is still picked.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker f82e299736 db: Add tracks.trackid ASC as a fallback sort option
This keeps us from ever completely clearing the sort field in the
playlist state, since that would lead to an incomplete SQL query error.

Fixes: #38 (PlaylistStates should not allow completely clearing sort)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 14724aa81e db: Give Playlists a passthrough for PlaylistState properties
This lets us handle changes easier, since we'll catch them as they
happen. This lets us emit the "refreshed" signal when sorting changes,
for example.

Implements: Issue #32 (Passthrough PlaylistState properties)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 13:29:09 -04:00
Anna Schumaker 0688088318 db: Create a MappedPlaylist type
For genre and most user playlists that rely on an extra map table to
figure out which tracks they have.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
Anna Schumaker a52a815338 db: Give Playlists a "rowkey" property
Most playlists will use this to look up their tracks in the track table

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
Anna Schumaker 6f9fb34792 db: Give playlists a delete() function
So we can remove playlists from the database when needed.

Implemets: Issue #29 (Give playlists a delete() function)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-16 17:37:23 -04:00
Anna Schumaker 2aad28f708 db: Give Playlists an "icon-name" property
This will be used by the sidebar to display playlist rows

Implements: Issue #20 (Give Playlist database items a icon-name property)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-15 16:11:34 -04:00
Anna Schumaker 6d796e0a89 db: Create new Playlist and ParentPlaylist classes
These are the base classes that will be used by all our Playlist-like
objects.

Implements: Issue #11 (Cache database items fields)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:56 -04:00
Anna Schumaker a4fbd5f2f3 db: Rename playlist.py -> user.py
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:43 -04:00
Anna Schumaker 9cf1df7c33 db: Move SQLite Connection stuff into a new file
I find this cleaner than importing from the toplevel module

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-07 13:58:09 -04:00
Anna Schumaker e94346fdd9 db: Give Playlists a PlaylistState property
And clean up how the default playlists are created so the test doesn't
fall over with the new column.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:48:20 -04:00
Anna Schumaker 0fd1069484 db: Add a PlaylistMap
And create both permanent and temporary maps for tracks. The temporary
map is intended to be used for the New Tracks and Previous playlists,
since we don't store the state across restarts.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:17:45 -04:00
Anna Schumaker 2b87707f16 db: Create a PlaylistTable and Playlist object
And populate the table with some default playlist values.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:17:17 -04:00