summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-01 16:20:40 (UTC)
committer eilers <eilers>2002-10-01 16:20:40 (UTC)
commit541bd9eaebd630a39a9f1df320bf6e46d499c10a (patch) (unidiff)
treeb897e17212c13432b142574ed4e23f59020e5a5d
parent3352558f31f2f3f5f32730a28f07161fe71787a9 (diff)
downloadopie-541bd9eaebd630a39a9f1df320bf6e46d499c10a.zip
opie-541bd9eaebd630a39a9f1df320bf6e46d499c10a.tar.gz
opie-541bd9eaebd630a39a9f1df320bf6e46d499c10a.tar.bz2
Implementation of some virtual methods
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp12
-rw-r--r--libopie/pim/ocontact.h11
-rw-r--r--libopie2/opiepim/ocontact.cpp12
-rw-r--r--libopie2/opiepim/ocontact.h11
4 files changed, 26 insertions, 20 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 66632f5..828a9de 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1348,86 +1348,86 @@ void OContact::writeVCard( const QString &filename, const OContact &contact)
1348 if ( !f.open( IO_WriteOnly ) ) { 1348 if ( !f.open( IO_WriteOnly ) ) {
1349 qWarning("Unable to open vcard write"); 1349 qWarning("Unable to open vcard write");
1350 return; 1350 return;
1351 } 1351 }
1352 1352
1353 VObject *obj = createVObject( contact ); 1353 VObject *obj = createVObject( contact );
1354 writeVObject( f.directHandle() , obj ); 1354 writeVObject( f.directHandle() , obj );
1355 cleanVObject( obj ); 1355 cleanVObject( obj );
1356 1356
1357 cleanStrTbl(); 1357 cleanStrTbl();
1358} 1358}
1359 1359
1360/*! 1360/*!
1361 Returns the set of contacts read as VCards from the file \a filename. 1361 Returns the set of contacts read as VCards from the file \a filename.
1362*/ 1362*/
1363QValueList<OContact> OContact::readVCard( const QString &filename ) 1363QValueList<OContact> OContact::readVCard( const QString &filename )
1364{ 1364{
1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1367 1367
1368 qDebug("vobject = %p", obj ); 1368 qDebug("vobject = %p", obj );
1369 1369
1370 QValueList<OContact> contacts; 1370 QValueList<OContact> contacts;
1371 1371
1372 while ( obj ) { 1372 while ( obj ) {
1373 contacts.append( parseVObject( obj ) ); 1373 contacts.append( parseVObject( obj ) );
1374 1374
1375 VObject *t = obj; 1375 VObject *t = obj;
1376 obj = nextVObjectInList(obj); 1376 obj = nextVObjectInList(obj);
1377 cleanVObject( t ); 1377 cleanVObject( t );
1378 } 1378 }
1379 1379
1380 return contacts; 1380 return contacts;
1381} 1381}
1382 1382
1383/*! 1383/*!
1384 Returns TRUE if the contact matches the regular expression \a regexp. 1384 Returns TRUE if the contact matches the regular expression \a regexp.
1385 Otherwise returns FALSE. 1385 Otherwise returns FALSE.
1386*/ 1386*/
1387bool OContact::match( const QString &regexp ) const 1387bool OContact::match( const QString &regexp ) const
1388{ 1388{
1389 return match(QRegExp(regexp)); 1389 return match(QRegExp(regexp));
1390} 1390}
1391 1391
1392/*! 1392/*!
1393 \overload 1393 \overload
1394 Returns TRUE if the contact matches the regular expression \a regexp. 1394 Returns TRUE if the contact matches the regular expression \a regexp.
1395 Otherwise returns FALSE. 1395 Otherwise returns FALSE.
1396*/ 1396*/
1397bool OContact::match( const QRegExp &r ) const 1397bool OContact::match( const QRegExp &r ) const
1398{ 1398{
1399 bool match; 1399 bool match;
1400 match = false; 1400 match = false;
1401 QMap<int, QString>::ConstIterator it; 1401 QMap<int, QString>::ConstIterator it;
1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
1403 if ( (*it).find( r ) > -1 ) { 1403 if ( (*it).find( r ) > -1 ) {
1404 match = true; 1404 match = true;
1405 break; 1405 break;
1406 } 1406 }
1407 } 1407 }
1408 return match; 1408 return match;
1409} 1409}
1410 1410
1411 1411
1412// Noch nicht definiert ! :SX
1413QString OContact::toShortText() const 1412QString OContact::toShortText() const
1414{ 1413{
1415 return ( QString::fromLatin1( "Not defined!") ); 1414 return ( fullName() );
1416} 1415}
1417QString OContact::type() const 1416QString OContact::type() const
1418{ 1417{
1419 return QString::fromLatin1( "OContact" ); 1418 return QString::fromLatin1( "OContact" );
1420} 1419}
1421 1420
1422// Noch nicht definiert ! :SX 1421// Definition is missing ! (se)
1423QMap<QString,QString> OContact::toExtraMap() const 1422QMap<QString,QString> OContact::toExtraMap() const
1424{ 1423{
1424 qWarning ("Function not implemented: OContact::toExtraMap()");
1425 QMap <QString,QString> useless; 1425 QMap <QString,QString> useless;
1426 return useless; 1426 return useless;
1427} 1427}
1428 1428
1429// Noch nicht definiert ! :SX 1429class QString OContact::recordField( int pos ) const
1430class QString OContact::recordField(int) const
1431{ 1430{
1432 return QString::fromLatin1( "Noch nicht implementiert !" ); 1431 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1432 return SLFIELDS[pos];
1433} 1433}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index e0555c8..756c87d 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -147,138 +147,141 @@ public:
147 147
148 // business 148 // business
149 QString company() const { return find( Qtopia::Company ); } 149 QString company() const { return find( Qtopia::Company ); }
150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
151 QString businessCity() const { return find( Qtopia::BusinessCity ); } 151 QString businessCity() const { return find( Qtopia::BusinessCity ); }
152 QString businessState() const { return find( Qtopia::BusinessState ); } 152 QString businessState() const { return find( Qtopia::BusinessState ); }
153 QString businessZip() const { return find( Qtopia::BusinessZip ); } 153 QString businessZip() const { return find( Qtopia::BusinessZip ); }
154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
156 QString jobTitle() const { return find( Qtopia::JobTitle ); } 156 QString jobTitle() const { return find( Qtopia::JobTitle ); }
157 QString department() const { return find( Qtopia::Department ); } 157 QString department() const { return find( Qtopia::Department ); }
158 QString office() const { return find( Qtopia::Office ); } 158 QString office() const { return find( Qtopia::Office ); }
159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
160 QString businessFax() const { return find( Qtopia::BusinessFax ); } 160 QString businessFax() const { return find( Qtopia::BusinessFax ); }
161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
162 QString businessPager() const { return find( Qtopia::BusinessPager ); } 162 QString businessPager() const { return find( Qtopia::BusinessPager ); }
163 QString profession() const { return find( Qtopia::Profession ); } 163 QString profession() const { return find( Qtopia::Profession ); }
164 QString assistant() const { return find( Qtopia::Assistant ); } 164 QString assistant() const { return find( Qtopia::Assistant ); }
165 QString manager() const { return find( Qtopia::Manager ); } 165 QString manager() const { return find( Qtopia::Manager ); }
166 /** Multi line string containing all non-empty address info in the form 166 /** Multi line string containing all non-empty address info in the form
167 * Street 167 * Street
168 * City, State Zip 168 * City, State Zip
169 * Country 169 * Country
170 */ 170 */
171 QString displayBusinessAddress() const; 171 QString displayBusinessAddress() const;
172 172
173 //personal 173 //personal
174 QString spouse() const { return find( Qtopia::Spouse ); } 174 QString spouse() const { return find( Qtopia::Spouse ); }
175 QString gender() const { return find( Qtopia::Gender ); } 175 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 176 QString birthday() const { return find( Qtopia::Birthday ); }
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 177 QString anniversary() const { return find( Qtopia::Anniversary ); }
178 QString nickname() const { return find( Qtopia::Nickname ); } 178 QString nickname() const { return find( Qtopia::Nickname ); }
179 QString children() const { return find( Qtopia::Children ); } 179 QString children() const { return find( Qtopia::Children ); }
180 QStringList childrenList() const; 180 QStringList childrenList() const;
181 181
182 // other 182 // other
183 QString notes() const { return find( Qtopia::Notes ); } 183 QString notes() const { return find( Qtopia::Notes ); }
184 QString groups() const { return find( Qtopia::Groups ); } 184 QString groups() const { return find( Qtopia::Groups ); }
185 QStringList groupList() const; 185 QStringList groupList() const;
186 186
187// // custom 187// // custom
188// const QString &customField( const QString &key ) 188// const QString &customField( const QString &key )
189// { return find( Custom- + key ); } 189// { return find( Custom- + key ); }
190 190
191 static QStringList fields(); 191 static QStringList fields();
192 static QStringList trfields(); 192 static QStringList trfields();
193 193
194 QString toRichText() const; 194 QString toRichText() const;
195 QMap<int, QString> toMap() const; 195 QMap<int, QString> toMap() const;
196 QString field( int key ) const { return find( key ); } 196 QString field( int key ) const { return find( key ); }
197 197
198 198
199 // journaling... 199 // journaling...
200 void saveJournal( journal_action action, const QString &key = QString::null ); 200 void saveJournal( journal_action action, const QString &key = QString::null );
201 void save( QString &buf ) const; 201 void save( QString &buf ) const;
202 202
203 void setUid( int i ) 203 void setUid( int i )
204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
205 205
206 QString toShortText()const; 206 QString toShortText()const;
207 QString OContact::type()const; 207 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
210 210
211 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma
214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); }
216
217
211private: 218private:
212 friend class AbEditor; 219 friend class AbEditor;
213 friend class AbTable; 220 friend class AbTable;
214 friend class AddressBookAccessPrivate; 221 friend class AddressBookAccessPrivate;
215 friend class XMLIO; 222 friend class XMLIO;
216 223
217 QString emailSeparator() const { return " "; }
218 // the emails should be seperated by a comma
219 void setEmails( const QString &v );
220 QString emails() const { return find( Qtopia::Emails ); }
221 224
222 void insert( int key, const QString &value ); 225 void insert( int key, const QString &value );
223 void replace( int key, const QString &value ); 226 void replace( int key, const QString &value );
224 QString find( int key ) const; 227 QString find( int key ) const;
225 228
226 QString displayAddress( const QString &street, 229 QString displayAddress( const QString &street,
227 const QString &city, 230 const QString &city,
228 const QString &state, 231 const QString &state,
229 const QString &zip, 232 const QString &zip,
230 const QString &country ) const; 233 const QString &country ) const;
231 234
232 Qtopia::UidGen &uidGen() { return sUidGen; } 235 Qtopia::UidGen &uidGen() { return sUidGen; }
233 static Qtopia::UidGen sUidGen; 236 static Qtopia::UidGen sUidGen;
234 QMap<int, QString> mMap; 237 QMap<int, QString> mMap;
235 ContactPrivate *d; 238 ContactPrivate *d;
236}; 239};
237 240
238// these methods are inlined to keep binary compatability with Qtopia 1.5 241// these methods are inlined to keep binary compatability with Qtopia 1.5
239inline void OContact::insertEmail( const QString &v ) 242inline void OContact::insertEmail( const QString &v )
240{ 243{
241 //qDebug("insertEmail %s", v.latin1()); 244 //qDebug("insertEmail %s", v.latin1());
242 QString e = v.simplifyWhiteSpace(); 245 QString e = v.simplifyWhiteSpace();
243 QString def = defaultEmail(); 246 QString def = defaultEmail();
244 247
245 // if no default, set it as the default email and don't insert 248 // if no default, set it as the default email and don't insert
246 if ( def.isEmpty() ) { 249 if ( def.isEmpty() ) {
247 setDefaultEmail( e ); // will insert into the list for us 250 setDefaultEmail( e ); // will insert into the list for us
248 return; 251 return;
249 } 252 }
250 253
251 // otherwise, insert assuming doesn't already exist 254 // otherwise, insert assuming doesn't already exist
252 QString emailsStr = find( Qtopia::Emails ); 255 QString emailsStr = find( Qtopia::Emails );
253 if ( emailsStr.contains( e )) 256 if ( emailsStr.contains( e ))
254 return; 257 return;
255 if ( !emailsStr.isEmpty() ) 258 if ( !emailsStr.isEmpty() )
256 emailsStr += emailSeparator(); 259 emailsStr += emailSeparator();
257 emailsStr += e; 260 emailsStr += e;
258 replace( Qtopia::Emails, emailsStr ); 261 replace( Qtopia::Emails, emailsStr );
259} 262}
260 263
261inline void OContact::removeEmail( const QString &v ) 264inline void OContact::removeEmail( const QString &v )
262{ 265{
263 QString e = v.simplifyWhiteSpace(); 266 QString e = v.simplifyWhiteSpace();
264 QString def = defaultEmail(); 267 QString def = defaultEmail();
265 QString emailsStr = find( Qtopia::Emails ); 268 QString emailsStr = find( Qtopia::Emails );
266 QStringList emails = emailList(); 269 QStringList emails = emailList();
267 270
268 // otherwise, must first contain it 271 // otherwise, must first contain it
269 if ( !emailsStr.contains( e ) ) 272 if ( !emailsStr.contains( e ) )
270 return; 273 return;
271 274
272 // remove it 275 // remove it
273 //qDebug(" removing email from list %s", e.latin1()); 276 //qDebug(" removing email from list %s", e.latin1());
274 emails.remove( e ); 277 emails.remove( e );
275 // reset the string 278 // reset the string
276 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 279 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
277 replace( Qtopia::Emails, emailsStr ); 280 replace( Qtopia::Emails, emailsStr );
278 281
279 // if default, then replace the default email with the first one 282 // if default, then replace the default email with the first one
280 if ( def == e ) { 283 if ( def == e ) {
281 //qDebug("removeEmail is default; setting new default"); 284 //qDebug("removeEmail is default; setting new default");
282 if ( !emails.count() ) 285 if ( !emails.count() )
283 clearEmails(); 286 clearEmails();
284 else // setDefaultEmail will remove e from the list 287 else // setDefaultEmail will remove e from the list
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 66632f5..828a9de 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1348,86 +1348,86 @@ void OContact::writeVCard( const QString &filename, const OContact &contact)
1348 if ( !f.open( IO_WriteOnly ) ) { 1348 if ( !f.open( IO_WriteOnly ) ) {
1349 qWarning("Unable to open vcard write"); 1349 qWarning("Unable to open vcard write");
1350 return; 1350 return;
1351 } 1351 }
1352 1352
1353 VObject *obj = createVObject( contact ); 1353 VObject *obj = createVObject( contact );
1354 writeVObject( f.directHandle() , obj ); 1354 writeVObject( f.directHandle() , obj );
1355 cleanVObject( obj ); 1355 cleanVObject( obj );
1356 1356
1357 cleanStrTbl(); 1357 cleanStrTbl();
1358} 1358}
1359 1359
1360/*! 1360/*!
1361 Returns the set of contacts read as VCards from the file \a filename. 1361 Returns the set of contacts read as VCards from the file \a filename.
1362*/ 1362*/
1363QValueList<OContact> OContact::readVCard( const QString &filename ) 1363QValueList<OContact> OContact::readVCard( const QString &filename )
1364{ 1364{
1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1367 1367
1368 qDebug("vobject = %p", obj ); 1368 qDebug("vobject = %p", obj );
1369 1369
1370 QValueList<OContact> contacts; 1370 QValueList<OContact> contacts;
1371 1371
1372 while ( obj ) { 1372 while ( obj ) {
1373 contacts.append( parseVObject( obj ) ); 1373 contacts.append( parseVObject( obj ) );
1374 1374
1375 VObject *t = obj; 1375 VObject *t = obj;
1376 obj = nextVObjectInList(obj); 1376 obj = nextVObjectInList(obj);
1377 cleanVObject( t ); 1377 cleanVObject( t );
1378 } 1378 }
1379 1379
1380 return contacts; 1380 return contacts;
1381} 1381}
1382 1382
1383/*! 1383/*!
1384 Returns TRUE if the contact matches the regular expression \a regexp. 1384 Returns TRUE if the contact matches the regular expression \a regexp.
1385 Otherwise returns FALSE. 1385 Otherwise returns FALSE.
1386*/ 1386*/
1387bool OContact::match( const QString &regexp ) const 1387bool OContact::match( const QString &regexp ) const
1388{ 1388{
1389 return match(QRegExp(regexp)); 1389 return match(QRegExp(regexp));
1390} 1390}
1391 1391
1392/*! 1392/*!
1393 \overload 1393 \overload
1394 Returns TRUE if the contact matches the regular expression \a regexp. 1394 Returns TRUE if the contact matches the regular expression \a regexp.
1395 Otherwise returns FALSE. 1395 Otherwise returns FALSE.
1396*/ 1396*/
1397bool OContact::match( const QRegExp &r ) const 1397bool OContact::match( const QRegExp &r ) const
1398{ 1398{
1399 bool match; 1399 bool match;
1400 match = false; 1400 match = false;
1401 QMap<int, QString>::ConstIterator it; 1401 QMap<int, QString>::ConstIterator it;
1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
1403 if ( (*it).find( r ) > -1 ) { 1403 if ( (*it).find( r ) > -1 ) {
1404 match = true; 1404 match = true;
1405 break; 1405 break;
1406 } 1406 }
1407 } 1407 }
1408 return match; 1408 return match;
1409} 1409}
1410 1410
1411 1411
1412// Noch nicht definiert ! :SX
1413QString OContact::toShortText() const 1412QString OContact::toShortText() const
1414{ 1413{
1415 return ( QString::fromLatin1( "Not defined!") ); 1414 return ( fullName() );
1416} 1415}
1417QString OContact::type() const 1416QString OContact::type() const
1418{ 1417{
1419 return QString::fromLatin1( "OContact" ); 1418 return QString::fromLatin1( "OContact" );
1420} 1419}
1421 1420
1422// Noch nicht definiert ! :SX 1421// Definition is missing ! (se)
1423QMap<QString,QString> OContact::toExtraMap() const 1422QMap<QString,QString> OContact::toExtraMap() const
1424{ 1423{
1424 qWarning ("Function not implemented: OContact::toExtraMap()");
1425 QMap <QString,QString> useless; 1425 QMap <QString,QString> useless;
1426 return useless; 1426 return useless;
1427} 1427}
1428 1428
1429// Noch nicht definiert ! :SX 1429class QString OContact::recordField( int pos ) const
1430class QString OContact::recordField(int) const
1431{ 1430{
1432 return QString::fromLatin1( "Noch nicht implementiert !" ); 1431 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1432 return SLFIELDS[pos];
1433} 1433}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index e0555c8..756c87d 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -147,138 +147,141 @@ public:
147 147
148 // business 148 // business
149 QString company() const { return find( Qtopia::Company ); } 149 QString company() const { return find( Qtopia::Company ); }
150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
151 QString businessCity() const { return find( Qtopia::BusinessCity ); } 151 QString businessCity() const { return find( Qtopia::BusinessCity ); }
152 QString businessState() const { return find( Qtopia::BusinessState ); } 152 QString businessState() const { return find( Qtopia::BusinessState ); }
153 QString businessZip() const { return find( Qtopia::BusinessZip ); } 153 QString businessZip() const { return find( Qtopia::BusinessZip ); }
154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
156 QString jobTitle() const { return find( Qtopia::JobTitle ); } 156 QString jobTitle() const { return find( Qtopia::JobTitle ); }
157 QString department() const { return find( Qtopia::Department ); } 157 QString department() const { return find( Qtopia::Department ); }
158 QString office() const { return find( Qtopia::Office ); } 158 QString office() const { return find( Qtopia::Office ); }
159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
160 QString businessFax() const { return find( Qtopia::BusinessFax ); } 160 QString businessFax() const { return find( Qtopia::BusinessFax ); }
161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
162 QString businessPager() const { return find( Qtopia::BusinessPager ); } 162 QString businessPager() const { return find( Qtopia::BusinessPager ); }
163 QString profession() const { return find( Qtopia::Profession ); } 163 QString profession() const { return find( Qtopia::Profession ); }
164 QString assistant() const { return find( Qtopia::Assistant ); } 164 QString assistant() const { return find( Qtopia::Assistant ); }
165 QString manager() const { return find( Qtopia::Manager ); } 165 QString manager() const { return find( Qtopia::Manager ); }
166 /** Multi line string containing all non-empty address info in the form 166 /** Multi line string containing all non-empty address info in the form
167 * Street 167 * Street
168 * City, State Zip 168 * City, State Zip
169 * Country 169 * Country
170 */ 170 */
171 QString displayBusinessAddress() const; 171 QString displayBusinessAddress() const;
172 172
173 //personal 173 //personal
174 QString spouse() const { return find( Qtopia::Spouse ); } 174 QString spouse() const { return find( Qtopia::Spouse ); }
175 QString gender() const { return find( Qtopia::Gender ); } 175 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 176 QString birthday() const { return find( Qtopia::Birthday ); }
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 177 QString anniversary() const { return find( Qtopia::Anniversary ); }
178 QString nickname() const { return find( Qtopia::Nickname ); } 178 QString nickname() const { return find( Qtopia::Nickname ); }
179 QString children() const { return find( Qtopia::Children ); } 179 QString children() const { return find( Qtopia::Children ); }
180 QStringList childrenList() const; 180 QStringList childrenList() const;
181 181
182 // other 182 // other
183 QString notes() const { return find( Qtopia::Notes ); } 183 QString notes() const { return find( Qtopia::Notes ); }
184 QString groups() const { return find( Qtopia::Groups ); } 184 QString groups() const { return find( Qtopia::Groups ); }
185 QStringList groupList() const; 185 QStringList groupList() const;
186 186
187// // custom 187// // custom
188// const QString &customField( const QString &key ) 188// const QString &customField( const QString &key )
189// { return find( Custom- + key ); } 189// { return find( Custom- + key ); }
190 190
191 static QStringList fields(); 191 static QStringList fields();
192 static QStringList trfields(); 192 static QStringList trfields();
193 193
194 QString toRichText() const; 194 QString toRichText() const;
195 QMap<int, QString> toMap() const; 195 QMap<int, QString> toMap() const;
196 QString field( int key ) const { return find( key ); } 196 QString field( int key ) const { return find( key ); }
197 197
198 198
199 // journaling... 199 // journaling...
200 void saveJournal( journal_action action, const QString &key = QString::null ); 200 void saveJournal( journal_action action, const QString &key = QString::null );
201 void save( QString &buf ) const; 201 void save( QString &buf ) const;
202 202
203 void setUid( int i ) 203 void setUid( int i )
204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
205 205
206 QString toShortText()const; 206 QString toShortText()const;
207 QString OContact::type()const; 207 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
210 210
211 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma
214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); }
216
217
211private: 218private:
212 friend class AbEditor; 219 friend class AbEditor;
213 friend class AbTable; 220 friend class AbTable;
214 friend class AddressBookAccessPrivate; 221 friend class AddressBookAccessPrivate;
215 friend class XMLIO; 222 friend class XMLIO;
216 223
217 QString emailSeparator() const { return " "; }
218 // the emails should be seperated by a comma
219 void setEmails( const QString &v );
220 QString emails() const { return find( Qtopia::Emails ); }
221 224
222 void insert( int key, const QString &value ); 225 void insert( int key, const QString &value );
223 void replace( int key, const QString &value ); 226 void replace( int key, const QString &value );
224 QString find( int key ) const; 227 QString find( int key ) const;
225 228
226 QString displayAddress( const QString &street, 229 QString displayAddress( const QString &street,
227 const QString &city, 230 const QString &city,
228 const QString &state, 231 const QString &state,
229 const QString &zip, 232 const QString &zip,
230 const QString &country ) const; 233 const QString &country ) const;
231 234
232 Qtopia::UidGen &uidGen() { return sUidGen; } 235 Qtopia::UidGen &uidGen() { return sUidGen; }
233 static Qtopia::UidGen sUidGen; 236 static Qtopia::UidGen sUidGen;
234 QMap<int, QString> mMap; 237 QMap<int, QString> mMap;
235 ContactPrivate *d; 238 ContactPrivate *d;
236}; 239};
237 240
238// these methods are inlined to keep binary compatability with Qtopia 1.5 241// these methods are inlined to keep binary compatability with Qtopia 1.5
239inline void OContact::insertEmail( const QString &v ) 242inline void OContact::insertEmail( const QString &v )
240{ 243{
241 //qDebug("insertEmail %s", v.latin1()); 244 //qDebug("insertEmail %s", v.latin1());
242 QString e = v.simplifyWhiteSpace(); 245 QString e = v.simplifyWhiteSpace();
243 QString def = defaultEmail(); 246 QString def = defaultEmail();
244 247
245 // if no default, set it as the default email and don't insert 248 // if no default, set it as the default email and don't insert
246 if ( def.isEmpty() ) { 249 if ( def.isEmpty() ) {
247 setDefaultEmail( e ); // will insert into the list for us 250 setDefaultEmail( e ); // will insert into the list for us
248 return; 251 return;
249 } 252 }
250 253
251 // otherwise, insert assuming doesn't already exist 254 // otherwise, insert assuming doesn't already exist
252 QString emailsStr = find( Qtopia::Emails ); 255 QString emailsStr = find( Qtopia::Emails );
253 if ( emailsStr.contains( e )) 256 if ( emailsStr.contains( e ))
254 return; 257 return;
255 if ( !emailsStr.isEmpty() ) 258 if ( !emailsStr.isEmpty() )
256 emailsStr += emailSeparator(); 259 emailsStr += emailSeparator();
257 emailsStr += e; 260 emailsStr += e;
258 replace( Qtopia::Emails, emailsStr ); 261 replace( Qtopia::Emails, emailsStr );
259} 262}
260 263
261inline void OContact::removeEmail( const QString &v ) 264inline void OContact::removeEmail( const QString &v )
262{ 265{
263 QString e = v.simplifyWhiteSpace(); 266 QString e = v.simplifyWhiteSpace();
264 QString def = defaultEmail(); 267 QString def = defaultEmail();
265 QString emailsStr = find( Qtopia::Emails ); 268 QString emailsStr = find( Qtopia::Emails );
266 QStringList emails = emailList(); 269 QStringList emails = emailList();
267 270
268 // otherwise, must first contain it 271 // otherwise, must first contain it
269 if ( !emailsStr.contains( e ) ) 272 if ( !emailsStr.contains( e ) )
270 return; 273 return;
271 274
272 // remove it 275 // remove it
273 //qDebug(" removing email from list %s", e.latin1()); 276 //qDebug(" removing email from list %s", e.latin1());
274 emails.remove( e ); 277 emails.remove( e );
275 // reset the string 278 // reset the string
276 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 279 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
277 replace( Qtopia::Emails, emailsStr ); 280 replace( Qtopia::Emails, emailsStr );
278 281
279 // if default, then replace the default email with the first one 282 // if default, then replace the default email with the first one
280 if ( def == e ) { 283 if ( def == e ) {
281 //qDebug("removeEmail is default; setting new default"); 284 //qDebug("removeEmail is default; setting new default");
282 if ( !emails.count() ) 285 if ( !emails.count() )
283 clearEmails(); 286 clearEmails();
284 else // setDefaultEmail will remove e from the list 287 else // setDefaultEmail will remove e from the list