21 #include "phonenumber.h"
23 #include <klocalizedstring.h>
26 #include <QtCore/QDataStream>
27 #include <QtCore/QSharedData>
40 : mId( KRandom::randomString( 8 ) ), mType( type )
44 Private(
const Private &other )
49 mNumber = other.mNumber;
58 : d( new Private( Home ) )
63 : d( new Private( type ) )
65 d->mNumber = cleanupNumber( number );
79 if ( d->mId != other.d->mId ) {
83 if ( d->mNumber != other.d->mNumber ) {
87 if ( d->mType != other.d->mType ) {
96 return !( other == *this );
101 if (
this != &other ) {
110 return d->mNumber.isEmpty();
125 d->mNumber = cleanupNumber( number );
164 return i18nc(
"Home phone",
"Home" );
167 return i18nc(
"Work phone",
"Work" );
170 return i18n(
"Messenger" );
173 return i18nc(
"Preferred phone",
"Preferred" );
176 return i18n(
"Voice" );
179 return i18n(
"Fax" );
182 return i18nc(
"Mobile Phone",
"Mobile" );
185 return i18nc(
"Video phone",
"Video" );
188 return i18n(
"Mailbox" );
191 return i18n(
"Modem" );
194 return i18nc(
"Car Phone",
"Car" );
197 return i18n(
"ISDN" );
200 return i18n(
"PCS" );
203 return i18n(
"Pager" );
206 return i18nc(
"another type of phone",
"Other" );
218 if ( type ==
Pref ) {
219 return i18n(
"Preferred Number" );
224 label = i18n(
"Home Fax" );
228 }
else if ( type &
Work ) {
229 label = i18n(
"Work Fax" );
240 for ( it = list.
begin(); it != end; ++it ) {
274 return s << phone.d->mId << (uint)phone.d->mType << phone.d->mNumber;
280 s >> phone.d->mId >> type >> phone.d->mNumber;
281 phone.d->mType = PhoneNumber::Type( type );
Personal Communication Service.
QString & append(QChar ch)
QString number() const
Returns the phone number.
bool operator==(const PhoneNumber &) const
Equality operator.
QString simplified() const
QString typeLabel() const
Returns a translated string of the address' type.
~PhoneNumber()
Destroys the phone number.
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
QString toString() const
Returns a string representation of the phone number.
void setType(Type type)
Sets the type.
void setNumber(const QString &number)
Sets the phone number.
Type type() const
Returns the type.
static QString typeFlagLabel(TypeFlag type)
Returns the translated label for phone number type.
bool operator!=(const PhoneNumber &) const
Not-Equal operator.
void setId(const QString &identifier)
Sets the unique identifier.
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
TypeFlag
Phone number types.
QString id() const
Returns the unique identifier.
QString fromLatin1(const char *str, int size)
bool isEmpty() const
Returns true, if the phone number is empty.
PhoneNumber & operator=(const PhoneNumber &other)
Assignment operator.
PhoneNumber()
Creates an empty phone number object.
static TypeList typeList()
Returns a list of all available types.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const