banshee r4554 - in trunk/banshee: . src/Backends/Banshee.Gnome/Banshee.GnomeBackend src/Core/Banshee.Services/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.SmartPlaylist src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp src/Dap/Banshee.Dap/Banshee.Dap src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView src/Libraries /Hyena/Hyena.Data



Author: gburt
Date: Tue Sep 16 21:07:28 2008
New Revision: 4554
URL: http://svn.gnome.org/viewvc/banshee?rev=4554&view=rev

Log:
2008-09-16  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/ListModel.cs:
	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/FilterableListModel.cs:
	Comment out unused classes; should probably be removed.

	* src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs:
	* src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs:
	* src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs:
	* src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs:
	* src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs:
	* src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs:
	* src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs:
	* src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs:
	* src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs:
	* src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs:
	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs:
	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs:
	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs:
	* src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs:
	* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistDefinition.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs:
	Update to use new DatabaseSource ctor that takes a PrimarySource, not its DbId.

	* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs:
	Use new ctor, and explicitly set TrackModel.CanReorder to true.

	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs:
	Persist on a per-source basis the sort column/direction (BGO #524656).

	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs:
	Set IsEverReordereable to true; but whether the TrackList is actually
	reorderable also depends on the IsReorderable property, which is set
	automatically if the SortColumn's SortType is None (BGO #551969).

	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs:
	Added logic to ignore Sort requests if we already are sorted by the
	current key/direction.  Also, return true/false based on whether a new
	sort was applied (and therefore the model should be Reloaded).  Move the
	logic that iterates through None/Asc/Desc and that sets the initial
	direction to Asc when sorting by a different column into the ListView.

	* src/Core/Banshee.Services/Banshee.Sources/Source.cs: Rename
	ConfigurationId property to ParentConfigurationId, and add a new
	ConfigurationId property that is actually unique to this source.

	* src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs:
	* src/Core/Banshee.Services/Banshee.Collection/BansheeListModel.cs:
	* src/Libraries/Hyena/Hyena.Data/IListModel.cs:
	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListViewTestModule.cs:
	Add CanReorder property.

	* src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs: Remove
	some more columns from the default (music) column list, and set a default
	sort-column.

	* src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GConfConfigurationClient.cs:
	Replace / chars in the namespace with _ for .-separated keys.

	* src/Libraries/Hyena/Hyena.Data/ISortable.cs: Change Sort to return bool.

	* src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs: Add Id getter.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs: Add
	SortColumn property, used to get access to the currently-sorted-by column.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs:
	Replace Reorderable property into IsReorderable and IsEverReorderable,
	both of which must be set to true for the ListView to turn be a drag
	source/drop dest (overridable as before w/ the Force* properties).

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
	Reorderable renamed to IsReorderable.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
	Moved the logic for iterating through None/Asc/Desc here from
	DatabaseTrackListModel.cs.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs: When
	setting the ListView's model, update the sort column, since it is
	remembered on a per-source basis now.



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GConfConfigurationClient.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/BansheeListModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistDefinition.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
   trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
   trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/FilterableListModel.cs
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/ListModel.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListViewTestModule.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data/IListModel.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortable.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortableColumn.cs

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GConfConfigurationClient.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GConfConfigurationClient.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GConfConfigurationClient.cs	Tue Sep 16 21:07:28 2008
@@ -70,6 +70,7 @@
                         key_table.Add (hash_key, String.Format ("{0}{1}{2}", @namespace,
                             @namespace.EndsWith ("/") ? String.Empty : "/", StringUtil.CamelCaseToUnderCase (part)));
                     } else {
+                        @namespace = @namespace.Replace ('/', '_');
                         key_table.Add (hash_key, String.Format ("{0}{1}",
                             base_key, StringUtil.CamelCaseToUnderCase (String.Format ("{0}/{1}", @namespace.Replace (".", "/"), part))
                         ));

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs	Tue Sep 16 21:07:28 2008
@@ -135,31 +135,26 @@
                 : BansheeQuery.GetSort (SortColumn.SortKey, SortColumn.SortType == SortType.Ascending);
         }
 
