1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2007-04-09
7 * Description : Collection location abstraction
8 *
9 * Copyright (C) 2007-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 *
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation;
14 * either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * ============================================================ */
23
24 #ifndef DIGIKAM_COLLECTION_LOCATION_H
25 #define DIGIKAM_COLLECTION_LOCATION_H
26
27 // Qt includes
28
29 #include <QString>
30 #include <QHash>
31
32 // Local includes
33
34 #include "digikam_export.h"
35 #include "coredbalbuminfo.h"
36
37 namespace Digikam
38 {
39
40 class DIGIKAM_DATABASE_EXPORT CollectionLocation
41 {
42
43 public:
44
45 enum Status
46 {
47 /**
48 * An invalid status. A location has this status if it is not valid,
49 * and it had this status before its creation (for oldStatus information)
50 */
51 LocationNull,
52
53 /**
54 * The location if available. This is the most common status.
55 */
56 LocationAvailable,
57
58 /**
59 * The location is explicitly hidden. This gives no information if
60 * the location was available were it not hidden.
61 */
62 LocationHidden,
63
64 /**
65 * The location is currently not available. (Harddisk unplugged, CD not in drive,
66 * network fs not mounted etc.) It may become available any time.
67 */
68 LocationUnavailable,
69
70 /**
71 * An invalid status. A location object acquires this status if it has been deleted.
72 * The object then does no longer point to an existing location.
73 */
74 LocationDeleted
75 };
76
77 public:
78
79 enum Type
80 {
81 /**
82 * The location is located on a storage device that is built-in
83 * without frequent removal: Hard-disk inside the machine
84 */
85 TypeVolumeHardWired = AlbumRoot::VolumeHardWired,
86
87 /**
88 * The location is located on a storage device that can be removed
89 * from the local machine, and is expected to be removed.
90 * USB stick, USB hard-disk, CD, DVD
91 */
92 TypeVolumeRemovable = AlbumRoot::VolumeRemovable,
93
94 /**
95 * The location is available via a network file system.
96 * The availability depends on the network connection.
97 */
98 TypeNetwork = AlbumRoot::Network
99 };
100
101 public:
102
103 CollectionLocation();
104
105 /**
106 * The id uniquely identifying this collection
107 */
108 int id() const;
109
110 /**
111 * The current status. See above for possible values.
112 */
113 Status status() const;
114
115 /**
116 * The type of location. See above for possible values.
117 */
118 Type type() const;
119
120 /**
121 * The current file system path leading to this album root.
122 * Only guaranteed to be valid for location with status Available.
123 */
124 QString albumRootPath() const;
125
126 /**
127 * A user-visible, optional label.
128 */
129 QString label() const;
130
isAvailable()131 bool isAvailable() const
132 {
133 return (m_status == LocationAvailable);
134 }
135
isNull()136 bool isNull() const
137 {
138 return (m_status == LocationNull);
139 }
140
hash()141 uint hash() const
142 {
143 return ::qHash(m_id);
144 }
145
146 protected:
147
148 int m_id;
149 QString m_path;
150 Status m_status;
151 Type m_type;
152 QString m_label;
153 };
154
qHash(const CollectionLocation & loc)155 inline uint qHash(const CollectionLocation& loc)
156 {
157 return loc.hash();
158 }
159
160 } // namespace Digikam
161
162 #endif // DIGIKAM_COLLECTION_LOCATION_H
163