libKipi
imageinfoshared.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-19
7 * Description : image info shared.
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// Qt includes.
27
28#include <qfileinfo.h>
29
30// KDE includes.
31
32#include <kdebug.h>
33
34// Local includes.
35
36#include "imageinfoshared.h"
37#include "interface.h"
38
40 : _url( url ), _count(1), _interface( interface )
41{
42}
43
45{
46 return _url;
47}
48
50{
51 if ( ! _url.isLocalFile() )
52 {
53 kdFatal() << "KIPI::ImageInfoShared::size does not yet support non local files, please fix\n" << endl;
54 return 0;
55 }
56 else
57 return QFileInfo( _url.path() ).size();
58}
59
61{
62 if ( ! _url.isLocalFile() )
63 {
64 kdFatal() << "KIPI::ImageInfoShared::time does not yet support non local files, please fix\n" << endl;
65 return QDateTime();
66 }
67 else
68 return QFileInfo( _url.path() ).lastModified();
69}
70
71void KIPI::ImageInfoShared::addRef()
72{
73 _count++;
74}
75
76void KIPI::ImageInfoShared::removeRef()
77{
78 _count--;
79 if ( _count == 0 )
80 {
81 delete this;
82 }
83}
84
86{
87 return 0;
88}
89
93
95{
96 return true;
97}
98
99void KIPI::ImageInfoShared::setTime( const QDateTime& /*time*/, TimeSpec /*spec*/ )
100{
101}
102
104{
105 kdWarning(51000) << "This method should only be invoked if the host application supports the KIPI::ImageTitlesWritable\n"
106 "If the host application do support that, then this function should\n"
107 "have been overridden in the host application.\n" << endl;
108}
109
111{
112 if ( _interface->hasFeature( ImageTitlesWritable ) )
113 setTitle( other->title() );
114
115 if ( _interface->hasFeature( ImagesHasComments ) )
116 setDescription( other->description() );
117
119 addAttributes( other->attributes() );
120
121 setTime( other->time( FromInfo ), FromInfo );
122 if ( _interface->hasFeature( SupportsDateRanges ) )
123 setTime( other->time( ToInfo ), ToInfo );
124
125 setAngle( other->angle() );
126}
KDStream & endl(KDStream &stream)
Definition KDStream.cpp:264
virtual void setAngle(int)
Definition imageinfoshared.cpp:90
virtual void setTime(const QDateTime &time, TimeSpec spec=FromInfo)
Definition imageinfoshared.cpp:99
virtual QString title()
Definition imageinfoshared.h:55
virtual void setDescription(const QString &)=0
virtual int size()
Definition imageinfoshared.cpp:49
virtual void clearAttributes()=0
virtual void addAttributes(const QMap< QString, QVariant > &)=0
virtual int angle()
Definition imageinfoshared.cpp:85
virtual void cloneData(ImageInfoShared *other)
Definition imageinfoshared.cpp:110
KURL _url
Definition imageinfoshared.h:82
ImageInfoShared(KIPI::Interface *interface, const KURL &url)
Definition imageinfoshared.cpp:39
virtual QDateTime time(KIPI::TimeSpec spec)
Definition imageinfoshared.cpp:60
virtual QString description()=0
virtual QMap< QString, QVariant > attributes()=0
virtual void setTitle(const QString &)
Definition imageinfoshared.cpp:103
virtual KURL path()
Definition imageinfoshared.cpp:44
virtual bool isTimeExact()
Definition imageinfoshared.cpp:94
Definition interface.h:64
@ ImageTitlesWritable
Definition interface.h:55
@ SupportsDateRanges
Definition interface.h:53
@ ImagesHasComments
Definition interface.h:51
TimeSpec
Definition imageinfo.h:49
@ FromInfo
Definition imageinfo.h:49
@ ToInfo
Definition imageinfo.h:49