[Kde-imaging] [libkipi] libkipi: Last method deprecated. Now all item attributes are managed through *attributes*() methods to preserve binary compatibility in libkipi.

Gilles Caulier caulier.gilles at gmail.com
Wed Feb 8 10:10:55 UTC 2012


Git commit 12d46dfeb13473463a3dd58a798c8baf0b15555b by Gilles Caulier.
Committed on 08/02/2012 at 11:03.
Pushed by cgilles into branch 'master'.

Last method deprecated. Now all item attributes are managed through *attributes*() methods to preserve binary compatibility in libkipi.
To manage easily item attributes on plugins, use KPImageInfo wrapper.
To kipi host maintainer, please read documentation from KIPI::ImageInfo and fix your kipi interface for next release.
lets' me hear if all compile fine for you. I already fixed digiKam and KphotoAlbum compile fine. I don't checked Gwenview.
CCMAIL: kde-imaging at kde.org
CCMAIL: digikam-devel at kde.org
CCMAIL: aurelien.gateau at free.fr
CCMAIL: blackie at kde.org

M  +25   -26   libkipi/imageinfo.cpp
M  +53   -49   libkipi/imageinfo.h
M  +3    -17   libkipi/imageinfoshared.cpp
M  +4    -4    libkipi/imageinfoshared.h

http://commits.kde.org/libkipi/12d46dfeb13473463a3dd58a798c8baf0b15555b

diff --git a/libkipi/imageinfo.cpp b/libkipi/imageinfo.cpp
index 5fb9897..cca6440 100644
--- a/libkipi/imageinfo.cpp
+++ b/libkipi/imageinfo.cpp
@@ -40,12 +40,12 @@
 namespace KIPI
 {
 
-ImageInfo::ImageInfo( ImageInfoShared* const shared )
-    : d( shared )
+ImageInfo::ImageInfo(ImageInfoShared* const shared)
+    : d(shared)
 {
 }
 
-ImageInfo::ImageInfo( const ImageInfo& rhs )
+ImageInfo::ImageInfo(const ImageInfo& rhs)
 {
     d = rhs.d;
     d->addRef();
@@ -56,17 +56,6 @@ ImageInfo::~ImageInfo()
     d->removeRef();
 }
 
-QString ImageInfo::name() const
-{
-    return d->name();
-}
-
-void ImageInfo::setName( const QString& name )
-{
-    d->setName( name );
-}
-
-
 int ImageInfo::size() const
 {
     return d->size();
@@ -77,14 +66,14 @@ QMap<QString,QVariant> ImageInfo::attributes() const
     return d->attributes();
 }
 
-void ImageInfo::addAttributes( const QMap<QString,QVariant>& attributes )
+void ImageInfo::addAttributes(const QMap<QString,QVariant>& attributes)
 {
     d->addAttributes( attributes );
 }
 
-void ImageInfo::delAttributes( const QStringList& attributes )
+void ImageInfo::delAttributes(const QStringList& attributes)
 {
-    d->delAttributes( attributes );
+    d->delAttributes(attributes);
 }
 
 void ImageInfo::clearAttributes()
@@ -92,26 +81,26 @@ void ImageInfo::clearAttributes()
     d->clearAttributes();
 }
 
-void ImageInfo::cloneData( const ImageInfo& other )
+void ImageInfo::cloneData(const ImageInfo& other)
 {
-    d->cloneData( other.d );
+    d->cloneData(other.d);
 }
 
-// Deprecated methods --------------------------------------------------------------
+// DEPRECATED METHODS --------------------------------------------------------------
 
 KUrl ImageInfo::path() const
 {
     return d->path();
 }
 
-QDateTime ImageInfo::time( TimeSpec spec ) const
+QDateTime ImageInfo::time(TimeSpec spec) const
 {
-    return d->time( spec );
+    return d->time(spec);
 }
 
-void ImageInfo::setTime( const QDateTime& time, TimeSpec spec )
+void ImageInfo::setTime(const QDateTime& time, TimeSpec spec)
 {
-    d->setTime( time, spec );
+    d->setTime(time, spec);
 }
 
 bool ImageInfo::isTimeExact() const
