23 #include <QtCore/QBuffer>
24 #include <QtCore/QSharedData>
28 class Picture::Private :
public QSharedData
36 Private(
const Private &other )
37 : QSharedData( other )
42 mIntern = other.mIntern;
48 mutable QByteArray mRawData;
81 if (
this != &other ) {
90 if ( d->mIntern != p.d->mIntern ) {
94 if ( d->mType != p.d->mType ) {
99 if ( !d->mData.isNull() && !p.d->mData.isNull() ) {
100 if ( d->mData != p.d->mData ) {
103 }
else if ( !d->mRawData.isEmpty() && !p.d->mRawData.isEmpty() ) {
104 if ( d->mRawData != p.d->mRawData ) {
107 }
else if ( ( !d->mData.isNull() || !d->mRawData.isEmpty() ) &&
108 ( !p.d->mData.isNull() || !p.d->mRawData.isEmpty() ) ) {
117 if ( d->mUrl != p.d->mUrl ) {
127 return !( p == *this );
133 ( ( d->mIntern ==
false && d->mUrl.isEmpty() ) ||
134 ( d->mIntern ==
true && d->mData.isNull() && d->mRawData.isEmpty() ) );
158 if ( !d->mData.hasAlphaChannel() ) {
159 d->mType = QLatin1String(
"jpeg" );
161 d->mType = QLatin1String(
"png" );
190 if ( d->mData.isNull() && !d->mRawData.isEmpty() ) {
191 d->mData.loadFromData( d->mRawData );
199 if ( d->mRawData.isEmpty() && !d->mData.isNull() ) {
200 QBuffer buffer( &d->mRawData );
201 buffer.open( QIODevice::WriteOnly );
204 d->mData.save( &buffer, d->mType.toUpper().toLatin1().data() );
219 str += QLatin1String(
"Picture {\n" );
220 str += QString::fromLatin1(
" Type: %1\n" ).arg( d->mType );
221 str += QString::fromLatin1(
" IsIntern: %1\n" ).
222 arg( d->mIntern ? QLatin1String(
"true" ) : QLatin1String(
"false" ) );
224 str += QString::fromLatin1(
" Data: %1\n" ).arg( QString::fromLatin1(
rawData().toBase64() ) );
226 str += QString::fromLatin1(
" Url: %1\n" ).arg( d->mUrl );
228 str += QLatin1String(
"}\n" );
233 QDataStream &KABC::operator<<( QDataStream &s,
const Picture &picture )
235 return s << picture.d->mIntern << picture.d->mUrl << picture.d->mType << picture.
data();
238 QDataStream &KABC::operator>>( QDataStream &s,
Picture &picture )
240 s >> picture.d->mIntern >> picture.d->mUrl >> picture.d->mType >> picture.d->mData;
A class to store a picture of an addressee.
void setType(const QString &type)
Sets the type of the picture.
Picture & operator=(const Picture &other)
Assignment operator.
QString toString() const
Returns string representation of the picture.
QByteArray rawData() const
Returns the raw data of this picture.
void setRawData(const QByteArray &rawData, const QString &type)
Sets the raw data of the picture.
QString url() const
Returns the location URL of this picture.
QImage data() const
Returns the image data of this picture.
void setData(const QImage &data)
Sets the image data of the picture.
bool isEmpty() const
Returns true, if the picture is empty.
bool operator==(const Picture &) const
Equality operator.
QString type() const
Returns the type of this picture.
bool operator!=(const Picture &) const
Not-Equal operator.
void setUrl(const QString &url)
Sets a URL for the location of the picture file.
bool isIntern() const
Returns whether the picture is described by a URL (extern) or by the raw data (intern).
Picture()
Creates an empty picture.