Commit Graph

16 Commits

Author SHA1 Message Date
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 edb6857292 db: Give playlists a get_tracks() function
So the UI's Gio.ListModel can get the list of tracks when it is created,
instead of needing to look up individual tracks by index through a sql
query.

Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:08 -04:00
Anna Schumaker 0c3afb9d56 db: Give playlists a remove_track() function
And emit a "track-removed" signal to notify the higher layers.

Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:04 -04:00
Anna Schumaker 9b4153737b db: Give playlists an add_track() function
And emit a "track-added" signal to notify higher layers

Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
Anna Schumaker 847f182173 db: Give playlists a get_track_index() function
So we can send an "items-changed" signal once Playlists have been
converted to a Gio.ListModel

Implements: Issue #3 (Sort playlists through SQLite)
Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:24:59 -04:00
Anna Schumaker 1d5f88f080 db: Give playlists a get_track() function
For finding a single track at a given index into the select query
results, ordered by the configured sort order.

Implements: Issue #3 (Sort playlists through SQLite)
Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:24:56 -04:00
Anna Schumaker 729b1efc9a db: Give playlists a get_n_tracks() function
For finding the number of tracks in the specific playlist.

Implements: Issue #15 (Convert Playlists into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:24:22 -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 90c6593921 db: Give Decades a find_year() function
And adjust the Year table and Track table to take a Decade as an
argument.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker 4141ca211c db: Convert the YearTable into a playlist.ChildModel
Implements: Issue #11 (Cache database items fields)
Implements: Issue #14 (Convert Tables into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker 84ad195716 db: Convert the PlaylistStateTable into a table.Table
This gives us access to the new functions and built-in caching. I also
change the PlaylistState object to cache its values rather than querying
the database for everything.

Implements: Issue #11 (Cache database items fields)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -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 8a0364760d db: Give Years a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:30 -04:00
Anna Schumaker 2af61f8787 db: Create a YearTable and Year object
I do lookups and inserts based only on the year field. Decades are
created automatically on insert.

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