@@ -126,7 +115,7 @@ QString ImageInfo::description() const
 
 void ImageInfo::setDescription( const QString& description )
 {
-    d->setDescription( description );
+    d->setDescription(description);
 }
 
 int ImageInfo::angle() const
@@ -136,7 +125,17 @@ int ImageInfo::angle() const
 
 void ImageInfo::setAngle( int angle )
 {
-    d->setAngle( angle );
+    d->setAngle(angle);
+}
+
+QString ImageInfo::name() const
+{
+    return d->name();
+}
+
+void ImageInfo::setName( const QString& name )
+{
+    d->setName(name);
 }
 
 } // namespace KIPI
diff --git a/libkipi/imageinfo.h b/libkipi/imageinfo.h
index f057fc0..7df782f 100644
--- a/libkipi/imageinfo.h
+++ b/libkipi/imageinfo.h
@@ -75,63 +75,63 @@ public:
     /** constructor
         Interface for host application + general stuff
      */
-    ImageInfo( ImageInfoShared* const );
-    ImageInfo( const ImageInfo& );
+    ImageInfo(ImageInfoShared* const);
+    ImageInfo(const ImageInfo&);
     ~ImageInfo();
 
-    QString name() const;
-    void setName( const QString& name );
-
     /**
         Returns a Map of attributes of the image
         In case the host application supports some special attributes of the image
         this function can be used to return them. Following attributes are supported by these features:
 
-        QString("comment")     :: QString         :: default item comment.
-        QString("date")        :: QDateTime       :: date of item (usually the creation date).
-                                                     In the case the application supports date ranges (like this image is from 1998-2000),
-                                                     this attribute always return the start of date range.
-        QString("dateto")      :: QDateTime       :: in the case the application supports date ranges (like this image is from 1998-2000),
-                                                     this attribute return the end of date range.
-        QString("isexactdate") :: bool value      :: in the case the application supports date ranges (like this image is from 1998-2000),
-                                                     this attribute will be true if the date is an exact specification, and thus not a range.
-        QString("orientation") :: integer value   :: Orientation information. See KExiv2::ImageOrientation value for details).
-        QString("title")       :: QString         :: default item title.
-        QString("rating")      :: integer value   :: item starts 0 <= rate <= 5).
-        QString("colorlabel")  :: integer value   :: item color flag 0 <= colorlabel <= 10.
-        QString("picklabel")   :: integer value   :: item workflow flag 0 <= picklabel <= 4.
-        QString("latitude")    :: double value    :: latitude in degrees (-90.0 >= lat <=90.0).
-        QString("longitude")   :: double value    :: longitude in degrees (-180.0 >= long <=180.0).
-        QString("altitude")    :: double value    :: altitude in meters.
-        QString("tagspath")    :: QStringList     :: all tags path list formated as "Country/France/City/Paris" for ex.
-        QString("keywords")    :: QStringList     :: all tags name list (without path).
-        QString("filesize")    :: qlonglong value :: file size in bytes.
-
-        QString("tags")        :: DEPRECATED: for compatibility. Deprecated and replaced by "keywords" attribute.
-        QString("angle")       :: DEPRECATED: for compatibility. Deprecated and replaced by "orientation" attribute.
+        ATTRIBUTES    :: VALUE RETURNED  :: COMMENTS
+        ----------------------------------------------------------------------------------------------------------------------------
+        "name"        :: QString         :: name of item (usually file name).
+        "comment"     :: QString         :: default item comment.
+        "date"        :: QDateTime       :: date of item (usually the creation date).
+                                            In the case the application supports date ranges (like this image is from 1998-2000),
+                                            this attribute always return the start of date range.
+        "dateto"      :: QDateTime       :: in the case the application supports date ranges (like this image is from 1998-2000),
+                                            this attribute return the end of date range.
+        "isexactdate" :: bool value      :: in the case the application supports date ranges (like this image is from 1998-2000),
+                                            this attribute will be true if the date is an exact specification, and thus not a range.
+        "orientation" :: integer value   :: Orientation information. See KExiv2::ImageOrientation value for details).
+        "title"       :: QString         :: default item title.
+        "rating"      :: integer value   :: item starts 0 <= rate <= 5).
+        "colorlabel"  :: integer value   :: item color flag 0 <= colorlabel <= 10.
+        "picklabel"   :: integer value   :: item workflow flag 0 <= picklabel <= 4.
+        "latitude"    :: double value    :: latitude in degrees (-90.0 >= lat <=90.0).
+        "longitude"   :: double value    :: longitude in degrees (-180.0 >= long <=180.0).
+        "altitude"    :: double value    :: altitude in meters.
+        "tagspath"    :: QStringList     :: all tags path list formated as "Country/France/City/Paris" for ex.
+        "keywords"    :: QStringList     :: all tags name list (without path).
+        "filesize"    :: qlonglong value :: file size in bytes.
+
+        "tags"        :: QStringList     :: DEPRECATED: for compatibility. Deprecated and replaced by "keywords" attribute.
+        "angle"       :: integer value   :: DEPRECATED: for compatibility. Deprecated and replaced by "orientation" attribute.
     */
     QMap<QString, QVariant> attributes() const;
 
     /** Set the attributes defined from the map to the image. Following keys/values are the same the attributes(),
-     *  excepted "tags" property which is read-only.
+     *  excepted "keywords", "filesize", and "isexactdate" properties which are read-only values.
     */
     void addAttributes(const QMap<QString, QVariant>&);
 
     /** Remove attributes listed from the image. Following values can be used:
-        QString("comment")     :: Remove all comments.
-        QString("date")        :: Remove date info.
-        QString("orientation") :: Remove orientation info.
-        QString("title")       :: Remove all titles.
-        QString("tagspath")    :: Remove all tags path.
-        QString("rating")      :: Remove rating info.
-        QString("colorlabel")  :: Remove color labels info.
-        QString("picklabel")   :: Remove pick labels info.
-        QString("gpslocation") :: Remove latitude, longitude, and altitude values.
-
-        QString("tags")        :: DEPRECATED: for compatibility. Deprecated and replaced by "tagspath" attribute.
-        QString("angle")       :: DEPRECATED: for compatibility. Deprecated and replaced by "orientation" attribute.
+        "comment"     :: Remove all comments.
+        "date"        :: Remove date info.
+        "orientation" :: Remove orientation info.
+        "title"       :: Remove all titles.
+        "tagspath"    :: Remove all tags path.
+        "rating"      :: Remove rating info.
+        "colorlabel"  :: Remove color labels info.
+        "picklabel"   :: Remove pick labels info.
+        "gpslocation" :: Remove latitude, longitude, and altitude values.
+
+        "tags"        :: DEPRECATED: for compatibility. Deprecated and replaced by "tagspath" attribute.
+        "angle"       :: DEPRECATED: for compatibility. Deprecated and replaced by "orientation" attribute.
     */
