summaryrefslogtreecommitdiffabout
path: root/kabc/address.cpp
Side-by-side diff
Diffstat (limited to 'kabc/address.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index c820a6c..5ffe511 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -43,96 +43,109 @@ using namespace KABC;
QMap<QString, QString> Address::mISOMap;
Address::Address() :
mEmpty( true ), mType( 0 )
{
mId = KApplication::randomString( 10 );
}
Address::Address( int type ) :
mEmpty( true ), mType( type )
{
mId = KApplication::randomString( 10 );
}
bool Address::operator==( const Address &a ) const
{
if ( mPostOfficeBox != a.mPostOfficeBox ) return false;
if ( mExtended != a.mExtended ) return false;
if ( mStreet != a.mStreet ) return false;
if ( mLocality != a.mLocality ) return false;
if ( mRegion != a.mRegion ) return false;
if ( mPostalCode != a.mPostalCode ) return false;
if ( mCountry != a.mCountry ) return false;
if ( mLabel != a.mLabel ) return false;
return true;
}
bool Address::operator!=( const Address &a ) const
{
return !( a == *this );
}
bool Address::isEmpty() const
{
if ( mPostOfficeBox.isEmpty() &&
mExtended.isEmpty() &&
mStreet.isEmpty() &&
mLocality.isEmpty() &&
mRegion.isEmpty() &&
mPostalCode.isEmpty() &&
mCountry.isEmpty() &&
mLabel.isEmpty() ) {
return true;
}
return false;
}
+QStringList Address::asList()
+{
+ QStringList result;
+ if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox);
+ if ( ! mExtended.isEmpty())result.append(mExtended);
+ if ( ! mStreet.isEmpty())result.append(mStreet);
+ if ( ! mLocality.isEmpty() )result.append(mLocality);
+ if ( ! mRegion.isEmpty())result.append(mRegion);
+ if ( ! mPostalCode.isEmpty())result.append(mPostalCode);
+ if ( ! mCountry.isEmpty())result.append(mCountry);
+ if ( ! mLabel.isEmpty() )result.append(mLabel);
+ return result;
+}
void Address::clear()
{
*this = Address();
}
void Address::setId( const QString &id )
{
mEmpty = false;
mId = id;
}
QString Address::id() const
{
return mId;
}
void Address::setType( int type )
{
mEmpty = false;
mType = type;
}
int Address::type() const
{
return mType;
}
QString Address::typeLabel() const
{
QString label;
bool first = true;
TypeList list = typeList();
TypeList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
if ( first )
first = false;
}
}
return label;
}