TQt4 port libkexiv2

This enables compilation under Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/libkexiv2@1232461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 84d52ca133
commit 9537154bbf

File diff suppressed because it is too large Load Diff

@ -30,11 +30,11 @@
// QT includes.
#include <qcstring.h>
#include <qstring.h>
#include <qimage.h>
#include <qdatetime.h>
#include <qmap.h>
#include <tqcstring.h>
#include <tqstring.h>
#include <tqimage.h>
#include <tqdatetime.h>
#include <tqmap.h>
// Local includes.
@ -78,7 +78,7 @@ public:
/** A map used by decodeExifMetadata() decodeIptcMetadata() methods
to store Tags Key and Tags Value.
*/
typedef QMap<QString, QString> MetaDataMap;
typedef TQMap<TQString, TQString> MetaDataMap;
public:
@ -88,7 +88,7 @@ public:
/** Contructor to Load Metadata from image file.
*/
KExiv2(const QString& filePath);
KExiv2(const TQString& filePath);
/** Standard destructor
*/
@ -96,15 +96,15 @@ public:
/** Return true if library can writte metadata to typeMime file format.
*/
static bool supportMetadataWritting(const QString& typeMime);
static bool supportMetadataWritting(const TQString& typeMime);
/** Return a string version of Exiv2 release in format "major.minor.patch"
*/
static QString Exiv2Version();
static TQString Exiv2Version();
/** Return a string version of libkexiv2 release
*/
static QString version();
static TQString version();
//-- Metadata manipulation methods ----------------------------------------------
@ -122,62 +122,62 @@ public:
/** Return the file path open with the current instance of interface.
*/
QString getFilePath() const;
TQString getFilePath() const;
/** Return a Qt byte array copy of Comments container get from current image.
/** Return a TQt byte array copy of Comments container get from current image.
Comments are JFIF section of JPEG images. Look Exiv2 API for more information.
Return a null Qt byte array if there is no Comments metadata in memory.
Return a null TQt byte array if there is no Comments metadata in memory.
*/
QByteArray getComments() const;
TQByteArray getComments() const;
/** Return a Qt string object of Comments from current image decoded using
/** Return a TQt string object of Comments from current image decoded using
the 'detectEncodingAndDecode()' method. Return a null string if there is no
Comments metadata available.
*/
QString getCommentsDecoded() const;
TQString getCommentsDecoded() const;
/** Return a Qt byte array copy of Exif container get from current image.
Return a null Qt byte array if there is no Exif metadata in memory.
/** Return a TQt byte array copy of Exif container get from current image.
Return a null TQt byte array if there is no Exif metadata in memory.
*/
QByteArray getExif() const;
TQByteArray getExif() const;
/** Return a Qt byte array copy of Iptc container get from current image.
/** Return a TQt byte array copy of Iptc container get from current image.
Set true 'addIrbHeader' parameter to add an Irb header to IPTC metadata.
Return a null Qt byte array if there is no Iptc metadata in memory.
Return a null TQt byte array if there is no Iptc metadata in memory.
*/
QByteArray getIptc(bool addIrbHeader=false) const;
TQByteArray getIptc(bool addIrbHeader=false) const;
/** Set the Comments data using a Qt byte array. Return true if Comments metadata
/** Set the Comments data using a TQt byte array. Return true if Comments metadata
have been changed in memory.
*/
bool setComments(const QByteArray& data);
bool setComments(const TQByteArray& data);
/** Set the Exif data using a Qt byte array. Return true if Exif metadata
/** Set the Exif data using a TQt byte array. Return true if Exif metadata
have been changed in memory.
*/
bool setExif(const QByteArray& data);
bool setExif(const TQByteArray& data);
/** Set the Iptc data using a Qt byte array. Return true if Iptc metadata
/** Set the Iptc data using a TQt byte array. Return true if Iptc metadata
have been changed in memory.
*/
bool setIptc(const QByteArray& data);
bool setIptc(const TQByteArray& data);
//-- File access methods ----------------------------------------------
/** Load all metadata (EXIF, IPTC and JFIF Comments) from a byte array.
Return true if metadata have been loaded successfully from image data.
*/
bool load(const QByteArray& imgData);
bool load(const TQByteArray& imgData);
/** Load all metadata (EXIF, IPTC and JFIF Comments) from a picture (JPEG, RAW, TIFF, PNG,
DNG, etc...). Return true if metadata have been loaded successfully from file.
*/
virtual bool load(const QString& filePath);
virtual bool load(const TQString& filePath);
/** Save all metadata to a file. This one can be different than original picture to perform
transfert operation Return true if metadata have been saved into file.
*/
bool save(const QString& filePath);
bool save(const TQString& filePath);
/** The same than save() method, but it apply on current image. Return true if metadata
have been saved into file.
@ -186,47 +186,47 @@ public:
/** return true is the file metadata cannot be written by Exiv2.
*/
static bool isReadOnly(const QString& filePath);
static bool isReadOnly(const TQString& filePath);
/** Return 'true' if Comments can be written in file.
*/
static bool canWriteComment(const QString& filePath);
static bool canWriteComment(const TQString& filePath);
/** Return 'true' if Exif can be written in file.
*/
static bool canWriteExif(const QString& filePath);
static bool canWriteExif(const TQString& filePath);
/** Return 'true' if Iptc can be written in file.
*/
static bool canWriteIptc(const QString& filePath);
static bool canWriteIptc(const TQString& filePath);
//-- Metadata Image Information manipulation methods ----------------
/** Set Program name and program version in Exif and Iptc Metadata. Return true if information
have been changed in metadata.
*/
bool setImageProgramId(const QString& program, const QString& version);
bool setImageProgramId(const TQString& program, const TQString& version);
/** Return the size of image in pixels using Exif tags. Return a null dimmension if size cannot
be found.
*/
QSize getImageDimensions() const;
TQSize getImageDimensions() const;
/** Set the size of image in pixels in Exif tags. Return true if size have been changed
in metadata.
*/
bool setImageDimensions(const QSize& size, bool setProgramName=true);
bool setImageDimensions(const TQSize& size, bool setProgramName=true);
/** Return a QImage copy of Exif thumbnail image. Return a null image if thumbnail cannot
/** Return a TQImage copy of Exif thumbnail image. Return a null image if thumbnail cannot
be found. The 'fixOrientation' parameter will rotate automatically the thumbnail if Exif
orientation tags information are attached with thumbnail.
*/
QImage getExifThumbnail(bool fixOrientation) const;
TQImage getExifThumbnail(bool fixOrientation) const;
/** Set the Exif Thumbnail image. The thumbnail image must have the right dimensions before.
Look Exif specification for details. Return true if thumbnail have been changed in metadata.
*/
bool setExifThumbnail(const QImage& thumb, bool setProgramName=true);
bool setExifThumbnail(const TQImage& thumb, bool setProgramName=true);
/** Return the image orientation set in Exif metadata. The makernotes of image are also parsed to
get this information. See ImageOrientation values for details.
@ -251,18 +251,18 @@ public:
/** Return the time stamp of image. Exif information are check in first, IPTC in second
if image don't have Exif information. If no time stamp is found, a null date is returned.
*/
QDateTime getImageDateTime() const;
TQDateTime getImageDateTime() const;
/** Set the Exif and Iptc time stamp. If 'setDateTimeDigitized' parameter is true, the 'Digitalized'
time stamp is set, else only 'Created' time stamp is set.
*/
bool setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized = false,
bool setImageDateTime(const TQDateTime& dateTime, bool setDateTimeDigitized = false,
bool setProgramName=true);
/** Return a QImage copy of Iptc preview image. Return a null image if preview cannot
/** Return a TQImage copy of Iptc preview image. Return a null image if preview cannot
be found.
*/
bool getImagePreview(QImage& preview) const;
bool getImagePreview(TQImage& preview) const;
/** Set the Iptc preview image. The thumbnail image must have the right size before (64Kb max
with JPEG file, else 256Kb). Look Iptc specification for details. Return true if preview
@ -270,52 +270,52 @@ public:
Re-implemente this method if you want to use another image file format than JPEG to
save preview.
*/
virtual bool setImagePreview(const QImage& preview, bool setProgramName=true);
virtual bool setImagePreview(const TQImage& preview, bool setProgramName=true);
/** Return a strings list of Iptc keywords from image. Return an empty list if no keyword are set. */
QStringList getImageKeywords() const;
TQStringList getImageKeywords() const;
/** Set Iptc keywords using a list of strings defined by 'newKeywords' parameter. Use 'getImageKeywords()'
method to set 'oldKeywords' parameter with existing keywords from image. The method will compare
all new keywords with all old keywords to prevent duplicate entries in image. Return true if keywords
have been changed in metadata.
*/
bool setImageKeywords(const QStringList& oldKeywords, const QStringList& newKeywords,
bool setImageKeywords(const TQStringList& oldKeywords, const TQStringList& newKeywords,
bool setProgramName=true);
/** Return a strings list of Iptc subjects from image. Return an empty list if no subject are set. */
QStringList getImageSubjects() const;
TQStringList getImageSubjects() const;
/** Set Iptc subjects using a list of strings defined by 'newSubjects' parameter. Use 'getImageSubjects()'
method to set 'oldSubjects' parameter with existing subjects from image. The method will compare
all new subjects with all old subjects to prevent duplicate entries in image. Return true if subjects
have been changed in metadata.
*/
bool setImageSubjects(const QStringList& oldSubjects, const QStringList& newSubjects,
bool setImageSubjects(const TQStringList& oldSubjects, const TQStringList& newSubjects,
bool setProgramName=true);
/** Return a strings list of Iptc sub-categories from image. Return an empty list if no sub-category
are set.
*/
QStringList getImageSubCategories() const;
TQStringList getImageSubCategories() const;
/** Set Iptc sub-categories using a list of strings defined by 'newSubCategories' parameter. Use
'getImageSubCategories()' method to set 'oldSubCategories' parameter with existing sub-categories
from image. The method will compare all new sub-categories with all old sub-categories to prevent
duplicate entries in image. Return true if sub-categories have been changed in metadata.
*/
bool setImageSubCategories(const QStringList& oldSubCategories, const QStringList& newSubCategories,
bool setImageSubCategories(const TQStringList& oldSubCategories, const TQStringList& newSubCategories,
bool setProgramName=true);
/** Return a QString copy of Exif user comments. Return a null string if user comments cannot
/** Return a TQString copy of Exif user comments. Return a null string if user comments cannot
be found.
*/
QString getExifComment() const;
TQString getExifComment() const;
/** Set the Exif user comments from image. Look Exif specification for more details about this tag.
Return true if Exif user comments have been changed in metadata.
*/
bool setExifComment(const QString& comment, bool setProgramName=true);
bool setExifComment(const TQString& comment, bool setProgramName=true);
/** Get all GPS location information set in image. Return true if all information can be found.
*/
@ -336,11 +336,11 @@ public:
/** Get an Exif tags content like a string. If 'escapeCR' parameter is true, the CR characters
will be removed. If Exif tag cannot be found a null string is returned.
*/
QString getExifTagString(const char *exifTagName, bool escapeCR=true) const;
TQString getExifTagString(const char *exifTagName, bool escapeCR=true) const;
/** Set an Exif tag content using a string. Return true if tag is set successfully.
*/
bool setExifTagString(const char *exifTagName, const QString& value, bool setProgramName=true);
bool setExifTagString(const char *exifTagName, const TQString& value, bool setProgramName=true);
/** Get an Exif tags content like a long value. Return true if Exif tag be found.
*/
@ -365,29 +365,29 @@ public:
/** Get an Exif tags content like a bytes array. Return an empty bytes array if Exif
tag cannot be found.
*/
QByteArray getExifTagData(const char *exifTagName) const;
TQByteArray getExifTagData(const char *exifTagName) const;
/** Set an Exif tag content using a bytes array. Return true if tag is set successfully.
*/
bool setExifTagData(const char *exifTagName, const QByteArray& data, bool setProgramName=true);
bool setExifTagData(const char *exifTagName, const TQByteArray& data, bool setProgramName=true);
/** Get an Iptc tags content like a string. If 'escapeCR' parameter is true, the CR characters
will be removed. If Iptc tag cannot be found a null string is returned.
*/
QString getIptcTagString(const char* iptcTagName, bool escapeCR=true) const;
TQString getIptcTagString(const char* iptcTagName, bool escapeCR=true) const;
/** Set an Iptc tag content using a string. Return true if tag is set successfully.
*/
bool setIptcTagString(const char *iptcTagName, const QString& value, bool setProgramName=true);
bool setIptcTagString(const char *iptcTagName, const TQString& value, bool setProgramName=true);
/** Get an Iptc tags content like a bytes array. Return an empty bytes array if Iptc
tag cannot be found.
*/
QByteArray getIptcTagData(const char *iptcTagName) const;
TQByteArray getIptcTagData(const char *iptcTagName) const;
/** Set an Iptc tag content using a bytes array. Return true if tag is set successfully.
*/
bool setIptcTagData(const char *iptcTagName, const QByteArray& data, bool setProgramName=true);
bool setIptcTagData(const char *iptcTagName, const TQByteArray& data, bool setProgramName=true);
/** Remove the Exif tag 'exifTagName' from Exif metadata. Return true if tag is
removed successfully.
@ -401,24 +401,24 @@ public:
/** Return the Exif Tag title or a null string.
*/
QString getExifTagTitle(const char *exifTagName);
TQString getExifTagTitle(const char *exifTagName);
/** Return the Exif Tag description or a null string.
*/
QString getExifTagDescription(const char *exifTagName);
TQString getExifTagDescription(const char *exifTagName);
/** Return the Iptc Tag title or a null string.
*/
QString getIptcTagTitle(const char *iptcTagName);
TQString getIptcTagTitle(const char *iptcTagName);
/** Return the Iptc Tag description or a null string.
*/
QString getIptcTagDescription(const char *iptcTagName);
TQString getIptcTagDescription(const char *iptcTagName);
/** Return a map of Exif tags name/value found in metadata sorted by
Exif keys given by 'exifKeysFilter'.
'exifKeysFilter' is a QStringList of Exif keys.
'exifKeysFilter' is a TQStringList of Exif keys.
For example, if you use the string list given below:
"Iop"
@ -433,12 +433,12 @@ public:
- not include "Iop", or "Thumbnail", or "Image", or "Photo" in the Exif tag keys
if 'inverSelection' is true.
*/
KExiv2::MetaDataMap getExifTagsDataList(const QStringList &exifKeysFilter, bool invertSelection=false);
KExiv2::MetaDataMap getExifTagsDataList(const TQStringList &exifKeysFilter, bool invertSelection=false);
/** Return a map of Iptc tags name/value found in metadata sorted by
Iptc keys given by 'iptcKeysFilter'.
'iptcKeysFilter' is a QStringList of Iptc keys.
'iptcKeysFilter' is a TQStringList of Iptc keys.
For example, if you use the string list given below:
"Envelope"
@ -451,7 +451,7 @@ public:
- not include "Envelope", or "Application2" in the Iptc tag keys
if 'inverSelection' is true.
*/
KExiv2::MetaDataMap getIptcTagsDataList(const QStringList &iptcKeysFilter, bool invertSelection=false);
KExiv2::MetaDataMap getIptcTagsDataList(const TQStringList &iptcKeysFilter, bool invertSelection=false);
//-- Advanced methods to convert and decode data -------------------------
@ -471,8 +471,8 @@ protected:
if (on)
{
QString version(digikam_version);
QString software("digiKam");
TQString version(digikam_version);
TQString software("digiKam");
return setImageProgramId(software, version);
}

@ -101,13 +101,13 @@ bool KExiv2Priv::setIptc(Exiv2::DataBuf const data)
return false;
}
void KExiv2Priv::printExiv2ExceptionError(const QString& msg, Exiv2::Error& e)
void KExiv2Priv::printExiv2ExceptionError(const TQString& msg, Exiv2::Error& e)
{
std::string s(e.what());
qDebug("%s (Error #%i: %s)", msg.ascii(), e.code(), s.c_str());
}
QString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)
TQString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)
{
try
{
@ -129,7 +129,7 @@ QString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)
#endif
// libexiv2 will prepend "charset=\"SomeCharset\" " if charset is specified
// Before conversion to QString, we must know the charset, so we stay with std::string for a while
// Before conversion to TQString, we must know the charset, so we stay with std::string for a while
if (comment.length() > 8 && comment.substr(0, 8) == "charset=")
{
// the prepended charset specification is followed by a blank
@ -145,19 +145,19 @@ QString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)
if (charset == "\"Unicode\"")
{
// QString expects a null-terminated UCS-2 string.
// TQString expects a null-terminated UCS-2 string.
// Is it already null terminated? In any case, add termination "\0\0" for safety.
comment.resize(comment.length() + 2, '\0');
return QString::fromUcs2((unsigned short *)comment.data());
return TQString::fromUcs2((unsigned short *)comment.data());
}
else if (charset == "\"Jis\"")
{
QTextCodec *codec = QTextCodec::codecForName("JIS7");
TQTextCodec *codec = TQTextCodec::codecForName("JIS7");
return codec->toUnicode(comment.c_str());
}
else if (charset == "\"Ascii\"")
{
return QString::fromLatin1(comment.c_str());
return TQString::tqfromLatin1(comment.c_str());
}
else
{
@ -169,40 +169,40 @@ QString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)
printExiv2ExceptionError("Cannot convert Comment using Exiv2 ", e);
}
return QString();
return TQString();
}
QString KExiv2Priv::detectEncodingAndDecode(const std::string &value)
TQString KExiv2Priv::detectEncodingAndDecode(const std::string &value)
{
// For charset autodetection, we could use sophisticated code
// (Mozilla chardet, KHTML's autodetection, QTextCodec::codecForContent),
// (Mozilla chardet, KHTML's autodetection, TQTextCodec::codecForContent),
// but that is probably too much.
// We check for UTF8, Local encoding and ASCII.
if (value.empty())
return QString();
return TQString();
#if KDE_IS_VERSION(3,2,0)
if (KStringHandler::isUtf8(value.c_str()))
{
return QString::fromUtf8(value.c_str());
return TQString::fromUtf8(value.c_str());
}
#else
// anyone who is still running KDE 3.0 or 3.1 is missing so many features
// that he will have to accept this missing feature.
return QString::fromUtf8(value.c_str());
return TQString::fromUtf8(value.c_str());
#endif
// Utf8 has a pretty unique byte pattern.
// Thats not true for ASCII, it is not possible
// to reliably autodetect different ISO-8859 charsets.
// We try if QTextCodec can decide here, otherwise we use Latin1.
// We try if TQTextCodec can decide here, otherwise we use Latin1.
// Or use local8Bit as default?
// load QTextCodecs
QTextCodec *latin1Codec = QTextCodec::codecForName("iso8859-1");
//QTextCodec *utf8Codec = QTextCodec::codecForName("utf8");
QTextCodec *localCodec = QTextCodec::codecForLocale();
// load TQTextCodecs
TQTextCodec *latin1Codec = TQTextCodec::codecForName("iso8859-1");
//TQTextCodec *utf8Codec = TQTextCodec::codecForName("utf8");
TQTextCodec *localCodec = TQTextCodec::codecForLocale();
// make heuristic match
int latin1Score = latin1Codec->heuristicContentMatch(value.c_str(), value.length());
@ -213,14 +213,14 @@ QString KExiv2Priv::detectEncodingAndDecode(const std::string &value)
if (localScore >= 0 && localScore >= latin1Score)
{
// workaround for bug #134999:
// The QLatin15Codec may crash if strlen < value.length()
// The TQLatin15Codec may crash if strlen < value.length()
int length = value.length();
if (localCodec->name() == QString::fromLatin1("ISO 8859-15"))
if (localCodec->name() == TQString::tqfromLatin1("ISO 8859-15"))
length = strlen(value.c_str());
return localCodec->toUnicode(value.c_str(), length);
}
else
return QString::fromLatin1(value.c_str());
return TQString::tqfromLatin1(value.c_str());
}
} // NameSpace KExiv2Iface