-    void delAttributes( const QStringList& );
+    void delAttributes(const QStringList&);
 
     /** Remove all attribute from the image. See delAttributes() for list of all attributes removed.
      */
@@ -140,19 +140,23 @@ public:
     /**
         Copies all the attributes from the other imageinfo
     */
-    void cloneData( const ImageInfo& other );
+    void cloneData(const ImageInfo& other);
 
     // -------------------------------------------------------------------------------------------------------
-    // NOTE: Deprecated Methods. Do not use it, they will be removed in the future...
+    // DEPRECATED METHODS. Do not use it, they will be removed in the future...
     //
     // More universal methods based on attributes must be used instead to extend more easily data exange between 
     // kipi-plugins and kipi host without to break binary compatibility.
 
-    /**
-        Managed by attribute "date" and "dateto".
+    /** Managed by attribute "name".
+     */
+    KDE_DEPRECATED QString name() const;
+    KDE_DEPRECATED void    setName(const QString& name);
+
+    /** Managed by attribute "date" and "dateto".
      */
-    KDE_DEPRECATED QDateTime time( TimeSpec spec = FromInfo ) const;
-    KDE_DEPRECATED void setTime( const QDateTime& time, TimeSpec spec = FromInfo );
+    KDE_DEPRECATED QDateTime time(TimeSpec spec = FromInfo) const;
+    KDE_DEPRECATED void      setTime(const QDateTime& time, TimeSpec spec = FromInfo);
 
     /** Managed by attribute "isexactdate".
      */