-        public void Sort (ISortableColumn column)
+        private SortType last_sort_type = SortType.None;
+        public bool Sort (ISortableColumn column)
         {
             lock (this) {
                 if (forced_sort_query) {
-                    return;
+                    return false;
                 }
-                
-                if (sort_column == column && sort_column != null) {
-                    switch (sort_column.SortType) {
-                        case SortType.Ascending:    sort_column.SortType = SortType.Descending; break;
-                        case SortType.Descending:   sort_column.SortType = SortType.None; break;
-                        case SortType.None:         sort_column.SortType = SortType.Ascending; break;
-                    }
-                }
-                
-                // If we're switching from a different column, or we aren't in a playlist, make sure sort type isn't None
-                if (sort_column != null && (sort_column != column || !(source is Banshee.Playlist.PlaylistSource)) && sort_column.SortType == SortType.None) {
-                    sort_column.SortType = SortType.Ascending;
+
+                // Don't sort by the same column and the same sort-type more than once
+                if (sort_column != null && sort_column == column && column.SortType == last_sort_type) {
+                    return false;
                 }
-                
+
+                last_sort_type = column.SortType;
                 sort_column = column;
-            
+
                 GenerateSortQueryPart ();
                 cache.Clear ();
             }
+            return true;
         }
 
         private void HandleCacheAggregatesUpdated (IDataReader reader)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/BansheeListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/BansheeListModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/BansheeListModel.cs	Tue Sep 16 21:07:28 2008
@@ -97,5 +97,11 @@
         public T FocusedItem {
             get { return Selection.FocusedIndex == -1 ? default(T) : this[Selection.FocusedIndex]; }
         }
+
+        private bool can_reorder = false;
+        public bool CanReorder {
+            get { return can_reorder; }
+            set { can_reorder = value; }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs	Tue Sep 16 21:07:28 2008
@@ -50,6 +50,11 @@
                   <remove-default column=""DiscColumn"" />
                   <remove-default column=""AlbumColumn"" />
                   <remove-default column=""ComposerColumn"" />
+                  <remove-default column=""AlbumArtistColumn"" />
+                  <remove-default column=""ConductorColumn"" />
+                  <remove-default column=""ComposerColumn"" />
+                  <remove-default column=""BpmColumn"" />
+                  <sort-column direction=""asc"">track_title</sort-column>
                   <column modify-default=""ArtistColumn"">
                     <title>{0}</title>
                   </column>

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs	Tue Sep 16 21:07:28 2008
@@ -127,19 +127,22 @@
             }
         }
 
-        public AbstractPlaylistSource (string generic_name, string name, int primarySourceId) : base ()
+        public AbstractPlaylistSource (string generic_name, string name, PrimarySource parent) : base ()
         {
             GenericName = generic_name;
             Name = name;
-            primary_source_id = primarySourceId;
+            if (parent != null) {
+                primary_source_id = parent.DbId;
+                SetParentSource (parent);
+            }
         }
 
-        public AbstractPlaylistSource (string generic_name, string name, int dbid, int sortColumn, int sortType, int primarySourceId, bool is_temp)
-            : base (generic_name, name, dbid.ToString (), 500)
+        public AbstractPlaylistSource (string generic_name, string name, int dbid, int sortColumn, int sortType, PrimarySource parent, bool is_temp)
+            : base (generic_name, name, dbid.ToString (), 500, parent)
         {
+            primary_source_id = parent.DbId;
             DbId = dbid;
             IsTemporary = is_temp;
-            this.primary_source_id = primarySourceId;
             AfterInitialized ();
         }
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	Tue Sep 16 21:07:28 2008
@@ -239,7 +239,7 @@
         private void CreatePlaylist (object o, EventArgs args)
         {
             try {
-                PlaylistSource playlist = new PlaylistSource (name, source.DbId);
+                PlaylistSource playlist = new PlaylistSource (name, source);
                 playlist.Save ();
                 source.AddChildSource (playlist);
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	Tue Sep 16 21:07:28 2008
@@ -107,17 +107,17 @@
 
 #region Constructors
 
-        public PlaylistSource (string name, int primarySourceId) : base (generic_name, name, primarySourceId)
+        public PlaylistSource (string name, PrimarySource parent) : base (generic_name, name, parent)
         {
             SetProperties ();
         }
 
-        protected PlaylistSource (string name, int dbid, int primarySourceId) : this (name, dbid, -1, 0, primarySourceId, 0, false)
+        protected PlaylistSource (string name, int dbid, PrimarySource parent) : this (name, dbid, -1, 0, parent, 0, false)
         {
         }
 
-        protected PlaylistSource (string name, int dbid, int sortColumn, int sortType, int primarySourceId, int count, bool is_temp)
-            : base (generic_name, name, dbid, sortColumn, sortType, primarySourceId, is_temp)
+        protected PlaylistSource (string name, int dbid, int sortColumn, int sortType, PrimarySource parent, int count, bool is_temp)
+            : base (generic_name, name, dbid, sortColumn, sortType, parent, is_temp)
         {
             SetProperties ();
             SavedCount = count;
@@ -157,6 +157,8 @@
                 PrimarySource.TracksChanged += HandleTracksChanged;
                 PrimarySource.TracksDeleted += HandleTracksDeleted;
             }
+
+            TrackModel.CanReorder = true;
         }
 
         protected override void Update ()
@@ -336,16 +338,16 @@
             }
         }
 
