libKipi
imagecollection.cpp
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of kipi-plugins project
4 * http://www.kipi-plugins.org
5 *
6 * Date : 2004-02-01
7 * Description : image collection
8 *
9 * Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * Copyright (C) 2004-2005 by Renchi Raju <renchi.raju at kdemail.net>
11 * Copyright (C) 2004-2005 by Jesper K. Pedersen <blackie at kde.org>
12 * Copyright (C) 2004-2005 by Aurelien Gateau <aurelien dot gateau at free.fr>
13 *
14 * This program is free software; you can redistribute it
15 * and/or modify it under the terms of the GNU General
16 * Public License as published by the Free Software Foundation;
17 * either version 2, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * ============================================================ */
25
26// KDE includes.
27
28#include <kdebug.h>
29#include <klocale.h>
30
31// Local includes.
32
33#include "imagecollection.h"
35
42{
43 if ( _data )
44 return _data->comment();
45 else {
46 printNullError();
47 return QString::null;
48 }
49}
50
55{
56 if ( _data )
57 return _data->name();
58 else {
59 printNullError();
60 return QString::null;
61 }
62}
63
69{
70 if ( _data )
71 return _data->category();
72 else {
73 printNullError();
74 return QString::null;
75 }
76}
77
83{
84 if ( _data )
85 return _data->date();
86 else {
87 printNullError();
88 return QDate();
89 }
90}
91
96{
97 if ( _data )
98 return _data->images();
99 else {
100 printNullError();
101 return KURL::List();
102 }
103}
104
109
111{
112 if ( _data )
113 _data->removeRef();
114}
115
117{
118 if ( rhs._data ) {
119 _data = rhs._data;
120 _data->addRef();
121 }
122 else
123 _data = 0;
124}
125
127{
128 _data = 0;
129}
130
132{
133 if ( rhs._data == _data )
134 return *this;
135
136 if ( _data )
137 _data->removeRef();
138 if ( !rhs._data ) {
139 printNullError();
140 _data = 0;
141 }
142 else {
143 _data = rhs._data;
144 _data->addRef();
145 }
146 return *this;
147}
148
158{
159 if ( _data )
160 return _data->path();
161 else {
162 printNullError();
163 return KURL();
164 }
165}
166
180{
181 if ( _data )
182 return _data->uploadPath();
183 else {
184 printNullError();
185 return KURL();
186 }
187}
188
205{
206 if ( _data )
207 return _data->uploadRoot();
208 else {
209 printNullError();
210 return KURL();
211 }
212}
213
220{
221 if ( _data )
222 return _data->uploadRootName();
223 else {
224 printNullError();
225 return QString::null;
226 }
227}
228
229/*
230 Returns whether an imagecollection is a physical folder on the filesystem
231 or not. Its important to check this, if your plugin needs to do folder
232 based operations for an imagecollection
233*/
235{
236 if ( _data )
237 return _data->isDirectory();
238 else {
239 printNullError();
240 return false;
241 }
242}
243
245{
246 return (_data != 0);
247}
248
249void KIPI::ImageCollection::printNullError() const
250{
251 kdWarning( 51000 ) << "Image collection is invalid - this might be the case if you asked for an album, " << endl
252 << "and not album existed. You should check using .isValid() first." << endl
253 << "Notice: Plugins should never create an instance of ImageCollection, only the host application "
254 << "should do that." << endl;
255}
256
257
259 if (!_data || !(ic._data))
260 {
261 printNullError();
262 return false;
263 }
264 return *_data == *(ic._data);
265}
KDStream & endl(KDStream &stream)
Definition KDStream.cpp:264
Definition imagecollectionshared.h:46
Definition imagecollection.h:53
~ImageCollection()
Definition imagecollection.cpp:110
ImageCollection()
Definition imagecollection.cpp:126
bool isDirectory() const
Definition imagecollection.cpp:234
KURL::List images() const
Definition imagecollection.cpp:95
bool isValid() const
Definition imagecollection.cpp:244
QString uploadRootName() const
Definition imagecollection.cpp:219
ImageCollection(ImageCollectionShared *)
Definition imagecollection.cpp:105
ImageCollection & operator=(const ImageCollection &)
Definition imagecollection.cpp:131
KURL uploadRoot() const
Definition imagecollection.cpp:204
QString comment() const
Definition imagecollection.cpp:41
QDate date() const
Definition imagecollection.cpp:82
QString category() const
Definition imagecollection.cpp:68
QString name() const
Definition imagecollection.cpp:54
KURL uploadPath() const
Definition imagecollection.cpp:179
bool operator==(const ImageCollection &) const
Definition imagecollection.cpp:258
KURL path() const
Definition imagecollection.cpp:157