~ubuntu-branches/ubuntu/maverick/f-spot/maverick

« back to all changes in this revision

Viewing changes to lib/Hyena/src/Hyena/Hyena.Data/BaseListModel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2010-05-24 10:35:57 UTC
  • mfrom: (2.4.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20100524103557-1j0i8f66caybci2n
Tags: 0.7.0-1
* New upstream release 0.7.0
 + First release of the unstable 0.7 development series. Massive changes.
 + Reparenting and detaching support (Anton Keks) (Closes: #559745)
 + A new Mallard-based documentation (Harold Schreckengost)
 + No longer embeds flickrnet, uses distribution copy (Iain Lane)
 + Adoption of a large amount of Hyena functionality (Paul Lange, Peter
   Goetz)
 + No longer embeds gnome-keyring-sharp
 + Completely rewritten import, much faster and less memory hungry (Ruben
   Vermeersch) (Closes: #559080, #492658, #341790, #357811, #426017) (LP:
   #412091)
 + No longer use gphoto2-sharp, now uses gvfs which is less crash-pron
   (Ruben Vermeersch)
 + Fix Facebook support (Ruben Vermeersch)
 + Modernized unit tests
 + Revamped build (Mike Gemünde)
 + Much improved duplicate detection (much faster too) (Ruben Vermeersch)
 + Mouse selection in Iconview (Vincent Pomey)
 + Image panning support using middle mouse button (Wojciech Dzierżanowski)
 + Timeline slider now restricted to the size of the window (Iain Churcher)
 + Over 100 bugs closed (http://bit.ly/cyVjnD)
   - No more warnings about schema defaults (Closes: #584215) (LP: #586132)
* debian/control: Clean up build deps to match configure checks
* debian/rules: Don't run dh_makeshilbs as we don't ship any shared
  libraries. There are some private ones though, which get picked up and
  result in a useless postinst/postrm call to ldconfig. Thanks, lintian.
* debian/patches/debian_fix-distclean.patch,
  debian/patches/debian_fix_f-spot.exe.config.patch,
  debian/patches/debian_link-system-flickrnet.patch,
  debian/patches/debian_link-system-gnome-keyring.patch,
  debian/patches/debian_disable-unit-tests,
  debian/patches/git_transition_duration.patch,
  debian/patches/ubuntu_fix_folder_export_hang.patch:
  Clean up obsolete patches which are no longer necessary 
* debian/patches/*: Temporarily disable patches which originated from Ubuntu
  and no longer apply cleanly. We will get these back in a future upstream
  development release.
* debian/patches/*: Refresh to apply cleanly 
* debian/rules: Add new include dir to autoreconf call to pick up f-spot
  macros 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// BaseListModel.cs
 
3
//
 
4
// Author:
 
5
//   Gabriel Burt <gburt@novell.com>
 
6
//   Aaron Bockover <abockover@novell.com>
 
7
//
 
8
// Copyright (C) 2007-2008 Novell, Inc.
 
9
//
 
10
// Permission is hereby granted, free of charge, to any person obtaining
 
11
// a copy of this software and associated documentation files (the
 
12
// "Software"), to deal in the Software without restriction, including
 
13
// without limitation the rights to use, copy, modify, merge, publish,
 
14
// distribute, sublicense, and/or sell copies of the Software, and to
 
15
// permit persons to whom the Software is furnished to do so, subject to
 
16
// the following conditions:
 
17
//
 
18
// The above copyright notice and this permission notice shall be
 
19
// included in all copies or substantial portions of the Software.
 
20
//
 
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
22
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
23
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
24
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
25
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
26
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
27
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
28
//
 
29
 
 
30
using System;
 
31
 
 
32
using Hyena.Collections;
 
33
 
 
34
namespace Hyena.Data
 
35
{
 
36
    public abstract class BaseListModel<T> : IListModel<T>
 
37
    {
 
38
        private Selection selection;
 
39
 
 
40
        public event EventHandler Cleared;
 
41
        public event EventHandler Reloaded;
 
42
 
 
43
        public BaseListModel () : base ()
 
44
        {
 
45
        }
 
46
 
 
47
        protected virtual void OnCleared ()
 
48
        {
 
49
            Selection.MaxIndex = Count - 1;
 
50
 
 
51
            EventHandler handler = Cleared;
 
52
            if(handler != null) {
 
53
                handler(this, EventArgs.Empty);
 
54
            }
 
55
        }
 
56
 
 
57
        protected virtual void OnReloaded ()
 
58
        {
 
59
            Selection.MaxIndex = Count - 1;
 
60
 
 
61
            EventHandler handler = Reloaded;
 
62
            if(handler != null) {
 
63
                handler(this, EventArgs.Empty);
 
64
            }
 
65
        }
 
66
 
 
67
        public void RaiseReloaded ()
 
68
        {
 
69
            OnReloaded ();
 
70
        }
 
71
 
 
72
        public abstract void Clear();
 
73
 
 
74
        public abstract void Reload();
 
75
 
 
76
        public abstract T this[int index] { get; }
 
77
 
 
78
        public abstract int Count { get; }
 
79
 
 
80
        public virtual object GetItem (int index)
 
81
        {
 
82
            return this[index];
 
83
        }
 
84
 
 
85
        public virtual Selection Selection {
 
86
            get { return selection; }
 
87
            protected set { selection = value; }
 
88
        }
 
89
 
 
90
        protected ModelSelection<T> model_selection;
 
91
        public virtual ModelSelection<T> SelectedItems {
 
92
            get {
 
93
                return model_selection ?? (model_selection = new ModelSelection<T> (this, Selection));
 
94
            }
 
95
        }
 
96
 
 
97
        public T FocusedItem {
 
98
            get { return Selection.FocusedIndex == -1 ? default(T) : this[Selection.FocusedIndex]; }
 
99
        }
 
100
 
 
101
        private bool can_reorder = false;
 
102
        public bool CanReorder {
 
103
            get { return can_reorder; }
 
104
            set { can_reorder = value; }
 
105
        }
 
106
    }
 
107
}