KContacts::PhoneNumber Class

class KContacts::PhoneNumber

Phonenumber information. More...

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

Public Types

List
flags Type
enum TypeFlag { Home, Work, Msg, Pref, Voice, …, Undefined }
TypeList

Properties

Public Functions

PhoneNumber()
PhoneNumber(const QString &number, KContacts::PhoneNumber::Type type = Home)
PhoneNumber(const KContacts::PhoneNumber &other)
QString id() const
bool isEmpty() const
(since 5.12) bool isPreferred() const
(since 5.12) QString normalizedNumber() const
QString number() const
void setId(const QString &identifier)
void setNumber(const QString &number)
void setType(KContacts::PhoneNumber::Type type)
(since 5.12) bool supportsSms() const
QString toString() const
KContacts::PhoneNumber::Type type() const
QString typeLabel() const
bool operator!=(const KContacts::PhoneNumber &other) const
KContacts::PhoneNumber &operator=(const KContacts::PhoneNumber &other)
bool operator==(const KContacts::PhoneNumber &other) const

Static Public Members

(since 4.5) QString typeFlagLabel(KContacts::PhoneNumber::TypeFlag type)
QString typeLabel(KContacts::PhoneNumber::Type type)
KContacts::PhoneNumber::TypeList typeList()
QDataStream &operator<<(QDataStream &stream, const KContacts::PhoneNumber &number)
QDataStream &operator>>(QDataStream &stream, KContacts::PhoneNumber &number)

Detailed Description

This class provides phone number information. A phone number is classified by a type. The following types are available, it's possible to use multiple types Types for a number by combining them through a logical or.

Member Type Documentation

PhoneNumber::List

List of phone numbers.

enum PhoneNumber::TypeFlag
flags PhoneNumber::Type

Phone number types.

ConstantValueDescription
KContacts::PhoneNumber::Home1Home number
KContacts::PhoneNumber::Work2Office number
KContacts::PhoneNumber::Msg4Messaging
KContacts::PhoneNumber::Pref8Preferred number
KContacts::PhoneNumber::Voice16Voice
KContacts::PhoneNumber::Fax32Fax machine
KContacts::PhoneNumber::Cell64Cell phone
KContacts::PhoneNumber::Video128Video phone
KContacts::PhoneNumber::Bbs256Mailbox
KContacts::PhoneNumber::Modem512Modem
KContacts::PhoneNumber::Car1024Car phone
KContacts::PhoneNumber::Isdn2048ISDN connection
KContacts::PhoneNumber::Pcs4096Personal Communication Service
KContacts::PhoneNumber::Pager8192Pager
KContacts::PhoneNumber::Undefined16384Undefined number type

The Type type is a typedef for QFlags<TypeFlag>. It stores an OR combination of TypeFlag values.

PhoneNumber::TypeList

List of phone number types.

Property Documentation

id : QString

Access functions:

QString id() const
void setId(const QString &identifier)

[read-only] isEmpty : const bool

Access functions:

bool isEmpty() const

[read-only] isPreferred : const bool

Access functions:

bool isPreferred() const

[read-only] normalizedNumber : const QString

Access functions:

QString normalizedNumber() const

number : QString

Access functions:

QString number() const
void setNumber(const QString &number)

[read-only] supportsSms : const bool

Access functions:

bool supportsSms() const

type : Type

Access functions:

KContacts::PhoneNumber::Type type() const
void setType(KContacts::PhoneNumber::Type type)

[read-only] typeLabel : const QString

Access functions:

QString typeLabel() const
QString typeLabel(KContacts::PhoneNumber::Type type)

Member Function Documentation

PhoneNumber::PhoneNumber()

Creates an empty phone number object.

PhoneNumber::PhoneNumber(const QString &number, KContacts::PhoneNumber::Type type = Home)

Creates a phone number object.

number Number

type Type as defined in enum. Multiple types can be specified by combining them by a logical or.

PhoneNumber::PhoneNumber(const KContacts::PhoneNumber &other)

Copy constructor.

Fast operation, PhoneNumber's data is implicitly shared.

other The PhoneNumber object to copy from

QString PhoneNumber::id() const

Returns the unique identifier.

Note: Getter function for property id.

See also setId().

bool PhoneNumber::isEmpty() const

Returns true, if the phone number is empty.

Note: Getter function for property isEmpty.

[since 5.12] bool PhoneNumber::isPreferred() const

Returns whether this phone number is marked as preferred.

Note: Getter function for property isPreferred.

This function was introduced in 5.12.

[since 5.12] QString PhoneNumber::normalizedNumber() const

Returns the phone number normalized for dialing. This has all formatting stripped for passing to dialers or tel: URLs.

Note: Getter function for property normalizedNumber.

This function was introduced in 5.12.

See also number().

QString PhoneNumber::number() const

Returns the phone number. This is the number as entered/stored with all formatting preserved. Preferred for display.

Note: Getter function for property number.

See also setNumber() and normalizedNumber().

void PhoneNumber::setId(const QString &identifier)

Sets the unique identifier.

Note: Setter function for property id.

See also id().

void PhoneNumber::setNumber(const QString &number)

Sets the phone number.

Note: Setter function for property number.

See also number().

void PhoneNumber::setType(KContacts::PhoneNumber::Type type)

Sets the type. Multiple types can be specified by combining them by a logical or.

type The #Type of the phone number

Note: Setter function for property type.

See also type().

[since 5.12] bool PhoneNumber::supportsSms() const

Returns whether this phone number is expected to support receiving SMS messages.

Note: Getter function for property supportsSms.

This function was introduced in 5.12.

QString PhoneNumber::toString() const

Returns a string representation of the phone number.

KContacts::PhoneNumber::Type PhoneNumber::type() const

Returns the type. Can be a multiple types combined by a logical or.

Note: Getter function for property type.

See also setType(), TypeFlag, and typeLabel().

[static, since 4.5] QString PhoneNumber::typeFlagLabel(KContacts::PhoneNumber::TypeFlag type)

Returns the translated label for phone number type.

type An OR'ed combination of #TypeFlag

This function was introduced in 4.5.

See also typeLabel().

QString PhoneNumber::typeLabel() const

Returns a translated string of the address' type.

Note: Getter function for property typeLabel.

[static] QString PhoneNumber::typeLabel(KContacts::PhoneNumber::Type type)

Returns the translated label for phone number type.

In opposite to typeFlagLabel( TypeFlag type ), it returns all types of the phone number concatenated by '/'.

type An OR'ed combination of #TypeFlag

Note: Getter function for property typeLabel.

See also type().

[static] KContacts::PhoneNumber::TypeList PhoneNumber::typeList()

Returns a list of all available types

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

Not-Equal operator.

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

Assignment operator.

Fast operation, PhoneNumber's data is implicitly shared.

other The PhoneNumber object to asssign to this

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

Equality operator.

Returns true if number, type and identifier are equal, otherwise false

Related Non-Members

QDataStream &operator<<(QDataStream &stream, const KContacts::PhoneNumber &number)

Serializes the phone number object into the stream.

stream The stream to write into

number The phone number object to serialize

QDataStream &operator>>(QDataStream &stream, KContacts::PhoneNumber &number)

Initializes the phone number object from the stream.

stream The stream to read from

number The phone number object to deserialize into