00001 /* ============================================================ 00002 * File : imageinfoshared.cpp 00003 * Authors: Jesper K. Pedersen <blackie@kde.org> 00004 * 00005 * Date : 2004-02-19 00006 * Description : 00007 * 00008 * Copyright 2004 by Jesper K. Pedersen 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 // Qt includes. 00024 00025 #include <qfileinfo.h> 00026 00027 // KDE includes. 00028 00029 #include <kdebug.h> 00030 00031 // Local includes. 00032 00033 #include "imageinfoshared.h" 00034 #include "interface.h" 00035 00036 KIPI::ImageInfoShared::ImageInfoShared( Interface* interface, const KURL& url ) 00037 : _url( url ), _count(1), _interface( interface ) 00038 { 00039 } 00040 00041 KURL KIPI::ImageInfoShared::path() 00042 { 00043 return _url; 00044 } 00045 00046 int KIPI::ImageInfoShared::size() 00047 { 00048 if ( ! _url.isLocalFile() ) { 00049 kdFatal() << "KIPI::ImageInfoShared::size does not yet support non local files, please fix\n"; 00050 return 0; 00051 } 00052 else 00053 return QFileInfo( _url.path() ).size(); 00054 } 00055 00056 QDateTime KIPI::ImageInfoShared::time( KIPI::TimeSpec ) 00057 { 00058 if ( ! _url.isLocalFile() ) { 00059 kdFatal() << "KIPI::ImageInfoShared::time does not yet support non local files, please fix\n"; 00060 return QDateTime(); 00061 } 00062 else 00063 return QFileInfo( _url.path() ).lastModified(); 00064 } 00065 00066 void KIPI::ImageInfoShared::addRef() 00067 { 00068 _count++; 00069 } 00070 00071 void KIPI::ImageInfoShared::removeRef() 00072 { 00073 _count--; 00074 if ( _count == 0 ) { 00075 delete this; 00076 } 00077 } 00078 00079 int KIPI::ImageInfoShared::angle() 00080 { 00081 return 0; 00082 } 00083 00084 void KIPI::ImageInfoShared::setAngle( int ) 00085 { 00086 } 00087 00088 bool KIPI::ImageInfoShared::isTimeExact() 00089 { 00090 return true; 00091 } 00092 00093 void KIPI::ImageInfoShared::setTime( const QDateTime& /*time*/, TimeSpec /*spec*/ ) 00094 { 00095 } 00096 00097 void KIPI::ImageInfoShared::setTitle( const QString& ) 00098 { 00099 kdWarning(51000) << "This method should only be invoked if the host application supports the KIPI::ImageTitlesWritable\n" 00100 "If the host application do support that, then this function should\n" 00101 "have been overriden in the host application.\n"; 00102 } 00103 00104 void KIPI::ImageInfoShared::cloneData( ImageInfoShared* other ) 00105 { 00106 if ( _interface->hasFeature( ImageTitlesWritable ) ) 00107 setTitle( other->title() ); 00108 00109 if ( _interface->hasFeature( ImagesHasComments ) ) 00110 setDescription( other->description() ); 00111 00112 clearAttributes(); 00113 addAttributes( other->attributes() ); 00114 00115 setTime( other->time( FromInfo ), FromInfo ); 00116 if ( _interface->hasFeature( SupportsDateRanges ) ) 00117 setTime( other->time( ToInfo ), ToInfo ); 00118 00119 setAngle( other->angle() ); 00120 }
1.5.3