banshee r3699 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.ThickClient/Banshee.Gui



Author: gburt
Date: Mon Apr  7 02:47:12 2008
New Revision: 3699
URL: http://svn.gnome.org/viewvc/banshee?rev=3699&view=rev

Log:
2008-04-06  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs:
	Add UpdateOrCreate methods that will overwrite an artist/album if it
	already exists, otherwise will just save the new one.

	* src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs: Change Edit
	Track Metadata to Edit Track Information in pursuit of user-friendliness.
	Thanks to Chris Lord for the suggestion.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs	Mon Apr  7 02:47:12 2008
@@ -61,35 +61,55 @@
         private static int last_artist_id;
         private static string last_title;
         private static DatabaseAlbumInfo last_album;
+
         public static DatabaseAlbumInfo FindOrCreate (DatabaseArtistInfo artist, string title)
         {
-            if (title == last_title && artist.DbId == last_artist_id && last_album != null) {
+            DatabaseAlbumInfo album = new DatabaseAlbumInfo ();
+            album.Title = title;
+            return FindOrCreate (artist, album);
+        }
+
+        public static DatabaseAlbumInfo FindOrCreate (DatabaseArtistInfo artist, DatabaseAlbumInfo album)
+        {
+            if (album.Title == last_title && artist.DbId == last_artist_id && last_album != null) {
                 return last_album;
             }
 
-            if (String.IsNullOrEmpty (title) || title.Trim () == String.Empty) {
-                title = Catalog.GetString ("Unknown Album");
+            if (String.IsNullOrEmpty (album.Title) || album.Title.Trim () == String.Empty) {
+                album.Title = Catalog.GetString ("Unknown Album");
             }
 
-            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.DbId, title)) {
+            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.DbId, album.Title)) {
                 if (reader.Read ()) {
                     last_album = new DatabaseAlbumInfo (reader);
                     last_album.ArtistId = artist.DbId;
                     last_album.ArtistName = artist.Name;
                 } else {
-                    last_album = new DatabaseAlbumInfo ();
-                    last_album.Title = title;
+                    last_album = album;
                     last_album.ArtistId = artist.DbId;
                     last_album.ArtistName = artist.Name;
                     last_album.Save ();
                 }
             }
             
-            last_title = title;
+            last_title = album.Title;
             last_artist_id = artist.DbId;
             return last_album;
         }
 
+        public static DatabaseAlbumInfo UpdateOrCreate (DatabaseArtistInfo artist, DatabaseAlbumInfo album)
+        {
+            DatabaseAlbumInfo found = FindOrCreate (artist, album);
+            if (found != album) {
+                // Overwrite the found album
+                album.Title = found.Title;
+                album.dbid = found.DbId;
+                album.ArtistId = found.ArtistId;
+                album.Save ();
+            }
+            return album;
+        }
+
         public DatabaseAlbumInfo () : base (null)
         {
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs	Mon Apr  7 02:47:12 2008
@@ -59,29 +59,48 @@
 
         private static string last_artist_name = null;
         private static DatabaseArtistInfo last_artist = null;
+
         public static DatabaseArtistInfo FindOrCreate (string artistName)
         {
-            if (artistName == last_artist_name && last_artist != null) {
+            DatabaseArtistInfo artist = new DatabaseArtistInfo ();
+            artist.Name = artistName;
+            return FindOrCreate (artist);
+        }
+
+        public static DatabaseArtistInfo FindOrCreate (DatabaseArtistInfo artist)
+        {
+            if (artist.Name == last_artist_name && last_artist != null) {
                 return last_artist;
             }
 
-            if (String.IsNullOrEmpty (artistName) || artistName.Trim () == String.Empty) {
-                artistName = Catalog.GetString ("Unknown Artist");
+            if (String.IsNullOrEmpty (artist.Name) || artist.Name.Trim () == String.Empty) {
+                artist.Name = Catalog.GetString ("Unknown Artist");
             }
 
-            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artistName)) {
+            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.Name)) {
                 if (reader.Read ()) {
                     last_artist = new DatabaseArtistInfo (reader);
                 } else {
-                    last_artist = new DatabaseArtistInfo ();
-                    last_artist.Name = artistName;
+                    last_artist = artist;
                     last_artist.Save ();
                 }
             }
             
-            last_artist_name = artistName;
+            last_artist_name = artist.Name;
             return last_artist;
         }
+
+        public static DatabaseArtistInfo UpdateOrCreate (DatabaseArtistInfo artist)
+        {
+            DatabaseArtistInfo found = FindOrCreate (artist);
+            if (found != artist) {
+                // Overwrite the found artist
+                artist.Name = found.Name;
+                artist.dbid = found.DbId;
+                artist.Save ();
+            }
+            return artist;
+        }
         
         public DatabaseArtistInfo () : base (null)
         {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	Mon Apr  7 02:47:12 2008
@@ -92,8 +92,8 @@
                     Catalog.GetString("Unselect all tracks"), OnSelectNone),
 
                 new ActionEntry ("TrackPropertiesAction", Stock.Edit,
-                    Catalog.GetString ("_Edit Track Metadata"), "E",
-                    Catalog.GetString ("Edit metadata on selected tracks"), OnTrackProperties),
+                    Catalog.GetString ("_Edit Track Information"), "E",
+                    Catalog.GetString ("Edit information on selected tracks"), OnTrackProperties),
 
                 new ActionEntry ("AddToPlaylistAction", null,
                     Catalog.GetString ("Add _to Playlist"), null,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]