1 /** ===========================================================
2  * @file
3  *
4  * This file is a part of KDE project
5  *
6  *
7  * @date   2004-07-22
8  * @brief  image info
9  *
10  * @author Copyright (C) 2004-2018 by Gilles Caulier
11  *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
12  * @author Copyright (C) 2004-2005 by Renchi Raju
13  *         <a href="mailto:renchi dot raju at gmail dot com">renchi dot raju at gmail dot com</a>
14  * @author Copyright (C) 2004-2005 by Jesper K. Pedersen
15  *         <a href="mailto:blackie at kde dot org">blackie at kde dot org</a>
16  * @author Copyright (C) 2004-2005 by Aurelien Gateau
17  *         <a href="mailto:aurelien dot gateau at free dot fr">aurelien dot gateau at free dot fr</a>
18  *
19  * This program is free software; you can redistribute it
20  * and/or modify it under the terms of the GNU General
21  * Public License as published by the Free Software Foundation;
22  * either version 2, or (at your option)
23  * any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  * GNU General Public License for more details.
29  *
30  * ============================================================ */
31 
32 #ifndef KIPI_IMAGEINFO_H
33 #define KIPI_IMAGEINFO_H
34 
35 // Qt includes
36 
37 #include <QString>
38 #include <QDateTime>
39 #include <QMap>
40 #include <QVariant>
41 #include <QUrl>
42 
43 // Local includes
44 
45 #include "libkipi_export.h"
46 
47 namespace KIPI
48 {
49 
50 class ImageInfoShared;
51 
52 /** @class ImageInfo
53     Holds info about an image from KIPI host application.
54     NOTE: If you want to manage item properties from kipi-plugins, use wrapper class KIPIPlugins::KPImageInfo,
55     not this class directly. See kipi-plugins/common/libkipi-plugins API for details.
56     IMPORTANT: this class must re-implemented in KIPI host application through KIPI::ImageInfoShared. This implementation
57     must be thread-safe, due to possible use into kipi plugins separated thread implementation in the future.
58  */
59 class LIBKIPI_EXPORT ImageInfo
60 {
61 
62 public:
63 
64     /** Constructor and interface for host application.
65      */
66     ImageInfo(ImageInfoShared* const);
67     ImageInfo(const ImageInfo&);
68     ~ImageInfo();
69 
70     /**
71         Returns a Map of attributes of the image.
72         In case the host application supports some special attributes of the image,
73         this function can be used to return them. Following attributes are supported:
74 
75       <table><tr>
76             <th>ATTRIBUTES</th>
77             <th>VALUE RETURNED</th>
78             <th>COMMENTS</th>
79         </tr><tr>
80             <th>"name"</th>
81             <td>QString</td>
82             <td>Returns name of item (usually file name).</td>
83         </tr><tr>
84             <th>"comment"</th>
85             <td>QString</td>
86             <td>Returns default item comment.</td>
87         </tr><tr>
88             <th>"date"</th>
89             <td>QDateTime</td>
90             <td>Returns date of item (usually the creation date). In the case the application supports date ranges (like this image is from 1998-2000), this attribute always return the start of date range.</td>
91         </tr><tr>
92             <th>"dateto"</th>
93             <td>QDateTime</td>
94             <td>In the case the application supports date ranges (like this image is from 1998-2000), this attribute returns the end of date range.</td>
95         </tr><tr>
96             <th>"isexactdate"</th>
97             <td>bool value</td>
98             <td>In the case the application supports date ranges (like this image is from 1998-2000), this attribute returns true if the date is an exact specification, and thus not a range.</td>
99         </tr><tr>
100             <th>"orientation"</th>
101             <td>integer value</td>
102             <td>Returns orientation information. See ExifOrientation values for details).</td>
103         </tr><tr>
104             <th>"title"</th>
105             <td>QString</td>
106             <td>Returns default item title.</td>
107         </tr><tr>
108             <th>"rating"</th>
109             <td>integer value</td>
110             <td>Returns item starts 0 <= rate <= 5).</td>
111         </tr><tr>
112             <th>"colorlabel"</th>
113             <td>integer value</td>
114             <td>Return item color flag 0 <= colorlabel <= 10.</td>
115         </tr><tr>
116             <th>"picklabel"</th>
117             <td>integer value</td>
118             <td>Return item workflow flag 0 <= picklabel <= 4.</td>
119         </tr><tr>
120             <th>"latitude"</th>
121             <td>double value</td>
122             <td>Return item latitude in degrees (-90.0 >= lat <=90.0).</td>
123         </tr><tr>
124             <th>"longitude"</th>
125             <td>double value</td>
126             <td>Return item longitude in degrees (-180.0 >= long <=180.0).</td>
127         </tr><tr>
128             <th>"altitude"</th>
129             <td>double value</td>
130             <td>Return item altitude in meters.</td>
131         </tr><tr>
132             <th>"tagspath"</th>
133             <td>QStringList</td>
134             <td>Return all tags path list of item, formatted as "Country/France/City/Paris" for ex.</td>
135         </tr><tr>
136             <th>"keywords"</th>
137             <td>QStringList</td>
138             <td>Return all tags name list (without path).</td>
139         </tr><tr>
140             <th>"filesize"</th>
141             <td>qlonglong value</td>
142             <td>Return item file size in bytes.</td>
143         </tr><tr>
144             <th>"creators"</th>
145             <td>QStringList</td>
146             <td>Return creators list of item.</td>
147         </tr><tr>
148             <th>"credit"</th>
149             <td>QString</td>
150             <td>Return credit of item.</td>
151         </tr><tr>
152             <th>"rights"</th>
153             <td>QString</td>
154             <td>Return rights of item.</td>
155         </tr><tr>
156             <th>"source"</th>
157             <td>QString</td>
158             <td>Return source of item.</td>
159         </tr><tr>
160             <th>"tags"</th>
161             <td>QStringList</td>
162             <td>For compatibility. DEPRECATED and replaced by "keywords" attribute.</td>
163         </tr><tr>
164             <th>"angle"</th>
165             <td>integer value</td>
166             <td>For compatibility. DEPRECATED and replaced by "orientation" attribute.</td>
167       </tr></table>
168     */
169     QMap<QString, QVariant> attributes() const;
170 
171     /** Set the attributes defined from the map to the image. Following keys/values are the same the attributes(),
172      *  excepted "keywords", "filesize", and "isexactdate" properties which are read-only values.
173     */
174     void addAttributes(const QMap<QString, QVariant>&);
175 
176     /** Remove attributes listed from the image. Following values can be used:
177 
178       <table><tr>
179             <th>ATTRIBUTES</th>
180             <th>COMMENTS</th>
181         </tr><tr>
182             <th>"comment"</th>
183             <td>Remove all comments.</td>
184         </tr><tr>
185             <th>"date"</th>
186             <td>Remove date info.</td>
187         </tr><tr>
188             <th>"orientation"</th>
189             <td>Remove orientation info.</td>
190         </tr><tr>
191             <th>"title"</th>
192             <td>Remove all titles.</td>
193         </tr><tr>
194             <th>"rating"</th>
195             <td>Remove rating info.</td>
196         </tr><tr>
197             <th>"colorlabel"</th>
198             <td>Remove color labels info.</td>
199         </tr><tr>
200             <th>"picklabel"</th>
201             <td>Remove pick labels info.</td>
202         </tr><tr>
203             <th>"gpslocation"</th>
204             <td>Return item altitude in meters.</td>
205         </tr><tr>
206             <th>"tagspath"</th>
207             <td>Remove all tags path.</td>
208         </tr><tr>
209             <th>"copyrights"</th>
210             <td>Remove all copyrights info.</td>
211         </tr><tr>
212             <th>"tags"</th>
213             <td>For compatibility. DEPRECATED and replaced by "keywords" attribute.</td>
214         </tr><tr>
215             <th>"angle"</th>
216             <td>For compatibility. DEPRECATED and replaced by "orientation" attribute.</td>
217       </tr></table>
218     */
219     void delAttributes(const QStringList&);
220 
221     /** Remove all attribute from the image. See delAttributes() for list of all attributes removed.
222      */
223     void clearAttributes();
224 
225     /** Copies all the attributes from the other imageinfo.
226     */
227     void cloneData(const ImageInfo& other);
228 
229     /** Return item url.
230     */
231     QUrl url() const;
232 
233 private:
234 
235     ImageInfo();                            /// Disable
236     ImageInfo& operator=(const ImageInfo&); /// Disable
237 
238 private:
239 
240     mutable ImageInfoShared* d;
241 };
242 
243 } // namespace KIPI
244 
245 #endif /* KIPI_IMAGEINFO_H */
246