KContacts::Picture Class

class KContacts::Picture

A class to store a picture of an addressee. More...

Header: #include <KContacts/Picture>
CMake: find_package(KF6 REQUIRED COMPONENTS Contacts)
target_link_libraries(mytarget PRIVATE KF6::Contacts)
In QML: picture

Public Types

Properties

Public Functions

Picture()
Picture(const QImage &data)
Picture(const QString &url)
Picture(const KContacts::Picture &picture)
QImage data() const
bool isEmpty() const
bool isIntern() const
(since 4.10) QByteArray rawData() const
void setData(const QImage &data)
(since 4.10) void setRawData(const QByteArray &rawData, const QString &type)
void setUrl(const QString &url)
(since 4.10) void setUrl(const QString &url, const QString &type)
QString toString() const
QString type() const
QString url() const
bool operator!=(const KContacts::Picture &other) const
KContacts::Picture &operator=(const KContacts::Picture &other)
bool operator==(const KContacts::Picture &other) const
QDataStream &operator<<(QDataStream &stream, const KContacts::Picture &picture)
QDataStream &operator>>(QDataStream &stream, KContacts::Picture &picture)

Detailed Description

It can store the data directly or an url reference to a picture.

Member Type Documentation

Picture::List

Property Documentation

data : QImage

Access functions:

QImage data() const
void setData(const QImage &data)

[read-only] isEmpty : const bool

Access functions:

bool isEmpty() const

[read-only] isIntern : const bool

Access functions:

bool isIntern() const

url : QString

Access functions:

QString url() const
void setUrl(const QString &url)
void setUrl(const QString &url, const QString &type)

Member Function Documentation

Picture::Picture()

Creates an empty picture.

Picture::Picture(const QImage &data)

Creates a picture with the given data.

data The raw data of the picture.

Picture::Picture(const QString &url)

Creates a picture which points to the given url.

url A URL that describes the location of the picture file.

Picture::Picture(const KContacts::Picture &picture)

Copy constructor.

Fast operation, Picture's data is implicitly shared.

picture The Picture instance to copy from

QImage Picture::data() const

Returns the image data of this picture.

Note: Getter function for property data.

See also setData().

bool Picture::isEmpty() const

Returns true, if the picture is empty.

Note: Getter function for property isEmpty.

bool Picture::isIntern() const

Returns whether the picture is described by a URL (extern) or by the raw data (intern).

When this method returns 'true' you can use data() to get the raw data. Otherwise you can request the URL of this picture by url() and load the raw data from that location.

Note: Getter function for property isIntern.

[since 4.10] QByteArray Picture::rawData() const

Returns the raw data of this picture.

This function was introduced in 4.10.

See also setRawData().

void Picture::setData(const QImage &data)

Sets the image data of the picture. When using this function, isIntern() will return 'true' until you use setUrl(). This also sets type to "png" or "jpeg" depending on whether the image has an alpha channel or not.

data The image data of the picture.

Note: Setter function for property data.

See also data().

[since 4.10] void Picture::setRawData(const QByteArray &rawData, const QString &type)

Sets the raw data of the picture. When using this function, isIntern() will return 'true' until you use setUrl().

rawData The raw data of the picture.

type The encoding format of the image, e.g. jpeg or png

This function was introduced in 4.10.

See also rawData().

void Picture::setUrl(const QString &url)

Sets a URL for the location of the picture file. When using this function, isIntern() will return 'false' until you use setData(). This also clears the type, as it is unknown.

url The location URL of the picture file.

Note: Setter function for property url.

See also url().

[since 4.10] void Picture::setUrl(const QString &url, const QString &type)

Sets a URL for the location of the picture file. When using this function, isIntern() will return 'false' until you use setData().

url The location URL of the picture file.

type The encoding format of the image, e.g. jpeg or png

Note: Setter function for property url.

This function was introduced in 4.10.

QString Picture::toString() const

Returns string representation of the picture.

QString Picture::type() const

Returns the type of this picture.

QString Picture::url() const

Returns the location URL of this picture.

Note: Getter function for property url.

See also setUrl().

bool Picture::operator!=(const KContacts::Picture &other) const

Not-Equal operator.

KContacts::Picture &Picture::operator=(const KContacts::Picture &other)

Assignment operator

Fast operation, Picture's data is implicitly shared.

other The Picture instance to assign to this

bool Picture::operator==(const KContacts::Picture &other) const

Equality operator.

Related Non-Members

QDataStream &operator<<(QDataStream &stream, const KContacts::Picture &picture)

Serializes the picture object into the stream.

QDataStream &operator>>(QDataStream &stream, KContacts::Picture &picture)

Initializes the picture object from the stream.