banshee r5143 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Collection.Database/Tests src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Libraries/Hyena/Hyena



Author: gburt
Date: Fri Mar 20 02:11:31 2009
New Revision: 5143
URL: http://svn.gnome.org/viewvc/banshee?rev=5143&view=rev

Log:
2009-03-19  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs:
	* src/Core/Banshee.Core/Banshee.Collection/ArtistInfo.cs:
	* src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseAlbumInfoTests.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseArtistInfoTests.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseTrackInfoTests.cs:
	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	* src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs:
	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtistListView.cs:
	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs:
	* src/Libraries/Hyena/Hyena/StringUtil.cs: Patch from AndrÃs G.
	Aragoneses with input from John Millikin to keep displaying and sorting
	unknown artist/albums/tracks as "Unknown .." but to keep the actual
	value of the artist/album/title in the database (and written back to
	files) null (BGO #528493)

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/ArtistInfo.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
   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.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseAlbumInfoTests.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseArtistInfoTests.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseTrackInfoTests.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtistListView.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
   trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs	Fri Mar 20 02:11:31 2009
@@ -28,13 +28,17 @@
 
 using System;
 using System.Text.RegularExpressions;
+using Mono.Unix;
 
+using Hyena;
 using Banshee.Base;
 
 namespace Banshee.Collection
 {
     public class AlbumInfo : CacheableItem
     {
+        public static readonly string UnknownAlbumTitle = Catalog.GetString ("Unknown Album");
+        
         private string title;
         private string title_sort;
         private string artist_name;
@@ -97,5 +101,13 @@
                 return artwork_id;
             }
         }
+        
+        public string DisplayArtistName {
+            get { return StringUtil.MaybeFallback (ArtistName, ArtistInfo.UnknownArtistName); }
+        }
+        
+        public string DisplayTitle {
+            get { return StringUtil.MaybeFallback (Title, UnknownAlbumTitle); }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/ArtistInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/ArtistInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/ArtistInfo.cs	Fri Mar 20 02:11:31 2009
@@ -27,11 +27,15 @@
 //
 
 using System;
+using Mono.Unix;
+using Hyena;
 
 namespace Banshee.Collection
 {
     public class ArtistInfo : CacheableItem
     {
+        public static readonly string UnknownArtistName = Catalog.GetString ("Unknown Artist");
+        
         private string name;
         private string name_sort;
         private string musicbrainz_id;
@@ -60,5 +64,9 @@
             get { return name_sort; }
             set { name_sort = String.IsNullOrEmpty (value) ? null : value; }
         }
+        
+        public string DisplayName {
+            get { return StringUtil.MaybeFallback (Name, UnknownArtistName); }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs	Fri Mar 20 02:11:31 2009
@@ -44,7 +44,9 @@
     public class TrackInfo : CacheableItem, ITrackInfo
     {
         public const string ExportVersion = "1.0";
-    
+
+        public static readonly string UnknownTitle = Catalog.GetString ("Unknown Title");
+
         public class ExportableAttribute : Attribute
         {
             private string export_name;
@@ -59,7 +61,7 @@
 
         public delegate void PlaybackFinishedHandler (TrackInfo track, double percentComplete);
         public static event PlaybackFinishedHandler PlaybackFinished;
-            
+
         private SafeUri uri;
         private SafeUri more_info_uri;
         private string mimetype;
@@ -283,49 +285,29 @@
         }
         
         public string DisplayArtistName { 
-            get {
-                string name = ArtistName == null ? null : ArtistName.Trim ();
-                return String.IsNullOrEmpty (name)
-                    ? Catalog.GetString ("Unknown Artist") 
-                    : name; 
-            } 
+            get { return StringUtil.MaybeFallback (ArtistName, ArtistInfo.UnknownArtistName); } 
         }
 
         public string DisplayAlbumArtistName {
-            get {
-                string name = AlbumArtist == null ? null : AlbumArtist.Trim ();
-                return String.IsNullOrEmpty (name)
-                    ? DisplayArtistName
-                    : name;
-            }
+            get { return StringUtil.MaybeFallback (AlbumArtist, DisplayArtistName); }
         }
 
         public string DisplayAlbumTitle { 
-            get { 
-                string title = AlbumTitle == null ? null : AlbumTitle.Trim ();
-                return String.IsNullOrEmpty (title) 
-                    ? Catalog.GetString ("Unknown Album") 
-                    : title; 
-            } 
+            get { return StringUtil.MaybeFallback (AlbumTitle, AlbumInfo.UnknownAlbumTitle); } 
         }
 
         public string DisplayTrackTitle { 
-            get { 
-                string title = TrackTitle == null ? null : TrackTitle.Trim ();
-                return String.IsNullOrEmpty (title) 
-                    ? Catalog.GetString ("Unknown Title") 
-                    : title; 
-            } 
-        }     
+            get { return StringUtil.MaybeFallback (TrackTitle, UnknownTitle); } 
+        }
 
         public string DisplayGenre { 
             get { 
                 string genre = Genre == null ? null : Genre.Trim ();
-                return String.IsNullOrEmpty (genre) 
-                    ? Catalog.GetString ("Unknown Genre") 
-                    : genre; 
-            } 
-        }     
+                return String.IsNullOrEmpty (genre)
+                    ? String.Empty
+                    : genre;
+            }
+        }
         
         [Exportable (ExportName = "artwork-id")]
         public virtual string ArtworkId { 

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	Fri Mar 20 02:11:31 2009
@@ -49,12 +49,18 @@
             get { return provider; }
         }
 
-        private static HyenaSqliteCommand select_command = new HyenaSqliteCommand (String.Format (
+        private static HyenaSqliteCommand default_select_command = new HyenaSqliteCommand (String.Format (
             "SELECT {0} FROM {1} WHERE {2} AND CoreAlbums.ArtistID = ? AND CoreAlbums.Title = ?",
             provider.Select, provider.From,
             (String.IsNullOrEmpty (provider.Where) ? "1=1" : provider.Where)
         ));
 
+        private static HyenaSqliteCommand null_select_command = new HyenaSqliteCommand (String.Format (
+            "SELECT {0} FROM {1} WHERE {2} AND CoreAlbums.ArtistID = ? AND CoreAlbums.Title IS NULL",
+            provider.Select, provider.From,
+            (String.IsNullOrEmpty (provider.Where) ? "1=1" : provider.Where)
+        ));
+
         private static int last_artist_id;
         private static string last_title;
         private static DatabaseAlbumInfo last_album;
@@ -75,6 +81,15 @@
             return FindOrCreate (artist, album);
         }
 
+        private static IDataReader FindExistingArtists (int artist_id, string title)
+        {
+            HyenaSqliteConnection db = ServiceManager.DbConnection;
+            if (title == null) {
+                return db.Query (null_select_command, artist_id);
+            }
+            return db.Query (default_select_command, artist_id, title);
+        }
+        
         public static DatabaseAlbumInfo FindOrCreate (DatabaseArtistInfo artist, DatabaseAlbumInfo album)
         {
             if (album.Title == last_title && artist.DbId == last_artist_id && last_album != null) {
@@ -82,10 +97,10 @@
             }
 
             if (String.IsNullOrEmpty (album.Title) || album.Title.Trim () == String.Empty) {
-                album.Title = Catalog.GetString ("Unknown Album");
+                album.Title = null;
             }
 
-            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.DbId, album.Title)) {
+            using (IDataReader reader = FindExistingArtists (artist.DbId, album.Title)) {
                 if (reader.Read ()) {
                     bool save = false;
                     last_album = provider.Load (reader);
@@ -202,12 +217,12 @@
         
         [DatabaseColumn(Select = false)]
         internal byte[] TitleSortKey {
-            get { return Hyena.StringUtil.SortKey (TitleSort ?? Title); }
+            get { return Hyena.StringUtil.SortKey (TitleSort ?? DisplayTitle); }
         }
 
         [DatabaseColumn(Select = false)]
         internal string TitleLowered {
-            get { return Hyena.StringUtil.SearchKey (Title); }
+            get { return Hyena.StringUtil.SearchKey (DisplayTitle); }
         }
 
         [DatabaseColumn]
@@ -224,12 +239,12 @@
 
         [DatabaseColumn(Select = false)]
         internal byte[] ArtistNameSortKey {
-            get { return Hyena.StringUtil.SortKey (ArtistNameSort ?? ArtistName); }
+            get { return Hyena.StringUtil.SortKey (ArtistNameSort ?? DisplayArtistName); }
         }
         
         [DatabaseColumn(Select = false)]
         internal string ArtistNameLowered {
-            get { return Hyena.StringUtil.SearchKey (ArtistName); }
+            get { return Hyena.StringUtil.SearchKey (DisplayArtistName); }
         }
 
         public override string ToString ()

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	Fri Mar 20 02:11:31 2009
@@ -49,12 +49,18 @@
             get { return provider; }
         }
 
-        private static HyenaSqliteCommand select_command = new HyenaSqliteCommand (String.Format (
+        private static HyenaSqliteCommand default_select_command = new HyenaSqliteCommand (String.Format (
             "SELECT {0} FROM {1} WHERE {2} AND CoreArtists.Name = ?",
             provider.Select, provider.From,
             (String.IsNullOrEmpty (provider.Where) ? "1=1" : provider.Where)
         ));
 
+        private static HyenaSqliteCommand null_select_command = new HyenaSqliteCommand (String.Format (
+            "SELECT {0} FROM {1} WHERE {2} AND CoreArtists.Name IS NULL",
+            provider.Select, provider.From,
+            (String.IsNullOrEmpty (provider.Where) ? "1=1" : provider.Where)
+        ));
+        
         private static string last_artist_name = null;
         private static DatabaseArtistInfo last_artist = null;
 
@@ -71,7 +77,16 @@
             artist.NameSort = artistNameSort;
             return FindOrCreate (artist);
         }
-
+        
+        private static IDataReader FindExistingArtists (string name)
+        {
+            HyenaSqliteConnection db = ServiceManager.DbConnection;
+            if (name == null) {
+                return db.Query (null_select_command);
+            }
+            return db.Query (default_select_command, name);
+        }
+        
         public static DatabaseArtistInfo FindOrCreate (DatabaseArtistInfo artist)
         {
             if (artist.Name == last_artist_name && last_artist != null) {
@@ -79,10 +94,10 @@
             }
 
             if (String.IsNullOrEmpty (artist.Name) || artist.Name.Trim () == String.Empty) {
-                artist.Name = Catalog.GetString ("Unknown Artist");
+                artist.Name = null;
             }
-
-            using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.Name)) {
+            
+            using (IDataReader reader = FindExistingArtists (artist.Name)) {
                 if (reader.Read ()) {
                     last_artist = provider.Load (reader);
                     if (last_artist.NameSort != artist.NameSort) {
@@ -135,7 +150,7 @@
 
         [DatabaseColumn(Select = false)]
         internal string NameLowered {
-            get { return Hyena.StringUtil.SearchKey (Name); }
+            get { return Hyena.StringUtil.SearchKey (DisplayName); }
         }
 
         [DatabaseColumn]
@@ -146,7 +161,7 @@
 
         [DatabaseColumn(Select = false)]
         internal byte[] NameSortKey {
-            get { return Hyena.StringUtil.SortKey (NameSort ?? Name); }
+            get { return Hyena.StringUtil.SortKey (NameSort ?? DisplayName); }
         }
         
         [DatabaseColumn("MusicBrainzID")]

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs	Fri Mar 20 02:11:31 2009
@@ -458,12 +458,12 @@
         
         [DatabaseColumn("TitleSortKey", Select = false)]
         internal byte[] TrackTitleSortKey {
-            get { return Hyena.StringUtil.SortKey (TrackTitleSort ?? TrackTitle); }
+            get { return Hyena.StringUtil.SortKey (TrackTitleSort ?? DisplayTrackTitle); }
         }
         
         [DatabaseColumn(Select = false)]
         internal string TitleLowered {
-            get { return Hyena.StringUtil.SearchKey (TrackTitle); }
+            get { return Hyena.StringUtil.SearchKey (DisplayTrackTitle); }
         }
 
         [DatabaseColumn(Select = false)]

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseAlbumInfoTests.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseAlbumInfoTests.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseAlbumInfoTests.cs	Fri Mar 20 02:11:31 2009
@@ -28,6 +28,7 @@
 
 using NUnit.Framework;
 using Banshee.Collection.Database;
+using Banshee.Collection;
 
 namespace Banshee.Collection.Database.Tests
 {
@@ -71,7 +72,7 @@
         [Test]
         public void TestWithoutTitleSortKey ()
         {
-            AssertTitleSort ("", null,  new byte[] {1, 1, 1, 1, 0});
+            AssertTitleSort ("", null,  Hyena.StringUtil.SortKey (AlbumInfo.UnknownAlbumTitle));
             AssertTitleSort ("a", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
             AssertTitleSort ("a", "",   new byte[] {14, 2, 1, 1, 1, 1, 0});
             AssertTitleSort ("A", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
@@ -87,7 +88,7 @@
         [Test]
         public void TestTitleLowered ()
         {
-            AssertTitleLowered ("", "");
+            AssertTitleLowered ("", AlbumInfo.UnknownAlbumTitle.ToLower ());
             AssertTitleLowered ("A", "a");
             AssertTitleLowered ("\u0104", "a");
         }
@@ -95,7 +96,7 @@
         [Test]
         public void TestWithoutArtistNameSortKey ()
         {
-            AssertArtistNameSort ("", null, new byte[] {1, 1, 1, 1, 0});
+            AssertArtistNameSort ("", null, Hyena.StringUtil.SortKey (ArtistInfo.UnknownArtistName));
             AssertArtistNameSort ("a", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
             AssertArtistNameSort ("A", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
 
@@ -112,7 +113,7 @@
         [Test]
         public void TestArtistNameLowered ()
         {
-            AssertArtistNameLowered ("", "");
+            AssertArtistNameLowered ("", ArtistInfo.UnknownArtistName.ToLower ());
             AssertArtistNameLowered ("A", "a");
             AssertArtistNameLowered ("\u0104", "a");
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseArtistInfoTests.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseArtistInfoTests.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseArtistInfoTests.cs	Fri Mar 20 02:11:31 2009
@@ -28,6 +28,7 @@
 
 using NUnit.Framework;
 using Banshee.Collection.Database;
+using Banshee.Collection;
 
 namespace Banshee.Collection.Database.Tests
 {
@@ -56,7 +57,7 @@
         [Test]
         public void TestWithoutNameSortKey ()
         {
-            AssertNameSort ("", null, new byte[] {1, 1, 1, 1, 0});
+            AssertNameSort ("", null, Hyena.StringUtil.SortKey (ArtistInfo.UnknownArtistName));
             AssertNameSort ("a", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
             AssertNameSort ("A", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
 
@@ -73,7 +74,7 @@
         [Test]
         public void TestNameLowered ()
         {
-            AssertNameLowered ("", "");
+            AssertNameLowered ("", ArtistInfo.UnknownArtistName.ToLower ());
             AssertNameLowered ("A", "a");
             AssertNameLowered ("\u0104", "a");
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseTrackInfoTests.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseTrackInfoTests.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/Tests/DatabaseTrackInfoTests.cs	Fri Mar 20 02:11:31 2009
@@ -28,6 +28,7 @@
 
 using NUnit.Framework;
 using Banshee.Collection.Database;
+using Banshee.Collection;
 
 namespace Banshee.Collection.Database.Tests
 {
@@ -56,7 +57,7 @@
         [Test]
         public void TestWithoutTitleSortKey ()
         {
-            AssertTitleSort ("", null, new byte[] {1, 1, 1, 1, 0});
+            AssertTitleSort ("", null, Hyena.StringUtil.SortKey (TrackInfo.UnknownTitle));
             AssertTitleSort ("a", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
             AssertTitleSort ("A", null, new byte[] {14, 2, 1, 1, 1, 1, 0});
 
@@ -73,7 +74,7 @@
         [Test]
         public void TestTitleLowered ()
         {
-            AssertTitleLowered ("", "");
+            AssertTitleLowered ("", TrackInfo.UnknownTitle.ToLower ());
             AssertTitleLowered ("A", "a");
             AssertTitleLowered ("\u0104", "a");
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	Fri Mar 20 02:11:31 2009
@@ -52,7 +52,7 @@
         // NOTE: Whenever there is a change in ANY of the database schema,
         //       this version MUST be incremented and a migration method
         //       MUST be supplied to match the new version number
-        protected const int CURRENT_VERSION = 25;
+        protected const int CURRENT_VERSION = 26;
         protected const int CURRENT_METADATA_VERSION = 5;
         
 #region Migration Driver
@@ -592,6 +592,36 @@
         
 #endregion
 
+#region Version 26
+
+        [DatabaseVersion (26)]
+        private bool Migrate_26 ()
+        {
+            string unknown_artist = "Unknown Artist";
+            string unknown_album = "Unknown Album";
+            string unknown_title = "Unknown Title";
+
+            connection.Execute ("UPDATE CoreArtists SET Name = NULL, NameLowered = HYENA_SEARCH_KEY(?)" +
+                                " WHERE Name  IN ('', ?, ?) OR Name IS NULL", 
+                                ArtistInfo.UnknownArtistName, unknown_artist, ArtistInfo.UnknownArtistName);
+
+            connection.Execute ("UPDATE CoreAlbums SET ArtistName = NULL, ArtistNameLowered = HYENA_SEARCH_KEY(?)" +
+                                " WHERE ArtistName IN ('', ?, ?) OR ArtistName IS NULL",
+                                ArtistInfo.UnknownArtistName, unknown_artist, ArtistInfo.UnknownArtistName);
+
+            connection.Execute ("UPDATE CoreAlbums SET Title = NULL, TitleLowered = HYENA_SEARCH_KEY(?)" +
+                                " WHERE Title IN ('', ?, ?) OR Title IS NULL",
+                                AlbumInfo.UnknownAlbumTitle, unknown_album, AlbumInfo.UnknownAlbumTitle);
+
+            connection.Execute ("UPDATE CoreTracks SET Title = NULL, TitleLowered = HYENA_SEARCH_KEY(?)" +
+                                " WHERE Title IN ('', ?, ?) OR Title IS NULL",
+                                TrackInfo.UnknownTitle, unknown_title, TrackInfo.UnknownTitle);
+
+            return true;
+        }
+        
+#endregion
+
 #pragma warning restore 0169
         
 #region Fresh database setup

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs	Fri Mar 20 02:11:31 2009
@@ -90,7 +90,7 @@
 #region QueryField Definitions
 
         public static QueryField ArtistField = new QueryField (
-            "artist", "ArtistName",
+            "artist", "DisplayArtistName",
             Catalog.GetString ("Artist"), "CoreArtists.NameLowered", true,
             // Translators: These are unique search aliases for "artist".  Please, no spaces. Blank ok.
             Catalog.GetString ("artist"), Catalog.GetString ("by"), Catalog.GetString ("artists"),
@@ -98,7 +98,7 @@
         );
 
         public static QueryField AlbumArtistField = new QueryField (
-            "albumartist", "AlbumArtist",
+            "albumartist", "DisplayAlbumArtistName",
             Catalog.GetString ("Album Artist"), "CoreAlbums.ArtistNameLowered", true,
             // Translators: These are unique search aliases for "album artist".  Please, no spaces. Blank ok.
             Catalog.GetString ("albumartist"), Catalog.GetString ("compilationartist"),
@@ -108,7 +108,7 @@
         // TODO add IsCompilationField
 
         public static QueryField AlbumField = new QueryField (
-            "album", "AlbumTitle",
+            "album", "DisplayAlbumTitle",
             Catalog.GetString ("Album"), "CoreAlbums.TitleLowered", true,
             // Translators: These are unique search aliases for "album".  Please, no spaces. Blank ok.
             Catalog.GetString ("album"), Catalog.GetString ("on"), Catalog.GetString ("from"),
@@ -167,7 +167,7 @@
         );
 
         public static QueryField TitleField = new QueryField (
-            "title", "TrackTitle",
+            "title", "DisplayTrackTitle",
             Catalog.GetString ("Name"), "CoreTracks.TitleLowered", true,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("title"), Catalog.GetString ("titled"), Catalog.GetString ("name"), Catalog.GetString ("named"),

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtistListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtistListView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtistListView.cs	Fri Mar 20 02:11:31 2009
@@ -41,7 +41,7 @@
     {
         public ArtistListView () : base ()
         {
-            column_controller.Add (new Column ("Artist", new ColumnCellText ("Name", true), 1.0));
+            column_controller.Add (new Column ("Artist", new ColumnCellText ("DisplayName", true), 1.0));
             ColumnController = column_controller;
         }
 

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	Fri Mar 20 02:11:31 2009
@@ -95,7 +95,7 @@
             // Compute the layout sizes for both lines for centering on the cell
             int old_size = layout.FontDescription.Size;
             
-            layout.SetText (album.Title);
+            layout.SetText (album.DisplayTitle);
             layout.GetPixelSize (out fl_width, out fl_height);
             
             if (!String.IsNullOrEmpty (album.ArtistName)) {
@@ -118,12 +118,12 @@
             }
             
             // Render the first line, resetting the state
-            layout.SetText (album.Title);
+            layout.SetText (album.DisplayTitle);
             layout.FontDescription.Weight = Pango.Weight.Bold;
             layout.FontDescription.Size = old_size;
             layout.FontDescription.Style = Pango.Style.Normal;
             
-            layout.SetText (album.Title);
+            layout.SetText (album.DisplayTitle);
             
             context.Context.MoveTo (x, y);
             text_color.A = 1;
@@ -156,4 +156,4 @@
             return (height < image_size ? image_size : height) + 6;
         }
     }
-}
\ No newline at end of file
+}

Modified: trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs	Fri Mar 20 02:11:31 2009
@@ -246,5 +246,11 @@
             
             return invalid_path_regex.Replace (input, "_");
         }
+        
+        public static string MaybeFallback (string input, string fallback)
+        {
+            string trimmed = input == null ? null : input.Trim ();
+            return String.IsNullOrEmpty (trimmed) ? fallback : trimmed;
+        }
     }
 }



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