[banshee] [Hyena] Make model's Selection a property
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Hyena] Make model's Selection a property
- Date: Fri, 14 May 2010 22:41:51 +0000 (UTC)
commit 8074940d8de4a7873f5e61dfd655e4740d4ffb18
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu May 13 10:48:54 2010 -0700
[Hyena] Make model's Selection a property
And fix bug where the Selection's MaxIndex was updated by the ListView -
so models without a ListView didn't have an up to date Selection.
.../Banshee.Collection/AlbumListModel.cs | 8 ++++----
.../Banshee.Collection/ArtistListModel.cs | 8 ++++----
.../Banshee.Collection/FilterListModel.cs | 19 +++++++++++++++----
.../Banshee.Collection/TrackListModel.cs | 4 ++--
.../Banshee.Audiobook/AudiobookModel.cs | 2 +-
.../Hyena.Data.Gui/ListView/ListView_Model.cs | 4 ----
src/Libraries/Hyena/Hyena.Data/BaseListModel.cs | 7 ++++++-
src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs | 2 +-
8 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection/AlbumListModel.cs b/src/Core/Banshee.Services/Banshee.Collection/AlbumListModel.cs
index e99870a..073838f 100644
--- a/src/Core/Banshee.Services/Banshee.Collection/AlbumListModel.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection/AlbumListModel.cs
@@ -38,14 +38,14 @@ namespace Banshee.Collection
{
public AlbumListModel() : base ()
{
- selection = new SelectAllSelection ();
- selection.SelectAll ();
+ Selection = new SelectAllSelection ();
+ Selection.SelectAll ();
}
public AlbumListModel(IDBusExportable parent) : base(parent)
{
- selection = new SelectAllSelection ();
- selection.SelectAll ();
+ Selection = new SelectAllSelection ();
+ Selection.SelectAll ();
}
public override void Clear ()
diff --git a/src/Core/Banshee.Services/Banshee.Collection/ArtistListModel.cs b/src/Core/Banshee.Services/Banshee.Collection/ArtistListModel.cs
index a226268..fa9676f 100644
--- a/src/Core/Banshee.Services/Banshee.Collection/ArtistListModel.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection/ArtistListModel.cs
@@ -37,14 +37,14 @@ namespace Banshee.Collection
{
public ArtistListModel() : base ()
{
- selection = new SelectAllSelection ();
- selection.SelectAll ();
+ Selection = new SelectAllSelection ();
+ Selection.SelectAll ();
}
public ArtistListModel(IDBusExportable parent) : base(parent)
{
- selection = new SelectAllSelection ();
- selection.SelectAll ();
+ Selection = new SelectAllSelection ();
+ Selection.SelectAll ();
}
}
}
diff --git a/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs b/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs
index 6d9e682..9e0ddb5 100644
--- a/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs
@@ -50,16 +50,16 @@ namespace Banshee.Collection
{
browsing_model = trackModel;
- selection = new SelectAllSelection ();
+ var selection = new SelectAllSelection ();
selection.SelectAll ();
-
- Selection.Changed += HandleSelectionChanged;
+ Selection = selection;
}
public FilterListModel (IDBusExportable parent) : base (parent)
{
- selection = new SelectAllSelection ();
+ var selection = new SelectAllSelection ();
selection.SelectAll ();
+ Selection = selection;
}
public override void Reload ()
@@ -79,6 +79,17 @@ namespace Banshee.Collection
browsing_model.Reload (this);
}
+ public override Hyena.Collections.Selection Selection {
+ protected set {
+ if (Selection != null) {
+ Selection.Changed -= HandleSelectionChanged;
+ }
+
+ base.Selection = value;
+ Selection.Changed += HandleSelectionChanged;
+ }
+ }
+
#region IFilterModel Implementation
public abstract string GetSqlFilter ();
diff --git a/src/Core/Banshee.Services/Banshee.Collection/TrackListModel.cs b/src/Core/Banshee.Services/Banshee.Collection/TrackListModel.cs
index 41d12f9..a588d69 100644
--- a/src/Core/Banshee.Services/Banshee.Collection/TrackListModel.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection/TrackListModel.cs
@@ -41,12 +41,12 @@ namespace Banshee.Collection
{
public TrackListModel() : base ()
{
- selection = new Selection ();
+ Selection = new Selection ();
}
public TrackListModel(IDBusExportable parent) : base(parent)
{
- selection = new Selection ();
+ Selection = new Selection ();
}
public abstract int IndexOf (TrackInfo track);
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs
index 2c8cc57..71331ea 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs
@@ -47,7 +47,7 @@ namespace Banshee.Audiobook
{
public AudiobookModel (DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) : base (source, trackModel, connection, uuid)
{
- selection = new Hyena.Collections.Selection ();
+ Selection = new Hyena.Collections.Selection ();
//CalculateUnfilteredCount = true;
HasSelectAllItem = false;
}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
index 9570702..c342f71 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
@@ -112,10 +112,6 @@ namespace Hyena.Data.Gui
ScrollToY (vadjustment.Value);
}
- if (Model != null && Selection != null) {
- Selection.MaxIndex = Model.Count - 1;
- }
-
if (Parent is ScrolledWindow) {
Parent.QueueDraw ();
}
diff --git a/src/Libraries/Hyena/Hyena.Data/BaseListModel.cs b/src/Libraries/Hyena/Hyena.Data/BaseListModel.cs
index 221ec4e..43f6800 100644
--- a/src/Libraries/Hyena/Hyena.Data/BaseListModel.cs
+++ b/src/Libraries/Hyena/Hyena.Data/BaseListModel.cs
@@ -35,7 +35,7 @@ namespace Hyena.Data
{
public abstract class BaseListModel<T> : IListModel<T>
{
- protected Selection selection;
+ private Selection selection;
public event EventHandler Cleared;
public event EventHandler Reloaded;
@@ -46,6 +46,8 @@ namespace Hyena.Data
protected virtual void OnCleared ()
{
+ Selection.MaxIndex = Count - 1;
+
EventHandler handler = Cleared;
if(handler != null) {
handler(this, EventArgs.Empty);
@@ -54,6 +56,8 @@ namespace Hyena.Data
protected virtual void OnReloaded ()
{
+ Selection.MaxIndex = Count - 1;
+
EventHandler handler = Reloaded;
if(handler != null) {
handler(this, EventArgs.Empty);
@@ -80,6 +84,7 @@ namespace Hyena.Data
public virtual Selection Selection {
get { return selection; }
+ protected set { selection = value; }
}
protected ModelSelection<T> model_selection;
diff --git a/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs b/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
index 27ca87e..cdc2822 100644
--- a/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
+++ b/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
@@ -40,7 +40,7 @@ namespace Hyena.Data
public MemoryListModel ()
{
list = new List<T> ();
- selection = new Selection ();
+ Selection = new Selection ();
}
public override void Clear ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]