@ -34,13 +34,13 @@
#include <iomanip>
#include <string>
// Qt includes.
// TQt includes.
#include <qfile.h>
#include <qsize.h>
#include <qtextcodec.h>
#include <qwmatrix.h>
#include <qfileinfo.h>
#include <tqfile.h>
#include <tqsize.h>
#include <tqtextcodec.h>
#include <tqwmatrix.h>
#include <tqfileinfo.h>
// KDE includes.
@ -105,19 +105,19 @@ public:
/** Generic method to print the Exiv2 C++ Exception error message from 'e'.
'msg' string is printed just before like debug header.
*/
void printExiv2ExceptionError(const QString& msg, Exiv2::Error& e);
void printExiv2ExceptionError(const TQString& msg, Exiv2::Error& e);
/** Wrapper method to convert a Comments content to a QString.
/** Wrapper method to convert a Comments content to a TQString.
*/
QString convertCommentValue(const Exiv2::Exifdatum &exifDatum);
TQString convertCommentValue(const Exiv2::Exifdatum &exifDatum);
/** Charset autodetection to convert a string to a QString.
/** Charset autodetection to convert a string to a TQString.
*/
QString detectEncodingAndDecode(const std::string &value);
TQString detectEncodingAndDecode(const std::string &value);
public:
QString filePath;
TQString filePath;
std::string imageComments;

Loading…
Cancel
Save