Commit Graph

71 Commits

Author SHA1 Message Date
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
32dcd83865 db: Give Tracks a Decade property and genres() function
For accessing a Track's Decade playlist or list of genres

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
f6c72ed081 db: Remove the now unused objects.py file
Implements: Issue #18 (Remove the db.objects.Map class)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
932663f872 db: Remove the PlaylistMap objects
We can now do everything it did and more through the various user
playlist objects.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
bba00b3d27 db: Remove the GenreMap object
We can now do everything it did and more through the Genre playlist
object.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
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
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
8917600970 db: Clear MappedPlaylists before deleting
Otherwise we end up with a bunch of (playlistid, trackid) pairs in the
map table that don't refer to a valid playlist anymore.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:24:56 -04:00
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
5ff03cf33f db: Give MappedPlaylists add_track() and remove_track() functions
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
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
72f654508c initial sort squash
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
0851aeb0cf db: Give playlists a default sort order
Most playlists sort by artist -> album -> year -> discno -> trackno, but
the Previous playlist sorts by rowid with the most recently added
tracks first, and the Up Next playlist sorts by rowid with the most
recently added tracks last.

Implements: Issue #13 (Give most playlists a default sort order)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
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
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
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
063b93b66f db: Convert the TrackTable into a table.Table
Implements: Issue #11 (Cache database items fields)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-15 16:09:59 -04:00
4235e794bd db: Convert the UserTable to a playlist.Model
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-15 16:09:58 -04:00
67238ed385 db: Give Albums a find_disc() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 17:03:19 -04:00
44a002ecac db: Convert the DiscTable 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 17:02:04 -04:00
737d135d41 db: Give Artists a find_album() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
a1f54839bb db: Convert the AlbumTable 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
0728579cc4 db: Convert the ArtistTable into a playlist.Model
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
f7907e4142 db: Convert the GenreTable into a playlist.Model
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
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
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
8365afc0e3 db: Convert the DecadeTable into a playlist.Model
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
e6a65f8fe3 db: Convert the LibraryTable into a table.Model
I actually turn it into a playlist.Model, which is a table.Model that
handles playlist states for us.

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
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
ca3a88557f db: Create new playlist.Model and playlist.ChildModel classes
These take the table.Model and table.Child classes and add playlist
state management to them.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
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
a4fbd5f2f3 db: Rename playlist.py -> user.py
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:43 -04:00
658be5bef1 db: Create a new Child class
This inherites from the Table, but takes a parent instance for some
functions and calculates offsets for items that descend from this
parent.

Implements: Issue #1 (Have SQLite sort our sidebar tables)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:43 -04:00
feeee8809d db: Create a new Model class
This inherits from the Table, but also implements the Gio.ListModel
interface with sorting for use in the sidebar Gtk.ListView

Implements: Issue #1 (Have SQLite sort our sidebar tables)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:43 -04:00
427b9fb925 db: Create a new Table class
This is a simlified Table that can be inherited from to implement a
Table-based Gio.ListModel. This gives us the chance to have some tables
that aren't ListModel's, since not everything will need that interface
and unnecessary position-finding slows everything down.

Implements: Issue #8 (Split up db/objects.py)
Implements: Issue #12 (Make database items unique)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:27 -04:00
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
f14d73ce67 tagdb: Mark tracks as played using datetime.datetime.now()
So that we caputere the timestamp that the track finished at. I also
update tha sqlite importer code to account for the possibility of
receiving either a datetime.date or a datetime.datetime

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-01 11:16:02 -04:00
ad9cf2b135 db: Store lastplayed as a timestamp
Instead of just a date object.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:47 -04:00
7dd3ff8473 db: Give Tables a get_all() function
Right now I only implement it for Libraries. More tables can be added as
needed.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 14:18:06 -04:00
0e55bb25e9 db: Give Tracks a way to directly set playcount and lastplayed
This will be needed when importing tracks from the tagdb into the sqlite
db

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-25 13:27:54 -04:00
3fb6f3a2ba db: Track.path should return a Pathlib.Path
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-24 17:05:26 -04:00
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
8a0364760d db: Give Years a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:30 -04:00
6fbc5e0b27 db: Give Libraries a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:29 -04:00
c168fcbda3 db: Give Genres a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:29 -04:00
77c2b7cd81 db: Give Discs a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:28 -04:00
9a6cda7aab db: Give Decades a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:28 -04:00
e9a2a6f06a db: Give Artists a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:27 -04:00
3abf2d3cf7 db: Give Albums a PlaylistState property
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:25 -04:00
38861bbabf db: Create a PlaylistStateTable and PlaylistState object
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-23 13:18:24 -04:00