~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to extra/libkipi/libkipi/imagecollection.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** ===========================================================
 
2
 * @file
 
3
 *
 
4
 * This file is a part of digiKam project
 
5
 * <a href="http://www.digikam.org">http://www.digikam.org</a>
 
6
 *
 
7
 * @date   2004-02-01
 
8
 * @brief  image collection
 
9
 *
 
10
 * @author Copyright (C) 2004-2010 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
#include "imagecollection.h"
 
33
 
 
34
// KDE includes.
 
35
 
 
36
#include <kdebug.h>
 
37
 
 
38
// Local includes.
 
39
 
 
40
#include "imagecollectionshared.h"
 
41
 
 
42
namespace KIPI
 
43
{
 
44
 
 
45
/**
 
46
   @file imagecollection.cpp
 
47
   returns the comment for the collection of images or QString::null if that doesn't make any sense.
 
48
   A comment makes sense for an album, but not for a KIPI::Interface::currentSelection().
 
49
*/
 
50
QString ImageCollection::comment() const
 
51
{
 
52
    if ( d )
 
53
    {
 
54
        return d->comment();
 
55
    }
 
56
    else
 
57
    {
 
58
        printNullError();
 
59
        return QString::null;
 
60
    }
 
61
}
 
62
 
 
63
/**
 
64
   PENDING(blackie) document
 
65
*/
 
66
QString ImageCollection::name() const
 
67
{
 
68
    if ( d )
 
69
    {
 
70
        return d->name();
 
71
    }
 
72
    else
 
73
    {
 
74
        printNullError();
 
75
        return QString();
 
76
    }
 
77
}
 
78
 
 
79
/**
 
80
   Return the category of the image collection. For example in Digikam,
 
81
   a category is a sorting class like 'travels', 'friends', 'monuments', etc.
 
82
*/
 
83
QString ImageCollection::category() const
 
84
{
 
85
    if ( d )
 
86
    {
 
87
        return d->category();
 
88
    }
 
89
    else
 
90
    {
 
91
        printNullError();
 
92
        return QString::null;
 
93
    }
 
94
}
 
95
 
 
96
/**
 
97
   Return the Creation date of the image collection. The default implementation
 
98
   return a null date.
 
99
*/
 
100
QDate ImageCollection::date() const
 
101
{
 
102
    if ( d )
 
103
    {
 
104
        return d->date();
 
105
    }
 
106
    else
 
107
    {
 
108
        printNullError();
 
109
        return QDate();
 
110
    }
 
111
}
 
112
 
 
113
/**
 
114
   PENDING(blackie) document
 
115
*/
 
116
KUrl::List ImageCollection::images() const
 
117
{
 
118
    if ( d )
 
119
    {
 
120
        return d->images();
 
121
    }
 
122
    else
 
123
    {
 
124
        printNullError();
 
125
        return KUrl::List();
 
126
    }
 
127
}
 
128
 
 
129
ImageCollection::ImageCollection( ImageCollectionShared* const data )
 
130
               : d( data )
 
131
{
 
132
}
 
133
 
 
134
ImageCollection::ImageCollection( const ImageCollection& rhs )
 
135
{
 
136
    if ( rhs.d )
 
137
    {
 
138
        d = rhs.d;
 
139
        d->addRef();
 
140
    }
 
141
    else
 
142
    {
 
143
        d = 0;
 
144
    }
 
145
}
 
146
 
 
147
ImageCollection::ImageCollection()
 
148
{
 
149
    d = 0;
 
150
}
 
151
 
 
152
ImageCollection::~ImageCollection()
 
153
{
 
154
    if ( d )
 
155
        d->removeRef();
 
156
}
 
157
 
 
158
ImageCollection& ImageCollection::operator=( const ImageCollection& rhs )
 
159
{
 
160
    if ( rhs.d == d )
 
161
        return *this;
 
162
 
 
163
    if ( d )
 
164
        d->removeRef();
 
165
 
 
166
    if ( !rhs.d )
 
167
    {
 
168
        printNullError();
 
169
        d = 0;
 
170
    }
 
171
    else
 
172
    {
 
173
        d = rhs.d;
 
174
        d->addRef();
 
175
    }
 
176
    return *this;
 
177
}
 
178
 
 
179
/*!
 
180
  Returns the directory for the image collection.
 
181
  The host application may, however, return anything in case this
 
182
  imagecollection is not a directory (check isDirectory()),  or may
 
183
  return the directory of the first image in the collection, the root
 
184
   of the image collection (in case all images has a common root), or
 
185
   even an empty URL.
 
186
*/
 
187
KUrl ImageCollection::path() const
 
188
{
 
189
    if ( d )
 
190
    {
 
191
        return d->path();
 
192
    }
 
193
    else
 
194
    {
 
195
        printNullError();
 
196
        return KUrl();
 
197
    }
 
198
}
 
199
 
 
200
/*!
 
201
  Returns the directory to place images into.
 
202
  This function should only be called if KIPI::Features AcceptNewImages
 
203
  is available.
 
204
 
 
205
  The function may choose to return the directory for the image collection
 
206
  or if images from the collection are not available in a common directory,
 
207
  then instead a common upload directory.
 
208
  In contrast to \ref path, this function must return a valid url.
 
209
 
 
210
  <b>IMPORTANT:</b> uploadRoot() must be a subpath of uploadPath()
 
211
*/
 
212
KUrl ImageCollection::uploadPath() const
 
213
{
 
214
    if ( d )
 
215
    {
 
216
        return d->uploadPath();
 
217
    }
 
218
    else
 
219
    {
 
220
        printNullError();
 
221
        return KUrl();
 
222
    }
 
223
}
 
224
 
 
225
/*!
 
226
  When a plugin wants to upload images, it may choose to display an upload widget,
 
227
  which gives the user the possible to show a directory from a tree view.
 
228
 
 
229
  This tree view widget needs to starts at some URL. This function specifies that location.
 
230
  Here are a couble of possible return value different host applications may choose.
 
231
  <ul>
 
232
  <li> If all images are stored rooted at some tree (which is the case for
 
233
  KimDaBa), then this function may return this directory unconditionally.
 
234
  <li> The root directory returned by uploadPath() (which is the default implementation for this method)
 
235
  <li> The directory returned by uploadPath().
 
236
  </ul>
 
237
 
 
238
  <b>IMPORTANT:</b> uploadRoot() must be a subpath of uploadPath()
 
239
*/
 
240
KUrl ImageCollection::uploadRoot() const
 
241
{
 
242
    if ( d )
 
243
    {
 
244
        return d->uploadRoot();
 
245
    }
 
246
    else
 
247
    {
 
248
        printNullError();
 
249
        return KUrl();
 
250
    }
 
251
}
 
252
 
 
253
/*!
 
254
  This fonction return the name of the upload root path used by the
 
255
  the KIPI::UploadWidget. This name can be different for each host
 
256
  app (like "Images" for Kimdaba or "My Albums" for Digikam).
 
257
*/
 
258
QString ImageCollection::uploadRootName() const
 
259
{
 
260
    if ( d )
 
261
    {
 
262
        return d->uploadRootName();
 
263
    }
 
264
    else
 
265
    {
 
266
        printNullError();
 
267
        return QString();
 
268
    }
 
269
}
 
270
 
 
271
/*!
 
272
  Returns whether an imagecollection is a physical folder on the filesystem
 
273
  or not. It is important to check this, if your plugin needs to do folder
 
274
  based operations for an image collection.
 
275
*/
 
276
bool ImageCollection::isDirectory() const
 
277
{
 
278
    if ( d )
 
279
    {
 
280
        return d->isDirectory();
 
281
    }
 
282
    else
 
283
    {
 
284
        printNullError();
 
285
        return false;
 
286
    }
 
287
}
 
288
 
 
289
bool ImageCollection::isValid() const
 
290
{
 
291
    return (d != 0);
 
292
}
 
293
 
 
294
void ImageCollection::printNullError() const
 
295
{
 
296
    kWarning() << "Image collection is invalid - this might be the case if you asked for an album, " << endl
 
297
               << "and not album existed. You should check using .isValid() first." << endl
 
298
               << "Notice: Plugins should never create an instance of ImageCollection, only the host application "
 
299
               << "should do that.";
 
300
}
 
301
 
 
302
bool ImageCollection::operator==(const KIPI::ImageCollection& ic) const
 
303
{
 
304
    if (!d || !(ic.d))
 
305
    {
 
306
        printNullError();
 
307
        return false;
 
308
    }
 
309
    return *d == *(ic.d);
 
310
}
 
311
 
 
312
} // namespace KIPI