21 #include "phonenumber.h" 23 #include <klocalizedstring.h> 26 #include <QtCore/QDataStream> 27 #include <QtCore/QSharedData> 31 static QString cleanupNumber(
const QString &input )
33 return input.simplified();
36 class PhoneNumber::Private :
public QSharedData
40 : mId( KRandom::randomString( 8 ) ), mType( type )
44 Private(
const Private &other )
45 : QSharedData( 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 );
152 if ( list.isEmpty() ) {
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" );
238 TypeList::ConstIterator it;
239 TypeList::ConstIterator end( list.end() );
240 for ( it = list.begin(); it != end; ++it ) {
245 label.append( QLatin1Char(
'/' ) );
263 str += QString::fromLatin1(
"PhoneNumber {\n" );
264 str += QString::fromLatin1(
" Id: %1\n" ).arg( d->mId );
265 str += QString::fromLatin1(
" Type: %1\n" ).arg(
typeLabel( d->mType ) );
266 str += QString::fromLatin1(
" Number: %1\n" ).arg( d->mNumber );
267 str += QString::fromLatin1(
"}\n" );
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.
bool operator!=(const PhoneNumber &) const
Not-Equal operator.
QString typeLabel() const
Returns a translated string of the address' type.
QString toString() const
Returns a string representation of the phone number.
~PhoneNumber()
Destroys the phone number.
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
void setType(Type type)
Sets the type.
void setNumber(const QString &number)
Sets the phone number.
Type type() const
Returns the type.
QString id() const
Returns the unique identifier.
static QString typeFlagLabel(TypeFlag type)
Returns the translated label for phone number type.
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.
Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
QString number() const
Returns the phone number.
PhoneNumber & operator=(const PhoneNumber &other)
Assignment operator.
PhoneNumber()
Creates an empty phone number object.
static TypeList typeList()
Returns a list of all available types.
QList< TypeFlag > TypeList
List of phone number types.
bool operator==(const PhoneNumber &) const
Equality operator.
bool isEmpty() const
Returns true, if the phone number is empty.