-        public static IEnumerable<PlaylistSource> LoadAll (int primary_id)
+        public static IEnumerable<PlaylistSource> LoadAll (PrimarySource parent)
         {
             ClearTemporary ();
             using (HyenaDataReader reader = new HyenaDataReader (ServiceManager.DbConnection.Query (
                 @"SELECT PlaylistID, Name, SortColumn, SortType, PrimarySourceID, CachedCount, IsTemporary FROM CorePlaylists 
-                    WHERE Special = 0 AND PrimarySourceID = ?", primary_id))) {
+                    WHERE Special = 0 AND PrimarySourceID = ?", parent.DbId))) {
                 while (reader.Read ()) {
                     yield return new PlaylistSource (
                         reader.Get<string> (1), reader.Get<int> (0),
-                        reader.Get<int> (2), reader.Get<int> (3), reader.Get<int> (4),
+                        reader.Get<int> (2), reader.Get<int> (3), parent,
                         reader.Get<int> (5), reader.Get<bool> (6)
                     );
                 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistDefinition.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistDefinition.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistDefinition.cs	Tue Sep 16 21:07:28 2008
@@ -73,7 +73,7 @@
                 Name,
                 UserQueryParser.Parse (Condition, BansheeQuery.FieldSet),
                 Order, Limit, LimitNumber,
-                primary_source.DbId
+                primary_source
             );
         }
     }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	Tue Sep 16 21:07:28 2008
@@ -190,13 +190,13 @@
 
 #region Constructors
 
-        public SmartPlaylistSource (string name, int primarySourceId) : base (generic_name, name, primarySourceId)
+        public SmartPlaylistSource (string name, PrimarySource parent) : base (generic_name, name, parent)
         {
             SetProperties ();
         }
 
-        public SmartPlaylistSource (string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, int primarySourceId)
-            : this (name, primarySourceId)
+        public SmartPlaylistSource (string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, PrimarySource parent)
+            : this (name, parent)
         {
             ConditionTree = condition;
             QueryOrder = order;
@@ -208,8 +208,8 @@
         }
 
         // For existing smart playlists that we're loading from the database
-        protected SmartPlaylistSource (int dbid, string name, string condition_xml, string order_by, string limit_number, string limit_criterion, int primarySourceId, int count, bool is_temp) :
-            base (generic_name, name, dbid, -1, 0, primarySourceId, is_temp)
+        protected SmartPlaylistSource (int dbid, string name, string condition_xml, string order_by, string limit_number, string limit_criterion, PrimarySource parent, int count, bool is_temp) :
+            base (generic_name, name, dbid, -1, 0, parent, is_temp)
         {
             ConditionXml = condition_xml;
             QueryOrder = BansheeQuery.FindOrder (order_by);
@@ -482,12 +482,12 @@
             return sql;
         }
 
-        public static IEnumerable<SmartPlaylistSource> LoadAll (int primary_id)
+        public static IEnumerable<SmartPlaylistSource> LoadAll (PrimarySource parent)
         {
             ClearTemporary ();
             using (HyenaDataReader reader = new HyenaDataReader (ServiceManager.DbConnection.Query (
                 @"SELECT SmartPlaylistID, Name, Condition, OrderBy, LimitNumber, LimitCriterion, PrimarySourceID, CachedCount, IsTemporary
-                    FROM CoreSmartPlaylists WHERE PrimarySourceID = ?", primary_id))) {
+                    FROM CoreSmartPlaylists WHERE PrimarySourceID = ?", parent.DbId))) {
                 while (reader.Read ()) {
                     SmartPlaylistSource playlist = null;
                     try {
@@ -495,7 +495,7 @@
                             reader.Get<int> (0), reader.Get<string> (1),
                             reader.Get<string> (2), reader.Get<string> (3),
                             reader.Get<string> (4), reader.Get<string> (5),
-                            reader.Get<int> (6), reader.Get<int> (7), reader.Get<bool> (8)
+                            parent, reader.Get<int> (7), reader.Get<bool> (8)
                         );
                     } catch (Exception e) {
                         Log.Warning ("Ignoring Smart Playlist", String.Format ("Caught error: {0}", e), false);

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	Tue Sep 16 21:07:28 2008
@@ -69,9 +69,16 @@
         }
 
         private RateLimiter reload_limiter;
+
+        public DatabaseSource (string generic_name, string name, string id, int order) : this (generic_name, name, id, order, null)
+        {
+        }
         
-        public DatabaseSource (string generic_name, string name, string id, int order) : base (generic_name, name, order, id)
+        public DatabaseSource (string generic_name, string name, string id, int order, Source parent) : base (generic_name, name, order, id)
         {
+            if (parent != null) {
+                SetParentSource (parent);
+            }
             DatabaseSourceInitialize ();
         }
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ErrorSource.cs	Tue Sep 16 21:07:28 2008
@@ -125,6 +125,8 @@
         public override int Count {
             get { return messages.Count; }
         }
+
+        public bool CanReorder { get { return false; } }
         
         public virtual bool CanUnmap {
             get { return true; }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	Tue Sep 16 21:07:28 2008
@@ -243,12 +243,12 @@
             primary_sources[DbId] = this;
             
             // Load our playlists and smart playlists
-            foreach (PlaylistSource pl in PlaylistSource.LoadAll (DbId)) {
+            foreach (PlaylistSource pl in PlaylistSource.LoadAll (this)) {
                 AddChildSource (pl);
             }
 
             int sp_count = 0;
-            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll (DbId)) {
+            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll (this)) {
                 AddChildSource (pl);
                 sp_count++;
             }
@@ -274,7 +274,7 @@
             }
 
             expanded_schema = new SchemaEntry<bool> (
-                String.Format ("sources.{0}", ConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
+                String.Format ("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
             );
         }
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	Tue Sep 16 21:07:28 2008
@@ -543,9 +543,20 @@
         public virtual int Count {
             get { return 0; }
         }
-        
+
+        private string parent_conf_id;
+        public string ParentConfigurationId {
+            get {
+                if (parent_conf_id == null) {
+                    parent_conf_id = (Parent ?? this).UniqueId.Replace ('.', '_');
+                }
+                return parent_conf_id;
+            }
+        }
+
+        private string conf_id;
         public string ConfigurationId {
-            get { return (Parent == null ? UniqueId : Parent.UniqueId).Replace ('.', '_'); }
+            get { return conf_id ?? conf_id = UniqueId.Replace ('.', '_'); }
         }
 
         public virtual int FilteredCount { get { return Count; } }
@@ -568,8 +579,8 @@
         }
         
         public virtual int CurrentStatusFormat {
-            get { return ConfigurationClient.Get<int> (String.Format ("sources.{0}", ConfigurationId), "status_format", 0); }
-            set { ConfigurationClient.Set<int> (String.Format ("sources.{0}", ConfigurationId), "status_format", value); }
+            get { return ConfigurationClient.Get<int> (String.Format ("sources.{0}", ParentConfigurationId), "status_format", 0); }
+            set { ConfigurationClient.Set<int> (String.Format ("sources.{0}", ParentConfigurationId), "status_format", value); }
         }
         
         public SchemaEntry<T> CreateSchema<T> (string name)
@@ -579,12 +590,12 @@
         
         public SchemaEntry<T> CreateSchema<T> (string name, T defaultValue, string shortDescription, string longDescription)
         {
-            return new SchemaEntry<T> (String.Format ("sources.{0}", ConfigurationId), name, defaultValue, shortDescription, longDescription); 
+            return new SchemaEntry<T> (String.Format ("sources.{0}", ParentConfigurationId), name, defaultValue, shortDescription, longDescription); 
         }
         
         public SchemaEntry<T> CreateSchema<T> (string ns, string name, T defaultValue, string shortDescription, string longDescription)
         {
-            return new SchemaEntry<T> (String.Format ("sources.{0}.{1}", ConfigurationId, ns), name, defaultValue, shortDescription, longDescription); 
+            return new SchemaEntry<T> (String.Format ("sources.{0}.{1}", ParentConfigurationId, ns), name, defaultValue, shortDescription, longDescription); 
         }
         
         public void CycleStatusFormat ()

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs	Tue Sep 16 21:07:28 2008
@@ -54,7 +54,7 @@
             ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.StateChange);
             
             ForceDragSourceSet = true;
-            Reorderable = true;
+            IsEverReorderable = true;
             
             RowActivated += delegate (object o, RowActivatedArgs<TrackInfo> args) {
                 ITrackModelSource source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs	Tue Sep 16 21:07:28 2008
@@ -29,6 +29,7 @@
 using System;
 using System.Collections.Generic;
 
+using Hyena.Data;
 using Hyena.Data.Gui;
 using Banshee.Sources;
 using Banshee.Configuration;
@@ -42,7 +43,7 @@
         private bool pending_changes;
         private uint timer_id = 0;
         
-        private string source_id;
+        private string source_id, unique_source_id;
         private Source source;
         public Source Source {
             get { return source; }
@@ -56,11 +57,12 @@
                 }
                 
                 source = value;
-                source_id = null;
+                source_id = unique_source_id = null;
                 
                 if (source != null) {
                     // If we have a parent, use their UniqueId so all children of a parent persist the same columns
-                    source_id = source.ConfigurationId;
+                    source_id = source.ParentConfigurationId;
+                    unique_source_id = source.ConfigurationId;
                     Load ();
                 }
             }
@@ -103,12 +105,37 @@
                     
                     return a_order.CompareTo (b_order);
                 });
-                
+
+                string sort_ns = String.Format ("{0}.{1}.{2}", root_namespace, unique_source_id, "sort");
+                string sort_column_id = ConfigurationClient.Get<string> (sort_ns, "column", null);
+                if (sort_column_id != null) {
+                    ISortableColumn sort_column = null;
+                    foreach (Column column in this) {
+                        if (column.Id == sort_column_id) {
+                            sort_column = column as ISortableColumn;
+                            break;
+                        }
+                    }
+
+                    if (sort_column != null) {
+                        int sort_dir = ConfigurationClient.Get<int> (sort_ns, "direction", 0);
+                        SortType sort_type = sort_dir == 0 ? SortType.None : sort_dir == 1 ? SortType.Ascending : SortType.Descending;
+                        sort_column.SortType = sort_type;
+                        base.SortColumn = sort_column;
+                    }
+                } else {
+                    base.SortColumn = null;
+                }
+
                 loaded = true;
             }
             
             OnUpdated ();
         }
+
+        public override ISortableColumn SortColumn {
+            set { base.SortColumn = value; Save (); }
+        }
         
         public void Save ()
         {
@@ -143,6 +170,12 @@
                         Save (Columns[i], i);
                     }
                 }
