banshee r3392 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView src/Libraries/Hyena/Hyena.Data src/Libraries/Hyena/Hyena.Data.Sqlite



Author: gburt
Date: Fri Mar  7 00:08:03 2008
New Revision: 3392
URL: http://svn.gnome.org/viewvc/banshee?rev=3392&view=rev

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

	* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs:
	Add ToString override for debugging purposes.

	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs:
	Scroll to the top if artist or album selection changes to all selected.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs: When
	refreshing the view for the model, scroll to the first selected item if
	possible.

	* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs:
	* src/Libraries/Hyena/Hyena.Data/ModelCache.cs: Add locks to make
	thread-safe, solves (at least some) spurious browser issues people have
	been seeing.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Data/ModelCache.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs	Fri Mar  7 00:08:03 2008
@@ -124,5 +124,10 @@
             get { return base.ArtistName; }
             set { base.ArtistName = value; }
         }
+
+        public override string ToString ()
+        {
+            return String.Format ("<LibraryAlbumInfo Title={0} DbId={1}>", Title, DbId);
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs	Fri Mar  7 00:08:03 2008
@@ -272,8 +272,10 @@
                     if (!album_model.Selection.AllSelected) {
                         UpdateAlbumSelectionFilters ();
                     }
+                    artist_view.ScrollTo (0);
                 } else if (model != null && o == album_view.Selection) {
                     model.AlbumInfoFilter = null;
+                    album_view.ScrollTo (0);
                 }
                 return;
             }

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	Fri Mar  7 00:08:03 2008
@@ -69,7 +69,11 @@
             if (vpos != null) {
                 ScrollTo ((double) vpos);
             } else {
-                ScrollTo (vadjustment.Value);
+                if (Selection.Count > 0) {
+                    ScrollToRow (Selection.Ranges[0].Start + 1 - RowsInView/2);
+                } else {
+                    ScrollTo (vadjustment.Value);
+                }
             }
             
             if (Model != null) {

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs	Fri Mar  7 00:08:03 2008
@@ -217,23 +217,30 @@
 
         private long FirstOrderId {
             get {
-                if (first_order_id == -1) {
-                    first_order_id = connection.Query<long> (select_first_command);
+                lock (this) {
+                    if (first_order_id == -1) {
+                        first_order_id = connection.Query<long> (select_first_command);
+                    }
+                    return first_order_id;
                 }
-                return first_order_id;
              }
         }
         
         public long IndexOf (long item_id)
         {
-            if (rows == 0) {
-                return -1;
-            }
-            long target_id = connection.Query<long> (select_single_command, item_id);
-            if (target_id == 0) {
-                return -1;
+            lock (this) {
+                if (rows == 0)
+                    return -1;
+
+                if (item_id == FirstOrderId)
+                    return 0;
+
+                long target_id = connection.Query<long> (select_single_command, item_id);
+                if (target_id == 0) {
+                    return -1;
+                }
+                return target_id - FirstOrderId;
             }
-            return target_id - FirstOrderId;
         }
 
         private HyenaSqliteCommand last_reload_command;
@@ -241,30 +248,32 @@
 
         public override long Reload ()
         {
-            if (last_reload_fragment != model.ReloadFragment) {
-                last_reload_fragment = model.ReloadFragment;
-                last_reload_command = new HyenaSqliteCommand (reload_sql + last_reload_fragment);
-            }
+            lock (this) {
+                if (last_reload_fragment != model.ReloadFragment) {
+                    last_reload_fragment = model.ReloadFragment;
+                    last_reload_command = new HyenaSqliteCommand (reload_sql + last_reload_fragment);
+                }
 
-            if (!first_reload) {
-                SaveSelection ();
-            }
+                if (!first_reload) {
+                    SaveSelection ();
+                }
 
-            Clear ();
+                Clear ();
 
-            //using (new Timer (String.Format ("Generating cache table for {0}", model))) {
-                connection.Execute (last_reload_command);
-            //}
-            first_order_id = -1;
-            UpdateAggregates ();
+                //using (new Timer (String.Format ("Generating cache table for {0}", model))) {
+                    connection.Execute (last_reload_command);
+                //}
+                first_order_id = -1;
+                UpdateAggregates ();
+
+                if (!first_reload) {
+                    RestoreSelection ();
+                } else {
+                    first_reload = false;
+                }
 
-            if (!first_reload) {
-                RestoreSelection ();
-            } else {
-                first_reload = false;
+                return rows;
             }
-
-            return rows;
         }
 
         private void SaveSelection ()
@@ -314,6 +323,7 @@
 
         protected override void FetchSet (long offset, long limit)
         {
+            lock (this) {
             //using (new Timer (String.Format ("Fetching set for {0}", model))) {
                 using (IDataReader reader = connection.Query (select_range_command, offset, limit)) {
                     while (reader.Read ()) {
@@ -324,6 +334,7 @@
                      }
                  }
             //}
+            }
         }
         
         protected void UpdateAggregates ()

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data/ModelCache.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data/ModelCache.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data/ModelCache.cs	Fri Mar  7 00:08:03 2008
@@ -42,15 +42,17 @@
 
         public virtual T GetValue (long index)
         {
-            if (ContainsKey (index))
-                return this[index];
-            
-            FetchSet (index, model.FetchCount);
-            
-            if (ContainsKey (index))
-                return this[index];
-            
-            return default (T);
+            lock (this) {
+                if (ContainsKey (index))
+                    return this[index];
+                
+                FetchSet (index, model.FetchCount);
+                
+                if (ContainsKey (index))
+                    return this[index];
+                
+                return default (T);
+            }
         }
         
         // Responsible for fetching a set of items and placing them in the cache



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