@@ -161,11 +165,11 @@ public:
     /** Managed by attributes "comment"
      */
     KDE_DEPRECATED QString description() const;
-    KDE_DEPRECATED void setDescription( const QString& description);
+    KDE_DEPRECATED void    setDescription(const QString& description);
 
     /** Managed by attribute "angle"
     */
-    KDE_DEPRECATED int angle() const;
+    KDE_DEPRECATED int  angle() const;
     KDE_DEPRECATED void setAngle(int);
 
     /** In plugins use KIPIPlugins::KPImageInfo::url() instead.
diff --git a/libkipi/imageinfoshared.cpp b/libkipi/imageinfoshared.cpp
index c4acd4e..bc7c8d6 100644
--- a/libkipi/imageinfoshared.cpp
+++ b/libkipi/imageinfoshared.cpp
@@ -93,35 +93,21 @@ void ImageInfoShared::removeRef()
 
 void ImageInfoShared::cloneData(ImageInfoShared* const other)
 {
-    if ( d->interface->hasFeature(ImagesHasTitlesWritable))
-        setName(other->name());
-
     clearAttributes();
     addAttributes(other->attributes());
-
-    if ( d->interface->hasFeature(HostSupportsDateRanges))
-        setTime(other->time(ToInfo), ToInfo);
 }
 
+// DEPRECATED METHODS --------------------------------------------------------------------
+
 void ImageInfoShared::setName(const QString&)
 {
-    kWarning() << "This method should only be invoked if the host application "
-                  "supports the KIPI::ImagesHasTitlesWritable\n"
-                  "If the host application do support that, then this function should\n"
-                  "have been overridden in the host application.";
 }
 
 QString ImageInfoShared::name()
 {
-    kWarning() << "This method should only be invoked if the host application "
-                  "supports the KIPI::ImagesHasTitlesWritable\n"
-                  "If the host application do support that, then this function should\n"
-                  "have been overridden in the host application.";
-    return QString::null;
+    return QString();
 }
 
-// Deprecated methods --------------------------------------------------------------------
-
 QString ImageInfoShared::description()
 {
     return QString();
diff --git a/libkipi/imageinfoshared.h b/libkipi/imageinfoshared.h
index 861c09e..5bdcf68 100644
--- a/libkipi/imageinfoshared.h
+++ b/libkipi/imageinfoshared.h
@@ -62,9 +62,6 @@ public:
     ImageInfoShared(KIPI::Interface* const interface, const KUrl& url);
     virtual ~ImageInfoShared();
 
-    virtual QString name();
-    virtual void    setName(const QString&);
-
     /** These methods must be re-implemented in your KIPI host application to manage image attributes with plugins
      */
     virtual QMap<QString, QVariant> attributes() = 0;
@@ -75,7 +72,10 @@ public:
     virtual void cloneData(ImageInfoShared* const other);
 
     // ---------------------------------------------------------------------------------------
-    // Deprecated methods. Do not use it. See Imageinfo for details.
+    // DEPRECATED METHODS. Do not use it. See Imageinfo for details.
+
+    KDE_DEPRECATED virtual QString name();
+    KDE_DEPRECATED virtual void    setName(const QString&);
 
     KDE_DEPRECATED virtual QDateTime time(KIPI::TimeSpec spec);
     KDE_DEPRECATED virtual void      setTime(const QDateTime& time, TimeSpec spec = FromInfo);


More information about the Kde-imaging mailing list