+
+                if (SortColumn != null) {
+                    string ns = String.Format ("{0}.{1}.{2}", root_namespace, unique_source_id, "sort");
+                    ConfigurationClient.Set<string> (ns, "column", SortColumn.Id);
+                    ConfigurationClient.Set<int> (ns, "direction", (int)SortColumn.SortType);
+                }
             }
         }
         

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs	Tue Sep 16 21:07:28 2008
@@ -176,7 +176,7 @@
 
         private void OnNewPlaylist (object o, EventArgs args)
         {
-            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource.DbId);
+            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource);
             playlist.Save ();
             playlist.PrimarySource.AddChildSource (playlist);
             playlist.NotifyUser ();

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	Tue Sep 16 21:07:28 2008
@@ -334,7 +334,7 @@
         private void OnAddToNewPlaylist (object o, EventArgs args)
         {
             // TODO generate name based on the track selection, or begin editing it
-            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource.DbId);
+            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource);
             playlist.Save ();
             playlist.PrimarySource.AddChildSource (playlist);
             ThreadAssist.SpawnFromMain (delegate {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs	Tue Sep 16 21:07:28 2008
@@ -211,7 +211,7 @@
                 ThreadAssist.Spawn (delegate {
                     //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                     if (playlist == null) {
-                        playlist = new SmartPlaylistSource (name, primary_source.DbId);
+                        playlist = new SmartPlaylistSource (name, primary_source);
 
                         playlist.ConditionTree = condition_tree;
                         playlist.QueryOrder = order;

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs	Tue Sep 16 21:07:28 2008
@@ -446,7 +446,7 @@
             get {
                 return new_playlist_source ??
                     new_playlist_source = new PlaylistSource (Catalog.GetString ("New Playlist"), 
-                        ServiceManager.SourceManager.MusicLibrary.DbId);
+                        ServiceManager.SourceManager.MusicLibrary);
             }
         }
 

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs	Tue Sep 16 21:07:28 2008
@@ -209,7 +209,7 @@
                 
                 if (final_drag_source == NewPlaylistSource) {
                     PlaylistSource playlist = new PlaylistSource (Catalog.GetString ("New Playlist"), 
-                        (new_playlist_parent as PrimarySource).DbId);
+                        (new_playlist_parent as PrimarySource));
                     playlist.Save ();
                     playlist.PrimarySource.AddChildSource (playlist);
                     drop_source = playlist;

Modified: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs	Tue Sep 16 21:07:28 2008
@@ -222,7 +222,7 @@
                         Console.WriteLine ("have playlist {0} with {1} items but ignoring b/c otg or podcast", playlist.Name, playlist.Tracks.Count);
                         continue;
                     }
-                    PlaylistSource pl_src = new PlaylistSource (playlist.Name, this.DbId);
+                    PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
                     pl_src.Save ();
                     // We use the IPod.Track.Id here b/c we just shoved it into ExternalID above when we loaded
                     // the tracks, however when we sync, the Track.Id values may/will change.

Modified: trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs	Tue Sep 16 21:07:28 2008
@@ -147,7 +147,7 @@
                 if (loaded_playlist == null)
                     continue;
 
-                PlaylistSource playlist = new PlaylistSource (System.IO.Path.GetFileNameWithoutExtension (playlist_path), DbId);
+                PlaylistSource playlist = new PlaylistSource (System.IO.Path.GetFileNameWithoutExtension (playlist_path), this);
                 playlist.Save ();
                 //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                 foreach (Dictionary<string, object> element in loaded_playlist.Elements) {

Modified: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs	Tue Sep 16 21:07:28 2008
@@ -179,7 +179,7 @@
                     @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
                         SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND ExternalID = ?");
                 foreach (MTP.Playlist playlist in mtp_device.GetPlaylists ()) {
-                    PlaylistSource pl_src = new PlaylistSource (playlist.Name, this.DbId);
+                    PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
                     pl_src.Save ();
                     // TODO a transaction would make sense here (when the threading issue is fixed)
                     foreach (int id in playlist.TrackIds) {

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs	Tue Sep 16 21:07:28 2008
@@ -117,7 +117,7 @@
 
         private void BuildPreferences ()
         {
-            conf_ns = String.Format ("{0}.{1}", sync.ConfigurationNamespace, library.ConfigurationId);
+            conf_ns = String.Format ("{0}.{1}", sync.ConfigurationNamespace, library.ParentConfigurationId);
             
             enabled = sync.Dap.CreateSchema<bool> (conf_ns, "enabled", true,
                 String.Format (Catalog.GetString ("Sync {0}"), library.Name), "");
@@ -135,14 +135,14 @@
         private void BuildSyncLists ()
         {
             // This smart playlist is the list of items we want on the device - nothing more, nothing less
-            sync_src = new SmartPlaylistSource ("sync_list", library.DbId);
+            sync_src = new SmartPlaylistSource ("sync_list", library);
             sync_src.IsTemporary = true;
             sync_src.Save ();
             sync_src.AddCondition (library.AttributesCondition);
             sync_src.AddCondition (library.SyncCondition);
 
             // This is the same as the previous list with the items that are already on the device removed
-            to_add = new SmartPlaylistSource ("to_add", library.DbId);
+            to_add = new SmartPlaylistSource ("to_add", library);
             to_add.IsTemporary = true;
             to_add.Save ();
             to_add.ConditionTree = UserQueryParser.Parse (String.Format ("smartplaylistid:{0}", sync_src.DbId),
@@ -152,7 +152,7 @@
             ));
 
             // Any items on the device that aren't in the sync lists need to be removed
-            to_remove = new SmartPlaylistSource ("to_remove", sync.Dap.DbId);
+            to_remove = new SmartPlaylistSource ("to_remove", sync.Dap);
             to_remove.IsTemporary = true;
             to_remove.Save ();
             to_remove.AddCondition (library.AttributesCondition);
@@ -214,7 +214,7 @@
                         if (from.Count == 0) {
                             continue;
                         }
-                        PlaylistSource to = new PlaylistSource (from.Name, sync.Dap.DbId);
+                        PlaylistSource to = new PlaylistSource (from.Name, sync.Dap);
                         to.Save ();
 
                         ServiceManager.DbConnection.Execute (

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs	Tue Sep 16 21:07:28 2008
@@ -109,7 +109,7 @@
 
         private void BuildPreferences ()
         {
-            conf_ns = String.Format ("{0}.{1}", dap.ConfigurationId, "sync");
+            conf_ns = String.Format ("{0}.{1}", dap.ParentConfigurationId, "sync");
             
             manually_manage = dap.CreateSchema<bool> (conf_ns, "enabled", true,
                 Catalog.GetString ("Manually manage this device"),

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs	Tue Sep 16 21:07:28 2008
@@ -42,7 +42,7 @@
     {
         private DapSource parent;
         
-        public MediaGroupSource (DapSource parent, string name) : base (name, parent.DbId)
+        public MediaGroupSource (DapSource parent, string name) : base (name, parent)
         {
             this.parent = parent;
             

Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs	Tue Sep 16 21:07:28 2008
@@ -56,7 +56,7 @@
             get { return parent.Database; }
         }
         
-        public DaapPlaylistSource (DAAP.Playlist playlist, DaapSource parent) : base (playlist.Name, parent.DbId)
+        public DaapPlaylistSource (DAAP.Playlist playlist, DaapSource parent) : base (playlist.Name, parent)
         {
             this.parent = parent;
             Save ();

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	Tue Sep 16 21:07:28 2008
@@ -58,7 +58,7 @@
             get { return false; }
         }
         
-        public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), 0)
+        public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null)
         {
             BindToDatabase ();
             TypeUniqueId = DbId.ToString ();
@@ -70,6 +70,7 @@
             Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Play Queue"));
             
             DatabaseTrackModel.ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC";
+            DatabaseTrackModel.CanReorder = true;
             
             ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent);
             ServiceManager.PlaybackController.Transition += OnCanonicalPlaybackControllerTransition;

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/FilterableListModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/FilterableListModel.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/FilterableListModel.cs	Tue Sep 16 21:07:28 2008
@@ -41,7 +41,7 @@
 {           
     // It would be cool to move the filtering functionality to an external class 
     // that could be applied to models directly, or chained together before being applied. 
-    public class FilterableListModel<T> : ListModel<T>
+    /*public class FilterableListModel<T> : ListModel<T>
     {
         private Predicate<T> filter;
         private List<T> filteredList;
@@ -152,4 +152,5 @@
             }
         }
     }
+    */
 }
\ No newline at end of file

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/ListModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/ListModel.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Models/ListModel.cs	Tue Sep 16 21:07:28 2008
@@ -55,7 +55,7 @@
         public abstract int Compare (T lhs, T rhs);
     }
 
-    public class ListModel<T> : BansheeListModel<T>, ISortable
+    /*public class ListModel<T> : BansheeListModel<T>, ISortable
     {
         private ISortableColumn sortColumn;
         
@@ -213,5 +213,5 @@
                 Sort ();
             }         
         }
-    }
+    }*/
 }
\ No newline at end of file

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs	Tue Sep 16 21:07:28 2008
@@ -36,6 +36,7 @@
     {
         private List<Column> columns = new List<Column> ();
         private ISortableColumn default_sort_column;
+        private ISortableColumn sort_column;
         
         protected List<Column> Columns {
             get { return columns; }
@@ -182,6 +183,11 @@
             get { return default_sort_column; }
             set { default_sort_column = value; }
         }
+
+        public virtual ISortableColumn SortColumn {
+            get { return sort_column; }
+            set { sort_column = value;}
+        }
         
         public int Count {
             get { return columns.Count; }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs	Tue Sep 16 21:07:28 2008
@@ -57,11 +57,21 @@
             get { return drag_drop_dest_entries; }
         }
         
-        private bool reorderable = false;
-        public bool Reorderable {
-            get { return reorderable; }
+        private bool is_reorderable = false;
+        public bool IsReorderable {
+            get { return is_reorderable && IsEverReorderable; }
             set {
-                reorderable = value;
+                is_reorderable = value;
+                OnDragSourceSet ();
+                OnDragDestSet ();
+            }
+        }
+
+        private bool is_ever_reorderable = false;
+        public bool IsEverReorderable {
+            get { return is_ever_reorderable; }
+            set {
+                is_ever_reorderable = value;
                 OnDragSourceSet ();
                 OnDragDestSet ();
             }
@@ -87,7 +97,7 @@
         
         protected virtual void OnDragDestSet ()
         {
-            if (ForceDragDestSet || Reorderable) {
+            if (ForceDragDestSet || IsReorderable) {
                 Gtk.Drag.DestSet (this, DestDefaults.All, DragDropDestEntries, Gdk.DragAction.Move);
             } else {
                 Gtk.Drag.DestUnset (this);
@@ -96,7 +106,7 @@
         
         protected virtual void OnDragSourceSet ()
         {
-            if (ForceDragSourceSet || Reorderable) {
+            if (ForceDragSourceSet || IsReorderable) {
                 Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask, 
                     DragDropSourceEntries, Gdk.DragAction.Copy | Gdk.DragAction.Move);
             } else {
@@ -139,7 +149,7 @@
         
         protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
         {
-            if (!Reorderable) {
+            if (!IsReorderable) {
                 StopDragScroll ();
                 drag_reorder_row_index = -1;
                 drag_reorder_motion_y = -1;

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	Tue Sep 16 21:07:28 2008
@@ -460,7 +460,25 @@
             if (pressed_column_index >= 0 && pressed_column_index < column_cache.Length) {
                 Column column = column_cache[pressed_column_index].Column;
                 if (column != null && Model is ISortable && column is ISortableColumn) {
-                    ((ISortable)Model).Sort ((ISortableColumn)column);
+                    ISortableColumn sort_column = column as ISortableColumn;
+                    ISortable sortable = Model as ISortable;
+
+                    // Change the sort-type with every click
+                    switch (sort_column.SortType) {
+                        case SortType.Ascending:    sort_column.SortType = SortType.Descending; break;
+                        case SortType.Descending:   sort_column.SortType = SortType.None; break;
+                        case SortType.None:         sort_column.SortType = SortType.Ascending; break;
+                    }
+
+                    // If we're switching from a different column, or we aren't reorderable, make sure sort type isn't None
+                    if ((sort_column != ColumnController.SortColumn || !IsEverReorderable) && sort_column.SortType == SortType.None) {
+                        sort_column.SortType = SortType.Ascending;
+                    }
+
+                    sortable.Sort (sort_column);
+                    ColumnController.SortColumn = sort_column;
+                    IsReorderable = sortable.SortColumn == null || sortable.SortColumn.SortType == SortType.None;
+
                     Model.Reload ();
                     RecalculateColumnSizes ();
                     RegenerateColumnCache ();

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs	Tue Sep 16 21:07:28 2008
@@ -53,15 +53,23 @@
             
             model = value;
 
-            ISortable sortable = model as ISortable;
-            if (sortable != null && sortable.SortColumn == null && ColumnController.DefaultSortColumn != null) {
-                sortable.Sort (ColumnController.DefaultSortColumn);
-            }
-
             if (model != null) {
                 model.Cleared += OnModelClearedHandler;
                 model.Reloaded += OnModelReloadedHandler;
                 selection_proxy.Selection = model.Selection;
+                IsEverReorderable = model.CanReorder;
+            }
+
+            ISortable sortable = model as ISortable;
+            if (sortable != null) {
+                ISortableColumn sort_column = ColumnController.SortColumn ?? ColumnController.DefaultSortColumn;
+                if (sort_column != null) {
+                    sortable.Sort (sort_column);
+                    RecalculateColumnSizes ();
+                    RegenerateColumnCache ();
+                    InvalidateHeader ();
+                    IsReorderable = sortable.SortColumn == null || sortable.SortColumn.SortType == SortType.None;
+                }
             }
             
             RefreshViewForModel (vpos);

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	Tue Sep 16 21:07:28 2008
@@ -279,7 +279,7 @@
         
         private void PaintReorderLine (int row_index, Rectangle single_list_alloc)
         {
-            if (row_index == drag_reorder_row_index && Reorderable) {
+            if (row_index == drag_reorder_row_index && IsReorderable) {
                 cairo_context.Save ();
                 cairo_context.LineWidth = 1.0;
                 cairo_context.Antialias = Cairo.Antialias.None;

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListViewTestModule.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListViewTestModule.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListViewTestModule.cs	Tue Sep 16 21:07:28 2008
@@ -107,6 +107,10 @@
             public int Count {
                 get { return store.Count; }
             }
+
+            public bool CanReorder {
+                get { return false; }
+            }
             
             public ModelItem this[int index] {
                 get { return store[index]; }

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data/IListModel.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data/IListModel.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data/IListModel.cs	Tue Sep 16 21:07:28 2008
@@ -41,6 +41,7 @@
         void Reload ();
         
         int Count { get; }
+        bool CanReorder { get; }
     }
     
     public interface IListModel<T> : IListModel

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortable.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortable.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data/ISortable.cs	Tue Sep 16 21:07:28 2008
@@ -30,7 +30,7 @@
 {
     public interface ISortable
     {
-        void Sort (ISortableColumn column);
+        bool Sort (ISortableColumn column);
         ISortableColumn SortColumn { get; }
     }
 }

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	Tue Sep 16 21:07:28 2008
@@ -33,5 +33,6 @@
         string SortKey { get; }
         SortType SortType { get; set; }
         Hyena.Query.QueryField Field { get; }
+        string Id { get; }
     }
 }



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