summaryrefslogtreecommitdiff
path: root/library/backend/contact.h
Side-by-side diff
Diffstat (limited to 'library/backend/contact.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/contact.h102
1 files changed, 93 insertions, 9 deletions
diff --git a/library/backend/contact.h b/library/backend/contact.h
index a74cbbe..4999430 100644
--- a/library/backend/contact.h
+++ b/library/backend/contact.h
@@ -1,5 +1,5 @@
/**********************************************************************
-** Copyright (C) 2001 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
@@ -23,4 +23,4 @@
-#include <qpe/palmtoprecord.h>
-#include <qpe/recordfields.h>
+#include <qtopia/private/palmtoprecord.h>
+#include <qtopia/private/recordfields.h>
@@ -30,3 +30,3 @@
// MOC_SKIP_BEGIN
-template class QPC_EXPORT QMap<int, QString>;
+QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
// MOC_SKIP_END
@@ -58,5 +58,8 @@ public:
// default email address
- void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); }
- // the emails should be seperated by a semicolon
- void setEmails( const QString &v );
+ void setDefaultEmail( const QString &v );
+ // inserts email to list and ensure's doesn't already exist
+ void insertEmail( const QString &v );
+ void removeEmail( const QString &v );
+ void clearEmails();
+ void insertEmails( const QStringList &v );
@@ -125,3 +128,2 @@ public:
QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
- QString emails() const { return find( Qtopia::Emails ); }
QStringList emailList() const;
@@ -204,3 +206,12 @@ public:
private:
+ friend class AbEditor;
friend class AbTable;
+ friend class AddressBookAccessPrivate;
+ friend class XMLIO;
+
+ QString emailSeparator() const { return " "; }
+ // the emails should be seperated by a comma
+ void setEmails( const QString &v );
+ QString emails() const { return find( Qtopia::Emails ); }
+
void insert( int key, const QString &value );
@@ -221,2 +232,75 @@ private:
+// these methods are inlined to keep binary compatability with Qtopia 1.5
+inline void Contact::insertEmail( const QString &v )
+{
+ //qDebug("insertEmail %s", v.latin1());
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+
+ // if no default, set it as the default email and don't insert
+ if ( def.isEmpty() ) {
+ setDefaultEmail( e ); // will insert into the list for us
+ return;
+ }
+
+ // otherwise, insert assuming doesn't already exist
+ QString emailsStr = find( Qtopia::Emails );
+ if ( emailsStr.contains( e ))
+ return;
+ if ( !emailsStr.isEmpty() )
+ emailsStr += emailSeparator();
+ emailsStr += e;
+ replace( Qtopia::Emails, emailsStr );
+}
+
+inline void Contact::removeEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+ QString emailsStr = find( Qtopia::Emails );
+ QStringList emails = emailList();
+
+ // otherwise, must first contain it
+ if ( !emailsStr.contains( e ) )
+ return;
+
+ // remove it
+ //qDebug(" removing email from list %s", e.latin1());
+ emails.remove( e );
+ // reset the string
+ emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
+ replace( Qtopia::Emails, emailsStr );
+
+ // if default, then replace the default email with the first one
+ if ( def == e ) {
+ //qDebug("removeEmail is default; setting new default");
+ if ( !emails.count() )
+ clearEmails();
+ else // setDefaultEmail will remove e from the list
+ setDefaultEmail( emails.first() );
+ }
+}
+inline void Contact::clearEmails()
+{
+ mMap.remove( Qtopia::DefaultEmail );
+ mMap.remove( Qtopia::Emails );
+}
+inline void Contact::setDefaultEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+
+ //qDebug("Contact::setDefaultEmail %s", e.latin1());
+ replace( Qtopia::DefaultEmail, e );
+
+ if ( !e.isEmpty() )
+ insertEmail( e );
+
+}
+
+inline void Contact::insertEmails( const QStringList &v )
+{
+ for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
+ insertEmail( *it );
+}
+
#endif