imagecollection.cpp

Go to the documentation of this file.
00001 /* ============================================================
00002  * File   : imagecollection.cpp
00003  * Authors: KIPI team developers (see AUTHORS files for details)
00004  *          
00005  * Date   : 2004-02
00006  * Description :
00007  *
00008  * Copyright 2004 by the KIPI team
00009  *
00010  * This program is free software; you can redistribute it
00011  * and/or modify it under the terms of the GNU Library General
00012  * Public License as published by the Free Software Foundation;
00013  * either version 2, or (at your option)
00014  * any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Library General Public License for more details.
00020  *
00021  * ============================================================ */
00022 
00023 // KDE includes.
00024 
00025 #include <kdebug.h>
00026 #include <klocale.h>
00027 
00028 // Local includes.
00029   
00030 #include "imagecollection.h"
00031 #include "imagecollectionshared.h"
00032 
00038 QString KIPI::ImageCollection::comment() const
00039 {
00040     if ( _data )
00041         return _data->comment();
00042     else {
00043         printNullError();
00044         return QString::null;
00045     }
00046 }
00047 
00051 QString KIPI::ImageCollection::name() const
00052 {
00053     if ( _data )
00054         return _data->name();
00055     else {
00056         printNullError();
00057         return QString::null;
00058     }
00059 }
00060 
00065 QString KIPI::ImageCollection::category() const
00066 {
00067     if ( _data )
00068         return _data->category();
00069     else {
00070         printNullError();
00071         return QString::null;
00072     }
00073 }
00074 
00079 QDate KIPI::ImageCollection::date() const
00080 {
00081     if ( _data )
00082         return _data->date();
00083     else {
00084         printNullError();
00085         return QDate();
00086     }
00087 }
00088 
00092 KURL::List KIPI::ImageCollection::images() const
00093 {
00094     if ( _data )
00095         return _data->images();
00096     else {
00097         printNullError();
00098         return KURL::List();
00099     }
00100 }
00101 
00102 KIPI::ImageCollection::ImageCollection( ImageCollectionShared* data )
00103     : _data( data )
00104 {
00105 }
00106 
00107 KIPI::ImageCollection::~ImageCollection()
00108 {
00109     if ( _data )
00110         _data->removeRef();
00111 }
00112 
00113 KIPI::ImageCollection::ImageCollection( const ImageCollection& rhs )
00114 {
00115     if ( rhs._data ) {
00116         _data = rhs._data;
00117         _data->addRef();
00118     }
00119     else
00120         _data = 0;
00121 }
00122 
00123 KIPI::ImageCollection::ImageCollection()
00124 {
00125     _data = 0;
00126 }
00127 
00128 KIPI::ImageCollection& KIPI::ImageCollection::operator=( const KIPI::ImageCollection& rhs )
00129 {
00130     if ( rhs._data == _data )
00131         return *this;
00132 
00133     if ( _data )
00134         _data->removeRef();
00135     if ( !rhs._data ) {
00136         printNullError();
00137         _data = 0;
00138     }
00139     else {
00140         _data = rhs._data;
00141         _data->addRef();
00142     }
00143     return *this;
00144 }
00145 
00154 KURL KIPI::ImageCollection::path() const
00155 {
00156     if ( _data )
00157         return _data->path();
00158     else {
00159         printNullError();
00160         return KURL();
00161     }
00162 }
00163 
00176 KURL KIPI::ImageCollection::uploadPath() const
00177 {
00178     if ( _data )
00179         return _data->uploadPath();
00180     else {
00181         printNullError();
00182         return KURL();
00183     }
00184 }
00185 
00201 KURL KIPI::ImageCollection::uploadRoot() const
00202 {
00203     if ( _data )
00204         return _data->uploadRoot();
00205     else {
00206         printNullError();
00207         return KURL();
00208     }
00209 }
00210 
00216 QString KIPI::ImageCollection::uploadRootName() const
00217 {
00218     if ( _data )
00219         return _data->uploadRootName();
00220     else {
00221         printNullError();
00222         return QString::null;
00223     }
00224 }
00225 
00226 /*
00227   Returns whether an imagecollection is a physical folder on the filesystem
00228   or not. Its important to check this, if your plugin needs to do folder
00229   based operations for an imagecollection
00230 */
00231 bool KIPI::ImageCollection::isDirectory() const
00232 {
00233     if ( _data )
00234         return _data->isDirectory();
00235     else {
00236         printNullError();
00237         return false;
00238     }
00239 }
00240 
00241 bool KIPI::ImageCollection::isValid() const
00242 {
00243     return (_data != 0);
00244 }
00245 
00246 void KIPI::ImageCollection::printNullError() const
00247 {
00248     kdWarning( 51000 ) << "Image collection is invalid - this might be the case if you asked for an album, " << endl
00249                        << "and not album existed. You should check using .isValid() first." << endl
00250                        << "Notice: Plugins should never create an instance of ImageCollection, only the host application "
00251                        << "should do that." << endl;
00252 }
00253 
00254 
00255 bool KIPI::ImageCollection::operator==(const KIPI::ImageCollection& ic) const {
00256     if (!_data || !(ic._data))
00257     {
00258         printNullError();
00259         return false;
00260     }
00261     return *_data == *(ic._data);
00262 }

Generated on Mon Nov 27 23:42:22 2006 for libKipi by  doxygen 1.5.0