banshee r4263 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena/Hyena.Data src/Libraries/Hyena/Hyena.Query src/Libraries/Hyena/Hyena.Query/Tests



Author: gburt
Date: Sun Jul 27 20:40:11 2008
New Revision: 4263
URL: http://svn.gnome.org/viewvc/banshee?rev=4263&view=rev

Log:
2008-07-27  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs:
	Create default columns within a private method so we can manipulate them
	beyond just their ctor (not yet done, but will use this to set better
	widths soon).  Also, use the new Column/QueryField integration to avoid
	duplication of names/labels.

	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Fix
	properly the detection of if any of the columns changed in a TracksChanged
	event are being sorted by, using the new Field property on SortableColumn.

	* src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs: Add a
	PropertyName property used to create/bind columns from a QueryField
	object.  Add a comment field.  Modify the GetSort method just enough to
	work with the new 'sort keys' (QueryField.Name) that will be passed in.

	* src/Libraries/Hyena/Hyena.Query/QueryField.cs:
	* src/Libraries/Hyena/Hyena.Query/Tests/QueryTests.cs: Add PropertyName.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/SortableColumn.cs:
	* src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs: Add QueryField Field
	property, the first step in integrating columns with QueryFields, which
	should probably be named something more generic like ModelFields.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs: Implement
	ISizeRequestCell and add delegate property to allow external code to
	specify what width a text cell should have.  Not used yet.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/SortableColumn.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryField.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Query/Tests/QueryTests.cs

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	Sun Jul 27 20:40:11 2008
@@ -89,130 +89,162 @@
 #region QueryField Definitions
 
         public static QueryField ArtistField = new QueryField (
-            "artist", Catalog.GetString ("Artist"), "CoreArtists.NameLowered", true,
+            "artist", "ArtistName",
+            Catalog.GetString ("Artist"), "CoreArtists.NameLowered", true,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("artist"), Catalog.GetString ("by"), Catalog.GetString ("artists"),
             "by", "artist", "artists"
         );
 
         public static QueryField AlbumField = new QueryField (
-            "album", Catalog.GetString ("Album"), "CoreAlbums.TitleLowered", true,
+            "album", "AlbumTitle",
+            Catalog.GetString ("Album"), "CoreAlbums.TitleLowered", true,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("album"), Catalog.GetString ("on"), Catalog.GetString ("from"),
             "on", "album", "from", "albumtitle"
         );
 
         public static QueryField DiscField = new QueryField (
-            "disc", Catalog.GetString ("Disc"), "CoreTracks.Disc", typeof(NaturalIntegerQueryValue),
+            "disc", "Disc",
+            Catalog.GetString ("Disc"), "CoreTracks.Disc", typeof(NaturalIntegerQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("disc"), Catalog.GetString ("cd"), Catalog.GetString ("discnum"),
             "disc", "cd", "discnum"
         );
+        
+        public static QueryField TrackNumberField = new QueryField (
+            "track", "TrackNumber",
+            Catalog.GetString ("Track Number"), "CoreTracks.TrackNumber", typeof(NaturalIntegerQueryValue),
+            // Translators: These are unique search fields.  Please, no spaces. Blank ok.
+            "#", Catalog.GetString ("track"), Catalog.GetString ("trackno"), Catalog.GetString ("tracknum"),
+            "track", "trackno", "tracknum"
+        );
 
         public static QueryField TitleField = new QueryField (
-            "title", Catalog.GetString ("Track Title"), "CoreTracks.TitleLowered", true,
+            "title", "TrackTitle",
+            Catalog.GetString ("Track Title"), "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"),
             "title", "titled", "name", "named"
         );
 
         public static QueryField YearField = new QueryField (
-            "year", Catalog.GetString ("Year"), "CoreTracks.Year", typeof(YearQueryValue),
+            "year", "Year",
+            Catalog.GetString ("Year"), "CoreTracks.Year", typeof(YearQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("year"), Catalog.GetString ("released"), Catalog.GetString ("yr"),
             "year", "released", "yr"
         );
 
         public static QueryField GenreField = new QueryField (
-            "genre", Catalog.GetString ("Genre"), "CoreTracks.Genre", false,
+            "genre", "Genre",
+            Catalog.GetString ("Genre"), "CoreTracks.Genre", false,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("genre"), "genre"
         );
 
         public static QueryField ComposerField = new QueryField (
-            "composer", Catalog.GetString ("Composer"), "CoreTracks.Composer", false,
+            "composer", "Composer",
+            Catalog.GetString ("Composer"), "CoreTracks.Composer", false,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("composer"), "composer"
         );
 
+        public static QueryField CommentField = new QueryField (
+            "comment", "Comment",
+            Catalog.GetString ("Comment"), "CoreTracks.Comment", false,
+            // Translators: These are unique search fields.  Please, no spaces. Blank ok.
+            Catalog.GetString ("comment"), "comment"
+        );
+
         public static QueryField RatingField = new QueryField (
-            "rating", Catalog.GetString ("Rating"), "CoreTracks.Rating", new Type [] {typeof(RatingQueryValue)},//, typeof(NullQueryValue)},
+            "rating", "SavedRating",
+            Catalog.GetString ("Rating"), "CoreTracks.Rating", new Type [] {typeof(RatingQueryValue)},//, typeof(NullQueryValue)},
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("rating"), Catalog.GetString ("stars"),
             "rating", "stars"
         );
 
         public static QueryField PlayCountField = new QueryField (
-            "playcount", Catalog.GetString ("Play Count"), "CoreTracks.PlayCount", typeof(NaturalIntegerQueryValue),
+            "playcount", "PlayCount",
+            Catalog.GetString ("Play Count"), "CoreTracks.PlayCount", typeof(NaturalIntegerQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("plays"), Catalog.GetString ("playcount"), Catalog.GetString ("listens"),
             "plays", "playcount", "numberofplays", "listens"
         );
 
         public static QueryField SkipCountField = new QueryField (
-            "skipcount", Catalog.GetString ("Skip Count"), "CoreTracks.SkipCount", typeof(NaturalIntegerQueryValue),
+            "skipcount", "SkipCount",
+            Catalog.GetString ("Skip Count"), "CoreTracks.SkipCount", typeof(NaturalIntegerQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("skips"), Catalog.GetString ("skipcount"),
             "skips", "skipcount"
         );
 
         public static QueryField FileSizeField = new QueryField (
-            "filesize", Catalog.GetString ("File Size"), "CoreTracks.FileSize", typeof(FileSizeQueryValue),
+            "filesize", "FileSize",
+            Catalog.GetString ("File Size"), "CoreTracks.FileSize", typeof(FileSizeQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("size"), Catalog.GetString ("filesize"),
             "size", "filesize"
         );
 
         public static QueryField UriField = new QueryField (
-            "uri", Catalog.GetString ("File Location"), "CoreTracks.Uri",
+            "uri", "Uri",
+            Catalog.GetString ("File Location"), "CoreTracks.Uri",
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("uri"), Catalog.GetString ("path"), Catalog.GetString ("file"), Catalog.GetString ("location"),
             "uri", "path", "file", "location"
         );
 
         public static QueryField DurationField = new QueryField (
-            "duration", Catalog.GetString ("Duration"), "CoreTracks.Duration", typeof(TimeSpanQueryValue),
+            "duration", "Duration",
+            Catalog.GetString ("Duration"), "CoreTracks.Duration", typeof(TimeSpanQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("duration"), Catalog.GetString ("length"), Catalog.GetString ("time"),
             "duration", "length", "time"
         );
 
         public static QueryField MimeTypeField = new QueryField (
-            "mimetype", Catalog.GetString ("Mime Type"), "CoreTracks.MimeType {0} OR CoreTracks.Uri {0}",
+            "mimetype", "MimeType",
+            Catalog.GetString ("Mime Type"), "CoreTracks.MimeType {0} OR CoreTracks.Uri {0}",
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("type"), Catalog.GetString ("mimetype"), Catalog.GetString ("format"), Catalog.GetString ("ext"),
             "type", "mimetype", "format", "ext", "mime"
         );
 
         public static QueryField LastPlayedField = new QueryField (
-            "lastplayed", Catalog.GetString ("Last Played Date"), "CoreTracks.LastPlayedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
+            "lastplayed", "LastPlayed",
+            Catalog.GetString ("Last Played Date"), "CoreTracks.LastPlayedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("lastplayed"), Catalog.GetString ("played"), Catalog.GetString ("playedon"),
             "lastplayed", "played", "playedon"
         );
 
         public static QueryField LastSkippedField = new QueryField (
-            "lastskipped", Catalog.GetString ("Last Skipped Date"), "CoreTracks.LastSkippedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
+            "lastskipped", "LastSkipped",
+            Catalog.GetString ("Last Skipped Date"), "CoreTracks.LastSkippedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("lastskipped"), Catalog.GetString ("skipped"), Catalog.GetString ("skippedon"),
             "lastskipped", "skipped", "skippedon"
         );
 
         public static QueryField DateAddedField = new QueryField (
-            "added", Catalog.GetString ("Date Added"), "CoreTracks.DateAddedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
+            "added", "DateAdded",
+            Catalog.GetString ("Date Added"), "CoreTracks.DateAddedStamp", new Type [] {typeof(RelativeTimeSpanQueryValue), typeof(DateQueryValue)},
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             Catalog.GetString ("added"), Catalog.GetString ("imported"), Catalog.GetString ("addedon"), Catalog.GetString ("dateadded"), Catalog.GetString ("importedon"),
             "added", "imported", "addedon", "dateadded", "importedon"
         );
 
         public static QueryField PlaylistField = new QueryField (
-            "playlistid", Catalog.GetString ("Playlist"),
+            "playlistid", null, Catalog.GetString ("Playlist"),
             "CoreTracks.TrackID {2} IN (SELECT TrackID FROM CorePlaylistEntries WHERE PlaylistID = {1})", typeof(PlaylistQueryValue),
             "playlistid", "playlist"
         );
 
         public static QueryField SmartPlaylistField = new QueryField (
-            "smartplaylistid", Catalog.GetString ("Smart Playlist"),
+            "smartplaylistid", null, Catalog.GetString ("Smart Playlist"),
             "CoreTracks.TrackID {2} IN (SELECT TrackID FROM CoreSmartPlaylistEntries WHERE SmartPlaylistID = {1})", typeof(SmartPlaylistQueryValue),
             "smartplaylistid", "smartplaylist"
         );
@@ -220,7 +252,7 @@
 #endregion
 
         public static QueryFieldSet FieldSet = new QueryFieldSet (
-            ArtistField, AlbumField, DiscField, TitleField, YearField, GenreField, ComposerField, RatingField, PlayCountField,
+            ArtistField, AlbumField, DiscField, TitleField, YearField, GenreField, ComposerField, CommentField, RatingField, PlayCountField,
             SkipCountField, FileSizeField, UriField, DurationField, MimeTypeField, LastPlayedField, LastSkippedField,
             DateAddedField, PlaylistField, SmartPlaylistField
         );
@@ -236,8 +268,9 @@
             string ascDesc = asc ? "ASC" : "DESC";
             string sort_query = null;
             // TODO use the QueryFields here instead of matching on a string key
-            switch(key) {
-                case "Track":
+            string column = null;
+            switch (key.ToLower ()) {
+                case "track":
                     sort_query = String.Format (@"
                         CoreAlbums.ArtistNameLowered ASC, 
                         CoreAlbums.TitleLowered ASC, 
@@ -245,7 +278,7 @@
                         CoreTracks.TrackNumber {0}", ascDesc); 
                     break;
 
-                case "Artist":
+                case "artist":
                     sort_query = String.Format (@"
                         CoreArtists.NameLowered {0}, 
                         CoreAlbums.TitleLowered ASC,
@@ -253,42 +286,57 @@
                         CoreTracks.TrackNumber ASC", ascDesc); 
                     break;
 
-                case "Album":
+                case "album":
                     sort_query = String.Format (@"
                         CoreAlbums.TitleLowered {0},
                         CoreTracks.Disc ASC,
                         CoreTracks.TrackNumber ASC", ascDesc); 
                     break;
 
-                case "Title":
+                case "title":
                     sort_query = String.Format (@"
                         CoreTracks.TitleLowered {0},
                         CoreAlbums.ArtistNameLowered ASC, 
                         CoreAlbums.TitleLowered ASC", ascDesc); 
                     break;
 
-                case "Random":
+                case "random":
                     sort_query = "RANDOM ()";
                     break;
 
-                case "Year":
-                case "Genre":
-                case "Disc":
-                case "Duration":
-                case "Rating":
-                case "PlayCount":
-                case "SkipCount":
-                case "FileSize":
-                case "LastPlayedStamp":
-                case "LastSkippedStamp":
-                case "DateAddedStamp":
-                case "Uri":
-                case "Composer":
+                // FIXME hacks to aid in migration of these sort keys to actually
+                // using the QueryField (or at least their .Names)
+                case "lastplayed":
+                case "lastskipped":
+                    column = String.Format ("{0}stamp", key);
+                    goto case "comment";
+                case "added":
+                    column = "dateaddedstamp";
+                    goto case "comment";
+
+                case "year":
+                case "genre":
+                case "disc":
+                case "duration":
+                case "rating":
+                case "playcount":
+                case "skipcount":
+                case "filesize":
+                case "lastplayedstamp":
+                case "lastskippedstamp":
+                case "dateaddedstamp":
+                case "uri":
+                case "mimetype":
+                case "composer":
+                case "comment":
                     sort_query = String.Format (
                         "CoreTracks.{0} {1}, {2}",
-                        key, ascDesc, default_sort
+                        column ?? key, ascDesc, default_sort
                     );
                     break;
+                default:
+                    Hyena.Log.ErrorFormat ("Unknown sort key passed in! {0} not recognized", key);
+                    break;
             }
             return sort_query;
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	Sun Jul 27 20:40:11 2008
@@ -170,10 +170,9 @@
 
             ISortableColumn sort_column = (TrackModel is DatabaseTrackListModel)
                 ? (TrackModel as DatabaseTrackListModel).SortColumn : null;
+
             // If it's the field we're sorting by, then yes, we care
-            // FIXME this EndsWith is very hacky, we should link the ISortableColumn to a field and/or a
-            // QueryOrder object
-            if (sort_column != null && field.Column.EndsWith (sort_column.SortKey)) {
+            if (sort_column != null && sort_column.Field == field) {
                 return true;
             }
 

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs	Sun Jul 27 20:40:11 2008
@@ -29,6 +29,7 @@
 using System;
 using Mono.Unix;
 
+using Hyena.Query;
 using Hyena.Gui;
 using Hyena.Gui.Theming;
 using Hyena.Gui.Theatrics;
@@ -38,6 +39,7 @@
 using Banshee.ServiceStack;
 using Banshee.MediaEngine;
 using Banshee.Collection;
+using Banshee.Query;
 
 namespace Banshee.Collection.Gui
 {
@@ -50,6 +52,8 @@
         public DefaultColumnController (bool loadDefault) : base (String.Format ("{0}.{1}", 
             Application.ActiveClient.ClientId, "track_view_columns"))
         {
+            CreateDefaultColumns ();
+
             if (loadDefault) {
                 AddDefaultColumns ();
                 DefaultSortColumn = TrackColumn;
@@ -81,125 +85,164 @@
                 MimeTypeColumn
             );
         }
+
+        private void CreateDefaultColumns ()
+        {
+            indicator_column = new Column (null, "indicator", new ColumnCellStatusIndicator (null), 0.05, true, 30, 30);
+
+            // Visible-by-default column
+            track_column        = Create (BansheeQuery.TrackNumberField, 0.10, true, new ColumnCellTrackNumber (null, true));
+            title_column        = CreateText (BansheeQuery.TitleField, 0.25, true);
+            artist_column       = CreateText (BansheeQuery.ArtistField, 0.225, true);
+            album_column        = CreateText (BansheeQuery.AlbumField, 0.225, true);
+
+            // Others
+            genre_column        = CreateText (BansheeQuery.GenreField, 0.25);
+
+            duration_column     = Create (BansheeQuery.DurationField, 0.10, true, new ColumnCellDuration (null, true));
+            year_column         = Create (BansheeQuery.YearField, 0.15, false, new ColumnCellPositiveInt (null, true));
+            file_size_column    = Create (BansheeQuery.FileSizeField, 0.15, false, new ColumnCellFileSize (null, true));
+            disc_column         = Create (BansheeQuery.DiscField, 0.10, false, new ColumnCellPositiveInt (null, true));
+            rating_column       = Create (BansheeQuery.RatingField, 0.15, false, new ColumnCellRating (null, true));
+
+            composer_column     = CreateText (BansheeQuery.ComposerField, 0.25);
+            comment_column      = CreateText (BansheeQuery.CommentField, 0.25);
+            play_count_column   = CreateText (BansheeQuery.PlayCountField, 0.15);
+            skip_count_column   = CreateText (BansheeQuery.SkipCountField, 0.15);
+            uri_column          = CreateText (BansheeQuery.UriField, 0.15);
+            mime_type_column    = CreateText (BansheeQuery.MimeTypeField, 0.15);
+
+            last_played_column  = Create (BansheeQuery.LastPlayedField, 0.15, false, new ColumnCellDateTime (null, true));
+            last_skipped_column = Create (BansheeQuery.LastSkippedField, 0.15, false, new ColumnCellDateTime (null, true));
+            date_added_column   = Create (BansheeQuery.DateAddedField, 0.15, false, new ColumnCellDateTime (null, true));
+        }
+
+        private SortableColumn CreateText (QueryField field, double width)
+        {
+            return CreateText (field, width, false);
+        }
+
+        private SortableColumn CreateText (QueryField field, double width, bool visible)
+        {
+            return Create (field, width, visible, new ColumnCellText (field.PropertyName, true));
+        }
+
+        private SortableColumn Create (QueryField field, double width, bool visible, ColumnCell cell)
+        {
+            cell.Property = field.PropertyName;
+            SortableColumn col = new SortableColumn (
+                field.Label,
+                cell,
+                width, field.Name, visible
+            );
+            col.Field = field;
+
+            return col;
+        }
         
-        private Column indicator_column 
-            = new Column (null, "indicator", new ColumnCellStatusIndicator (null), 0.05, true, 30, 30);
+#region Column Properties
+
+        private Column indicator_column;
         public Column IndicatorColumn {
             get { return indicator_column; }
         }
         
-        private SortableColumn track_column = new SortableColumn (Catalog.GetString ("Track"), 
-            new ColumnCellTrackNumber ("TrackNumber", true), 0.10, "Track", true);
+        private SortableColumn track_column;
         public SortableColumn TrackColumn {
             get { return track_column; }
         }
         
-        private SortableColumn title_column = new SortableColumn (Catalog.GetString ("Title"), 
-            new ColumnCellText ("TrackTitle", true), 0.25, "Title", true);
+        private SortableColumn title_column;
         public SortableColumn TitleColumn {
             get { return title_column; }
         }
 
-        private SortableColumn artist_column = new SortableColumn (Catalog.GetString ("Artist"), 
-            new ColumnCellText ("ArtistName", true), 0.225, "Artist", true);
+        private SortableColumn artist_column;
         public SortableColumn ArtistColumn {
             get { return artist_column; }
         }
         
-        private SortableColumn album_column = new SortableColumn (Catalog.GetString ("Album"), 
-            new ColumnCellText ("AlbumTitle", true), 0.225, "Album", true);
+        private SortableColumn album_column;
         public SortableColumn AlbumColumn {
             get { return album_column; }
         }
         
-        private SortableColumn duration_column = new SortableColumn (Catalog.GetString ("Duration"),
-            new ColumnCellDuration ("Duration", true), 0.10, "Duration", true);
+        private SortableColumn duration_column;
         public SortableColumn DurationColumn {
             get { return duration_column; }
         }
         
-        private SortableColumn genre_column = new SortableColumn (Catalog.GetString ("Genre"), 
-            new ColumnCellText ("Genre", true), 0.25, "Genre", false);
+        private SortableColumn genre_column;
         public SortableColumn GenreColumn {
             get { return genre_column; }
         }
         
-        private SortableColumn year_column = new SortableColumn (Catalog.GetString ("Year"), 
-            new ColumnCellPositiveInt ("Year", true), 0.15, "Year", false);
+        private SortableColumn year_column;
         public SortableColumn YearColumn {
             get { return year_column; }
         }
 
-        private SortableColumn file_size_column = new SortableColumn (Catalog.GetString ("File Size"), 
-            new ColumnCellFileSize ("FileSize", true), 0.15, "FileSize", false);
+        private SortableColumn file_size_column;
         public SortableColumn FileSizeColumn {
             get { return file_size_column; }
         }
         
-        private SortableColumn composer_column = new SortableColumn (Catalog.GetString ("Composer"), 
-            new ColumnCellText ("Composer", true), 0.25, "Composer", false);
+        private SortableColumn composer_column;
         public SortableColumn ComposerColumn {
             get { return composer_column; }
         }
         
-        private SortableColumn comment_column = new SortableColumn (Catalog.GetString ("Comment"), 
-            new ColumnCellText ("Comment", true), 0.25, "Comment", false);
+        private SortableColumn comment_column;
         public SortableColumn CommentColumn {
             get { return comment_column; }
         }
         
-        private SortableColumn play_count_column = new SortableColumn (Catalog.GetString ("Play Count"), 
-            new ColumnCellText ("PlayCount", true), 0.15, "PlayCount", false);
+        private SortableColumn play_count_column;
         public SortableColumn PlayCountColumn {
             get { return play_count_column; }
         }
         
-        private SortableColumn skip_count_column = new SortableColumn (Catalog.GetString ("Skip Count"), 
-            new ColumnCellText ("SkipCount", true), 0.15, "SkipCount", false);
+        private SortableColumn skip_count_column;
         public SortableColumn SkipCountColumn {
             get { return skip_count_column; }
         }
         
-        private SortableColumn disc_column = new SortableColumn (Catalog.GetString ("Disc"), 
-            new ColumnCellPositiveInt ("Disc", true), 0.10, "Disc", false);
+        private SortableColumn disc_column;
         public SortableColumn DiscColumn {
             get { return disc_column; }
         }
         
-        private SortableColumn rating_column = new SortableColumn (Catalog.GetString ("Rating"),
-            new ColumnCellRating ("SavedRating", true), 0.15, "Rating", false);
+        private SortableColumn rating_column;
         public SortableColumn RatingColumn {
             get { return rating_column; }
         }
         
-        private SortableColumn last_played_column = new SortableColumn (Catalog.GetString ("Last Played"), 
-            new ColumnCellDateTime ("LastPlayed", true), 0.15, "LastPlayedStamp", false);
+        private SortableColumn last_played_column;
         public SortableColumn LastPlayedColumn {
             get { return last_played_column; }
         }
         
-        private SortableColumn last_skipped_column = new SortableColumn (Catalog.GetString ("Last Skipped"), 
-            new ColumnCellDateTime ("LastSkipped", true), 0.15, "LastSkippedStamp", false);
+        private SortableColumn last_skipped_column;
         public SortableColumn LastSkippedColumn {
             get { return last_skipped_column; }
         }
         
-        private SortableColumn date_added_column = new SortableColumn (Catalog.GetString ("Date Added"), 
-            new ColumnCellDateTime ("DateAdded", true), 0.15, "DateAddedStamp", false);
+        private SortableColumn date_added_column;
         public SortableColumn DateAddedColumn {
             get { return date_added_column; }
         }
         
-        private SortableColumn uri_column = new SortableColumn (Catalog.GetString ("Location"), 
-            new ColumnCellText ("Uri", true), 0.15, "Uri", false);
+        private SortableColumn uri_column;
         public SortableColumn UriColumn {
             get { return uri_column; }
         }
         
-        private SortableColumn mime_type_column = new SortableColumn (Catalog.GetString ("Mime Type"), 
-            new ColumnCellText ("MimeType", true), 0.15, "MimeType", false);
+        private SortableColumn mime_type_column;
         public SortableColumn MimeTypeColumn {
             get { return mime_type_column; }
         }
+
+#endregion
+
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	Sun Jul 27 20:40:11 2008
@@ -35,7 +35,7 @@
 
 namespace Hyena.Data.Gui
 {
-    public class ColumnCellText : ColumnCell
+    public class ColumnCellText : ColumnCell, ISizeRequestCell
     {
         public delegate string DataHandler ();
     
@@ -119,5 +119,35 @@
             layout.Dispose ();
             return row_height + 8;
         }
+
+        #region ISizeRequestCell implementation 
+        
+        public void GetSize (out int width, out int height)
+        {
+            if (get_size_request != null) {
+                get_size_request (out width, out height);
+            } else {
+                // Should never really get here, because RestrictSize should return false
+                width = height = 0;
+            }
+        }
+        
+        private bool restrict_size = false;
+        public bool RestrictSize {
+            get { return restrict_size && get_size_request != null; }
+            set { restrict_size = value; }
+        }
+        
+        #endregion
+        
+        public delegate void GetSizeRequestHandler (out int width, out int height);
+        private GetSizeRequestHandler get_size_request;
+        public GetSizeRequestHandler GetSizeHandler {
+            get { return get_size_request; }
+            set {
+                get_size_request = value;
+                RestrictSize = value != null;
+            }
+        }
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/SortableColumn.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/SortableColumn.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/SortableColumn.cs	Sun Jul 27 20:40:11 2008
@@ -37,6 +37,7 @@
     {
         private string sort_key;
         private SortType sort_type = SortType.Ascending;
+        private Hyena.Query.QueryField field;
         
         public SortableColumn(string title, ColumnCell cell, double width, string sort_key, bool visible) : 
             base(title, cell, width, visible)
@@ -59,5 +60,10 @@
             get { return sort_type; }
             set { sort_type = value; }
         }
+
+        public Hyena.Query.QueryField Field {
+            get { return field; }
+            set { field = value; }
+        }
     }
-}
\ No newline at end of file
+}

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs	Sun Jul 27 20:40:11 2008
@@ -32,5 +32,6 @@
     {
         string SortKey { get; }
         SortType SortType { get; set; }
+        Hyena.Query.QueryField Field { get; }
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryField.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryField.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Query/QueryField.cs	Sun Jul 27 20:40:11 2008
@@ -48,6 +48,12 @@
             get { return name; }
             set { name = value; }
         }
+        
+        private string property_name;
+        public string PropertyName {
+            get { return property_name; }
+            set { property_name = value; }
+        }
 
         private string label;
         public string Label {
@@ -74,29 +80,30 @@
             get { return is_default; }
         }
 
-        public QueryField (string name, string label, string column, params string [] aliases)
-            : this (name, label, column, false, aliases)
+        public QueryField (string name, string propertyName, string label, string column, params string [] aliases)
+            : this (name, propertyName, label, column, false, aliases)
         {
         }
 
-        public QueryField (string name, string label, string column, bool isDefault, params string [] aliases)
-            : this (name, label, column, new Type [] {typeof(StringQueryValue)}, isDefault, aliases)
+        public QueryField (string name, string propertyName, string label, string column, bool isDefault, params string [] aliases)
+            : this (name, propertyName, label, column, new Type [] {typeof(StringQueryValue)}, isDefault, aliases)
         {
         }
 
-        public QueryField (string name, string label, string column, Type valueType, params string [] aliases)
-            : this (name, label, column, new Type [] {valueType}, false, aliases)
+        public QueryField (string name, string propertyName, string label, string column, Type valueType, params string [] aliases)
+            : this (name, propertyName, label, column, new Type [] {valueType}, false, aliases)
         {
         }
 
-        public QueryField (string name, string label, string column, Type [] valueTypes, params string [] aliases)
-            : this (name, label, column, valueTypes, false, aliases)
+        public QueryField (string name, string propertyName, string label, string column, Type [] valueTypes, params string [] aliases)
+            : this (name, propertyName, label, column, valueTypes, false, aliases)
         {
         }
 
-        public QueryField (string name, string label, string column, Type [] valueTypes, bool isDefault, params string [] aliases)
+        public QueryField (string name, string propertyName, string label, string column, Type [] valueTypes, bool isDefault, params string [] aliases)
         {
             this.name = name;
+            this.property_name = propertyName;
             this.label = label;
             this.column = column;
             this.value_types = valueTypes;

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Query/Tests/QueryTests.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Query/Tests/QueryTests.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Query/Tests/QueryTests.cs	Sun Jul 27 20:40:11 2008
@@ -40,31 +40,31 @@
     public class QueryTests : Hyena.Tests.TestBase
     {
         private static QueryField ArtistField = new QueryField (
-            "artist", "Artist", "CoreArtists.NameLowered", true,
+            "artist", "ArtistName", "Artist", "CoreArtists.NameLowered", true,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             "by", "artist", "artists"
         );
 
         private static QueryField AlbumField = new QueryField (
-            "album", "Album", "CoreAlbums.TitleLowered", true,
+            "album", "AlbumTitle", "Album", "CoreAlbums.TitleLowered", true,
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             "on", "album", "from", "albumtitle"
         );
 
         private static QueryField PlayCountField = new QueryField (
-            "playcount", "Play Count", "CoreTracks.PlayCount", typeof(IntegerQueryValue),
+            "playcount", "PlayCount", "Play Count", "CoreTracks.PlayCount", typeof(IntegerQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             "plays", "playcount", "numberofplays", "listens"
         );
 
         private static QueryField DurationField = new QueryField (
-            "duration", "Duration", "CoreTracks.Duration", typeof(TimeSpanQueryValue),
+            "duration", "Duration", "Duration", "CoreTracks.Duration", typeof(TimeSpanQueryValue),
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             "duration", "length", "time"
         );
 
         private static QueryField MimeTypeField = new QueryField (
-            "mimetype", "Mime Type", "CoreTracks.MimeType {0} OR CoreTracks.Uri {0}",
+            "mimetype", "MimeType", "Mime Type", "CoreTracks.MimeType {0} OR CoreTracks.Uri {0}",
             // Translators: These are unique search fields.  Please, no spaces. Blank ok.
             "type", "mimetype", "format", "ext", "mime"
         );



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