summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/address.cpp27
-rw-r--r--kabc/address.h2
-rw-r--r--kabc/addressee.cpp25
-rw-r--r--kabc/addressee.h4
4 files changed, 58 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index 5ffe511..6151f9e 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -80,48 +80,75 @@ bool Address::isEmpty() const
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;
}
+
+bool Address::matchAddress( QRegExp* re ) const
+{
+
+#if QT_VERSION >= 0x030000
+ if (re->search( mPostOfficeBox ) == 0) return true;
+ if (re->search( mExtended ) == 0) return true;
+ if (re->search( mStreet ) == 0) return true;
+ if (re->search( mLocality ) == 0) return true;
+ if (re->search( mRegion ) == 0) return true;
+ if (re->search( mPostalCode ) == 0) return true;
+ if (re->search( mCountry ) == 0) return true;
+ if (re->search( mLabel ) == 0) return true;
+#else
+ if (re->match( mPostOfficeBox ) == 0) return true;
+ if (re->match( mExtended ) == 0) return true;
+ if (re->match( mStreet ) == 0) return true;
+ if (re->match( mLocality ) == 0) return true;
+ if (re->match( mRegion ) == 0) return true;
+ if (re->match( mPostalCode ) == 0) return true;
+ if (re->match( mCountry ) == 0) return true;
+ if (re->match( mLabel ) == 0) return true;
+#endif
+
+ return false;
+}
+
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;
}
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -9,48 +9,49 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KABC_ADDRESS_H
#define KABC_ADDRESS_H
#include <qmap.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
// template tags for address formatting localization
#define KABC_FMTTAG_realname QString("%n")
#define KABC_FMTTAG_REALNAME QString("%N")
#define KABC_FMTTAG_company QString("%cm")
#define KABC_FMTTAG_COMPANY QString("%CM")
#define KABC_FMTTAG_pobox QString("%p")
#define KABC_FMTTAG_street QString("%s")
#define KABC_FMTTAG_STREET QString("%S")
#define KABC_FMTTAG_zipcode QString("%z")
#define KABC_FMTTAG_location QString("%l")
#define KABC_FMTTAG_LOCATION QString("%L")
#define KABC_FMTTAG_region QString("%r")
#define KABC_FMTTAG_REGION QString("%R")
#define KABC_FMTTAG_newline QString("\\n")
#define KABC_FMTTAG_condcomma QString("%,")
#define KABC_FMTTAG_condwhite QString("%w")
#define KABC_FMTTAG_purgeempty QString("%0")
namespace KABC {
/**
@@ -74,48 +75,49 @@ class Address
Address types:
@li @p Dom - domestic
@li @p Intl - international
@li @p Postal - postal
@li @p Parcel - parcel
@li @p Home - home address
@li @p Work - address at work
@li @p Pref - preferred address
*/
enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
Pref = 64 };
/**
Constructor that creates an empty Address, which is initialized
with a unique id (see @ref id()).
*/
Address();
/**
This is like @ref Address() just above, with the difference
that you can specify the type.
*/
Address( int );
+ bool matchAddress( QRegExp* searchExp ) const;
bool operator==( const Address & ) const;
bool operator!=( const Address & ) const;
/**
Returns true, if the address is empty.
*/
bool isEmpty() const;
/**
Clears all entries of the address.
*/
void clear();
QStringList asList();
/**
Sets the unique id.
*/
void setId( const QString & );
/*
Returns the unique id.
*/
QString id() const;
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -285,49 +285,74 @@ void Addressee::computeCsum(const QString &dev)
//qDebug("lennnn %d %d ", find, t[iii].length());
if ( find < t[iii].length())
l.append( t[iii] );
}
KABC::Address::List::Iterator addressIter;
for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
++addressIter ) {
t = (*addressIter).asList();
t.sort();
for ( iii = 0; iii < t.count(); ++iii)
l.append( t[iii] );
}
uint cs = getCsum4List(l);
#if 0
for ( iii = 0; iii < l.count(); ++iii)
qDebug("%d***%s***",iii,l[iii].latin1());
qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
#endif
setCsum( dev, QString::number (cs ));
}
+bool Addressee::matchAddress( QRegExp* re ) const
+{
+ KABC::Address::List::Iterator addressIter;
+ for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
+ ++addressIter ) {
+ if ( (*addressIter).matchAddress( re ) )
+ return true;
+ }
+ return false;
+}
+bool Addressee::matchPhoneNumber( QRegExp* re ) const
+{
+ KABC::PhoneNumber::List::Iterator phoneIter;
+
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
+#if QT_VERSION >= 0x030000
+ if (re->search( (*phoneIter).number() ) == 0)
+#else
+ if (re->match( (*phoneIter).number() ) == 0)
+#endif
+ return true;
+ }
+ return false;
+
+}
void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
// merge all standard non-outlook fields.
//if isSubSet (e.g. mobile phone sync) merge all fields
detach();
if ( isSubSet ) {
if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
if ( !mData->birthday.isValid() )
if ( ad.mData->birthday.isValid())
mData->birthday = ad.mData->birthday;
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -10,48 +10,49 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KABC_ADDRESSEE_H
#define KABC_ADDRESSEE_H
#include <qdatetime.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <ksharedptr.h>
#include <kurl.h>
#include "address.h"
#include "agent.h"
#include "geo.h"
#include "key.h"
#include "phonenumber.h"
#include "picture.h"
#include "secrecy.h"
#include "sound.h"
#include "timezone.h"
namespace KABC {
class Resource;
/**
@short address book entry
This class represents an entry in the address book.
@@ -629,48 +630,51 @@ class Addressee
/**
Set the emails to @param.
The first email address gets the preferred one!
@param list The list of email addresses.
*/
void setEmails( const QStringList& list);
/**
Insert a phone number. If a phone number with the same id already exists
in this addressee it is not duplicated.
*/
void insertPhoneNumber( const PhoneNumber &phoneNumber );
/**
Remove phone number. If no phone number with the given id exists for this
addresse nothing happens.
*/
void removePhoneNumber( const PhoneNumber &phoneNumber );
/**
Return phone number, which matches the given type.
*/
PhoneNumber phoneNumber( int type ) const;
+ bool matchPhoneNumber( QRegExp* searchExp ) const;
+ bool matchAddress( QRegExp* searchExp ) const;
+
/**
Return list of all phone numbers.
*/
PhoneNumber::List phoneNumbers() const;
/**
Return list of phone numbers with a special type.
*/
PhoneNumber::List phoneNumbers( int type ) const;
/**
Return phone number with the given id.
*/
PhoneNumber findPhoneNumber( const QString &id ) const;
/**
Insert a key. If a key with the same id already exists
in this addressee it is not duplicated.
*/
void insertKey( const Key &key );
/**
Remove a key. If no key with the given id exists for this
addresse nothing happens.