~ubuntu-branches/ubuntu/quantal/shotwell/quantal

« back to all changes in this revision

Viewing changes to src/alien_db/f_spot/FSpotDatabasePhoto.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: package-import@ubuntu.com-20120221135258-ao9jiib5qicomq7q
Tags: upstream-0.11.92
ImportĀ upstreamĀ versionĀ 0.11.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2011 Yorba Foundation
2
 
 *
3
 
 * This software is licensed under the GNU Lesser General Public License
4
 
 * (version 2.1 or later).  See the COPYING file in this distribution. 
5
 
 */
6
 
 
7
 
namespace AlienDb.FSpot {
8
 
 
9
 
/**
10
 
 * The object that implements an F-Spot photo and provides access to all the
11
 
 * elements necessary to read data from the photographic source.
12
 
 */
13
 
public class FSpotDatabasePhoto : Object, AlienDatabasePhoto {
14
 
    private FSpotPhotoRow photo_row;
15
 
    private FSpotPhotoVersionRow? photo_version_row;
16
 
    private FSpotRollRow? roll_row;
17
 
    private Gee.Collection<AlienDatabaseTag> tags;
18
 
    private AlienDatabaseEvent? event;
19
 
    private Rating rating;
20
 
    
21
 
    public FSpotDatabasePhoto(
22
 
        FSpotPhotoRow photo_row,
23
 
        FSpotPhotoVersionRow? photo_version_row,
24
 
        FSpotRollRow? roll_row,
25
 
        Gee.Collection<AlienDatabaseTag> tags,
26
 
        AlienDatabaseEvent? event,
27
 
        bool is_hidden,
28
 
        bool is_favorite
29
 
    ) {
30
 
        this.photo_row = photo_row;
31
 
        this.photo_version_row = photo_version_row;
32
 
        this.roll_row = roll_row;
33
 
        this.tags = tags;
34
 
        this.event = event;
35
 
        if (photo_row.rating > 0)
36
 
            this.rating = Rating.unserialize(photo_row.rating);
37
 
        else if (is_hidden)
38
 
            this.rating = Rating.REJECTED;
39
 
        else if (is_favorite)
40
 
            this.rating = Rating.FIVE;
41
 
        else
42
 
            this.rating = Rating.UNRATED;
43
 
    }
44
 
    
45
 
    public string get_folder_path() {
46
 
        return (photo_version_row != null) ?
47
 
            photo_version_row.base_path.get_path() :
48
 
            photo_row.base_path.get_path();
49
 
    }
50
 
    
51
 
    public string get_filename() {
52
 
        return (photo_version_row != null) ?
53
 
            photo_version_row.filename :
54
 
            photo_row.filename;
55
 
    }
56
 
    
57
 
    public Gee.Collection<AlienDatabaseTag> get_tags() {
58
 
        return tags;
59
 
    }
60
 
    
61
 
    public AlienDatabaseEvent? get_event() {
62
 
        return event;
63
 
    }
64
 
    
65
 
    public Rating get_rating() {
66
 
        return rating;
67
 
    }
68
 
    
69
 
    public string? get_title() {
70
 
        return is_string_empty(photo_row.description) ? null : photo_row.description;
71
 
    }
72
 
    
73
 
    public ImportID? get_import_id() {
74
 
        if (roll_row != null)
75
 
            return ImportID((int64)roll_row.time);
76
 
        else
77
 
            return null;
78
 
    }
79
 
}
80
 
 
81
 
}
82