summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-10-29 23:13:22 (UTC)
committer zautrix <zautrix>2004-10-29 23:13:22 (UTC)
commitda80b510e4643fa3f78cf3f97af108e87097583d (patch) (unidiff)
tree01c328362a6bf1898853ba26fd5d48eb5cff1e27 /kabc
parentaafa695508796e86e9f267633ea5e6965d876031 (diff)
downloadkdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.zip
kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.gz
kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.bz2
added better category handling to kapi
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/field.cpp6
3 files changed, 11 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index eec0f1f..3ce733d 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1231,903 +1231,907 @@ Picture Addressee::photo() const
1231QString Addressee::photoLabel() 1231QString Addressee::photoLabel()
1232{ 1232{
1233 return i18n("Photo"); 1233 return i18n("Photo");
1234} 1234}
1235 1235
1236 1236
1237void Addressee::setSound( const Sound &sound ) 1237void Addressee::setSound( const Sound &sound )
1238{ 1238{
1239 if ( sound == mData->sound ) return; 1239 if ( sound == mData->sound ) return;
1240 detach(); 1240 detach();
1241 mData->empty = false; 1241 mData->empty = false;
1242 mData->sound = sound; 1242 mData->sound = sound;
1243} 1243}
1244 1244
1245Sound Addressee::sound() const 1245Sound Addressee::sound() const
1246{ 1246{
1247 return mData->sound; 1247 return mData->sound;
1248} 1248}
1249 1249
1250QString Addressee::soundLabel() 1250QString Addressee::soundLabel()
1251{ 1251{
1252 return i18n("Sound"); 1252 return i18n("Sound");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setAgent( const Agent &agent ) 1256void Addressee::setAgent( const Agent &agent )
1257{ 1257{
1258 if ( agent == mData->agent ) return; 1258 if ( agent == mData->agent ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->agent = agent; 1261 mData->agent = agent;
1262} 1262}
1263 1263
1264Agent Addressee::agent() const 1264Agent Addressee::agent() const
1265{ 1265{
1266 return mData->agent; 1266 return mData->agent;
1267} 1267}
1268 1268
1269QString Addressee::agentLabel() 1269QString Addressee::agentLabel()
1270{ 1270{
1271 return i18n("Agent"); 1271 return i18n("Agent");
1272} 1272}
1273 1273
1274 1274
1275 1275
1276void Addressee::setNameFromString( const QString &str ) 1276void Addressee::setNameFromString( const QString &str )
1277{ 1277{
1278 setFormattedName( str ); 1278 setFormattedName( str );
1279 setName( str ); 1279 setName( str );
1280 1280
1281 static bool first = true; 1281 static bool first = true;
1282 static QStringList titles; 1282 static QStringList titles;
1283 static QStringList suffixes; 1283 static QStringList suffixes;
1284 static QStringList prefixes; 1284 static QStringList prefixes;
1285 1285
1286 if ( first ) { 1286 if ( first ) {
1287 first = false; 1287 first = false;
1288 titles += i18n( "Dr." ); 1288 titles += i18n( "Dr." );
1289 titles += i18n( "Miss" ); 1289 titles += i18n( "Miss" );
1290 titles += i18n( "Mr." ); 1290 titles += i18n( "Mr." );
1291 titles += i18n( "Mrs." ); 1291 titles += i18n( "Mrs." );
1292 titles += i18n( "Ms." ); 1292 titles += i18n( "Ms." );
1293 titles += i18n( "Prof." ); 1293 titles += i18n( "Prof." );
1294 1294
1295 suffixes += i18n( "I" ); 1295 suffixes += i18n( "I" );
1296 suffixes += i18n( "II" ); 1296 suffixes += i18n( "II" );
1297 suffixes += i18n( "III" ); 1297 suffixes += i18n( "III" );
1298 suffixes += i18n( "Jr." ); 1298 suffixes += i18n( "Jr." );
1299 suffixes += i18n( "Sr." ); 1299 suffixes += i18n( "Sr." );
1300 1300
1301 prefixes += "van"; 1301 prefixes += "van";
1302 prefixes += "von"; 1302 prefixes += "von";
1303 prefixes += "de"; 1303 prefixes += "de";
1304 1304
1305 KConfig config( locateLocal( "config", "kabcrc") ); 1305 KConfig config( locateLocal( "config", "kabcrc") );
1306 config.setGroup( "General" ); 1306 config.setGroup( "General" );
1307 titles += config.readListEntry( "Prefixes" ); 1307 titles += config.readListEntry( "Prefixes" );
1308 titles.remove( "" ); 1308 titles.remove( "" );
1309 prefixes += config.readListEntry( "Inclusions" ); 1309 prefixes += config.readListEntry( "Inclusions" );
1310 prefixes.remove( "" ); 1310 prefixes.remove( "" );
1311 suffixes += config.readListEntry( "Suffixes" ); 1311 suffixes += config.readListEntry( "Suffixes" );
1312 suffixes.remove( "" ); 1312 suffixes.remove( "" );
1313 } 1313 }
1314 1314
1315 // clear all name parts 1315 // clear all name parts
1316 setPrefix( "" ); 1316 setPrefix( "" );
1317 setGivenName( "" ); 1317 setGivenName( "" );
1318 setAdditionalName( "" ); 1318 setAdditionalName( "" );
1319 setFamilyName( "" ); 1319 setFamilyName( "" );
1320 setSuffix( "" ); 1320 setSuffix( "" );
1321 1321
1322 if ( str.isEmpty() ) 1322 if ( str.isEmpty() )
1323 return; 1323 return;
1324 1324
1325 int i = str.find(','); 1325 int i = str.find(',');
1326 if( i < 0 ) { 1326 if( i < 0 ) {
1327 QStringList parts = QStringList::split( " ", str ); 1327 QStringList parts = QStringList::split( " ", str );
1328 int leftOffset = 0; 1328 int leftOffset = 0;
1329 int rightOffset = parts.count() - 1; 1329 int rightOffset = parts.count() - 1;
1330 1330
1331 QString suffix; 1331 QString suffix;
1332 while ( rightOffset >= 0 ) { 1332 while ( rightOffset >= 0 ) {
1333 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1333 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1334 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1334 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1335 rightOffset--; 1335 rightOffset--;
1336 } else 1336 } else
1337 break; 1337 break;
1338 } 1338 }
1339 setSuffix( suffix ); 1339 setSuffix( suffix );
1340 1340
1341 if ( rightOffset < 0 ) 1341 if ( rightOffset < 0 )
1342 return; 1342 return;
1343 1343
1344 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1344 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1345 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1345 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1346 rightOffset--; 1346 rightOffset--;
1347 } else 1347 } else
1348 setFamilyName( parts[ rightOffset ] ); 1348 setFamilyName( parts[ rightOffset ] );
1349 1349
1350 QString prefix; 1350 QString prefix;
1351 while ( leftOffset < rightOffset ) { 1351 while ( leftOffset < rightOffset ) {
1352 if ( titles.contains( parts[ leftOffset ] ) ) { 1352 if ( titles.contains( parts[ leftOffset ] ) ) {
1353 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1353 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1354 leftOffset++; 1354 leftOffset++;
1355 } else 1355 } else
1356 break; 1356 break;
1357 } 1357 }
1358 setPrefix( prefix ); 1358 setPrefix( prefix );
1359 1359
1360 if ( leftOffset < rightOffset ) { 1360 if ( leftOffset < rightOffset ) {
1361 setGivenName( parts[ leftOffset ] ); 1361 setGivenName( parts[ leftOffset ] );
1362 leftOffset++; 1362 leftOffset++;
1363 } 1363 }
1364 1364
1365 QString additionalName; 1365 QString additionalName;
1366 while ( leftOffset < rightOffset ) { 1366 while ( leftOffset < rightOffset ) {
1367 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1367 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1368 leftOffset++; 1368 leftOffset++;
1369 } 1369 }
1370 setAdditionalName( additionalName ); 1370 setAdditionalName( additionalName );
1371 } else { 1371 } else {
1372 QString part1 = str.left( i ); 1372 QString part1 = str.left( i );
1373 QString part2 = str.mid( i + 1 ); 1373 QString part2 = str.mid( i + 1 );
1374 1374
1375 QStringList parts = QStringList::split( " ", part1 ); 1375 QStringList parts = QStringList::split( " ", part1 );
1376 int leftOffset = 0; 1376 int leftOffset = 0;
1377 int rightOffset = parts.count() - 1; 1377 int rightOffset = parts.count() - 1;
1378 1378
1379 QString suffix; 1379 QString suffix;
1380 while ( rightOffset >= 0 ) { 1380 while ( rightOffset >= 0 ) {
1381 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1381 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1382 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1382 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1383 rightOffset--; 1383 rightOffset--;
1384 } else 1384 } else
1385 break; 1385 break;
1386 } 1386 }
1387 setSuffix( suffix ); 1387 setSuffix( suffix );
1388 1388
1389 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1389 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1390 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1390 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1391 rightOffset--; 1391 rightOffset--;
1392 } else 1392 } else
1393 setFamilyName( parts[ rightOffset ] ); 1393 setFamilyName( parts[ rightOffset ] );
1394 1394
1395 QString prefix; 1395 QString prefix;
1396 while ( leftOffset < rightOffset ) { 1396 while ( leftOffset < rightOffset ) {
1397 if ( titles.contains( parts[ leftOffset ] ) ) { 1397 if ( titles.contains( parts[ leftOffset ] ) ) {
1398 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1398 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1399 leftOffset++; 1399 leftOffset++;
1400 } else 1400 } else
1401 break; 1401 break;
1402 } 1402 }
1403 1403
1404 parts = QStringList::split( " ", part2 ); 1404 parts = QStringList::split( " ", part2 );
1405 1405
1406 leftOffset = 0; 1406 leftOffset = 0;
1407 rightOffset = parts.count(); 1407 rightOffset = parts.count();
1408 1408
1409 while ( leftOffset < rightOffset ) { 1409 while ( leftOffset < rightOffset ) {
1410 if ( titles.contains( parts[ leftOffset ] ) ) { 1410 if ( titles.contains( parts[ leftOffset ] ) ) {
1411 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1411 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1412 leftOffset++; 1412 leftOffset++;
1413 } else 1413 } else
1414 break; 1414 break;
1415 } 1415 }
1416 setPrefix( prefix ); 1416 setPrefix( prefix );
1417 1417
1418 if ( leftOffset < rightOffset ) { 1418 if ( leftOffset < rightOffset ) {
1419 setGivenName( parts[ leftOffset ] ); 1419 setGivenName( parts[ leftOffset ] );
1420 leftOffset++; 1420 leftOffset++;
1421 } 1421 }
1422 1422
1423 QString additionalName; 1423 QString additionalName;
1424 while ( leftOffset < rightOffset ) { 1424 while ( leftOffset < rightOffset ) {
1425 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1425 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1426 leftOffset++; 1426 leftOffset++;
1427 } 1427 }
1428 setAdditionalName( additionalName ); 1428 setAdditionalName( additionalName );
1429 } 1429 }
1430} 1430}
1431 1431
1432QString Addressee::realName() const 1432QString Addressee::realName() const
1433{ 1433{
1434 if ( !formattedName().isEmpty() ) 1434 if ( !formattedName().isEmpty() )
1435 return formattedName(); 1435 return formattedName();
1436 1436
1437 QString n = assembledName(); 1437 QString n = assembledName();
1438 1438
1439 if ( n.isEmpty() ) 1439 if ( n.isEmpty() )
1440 n = name(); 1440 n = name();
1441 1441
1442 return n; 1442 return n;
1443} 1443}
1444 1444
1445QString Addressee::assembledName() const 1445QString Addressee::assembledName() const
1446{ 1446{
1447 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1447 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1448 familyName() + " " + suffix(); 1448 familyName() + " " + suffix();
1449 1449
1450 return name.simplifyWhiteSpace(); 1450 return name.simplifyWhiteSpace();
1451} 1451}
1452 1452
1453QString Addressee::fullEmail( const QString &email ) const 1453QString Addressee::fullEmail( const QString &email ) const
1454{ 1454{
1455 QString e; 1455 QString e;
1456 if ( email.isNull() ) { 1456 if ( email.isNull() ) {
1457 e = preferredEmail(); 1457 e = preferredEmail();
1458 } else { 1458 } else {
1459 e = email; 1459 e = email;
1460 } 1460 }
1461 if ( e.isEmpty() ) return QString::null; 1461 if ( e.isEmpty() ) return QString::null;
1462 1462
1463 QString text; 1463 QString text;
1464 if ( realName().isEmpty() ) 1464 if ( realName().isEmpty() )
1465 text = e; 1465 text = e;
1466 else 1466 else
1467 text = assembledName() + " <" + e + ">"; 1467 text = assembledName() + " <" + e + ">";
1468 1468
1469 return text; 1469 return text;
1470} 1470}
1471 1471
1472void Addressee::insertEmail( const QString &email, bool preferred ) 1472void Addressee::insertEmail( const QString &email, bool preferred )
1473{ 1473{
1474 detach(); 1474 detach();
1475 1475
1476 QStringList::Iterator it = mData->emails.find( email ); 1476 QStringList::Iterator it = mData->emails.find( email );
1477 1477
1478 if ( it != mData->emails.end() ) { 1478 if ( it != mData->emails.end() ) {
1479 if ( !preferred || it == mData->emails.begin() ) return; 1479 if ( !preferred || it == mData->emails.begin() ) return;
1480 mData->emails.remove( it ); 1480 mData->emails.remove( it );
1481 mData->emails.prepend( email ); 1481 mData->emails.prepend( email );
1482 } else { 1482 } else {
1483 if ( preferred ) { 1483 if ( preferred ) {
1484 mData->emails.prepend( email ); 1484 mData->emails.prepend( email );
1485 } else { 1485 } else {
1486 mData->emails.append( email ); 1486 mData->emails.append( email );
1487 } 1487 }
1488 } 1488 }
1489} 1489}
1490 1490
1491void Addressee::removeEmail( const QString &email ) 1491void Addressee::removeEmail( const QString &email )
1492{ 1492{
1493 detach(); 1493 detach();
1494 1494
1495 QStringList::Iterator it = mData->emails.find( email ); 1495 QStringList::Iterator it = mData->emails.find( email );
1496 if ( it == mData->emails.end() ) return; 1496 if ( it == mData->emails.end() ) return;
1497 1497
1498 mData->emails.remove( it ); 1498 mData->emails.remove( it );
1499} 1499}
1500 1500
1501QString Addressee::preferredEmail() const 1501QString Addressee::preferredEmail() const
1502{ 1502{
1503 if ( mData->emails.count() == 0 ) return QString::null; 1503 if ( mData->emails.count() == 0 ) return QString::null;
1504 else return mData->emails.first(); 1504 else return mData->emails.first();
1505} 1505}
1506 1506
1507QStringList Addressee::emails() const 1507QStringList Addressee::emails() const
1508{ 1508{
1509 return mData->emails; 1509 return mData->emails;
1510} 1510}
1511void Addressee::setEmails( const QStringList& emails ) { 1511void Addressee::setEmails( const QStringList& emails ) {
1512 detach(); 1512 detach();
1513 mData->emails = emails; 1513 mData->emails = emails;
1514} 1514}
1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1516{ 1516{
1517 detach(); 1517 detach();
1518 mData->empty = false; 1518 mData->empty = false;
1519 1519
1520 PhoneNumber::List::Iterator it; 1520 PhoneNumber::List::Iterator it;
1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1522 if ( (*it).id() == phoneNumber.id() ) { 1522 if ( (*it).id() == phoneNumber.id() ) {
1523 *it = phoneNumber; 1523 *it = phoneNumber;
1524 return; 1524 return;
1525 } 1525 }
1526 } 1526 }
1527 mData->phoneNumbers.append( phoneNumber ); 1527 mData->phoneNumbers.append( phoneNumber );
1528} 1528}
1529 1529
1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1531{ 1531{
1532 detach(); 1532 detach();
1533 1533
1534 PhoneNumber::List::Iterator it; 1534 PhoneNumber::List::Iterator it;
1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1536 if ( (*it).id() == phoneNumber.id() ) { 1536 if ( (*it).id() == phoneNumber.id() ) {
1537 mData->phoneNumbers.remove( it ); 1537 mData->phoneNumbers.remove( it );
1538 return; 1538 return;
1539 } 1539 }
1540 } 1540 }
1541} 1541}
1542 1542
1543PhoneNumber Addressee::phoneNumber( int type ) const 1543PhoneNumber Addressee::phoneNumber( int type ) const
1544{ 1544{
1545 PhoneNumber phoneNumber( "", type ); 1545 PhoneNumber phoneNumber( "", type );
1546 PhoneNumber::List::ConstIterator it; 1546 PhoneNumber::List::ConstIterator it;
1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1548 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1548 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1549 if ( (*it).type() & PhoneNumber::Pref ) 1549 if ( (*it).type() & PhoneNumber::Pref )
1550 return (*it); 1550 return (*it);
1551 else if ( phoneNumber.number().isEmpty() ) 1551 else if ( phoneNumber.number().isEmpty() )
1552 phoneNumber = (*it); 1552 phoneNumber = (*it);
1553 } 1553 }
1554 } 1554 }
1555 1555
1556 return phoneNumber; 1556 return phoneNumber;
1557} 1557}
1558 1558
1559PhoneNumber::List Addressee::phoneNumbers() const 1559PhoneNumber::List Addressee::phoneNumbers() const
1560{ 1560{
1561 return mData->phoneNumbers; 1561 return mData->phoneNumbers;
1562} 1562}
1563 1563
1564PhoneNumber::List Addressee::phoneNumbers( int type ) const 1564PhoneNumber::List Addressee::phoneNumbers( int type ) const
1565{ 1565{
1566 PhoneNumber::List list; 1566 PhoneNumber::List list;
1567 1567
1568 PhoneNumber::List::ConstIterator it; 1568 PhoneNumber::List::ConstIterator it;
1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1570 if ( matchBinaryPattern( (*it).type(), type ) ) { 1570 if ( matchBinaryPattern( (*it).type(), type ) ) {
1571 list.append( *it ); 1571 list.append( *it );
1572 } 1572 }
1573 } 1573 }
1574 return list; 1574 return list;
1575} 1575}
1576 1576
1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1578{ 1578{
1579 PhoneNumber::List::ConstIterator it; 1579 PhoneNumber::List::ConstIterator it;
1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1581 if ( (*it).id() == id ) { 1581 if ( (*it).id() == id ) {
1582 return *it; 1582 return *it;
1583 } 1583 }
1584 } 1584 }
1585 return PhoneNumber(); 1585 return PhoneNumber();
1586} 1586}
1587 1587
1588void Addressee::insertKey( const Key &key ) 1588void Addressee::insertKey( const Key &key )
1589{ 1589{
1590 detach(); 1590 detach();
1591 mData->empty = false; 1591 mData->empty = false;
1592 1592
1593 Key::List::Iterator it; 1593 Key::List::Iterator it;
1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1595 if ( (*it).id() == key.id() ) { 1595 if ( (*it).id() == key.id() ) {
1596 *it = key; 1596 *it = key;
1597 return; 1597 return;
1598 } 1598 }
1599 } 1599 }
1600 mData->keys.append( key ); 1600 mData->keys.append( key );
1601} 1601}
1602 1602
1603void Addressee::removeKey( const Key &key ) 1603void Addressee::removeKey( const Key &key )
1604{ 1604{
1605 detach(); 1605 detach();
1606 1606
1607 Key::List::Iterator it; 1607 Key::List::Iterator it;
1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1609 if ( (*it).id() == key.id() ) { 1609 if ( (*it).id() == key.id() ) {
1610 mData->keys.remove( key ); 1610 mData->keys.remove( key );
1611 return; 1611 return;
1612 } 1612 }
1613 } 1613 }
1614} 1614}
1615 1615
1616Key Addressee::key( int type, QString customTypeString ) const 1616Key Addressee::key( int type, QString customTypeString ) const
1617{ 1617{
1618 Key::List::ConstIterator it; 1618 Key::List::ConstIterator it;
1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1620 if ( (*it).type() == type ) { 1620 if ( (*it).type() == type ) {
1621 if ( type == Key::Custom ) { 1621 if ( type == Key::Custom ) {
1622 if ( customTypeString.isEmpty() ) { 1622 if ( customTypeString.isEmpty() ) {
1623 return *it; 1623 return *it;
1624 } else { 1624 } else {
1625 if ( (*it).customTypeString() == customTypeString ) 1625 if ( (*it).customTypeString() == customTypeString )
1626 return (*it); 1626 return (*it);
1627 } 1627 }
1628 } else { 1628 } else {
1629 return *it; 1629 return *it;
1630 } 1630 }
1631 } 1631 }
1632 } 1632 }
1633 return Key( QString(), type ); 1633 return Key( QString(), type );
1634} 1634}
1635void Addressee::setKeys( const Key::List& list ) { 1635void Addressee::setKeys( const Key::List& list ) {
1636 detach(); 1636 detach();
1637 mData->keys = list; 1637 mData->keys = list;
1638} 1638}
1639 1639
1640Key::List Addressee::keys() const 1640Key::List Addressee::keys() const
1641{ 1641{
1642 return mData->keys; 1642 return mData->keys;
1643} 1643}
1644 1644
1645Key::List Addressee::keys( int type, QString customTypeString ) const 1645Key::List Addressee::keys( int type, QString customTypeString ) const
1646{ 1646{
1647 Key::List list; 1647 Key::List list;
1648 1648
1649 Key::List::ConstIterator it; 1649 Key::List::ConstIterator it;
1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1651 if ( (*it).type() == type ) { 1651 if ( (*it).type() == type ) {
1652 if ( type == Key::Custom ) { 1652 if ( type == Key::Custom ) {
1653 if ( customTypeString.isEmpty() ) { 1653 if ( customTypeString.isEmpty() ) {
1654 list.append(*it); 1654 list.append(*it);
1655 } else { 1655 } else {
1656 if ( (*it).customTypeString() == customTypeString ) 1656 if ( (*it).customTypeString() == customTypeString )
1657 list.append(*it); 1657 list.append(*it);
1658 } 1658 }
1659 } else { 1659 } else {
1660 list.append(*it); 1660 list.append(*it);
1661 } 1661 }
1662 } 1662 }
1663 } 1663 }
1664 return list; 1664 return list;
1665} 1665}
1666 1666
1667Key Addressee::findKey( const QString &id ) const 1667Key Addressee::findKey( const QString &id ) const
1668{ 1668{
1669 Key::List::ConstIterator it; 1669 Key::List::ConstIterator it;
1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1671 if ( (*it).id() == id ) { 1671 if ( (*it).id() == id ) {
1672 return *it; 1672 return *it;
1673 } 1673 }
1674 } 1674 }
1675 return Key(); 1675 return Key();
1676} 1676}
1677 1677
1678QString Addressee::asString() const 1678QString Addressee::asString() const
1679{ 1679{
1680 return "Smith, agent Smith..."; 1680 return "Smith, agent Smith...";
1681} 1681}
1682 1682
1683void Addressee::dump() const 1683void Addressee::dump() const
1684{ 1684{
1685 return; 1685 return;
1686 kdDebug(5700) << "Addressee {" << endl; 1686 kdDebug(5700) << "Addressee {" << endl;
1687 1687
1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1689 1689
1690 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1690 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1702 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1702 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1703 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1703 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1705 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1705 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1715 1715
1716 kdDebug(5700) << " Emails {" << endl; 1716 kdDebug(5700) << " Emails {" << endl;
1717 QStringList e = emails(); 1717 QStringList e = emails();
1718 QStringList::ConstIterator it; 1718 QStringList::ConstIterator it;
1719 for( it = e.begin(); it != e.end(); ++it ) { 1719 for( it = e.begin(); it != e.end(); ++it ) {
1720 kdDebug(5700) << " " << (*it) << endl; 1720 kdDebug(5700) << " " << (*it) << endl;
1721 } 1721 }
1722 kdDebug(5700) << " }" << endl; 1722 kdDebug(5700) << " }" << endl;
1723 1723
1724 kdDebug(5700) << " PhoneNumbers {" << endl; 1724 kdDebug(5700) << " PhoneNumbers {" << endl;
1725 PhoneNumber::List p = phoneNumbers(); 1725 PhoneNumber::List p = phoneNumbers();
1726 PhoneNumber::List::ConstIterator it2; 1726 PhoneNumber::List::ConstIterator it2;
1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1729 } 1729 }
1730 kdDebug(5700) << " }" << endl; 1730 kdDebug(5700) << " }" << endl;
1731 1731
1732 Address::List a = addresses(); 1732 Address::List a = addresses();
1733 Address::List::ConstIterator it3; 1733 Address::List::ConstIterator it3;
1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1735 (*it3).dump(); 1735 (*it3).dump();
1736 } 1736 }
1737 1737
1738 kdDebug(5700) << " Keys {" << endl; 1738 kdDebug(5700) << " Keys {" << endl;
1739 Key::List k = keys(); 1739 Key::List k = keys();
1740 Key::List::ConstIterator it4; 1740 Key::List::ConstIterator it4;
1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1742 kdDebug(5700) << " Type: " << int((*it4).type()) << 1742 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1743 " Key: " << (*it4).textData() << 1743 " Key: " << (*it4).textData() <<
1744 " CustomString: " << (*it4).customTypeString() << endl; 1744 " CustomString: " << (*it4).customTypeString() << endl;
1745 } 1745 }
1746 kdDebug(5700) << " }" << endl; 1746 kdDebug(5700) << " }" << endl;
1747 1747
1748 kdDebug(5700) << "}" << endl; 1748 kdDebug(5700) << "}" << endl;
1749} 1749}
1750 1750
1751 1751
1752void Addressee::insertAddress( const Address &address ) 1752void Addressee::insertAddress( const Address &address )
1753{ 1753{
1754 detach(); 1754 detach();
1755 mData->empty = false; 1755 mData->empty = false;
1756 1756
1757 Address::List::Iterator it; 1757 Address::List::Iterator it;
1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1759 if ( (*it).id() == address.id() ) { 1759 if ( (*it).id() == address.id() ) {
1760 *it = address; 1760 *it = address;
1761 return; 1761 return;
1762 } 1762 }
1763 } 1763 }
1764 mData->addresses.append( address ); 1764 mData->addresses.append( address );
1765} 1765}
1766 1766
1767void Addressee::removeAddress( const Address &address ) 1767void Addressee::removeAddress( const Address &address )
1768{ 1768{
1769 detach(); 1769 detach();
1770 1770
1771 Address::List::Iterator it; 1771 Address::List::Iterator it;
1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1773 if ( (*it).id() == address.id() ) { 1773 if ( (*it).id() == address.id() ) {
1774 mData->addresses.remove( it ); 1774 mData->addresses.remove( it );
1775 return; 1775 return;
1776 } 1776 }
1777 } 1777 }
1778} 1778}
1779 1779
1780Address Addressee::address( int type ) const 1780Address Addressee::address( int type ) const
1781{ 1781{
1782 Address address( type ); 1782 Address address( type );
1783 Address::List::ConstIterator it; 1783 Address::List::ConstIterator it;
1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1785 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1785 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1786 if ( (*it).type() & Address::Pref ) 1786 if ( (*it).type() & Address::Pref )
1787 return (*it); 1787 return (*it);
1788 else if ( address.isEmpty() ) 1788 else if ( address.isEmpty() )
1789 address = (*it); 1789 address = (*it);
1790 } 1790 }
1791 } 1791 }
1792 1792
1793 return address; 1793 return address;
1794} 1794}
1795 1795
1796Address::List Addressee::addresses() const 1796Address::List Addressee::addresses() const
1797{ 1797{
1798 return mData->addresses; 1798 return mData->addresses;
1799} 1799}
1800 1800
1801Address::List Addressee::addresses( int type ) const 1801Address::List Addressee::addresses( int type ) const
1802{ 1802{
1803 Address::List list; 1803 Address::List list;
1804 1804
1805 Address::List::ConstIterator it; 1805 Address::List::ConstIterator it;
1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1807 if ( matchBinaryPattern( (*it).type(), type ) ) { 1807 if ( matchBinaryPattern( (*it).type(), type ) ) {
1808 list.append( *it ); 1808 list.append( *it );
1809 } 1809 }
1810 } 1810 }
1811 1811
1812 return list; 1812 return list;
1813} 1813}
1814 1814
1815Address Addressee::findAddress( const QString &id ) const 1815Address Addressee::findAddress( const QString &id ) const
1816{ 1816{
1817 Address::List::ConstIterator it; 1817 Address::List::ConstIterator it;
1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1819 if ( (*it).id() == id ) { 1819 if ( (*it).id() == id ) {
1820 return *it; 1820 return *it;
1821 } 1821 }
1822 } 1822 }
1823 return Address(); 1823 return Address();
1824} 1824}
1825 1825
1826void Addressee::insertCategory( const QString &c ) 1826void Addressee::insertCategory( const QString &c )
1827{ 1827{
1828 detach(); 1828 detach();
1829 mData->empty = false; 1829 mData->empty = false;
1830 1830
1831 if ( mData->categories.contains( c ) ) return; 1831 if ( mData->categories.contains( c ) ) return;
1832 1832
1833 mData->categories.append( c ); 1833 mData->categories.append( c );
1834} 1834}
1835 1835
1836void Addressee::removeCategory( const QString &c ) 1836void Addressee::removeCategory( const QString &c )
1837{ 1837{
1838 detach(); 1838 detach();
1839 1839
1840 QStringList::Iterator it = mData->categories.find( c ); 1840 QStringList::Iterator it = mData->categories.find( c );
1841 if ( it == mData->categories.end() ) return; 1841 if ( it == mData->categories.end() ) return;
1842 1842
1843 mData->categories.remove( it ); 1843 mData->categories.remove( it );
1844} 1844}
1845 1845
1846bool Addressee::hasCategory( const QString &c ) const 1846bool Addressee::hasCategory( const QString &c ) const
1847{ 1847{
1848 return ( mData->categories.contains( c ) ); 1848 return ( mData->categories.contains( c ) );
1849} 1849}
1850 1850
1851void Addressee::setCategories( const QStringList &c ) 1851void Addressee::setCategories( const QStringList &c )
1852{ 1852{
1853 detach(); 1853 detach();
1854 mData->empty = false; 1854 mData->empty = false;
1855 1855
1856 mData->categories = c; 1856 mData->categories = c;
1857} 1857}
1858 1858
1859QStringList Addressee::categories() const 1859QStringList Addressee::categories() const
1860{ 1860{
1861 return mData->categories; 1861 return mData->categories;
1862} 1862}
1863 1863
1864void Addressee::insertCustom( const QString &app, const QString &name, 1864void Addressee::insertCustom( const QString &app, const QString &name,
1865 const QString &value ) 1865 const QString &value )
1866{ 1866{
1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1868 1868
1869 detach(); 1869 detach();
1870 mData->empty = false; 1870 mData->empty = false;
1871 1871
1872 QString qualifiedName = app + "-" + name + ":"; 1872 QString qualifiedName = app + "-" + name + ":";
1873 1873
1874 QStringList::Iterator it; 1874 QStringList::Iterator it;
1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1876 if ( (*it).startsWith( qualifiedName ) ) { 1876 if ( (*it).startsWith( qualifiedName ) ) {
1877 (*it) = qualifiedName + value; 1877 (*it) = qualifiedName + value;
1878 return; 1878 return;
1879 } 1879 }
1880 } 1880 }
1881 mData->custom.append( qualifiedName + value ); 1881 mData->custom.append( qualifiedName + value );
1882} 1882}
1883 1883
1884void Addressee::removeCustom( const QString &app, const QString &name) 1884void Addressee::removeCustom( const QString &app, const QString &name)
1885{ 1885{
1886 detach(); 1886 detach();
1887 1887
1888 QString qualifiedName = app + "-" + name + ":"; 1888 QString qualifiedName = app + "-" + name + ":";
1889 1889
1890 QStringList::Iterator it; 1890 QStringList::Iterator it;
1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1892 if ( (*it).startsWith( qualifiedName ) ) { 1892 if ( (*it).startsWith( qualifiedName ) ) {
1893 mData->custom.remove( it ); 1893 mData->custom.remove( it );
1894 return; 1894 return;
1895 } 1895 }
1896 } 1896 }
1897} 1897}
1898 1898
1899QString Addressee::custom( const QString &app, const QString &name ) const 1899QString Addressee::custom( const QString &app, const QString &name ) const
1900{ 1900{
1901 QString qualifiedName = app + "-" + name + ":"; 1901 QString qualifiedName = app + "-" + name + ":";
1902 QString value; 1902 QString value;
1903 1903
1904 QStringList::ConstIterator it; 1904 QStringList::ConstIterator it;
1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1906 if ( (*it).startsWith( qualifiedName ) ) { 1906 if ( (*it).startsWith( qualifiedName ) ) {
1907 value = (*it).mid( (*it).find( ":" ) + 1 ); 1907 value = (*it).mid( (*it).find( ":" ) + 1 );
1908 break; 1908 break;
1909 } 1909 }
1910 } 1910 }
1911 1911
1912 return value; 1912 return value;
1913} 1913}
1914 1914
1915void Addressee::setCustoms( const QStringList &l ) 1915void Addressee::setCustoms( const QStringList &l )
1916{ 1916{
1917 detach(); 1917 detach();
1918 mData->empty = false; 1918 mData->empty = false;
1919 1919
1920 mData->custom = l; 1920 mData->custom = l;
1921} 1921}
1922 1922
1923QStringList Addressee::customs() const 1923QStringList Addressee::customs() const
1924{ 1924{
1925 return mData->custom; 1925 return mData->custom;
1926} 1926}
1927 1927
1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1929 QString &email) 1929 QString &email)
1930{ 1930{
1931 int startPos, endPos, len; 1931 int startPos, endPos, len;
1932 QString partA, partB, result; 1932 QString partA, partB, result;
1933 char endCh = '>'; 1933 char endCh = '>';
1934 1934
1935 startPos = rawEmail.find('<'); 1935 startPos = rawEmail.find('<');
1936 if (startPos < 0) 1936 if (startPos < 0)
1937 { 1937 {
1938 startPos = rawEmail.find('('); 1938 startPos = rawEmail.find('(');
1939 endCh = ')'; 1939 endCh = ')';
1940 } 1940 }
1941 if (startPos < 0) 1941 if (startPos < 0)
1942 { 1942 {
1943 // We couldn't find any separators, so we assume the whole string 1943 // We couldn't find any separators, so we assume the whole string
1944 // is the email address 1944 // is the email address
1945 email = rawEmail; 1945 email = rawEmail;
1946 fullName = ""; 1946 fullName = "";
1947 } 1947 }
1948 else 1948 else
1949 { 1949 {
1950 // We have a start position, try to find an end 1950 // We have a start position, try to find an end
1951 endPos = rawEmail.find(endCh, startPos+1); 1951 endPos = rawEmail.find(endCh, startPos+1);
1952 1952
1953 if (endPos < 0) 1953 if (endPos < 0)
1954 { 1954 {
1955 // We couldn't find the end of the email address. We can only 1955 // We couldn't find the end of the email address. We can only
1956 // assume the entire string is the email address. 1956 // assume the entire string is the email address.
1957 email = rawEmail; 1957 email = rawEmail;
1958 fullName = ""; 1958 fullName = "";
1959 } 1959 }
1960 else 1960 else
1961 { 1961 {
1962 // We have a start and end to the email address 1962 // We have a start and end to the email address
1963 1963
1964 // Grab the name part 1964 // Grab the name part
1965 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1965 fullName = rawEmail.left(startPos).stripWhiteSpace();
1966 1966
1967 // grab the email part 1967 // grab the email part
1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1969 1969
1970 // Check that we do not have any extra characters on the end of the 1970 // Check that we do not have any extra characters on the end of the
1971 // strings 1971 // strings
1972 len = fullName.length(); 1972 len = fullName.length();
1973 if (fullName[0]=='"' && fullName[len-1]=='"') 1973 if (fullName[0]=='"' && fullName[len-1]=='"')
1974 fullName = fullName.mid(1, len-2); 1974 fullName = fullName.mid(1, len-2);
1975 else if (fullName[0]=='<' && fullName[len-1]=='>') 1975 else if (fullName[0]=='<' && fullName[len-1]=='>')
1976 fullName = fullName.mid(1, len-2); 1976 fullName = fullName.mid(1, len-2);
1977 else if (fullName[0]=='(' && fullName[len-1]==')') 1977 else if (fullName[0]=='(' && fullName[len-1]==')')
1978 fullName = fullName.mid(1, len-2); 1978 fullName = fullName.mid(1, len-2);
1979 } 1979 }
1980 } 1980 }
1981} 1981}
1982 1982
1983void Addressee::setResource( Resource *resource ) 1983void Addressee::setResource( Resource *resource )
1984{ 1984{
1985 detach(); 1985 detach();
1986 mData->resource = resource; 1986 mData->resource = resource;
1987} 1987}
1988 1988
1989Resource *Addressee::resource() const 1989Resource *Addressee::resource() const
1990{ 1990{
1991 return mData->resource; 1991 return mData->resource;
1992} 1992}
1993 1993
1994//US 1994//US
1995QString Addressee::resourceLabel() 1995QString Addressee::resourceLabel()
1996{ 1996{
1997 return i18n("Resource"); 1997 return i18n("Resource");
1998} 1998}
1999QString Addressee::categoryLabel()
2000{
2001 return i18n("Category");
2002}
1999 2003
2000void Addressee::setChanged( bool value ) 2004void Addressee::setChanged( bool value )
2001{ 2005{
2002 detach(); 2006 detach();
2003 mData->changed = value; 2007 mData->changed = value;
2004} 2008}
2005 2009
2006bool Addressee::changed() const 2010bool Addressee::changed() const
2007{ 2011{
2008 return mData->changed; 2012 return mData->changed;
2009} 2013}
2010 2014
2011void Addressee::setTagged( bool value ) 2015void Addressee::setTagged( bool value )
2012{ 2016{
2013 detach(); 2017 detach();
2014 mData->tagged = value; 2018 mData->tagged = value;
2015} 2019}
2016 2020
2017bool Addressee::tagged() const 2021bool Addressee::tagged() const
2018{ 2022{
2019 return mData->tagged; 2023 return mData->tagged;
2020} 2024}
2021 2025
2022QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2026QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2023{ 2027{
2024 if (!a.mData) return s; 2028 if (!a.mData) return s;
2025 2029
2026 s << a.uid(); 2030 s << a.uid();
2027 2031
2028 s << a.mData->name; 2032 s << a.mData->name;
2029 s << a.mData->formattedName; 2033 s << a.mData->formattedName;
2030 s << a.mData->familyName; 2034 s << a.mData->familyName;
2031 s << a.mData->givenName; 2035 s << a.mData->givenName;
2032 s << a.mData->additionalName; 2036 s << a.mData->additionalName;
2033 s << a.mData->prefix; 2037 s << a.mData->prefix;
2034 s << a.mData->suffix; 2038 s << a.mData->suffix;
2035 s << a.mData->nickName; 2039 s << a.mData->nickName;
2036 s << a.mData->birthday; 2040 s << a.mData->birthday;
2037 s << a.mData->mailer; 2041 s << a.mData->mailer;
2038 s << a.mData->timeZone; 2042 s << a.mData->timeZone;
2039 s << a.mData->geo; 2043 s << a.mData->geo;
2040 s << a.mData->title; 2044 s << a.mData->title;
2041 s << a.mData->role; 2045 s << a.mData->role;
2042 s << a.mData->organization; 2046 s << a.mData->organization;
2043 s << a.mData->note; 2047 s << a.mData->note;
2044 s << a.mData->productId; 2048 s << a.mData->productId;
2045 s << a.mData->revision; 2049 s << a.mData->revision;
2046 s << a.mData->sortString; 2050 s << a.mData->sortString;
2047 s << a.mData->url; 2051 s << a.mData->url;
2048 s << a.mData->secrecy; 2052 s << a.mData->secrecy;
2049 s << a.mData->logo; 2053 s << a.mData->logo;
2050 s << a.mData->photo; 2054 s << a.mData->photo;
2051 s << a.mData->sound; 2055 s << a.mData->sound;
2052 s << a.mData->agent; 2056 s << a.mData->agent;
2053 s << a.mData->phoneNumbers; 2057 s << a.mData->phoneNumbers;
2054 s << a.mData->addresses; 2058 s << a.mData->addresses;
2055 s << a.mData->emails; 2059 s << a.mData->emails;
2056 s << a.mData->categories; 2060 s << a.mData->categories;
2057 s << a.mData->custom; 2061 s << a.mData->custom;
2058 s << a.mData->keys; 2062 s << a.mData->keys;
2059 return s; 2063 return s;
2060} 2064}
2061 2065
2062QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2066QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2063{ 2067{
2064 if (!a.mData) return s; 2068 if (!a.mData) return s;
2065 2069
2066 s >> a.mData->uid; 2070 s >> a.mData->uid;
2067 2071
2068 s >> a.mData->name; 2072 s >> a.mData->name;
2069 s >> a.mData->formattedName; 2073 s >> a.mData->formattedName;
2070 s >> a.mData->familyName; 2074 s >> a.mData->familyName;
2071 s >> a.mData->givenName; 2075 s >> a.mData->givenName;
2072 s >> a.mData->additionalName; 2076 s >> a.mData->additionalName;
2073 s >> a.mData->prefix; 2077 s >> a.mData->prefix;
2074 s >> a.mData->suffix; 2078 s >> a.mData->suffix;
2075 s >> a.mData->nickName; 2079 s >> a.mData->nickName;
2076 s >> a.mData->birthday; 2080 s >> a.mData->birthday;
2077 s >> a.mData->mailer; 2081 s >> a.mData->mailer;
2078 s >> a.mData->timeZone; 2082 s >> a.mData->timeZone;
2079 s >> a.mData->geo; 2083 s >> a.mData->geo;
2080 s >> a.mData->title; 2084 s >> a.mData->title;
2081 s >> a.mData->role; 2085 s >> a.mData->role;
2082 s >> a.mData->organization; 2086 s >> a.mData->organization;
2083 s >> a.mData->note; 2087 s >> a.mData->note;
2084 s >> a.mData->productId; 2088 s >> a.mData->productId;
2085 s >> a.mData->revision; 2089 s >> a.mData->revision;
2086 s >> a.mData->sortString; 2090 s >> a.mData->sortString;
2087 s >> a.mData->url; 2091 s >> a.mData->url;
2088 s >> a.mData->secrecy; 2092 s >> a.mData->secrecy;
2089 s >> a.mData->logo; 2093 s >> a.mData->logo;
2090 s >> a.mData->photo; 2094 s >> a.mData->photo;
2091 s >> a.mData->sound; 2095 s >> a.mData->sound;
2092 s >> a.mData->agent; 2096 s >> a.mData->agent;
2093 s >> a.mData->phoneNumbers; 2097 s >> a.mData->phoneNumbers;
2094 s >> a.mData->addresses; 2098 s >> a.mData->addresses;
2095 s >> a.mData->emails; 2099 s >> a.mData->emails;
2096 s >> a.mData->categories; 2100 s >> a.mData->categories;
2097 s >> a.mData->custom; 2101 s >> a.mData->custom;
2098 s >> a.mData->keys; 2102 s >> a.mData->keys;
2099 2103
2100 a.mData->empty = false; 2104 a.mData->empty = false;
2101 2105
2102 return s; 2106 return s;
2103} 2107}
2104bool matchBinaryPattern( int value, int pattern ) 2108bool matchBinaryPattern( int value, int pattern )
2105{ 2109{
2106 /** 2110 /**
2107 We want to match all telephonnumbers/addresses which have the bits in the 2111 We want to match all telephonnumbers/addresses which have the bits in the
2108 pattern set. More are allowed. 2112 pattern set. More are allowed.
2109 if pattern == 0 we have a special handling, then we want only those with 2113 if pattern == 0 we have a special handling, then we want only those with
2110 exactly no bit set. 2114 exactly no bit set.
2111 */ 2115 */
2112 if ( pattern == 0 ) 2116 if ( pattern == 0 )
2113 return ( value == 0 ); 2117 return ( value == 0 );
2114 else 2118 else
2115 return ( pattern == ( pattern & value ) ); 2119 return ( pattern == ( pattern & value ) );
2116} 2120}
2117 2121
2118bool matchBinaryPatternP( int value, int pattern ) 2122bool matchBinaryPatternP( int value, int pattern )
2119{ 2123{
2120 2124
2121 if ( pattern == 0 ) 2125 if ( pattern == 0 )
2122 return ( value == 0 ); 2126 return ( value == 0 );
2123 else 2127 else
2124 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2128 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2125} 2129}
2126bool matchBinaryPatternA( int value, int pattern ) 2130bool matchBinaryPatternA( int value, int pattern )
2127{ 2131{
2128 2132
2129 if ( pattern == 0 ) 2133 if ( pattern == 0 )
2130 return ( value == 0 ); 2134 return ( value == 0 );
2131 else 2135 else
2132 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2136 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2133} 2137}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 2c81c1a..08d2f56 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -58,796 +58,796 @@ class Resource;
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet ); 119 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 QString uid() const; 134 QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 /** 157 /**
158 Return formatted name. 158 Return formatted name.
159 */ 159 */
160 QString formattedName() const; 160 QString formattedName() const;
161 /** 161 /**
162 Return translated label for formattedName field. 162 Return translated label for formattedName field.
163 */ 163 */
164 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
165 165
166 /** 166 /**
167 Set family name. 167 Set family name.
168 */ 168 */
169 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
170 /** 170 /**
171 Return family name. 171 Return family name.
172 */ 172 */
173 QString familyName() const; 173 QString familyName() const;
174 /** 174 /**
175 Return translated label for familyName field. 175 Return translated label for familyName field.
176 */ 176 */
177 static QString familyNameLabel(); 177 static QString familyNameLabel();
178 178
179 /** 179 /**
180 Set given name. 180 Set given name.
181 */ 181 */
182 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
183 /** 183 /**
184 Return given name. 184 Return given name.
185 */ 185 */
186 QString givenName() const; 186 QString givenName() const;
187 /** 187 /**
188 Return translated label for givenName field. 188 Return translated label for givenName field.
189 */ 189 */
190 static QString givenNameLabel(); 190 static QString givenNameLabel();
191 191
192 /** 192 /**
193 Set additional names. 193 Set additional names.
194 */ 194 */
195 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
196 /** 196 /**
197 Return additional names. 197 Return additional names.
198 */ 198 */
199 QString additionalName() const; 199 QString additionalName() const;
200 /** 200 /**
201 Return translated label for additionalName field. 201 Return translated label for additionalName field.
202 */ 202 */
203 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
204 204
205 /** 205 /**
206 Set honorific prefixes. 206 Set honorific prefixes.
207 */ 207 */
208 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
209 /** 209 /**
210 Return honorific prefixes. 210 Return honorific prefixes.
211 */ 211 */
212 QString prefix() const; 212 QString prefix() const;
213 /** 213 /**
214 Return translated label for prefix field. 214 Return translated label for prefix field.
215 */ 215 */
216 static QString prefixLabel(); 216 static QString prefixLabel();
217 217
218 /** 218 /**
219 Set honorific suffixes. 219 Set honorific suffixes.
220 */ 220 */
221 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
222 /** 222 /**
223 Return honorific suffixes. 223 Return honorific suffixes.
224 */ 224 */
225 QString suffix() const; 225 QString suffix() const;
226 /** 226 /**
227 Return translated label for suffix field. 227 Return translated label for suffix field.
228 */ 228 */
229 static QString suffixLabel(); 229 static QString suffixLabel();
230 230
231 /** 231 /**
232 Set nick name. 232 Set nick name.
233 */ 233 */
234 void setNickName( const QString &nickName ); 234 void setNickName( const QString &nickName );
235 /** 235 /**
236 Return nick name. 236 Return nick name.
237 */ 237 */
238 QString nickName() const; 238 QString nickName() const;
239 /** 239 /**
240 Return translated label for nickName field. 240 Return translated label for nickName field.
241 */ 241 */
242 static QString nickNameLabel(); 242 static QString nickNameLabel();
243 243
244 /** 244 /**
245 Set birthday. 245 Set birthday.
246 */ 246 */
247 void setBirthday( const QDateTime &birthday ); 247 void setBirthday( const QDateTime &birthday );
248 /** 248 /**
249 Return birthday. 249 Return birthday.
250 */ 250 */
251 QDateTime birthday() const; 251 QDateTime birthday() const;
252 /** 252 /**
253 Return translated label for birthday field. 253 Return translated label for birthday field.
254 */ 254 */
255 static QString birthdayLabel(); 255 static QString birthdayLabel();
256 256
257 /** 257 /**
258 Return translated label for homeAddressStreet field. 258 Return translated label for homeAddressStreet field.
259 */ 259 */
260 static QString homeAddressStreetLabel(); 260 static QString homeAddressStreetLabel();
261 261
262 /** 262 /**
263 Return translated label for homeAddressLocality field. 263 Return translated label for homeAddressLocality field.
264 */ 264 */
265 static QString homeAddressLocalityLabel(); 265 static QString homeAddressLocalityLabel();
266 266
267 /** 267 /**
268 Return translated label for homeAddressRegion field. 268 Return translated label for homeAddressRegion field.
269 */ 269 */
270 static QString homeAddressRegionLabel(); 270 static QString homeAddressRegionLabel();
271 271
272 /** 272 /**
273 Return translated label for homeAddressPostalCode field. 273 Return translated label for homeAddressPostalCode field.
274 */ 274 */
275 static QString homeAddressPostalCodeLabel(); 275 static QString homeAddressPostalCodeLabel();
276 276
277 /** 277 /**
278 Return translated label for homeAddressCountry field. 278 Return translated label for homeAddressCountry field.
279 */ 279 */
280 static QString homeAddressCountryLabel(); 280 static QString homeAddressCountryLabel();
281 281
282 /** 282 /**
283 Return translated label for homeAddressLabel field. 283 Return translated label for homeAddressLabel field.
284 */ 284 */
285 static QString homeAddressLabelLabel(); 285 static QString homeAddressLabelLabel();
286 286
287 /** 287 /**
288 Return translated label for businessAddressStreet field. 288 Return translated label for businessAddressStreet field.
289 */ 289 */
290 static QString businessAddressStreetLabel(); 290 static QString businessAddressStreetLabel();
291 291
292 /** 292 /**
293 Return translated label for businessAddressLocality field. 293 Return translated label for businessAddressLocality field.
294 */ 294 */
295 static QString businessAddressLocalityLabel(); 295 static QString businessAddressLocalityLabel();
296 296
297 /** 297 /**
298 Return translated label for businessAddressRegion field. 298 Return translated label for businessAddressRegion field.
299 */ 299 */
300 static QString businessAddressRegionLabel(); 300 static QString businessAddressRegionLabel();
301 301
302 /** 302 /**
303 Return translated label for businessAddressPostalCode field. 303 Return translated label for businessAddressPostalCode field.
304 */ 304 */
305 static QString businessAddressPostalCodeLabel(); 305 static QString businessAddressPostalCodeLabel();
306 306
307 /** 307 /**
308 Return translated label for businessAddressCountry field. 308 Return translated label for businessAddressCountry field.
309 */ 309 */
310 static QString businessAddressCountryLabel(); 310 static QString businessAddressCountryLabel();
311 311
312 /** 312 /**
313 Return translated label for businessAddressLabel field. 313 Return translated label for businessAddressLabel field.
314 */ 314 */
315 static QString businessAddressLabelLabel(); 315 static QString businessAddressLabelLabel();
316 316
317 /** 317 /**
318 Return translated label for homePhone field. 318 Return translated label for homePhone field.
319 */ 319 */
320 static QString homePhoneLabel(); 320 static QString homePhoneLabel();
321 321
322 /** 322 /**
323 Return translated label for businessPhone field. 323 Return translated label for businessPhone field.
324 */ 324 */
325 static QString businessPhoneLabel(); 325 static QString businessPhoneLabel();
326 326
327 /** 327 /**
328 Return translated label for mobilePhone field. 328 Return translated label for mobilePhone field.
329 */ 329 */
330 static QString mobilePhoneLabel(); 330 static QString mobilePhoneLabel();
331 331
332 /** 332 /**
333 Return translated label for homeFax field. 333 Return translated label for homeFax field.
334 */ 334 */
335 static QString homeFaxLabel(); 335 static QString homeFaxLabel();
336 336
337 /** 337 /**
338 Return translated label for businessFax field. 338 Return translated label for businessFax field.
339 */ 339 */
340 static QString businessFaxLabel(); 340 static QString businessFaxLabel();
341 341
342 /** 342 /**
343 Return translated label for carPhone field. 343 Return translated label for carPhone field.
344 */ 344 */
345 static QString carPhoneLabel(); 345 static QString carPhoneLabel();
346 346
347 /** 347 /**
348 Return translated label for isdn field. 348 Return translated label for isdn field.
349 */ 349 */
350 static QString isdnLabel(); 350 static QString isdnLabel();
351 351
352 /** 352 /**
353 Return translated label for pager field. 353 Return translated label for pager field.
354 */ 354 */
355 static QString pagerLabel(); 355 static QString pagerLabel();
356 356
357 /** 357 /**
358 Return translated label for sip field. 358 Return translated label for sip field.
359 */ 359 */
360 static QString sipLabel(); 360 static QString sipLabel();
361 361
362 /** 362 /**
363 Return translated label for email field. 363 Return translated label for email field.
364 */ 364 */
365 static QString emailLabel(); 365 static QString emailLabel();
366 366
367 /** 367 /**
368 Set mail client. 368 Set mail client.
369 */ 369 */
370 void setMailer( const QString &mailer ); 370 void setMailer( const QString &mailer );
371 /** 371 /**
372 Return mail client. 372 Return mail client.
373 */ 373 */
374 QString mailer() const; 374 QString mailer() const;
375 /** 375 /**
376 Return translated label for mailer field. 376 Return translated label for mailer field.
377 */ 377 */
378 static QString mailerLabel(); 378 static QString mailerLabel();
379 379
380 /** 380 /**
381 Set time zone. 381 Set time zone.
382 */ 382 */
383 void setTimeZone( const TimeZone &timeZone ); 383 void setTimeZone( const TimeZone &timeZone );
384 /** 384 /**
385 Return time zone. 385 Return time zone.
386 */ 386 */
387 TimeZone timeZone() const; 387 TimeZone timeZone() const;
388 /** 388 /**
389 Return translated label for timeZone field. 389 Return translated label for timeZone field.
390 */ 390 */
391 static QString timeZoneLabel(); 391 static QString timeZoneLabel();
392 392
393 /** 393 /**
394 Set geographic position. 394 Set geographic position.
395 */ 395 */
396 void setGeo( const Geo &geo ); 396 void setGeo( const Geo &geo );
397 /** 397 /**
398 Return geographic position. 398 Return geographic position.
399 */ 399 */
400 Geo geo() const; 400 Geo geo() const;
401 /** 401 /**
402 Return translated label for geo field. 402 Return translated label for geo field.
403 */ 403 */
404 static QString geoLabel(); 404 static QString geoLabel();
405 405
406 /** 406 /**
407 Set title. 407 Set title.
408 */ 408 */
409 void setTitle( const QString &title ); 409 void setTitle( const QString &title );
410 /** 410 /**
411 Return title. 411 Return title.
412 */ 412 */
413 QString title() const; 413 QString title() const;
414 /** 414 /**
415 Return translated label for title field. 415 Return translated label for title field.
416 */ 416 */
417 static QString titleLabel(); 417 static QString titleLabel();
418 418
419 /** 419 /**
420 Set role. 420 Set role.
421 */ 421 */
422 void setRole( const QString &role ); 422 void setRole( const QString &role );
423 /** 423 /**
424 Return role. 424 Return role.
425 */ 425 */
426 QString role() const; 426 QString role() const;
427 /** 427 /**
428 Return translated label for role field. 428 Return translated label for role field.
429 */ 429 */
430 static QString roleLabel(); 430 static QString roleLabel();
431 431
432 /** 432 /**
433 Set organization. 433 Set organization.
434 */ 434 */
435 void setOrganization( const QString &organization ); 435 void setOrganization( const QString &organization );
436 /** 436 /**
437 Return organization. 437 Return organization.
438 */ 438 */
439 QString organization() const; 439 QString organization() const;
440 /** 440 /**
441 Return translated label for organization field. 441 Return translated label for organization field.
442 */ 442 */
443 static QString organizationLabel(); 443 static QString organizationLabel();
444 444
445 /** 445 /**
446 Set note. 446 Set note.
447 */ 447 */
448 void setNote( const QString &note ); 448 void setNote( const QString &note );
449 /** 449 /**
450 Return note. 450 Return note.
451 */ 451 */
452 QString note() const; 452 QString note() const;
453 /** 453 /**
454 Return translated label for note field. 454 Return translated label for note field.
455 */ 455 */
456 static QString noteLabel(); 456 static QString noteLabel();
457 457
458 /** 458 /**
459 Set product identifier. 459 Set product identifier.
460 */ 460 */
461 void setProductId( const QString &productId ); 461 void setProductId( const QString &productId );
462 /** 462 /**
463 Return product identifier. 463 Return product identifier.
464 */ 464 */
465 QString productId() const; 465 QString productId() const;
466 /** 466 /**
467 Return translated label for productId field. 467 Return translated label for productId field.
468 */ 468 */
469 static QString productIdLabel(); 469 static QString productIdLabel();
470 470
471 /** 471 /**
472 Set revision date. 472 Set revision date.
473 */ 473 */
474 void setRevision( const QDateTime &revision ); 474 void setRevision( const QDateTime &revision );
475 /** 475 /**
476 Return revision date. 476 Return revision date.
477 */ 477 */
478 QDateTime revision() const; 478 QDateTime revision() const;
479 /** 479 /**
480 Return translated label for revision field. 480 Return translated label for revision field.
481 */ 481 */
482 static QString revisionLabel(); 482 static QString revisionLabel();
483 483
484 /** 484 /**
485 Set sort string. 485 Set sort string.
486 */ 486 */
487 void setSortString( const QString &sortString ); 487 void setSortString( const QString &sortString );
488 /** 488 /**
489 Return sort string. 489 Return sort string.
490 */ 490 */
491 QString sortString() const; 491 QString sortString() const;
492 /** 492 /**
493 Return translated label for sortString field. 493 Return translated label for sortString field.
494 */ 494 */
495 static QString sortStringLabel(); 495 static QString sortStringLabel();
496 496
497 /** 497 /**
498 Set URL. 498 Set URL.
499 */ 499 */
500 void setUrl( const KURL &url ); 500 void setUrl( const KURL &url );
501 /** 501 /**
502 Return URL. 502 Return URL.
503 */ 503 */
504 KURL url() const; 504 KURL url() const;
505 /** 505 /**
506 Return translated label for url field. 506 Return translated label for url field.
507 */ 507 */
508 static QString urlLabel(); 508 static QString urlLabel();
509 509
510 /** 510 /**
511 Set security class. 511 Set security class.
512 */ 512 */
513 void setSecrecy( const Secrecy &secrecy ); 513 void setSecrecy( const Secrecy &secrecy );
514 /** 514 /**
515 Return security class. 515 Return security class.
516 */ 516 */
517 Secrecy secrecy() const; 517 Secrecy secrecy() const;
518 /** 518 /**
519 Return translated label for secrecy field. 519 Return translated label for secrecy field.
520 */ 520 */
521 static QString secrecyLabel(); 521 static QString secrecyLabel();
522 522
523 /** 523 /**
524 Set logo. 524 Set logo.
525 */ 525 */
526 void setLogo( const Picture &logo ); 526 void setLogo( const Picture &logo );
527 /** 527 /**
528 Return logo. 528 Return logo.
529 */ 529 */
530 Picture logo() const; 530 Picture logo() const;
531 /** 531 /**
532 Return translated label for logo field. 532 Return translated label for logo field.
533 */ 533 */
534 static QString logoLabel(); 534 static QString logoLabel();
535 535
536 /** 536 /**
537 Set photo. 537 Set photo.
538 */ 538 */
539 void setPhoto( const Picture &photo ); 539 void setPhoto( const Picture &photo );
540 /** 540 /**
541 Return photo. 541 Return photo.
542 */ 542 */
543 Picture photo() const; 543 Picture photo() const;
544 /** 544 /**
545 Return translated label for photo field. 545 Return translated label for photo field.
546 */ 546 */
547 static QString photoLabel(); 547 static QString photoLabel();
548 548
549 /** 549 /**
550 Set sound. 550 Set sound.
551 */ 551 */
552 void setSound( const Sound &sound ); 552 void setSound( const Sound &sound );
553 /** 553 /**
554 Return sound. 554 Return sound.
555 */ 555 */
556 Sound sound() const; 556 Sound sound() const;
557 /** 557 /**
558 Return translated label for sound field. 558 Return translated label for sound field.
559 */ 559 */
560 static QString soundLabel(); 560 static QString soundLabel();
561 561
562 /** 562 /**
563 Set agent. 563 Set agent.
564 */ 564 */
565 void setAgent( const Agent &agent ); 565 void setAgent( const Agent &agent );
566 /** 566 /**
567 Return agent. 567 Return agent.
568 */ 568 */
569 Agent agent() const; 569 Agent agent() const;
570 /** 570 /**
571 Return translated label for agent field. 571 Return translated label for agent field.
572 */ 572 */
573 static QString agentLabel(); 573 static QString agentLabel();
574 574
575 /** 575 /**
576 Set name fields by parsing the given string and trying to associate the 576 Set name fields by parsing the given string and trying to associate the
577 parts of the string with according fields. This function should probably 577 parts of the string with according fields. This function should probably
578 be a bit more clever. 578 be a bit more clever.
579 */ 579 */
580 void setNameFromString( const QString & ); 580 void setNameFromString( const QString & );
581 581
582 /** 582 /**
583 Return the name of the addressee. This is calculated from all the name 583 Return the name of the addressee. This is calculated from all the name
584 fields. 584 fields.
585 */ 585 */
586 QString realName() const; 586 QString realName() const;
587 587
588 /** 588 /**
589 Return the name that consists of all name parts. 589 Return the name that consists of all name parts.
590 */ 590 */
591 QString assembledName() const; 591 QString assembledName() const;
592 592
593 /** 593 /**
594 Return email address including real name. 594 Return email address including real name.
595 595
596 @param email Email address to be used to construct the full email string. 596 @param email Email address to be used to construct the full email string.
597 If this is QString::null the preferred email address is used. 597 If this is QString::null the preferred email address is used.
598 */ 598 */
599 QString fullEmail( const QString &email=QString::null ) const; 599 QString fullEmail( const QString &email=QString::null ) const;
600 600
601 /** 601 /**
602 Insert an email address. If the email address already exists in this 602 Insert an email address. If the email address already exists in this
603 addressee it is not duplicated. 603 addressee it is not duplicated.
604 604
605 @param email Email address 605 @param email Email address
606 @param preferred Set to true, if this is the preferred email address of 606 @param preferred Set to true, if this is the preferred email address of
607 the addressee. 607 the addressee.
608 */ 608 */
609 void insertEmail( const QString &email, bool preferred=false ); 609 void insertEmail( const QString &email, bool preferred=false );
610 610
611 /** 611 /**
612 Remove email address. If the email address doesn't exist, nothing happens. 612 Remove email address. If the email address doesn't exist, nothing happens.
613 */ 613 */
614 void removeEmail( const QString &email ); 614 void removeEmail( const QString &email );
615 615
616 /** 616 /**
617 Return preferred email address. This is the first email address or the 617 Return preferred email address. This is the first email address or the
618 last one added with @ref insertEmail() with a set preferred parameter. 618 last one added with @ref insertEmail() with a set preferred parameter.
619 */ 619 */
620 QString preferredEmail() const; 620 QString preferredEmail() const;
621 621
622 /** 622 /**
623 Return list of all email addresses. 623 Return list of all email addresses.
624 */ 624 */
625 QStringList emails() const; 625 QStringList emails() const;
626 626
627 /** 627 /**
628 Set the emails to @param. 628 Set the emails to @param.
629 The first email address gets the preferred one! 629 The first email address gets the preferred one!
630 @param list The list of email addresses. 630 @param list The list of email addresses.
631 */ 631 */
632 void setEmails( const QStringList& list); 632 void setEmails( const QStringList& list);
633 633
634 /** 634 /**
635 Insert a phone number. If a phone number with the same id already exists 635 Insert a phone number. If a phone number with the same id already exists
636 in this addressee it is not duplicated. 636 in this addressee it is not duplicated.
637 */ 637 */
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 638 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 639
640 /** 640 /**
641 Remove phone number. If no phone number with the given id exists for this 641 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 642 addresse nothing happens.
643 */ 643 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 644 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 645
646 /** 646 /**
647 Return phone number, which matches the given type. 647 Return phone number, which matches the given type.
648 */ 648 */
649 PhoneNumber phoneNumber( int type ) const; 649 PhoneNumber phoneNumber( int type ) const;
650 650
651 /** 651 /**
652 Return list of all phone numbers. 652 Return list of all phone numbers.
653 */ 653 */
654 PhoneNumber::List phoneNumbers() const; 654 PhoneNumber::List phoneNumbers() const;
655 655
656 /** 656 /**
657 Return list of phone numbers with a special type. 657 Return list of phone numbers with a special type.
658 */ 658 */
659 PhoneNumber::List phoneNumbers( int type ) const; 659 PhoneNumber::List phoneNumbers( int type ) const;
660 660
661 /** 661 /**
662 Return phone number with the given id. 662 Return phone number with the given id.
663 */ 663 */
664 PhoneNumber findPhoneNumber( const QString &id ) const; 664 PhoneNumber findPhoneNumber( const QString &id ) const;
665 665
666 /** 666 /**
667 Insert a key. If a key with the same id already exists 667 Insert a key. If a key with the same id already exists
668 in this addressee it is not duplicated. 668 in this addressee it is not duplicated.
669 */ 669 */
670 void insertKey( const Key &key ); 670 void insertKey( const Key &key );
671 671
672 /** 672 /**
673 Remove a key. If no key with the given id exists for this 673 Remove a key. If no key with the given id exists for this
674 addresse nothing happens. 674 addresse nothing happens.
675 */ 675 */
676 void removeKey( const Key &key ); 676 void removeKey( const Key &key );
677 677
678 /** 678 /**
679 Return key, which matches the given type. 679 Return key, which matches the given type.
680 If @p type == Key::Custom you can specify a string 680 If @p type == Key::Custom you can specify a string
681 that should match. If you leave the string empty, the first 681 that should match. If you leave the string empty, the first
682 key with a custom value is returned. 682 key with a custom value is returned.
683 */ 683 */
684 Key key( int type, QString customTypeString = QString::null ) const; 684 Key key( int type, QString customTypeString = QString::null ) const;
685 685
686 /** 686 /**
687 Return list of all keys. 687 Return list of all keys.
688 */ 688 */
689 Key::List keys() const; 689 Key::List keys() const;
690 690
691 /** 691 /**
692 Set the list of keys 692 Set the list of keys
693 @param keys The keys to be set. 693 @param keys The keys to be set.
694 */ 694 */
695 void setKeys( const Key::List& keys); 695 void setKeys( const Key::List& keys);
696 696
697 /** 697 /**
698 Return list of keys with a special type. 698 Return list of keys with a special type.
699 If @p type == Key::Custom you can specify a string 699 If @p type == Key::Custom you can specify a string
700 that should match. If you leave the string empty, all custom 700 that should match. If you leave the string empty, all custom
701 keys will be returned. 701 keys will be returned.
702 */ 702 */
703 Key::List keys( int type, QString customTypeString = QString::null ) const; 703 Key::List keys( int type, QString customTypeString = QString::null ) const;
704 704
705 /** 705 /**
706 Return key with the given id. 706 Return key with the given id.
707 */ 707 */
708 Key findKey( const QString &id ) const; 708 Key findKey( const QString &id ) const;
709 709
710 /** 710 /**
711 Insert an address. If an address with the same id already exists 711 Insert an address. If an address with the same id already exists
712 in this addressee it is not duplicated. 712 in this addressee it is not duplicated.
713 */ 713 */
714 void insertAddress( const Address &address ); 714 void insertAddress( const Address &address );
715 715
716 /** 716 /**
717 Remove address. If no address with the given id exists for this 717 Remove address. If no address with the given id exists for this
718 addresse nothing happens. 718 addresse nothing happens.
719 */ 719 */
720 void removeAddress( const Address &address ); 720 void removeAddress( const Address &address );
721 721
722 /** 722 /**
723 Return address, which matches the given type. 723 Return address, which matches the given type.
724 */ 724 */
725 Address address( int type ) const; 725 Address address( int type ) const;
726 726
727 /** 727 /**
728 Return list of all addresses. 728 Return list of all addresses.
729 */ 729 */
730 Address::List addresses() const; 730 Address::List addresses() const;
731 731
732 /** 732 /**
733 Return list of addresses with a special type. 733 Return list of addresses with a special type.
734 */ 734 */
735 Address::List addresses( int type ) const; 735 Address::List addresses( int type ) const;
736 736
737 /** 737 /**
738 Return address with the given id. 738 Return address with the given id.
739 */ 739 */
740 Address findAddress( const QString &id ) const; 740 Address findAddress( const QString &id ) const;
741 741
742 /** 742 /**
743 Insert category. If the category already exists it is not duplicated. 743 Insert category. If the category already exists it is not duplicated.
744 */ 744 */
745 void insertCategory( const QString & ); 745 void insertCategory( const QString & );
746 746
747 /** 747 /**
748 Remove category. 748 Remove category.
749 */ 749 */
750 void removeCategory( const QString & ); 750 void removeCategory( const QString & );
751 751
752 /** 752 /**
753 Return, if addressee has the given category. 753 Return, if addressee has the given category.
754 */ 754 */
755 bool hasCategory( const QString & ) const; 755 bool hasCategory( const QString & ) const;
756 756
757 /** 757 /**
758 Set categories to given value. 758 Set categories to given value.
759 */ 759 */
760 void setCategories( const QStringList & ); 760 void setCategories( const QStringList & );
761 761
762 /** 762 /**
763 Return list of all set categories. 763 Return list of all set categories.
764 */ 764 */
765 QStringList categories() const; 765 QStringList categories() const;
766 766
767 /** 767 /**
768 Insert custom entry. The entry is identified by the name of the inserting 768 Insert custom entry. The entry is identified by the name of the inserting
769 application and a unique name. If an entry with the given app and name 769 application and a unique name. If an entry with the given app and name
770 already exists its value is replaced with the new given value. 770 already exists its value is replaced with the new given value.
771 */ 771 */
772 void insertCustom( const QString &app, const QString &name, 772 void insertCustom( const QString &app, const QString &name,
773 const QString &value ); 773 const QString &value );
774 774
775 /** 775 /**
776 Remove custom entry. 776 Remove custom entry.
777 */ 777 */
778 void removeCustom( const QString &app, const QString &name ); 778 void removeCustom( const QString &app, const QString &name );
779 779
780 /** 780 /**
781 Return value of custom entry, identified by app and entry name. 781 Return value of custom entry, identified by app and entry name.
782 */ 782 */
783 QString custom( const QString &app, const QString &name ) const; 783 QString custom( const QString &app, const QString &name ) const;
784 784
785 /** 785 /**
786 Set all custom entries. 786 Set all custom entries.
787 */ 787 */
788 void setCustoms( const QStringList & ); 788 void setCustoms( const QStringList & );
789 789
790 /** 790 /**
791 Return list of all custom entries. 791 Return list of all custom entries.
792 */ 792 */
793 QStringList customs() const; 793 QStringList customs() const;
794 794
795 /** 795 /**
796 Parse full email address. The result is given back in fullName and email. 796 Parse full email address. The result is given back in fullName and email.
797 */ 797 */
798 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 798 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
799 QString &email ); 799 QString &email );
800 800
801 /** 801 /**
802 Debug output. 802 Debug output.
803 */ 803 */
804 void dump() const; 804 void dump() const;
805 805
806 /** 806 /**
807 Returns string representation of the addressee. 807 Returns string representation of the addressee.
808 */ 808 */
809 QString asString() const; 809 QString asString() const;
810 810
811 /** 811 /**
812 Set resource where the addressee is from. 812 Set resource where the addressee is from.
813 */ 813 */
814 void setResource( Resource *resource ); 814 void setResource( Resource *resource );
815 815
816 /** 816 /**
817 Return pointer to resource. 817 Return pointer to resource.
818 */ 818 */
819 Resource *resource() const; 819 Resource *resource() const;
820 820
821 /** 821 /**
822 Return resourcelabel. 822 Return resourcelabel.
823 */ 823 */
824 //US 824 //US
825 static QString resourceLabel(); 825 static QString resourceLabel();
826 826 static QString categoryLabel();
827 /** 827 /**
828 Mark addressee as changed. 828 Mark addressee as changed.
829 */ 829 */
830 void setChanged( bool value ); 830 void setChanged( bool value );
831 831
832 /** 832 /**
833 Return whether the addressee is changed. 833 Return whether the addressee is changed.
834 */ 834 */
835 bool changed() const; 835 bool changed() const;
836 836
837 void setTagged( bool value ); 837 void setTagged( bool value );
838 bool tagged() const; 838 bool tagged() const;
839 839
840 private: 840 private:
841 Addressee copy(); 841 Addressee copy();
842 void detach(); 842 void detach();
843 843
844 struct AddresseeData; 844 struct AddresseeData;
845 mutable KSharedPtr<AddresseeData> mData; 845 mutable KSharedPtr<AddresseeData> mData;
846}; 846};
847 847
848QDataStream &operator<<( QDataStream &, const Addressee & ); 848QDataStream &operator<<( QDataStream &, const Addressee & );
849QDataStream &operator>>( QDataStream &, Addressee & ); 849QDataStream &operator>>( QDataStream &, Addressee & );
850 850
851} 851}
852 852
853#endif 853#endif
diff --git a/kabc/field.cpp b/kabc/field.cpp
index d95cd19..89d0b77 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -1,572 +1,578 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 Category,
60 HomeAddressStreet, 61 HomeAddressStreet,
61 HomeAddressLocality, 62 HomeAddressLocality,
62 HomeAddressRegion, 63 HomeAddressRegion,
63 HomeAddressPostalCode, 64 HomeAddressPostalCode,
64 HomeAddressCountry, 65 HomeAddressCountry,
65 HomeAddressLabel, 66 HomeAddressLabel,
66 BusinessAddressStreet, 67 BusinessAddressStreet,
67 BusinessAddressLocality, 68 BusinessAddressLocality,
68 BusinessAddressRegion, 69 BusinessAddressRegion,
69 BusinessAddressPostalCode, 70 BusinessAddressPostalCode,
70 BusinessAddressCountry, 71 BusinessAddressCountry,
71 BusinessAddressLabel, 72 BusinessAddressLabel,
72 HomePhone, 73 HomePhone,
73 BusinessPhone, 74 BusinessPhone,
74 MobilePhone, 75 MobilePhone,
75 HomeFax, 76 HomeFax,
76 BusinessFax, 77 BusinessFax,
77 CarPhone, 78 CarPhone,
78 Isdn, 79 Isdn,
79 Pager, 80 Pager,
80 Email, 81 Email,
81 Mailer, 82 Mailer,
82 Title, 83 Title,
83 Role, 84 Role,
84 Organization, 85 Organization,
85 Note, 86 Note,
86 Url, 87 Url,
87 Resource, 88 Resource,
88 Sip 89 Sip
89 }; 90 };
90 91
91 int fieldId() { return mFieldId; } 92 int fieldId() { return mFieldId; }
92 int category() { return mCategory; } 93 int category() { return mCategory; }
93 94
94 QString label() { return mLabel; } 95 QString label() { return mLabel; }
95 QString key() { return mKey; } 96 QString key() { return mKey; }
96 QString app() { return mApp; } 97 QString app() { return mApp; }
97 98
98 private: 99 private:
99 int mFieldId; 100 int mFieldId;
100 int mCategory; 101 int mCategory;
101 102
102 QString mLabel; 103 QString mLabel;
103 QString mKey; 104 QString mKey;
104 QString mApp; 105 QString mApp;
105}; 106};
106 107
107 108
108Field::List Field::mAllFields; 109Field::List Field::mAllFields;
109Field::List Field::mDefaultFields; 110Field::List Field::mDefaultFields;
110Field::List Field::mCustomFields; 111Field::List Field::mCustomFields;
111 112
112 113
113Field::Field( FieldImpl *impl ) 114Field::Field( FieldImpl *impl )
114{ 115{
115 mImpl = impl; 116 mImpl = impl;
116} 117}
117 118
118Field::~Field() 119Field::~Field()
119{ 120{
120 delete mImpl; 121 delete mImpl;
121} 122}
122 123
123QString Field::label() 124QString Field::label()
124{ 125{
125 switch ( mImpl->fieldId() ) { 126 switch ( mImpl->fieldId() ) {
126 case FieldImpl::FormattedName: 127 case FieldImpl::FormattedName:
127 return Addressee::formattedNameLabel(); 128 return Addressee::formattedNameLabel();
128 case FieldImpl::FamilyName: 129 case FieldImpl::FamilyName:
129 return Addressee::familyNameLabel(); 130 return Addressee::familyNameLabel();
130 case FieldImpl::GivenName: 131 case FieldImpl::GivenName:
131 return Addressee::givenNameLabel(); 132 return Addressee::givenNameLabel();
132 case FieldImpl::AdditionalName: 133 case FieldImpl::AdditionalName:
133 return Addressee::additionalNameLabel(); 134 return Addressee::additionalNameLabel();
134 case FieldImpl::Prefix: 135 case FieldImpl::Prefix:
135 return Addressee::prefixLabel(); 136 return Addressee::prefixLabel();
136 case FieldImpl::Suffix: 137 case FieldImpl::Suffix:
137 return Addressee::suffixLabel(); 138 return Addressee::suffixLabel();
138 case FieldImpl::NickName: 139 case FieldImpl::NickName:
139 return Addressee::nickNameLabel(); 140 return Addressee::nickNameLabel();
140 case FieldImpl::Birthday: 141 case FieldImpl::Birthday:
141 return Addressee::birthdayLabel(); 142 return Addressee::birthdayLabel();
142 case FieldImpl::HomeAddressStreet: 143 case FieldImpl::HomeAddressStreet:
143 return Addressee::homeAddressStreetLabel(); 144 return Addressee::homeAddressStreetLabel();
144 case FieldImpl::HomeAddressLocality: 145 case FieldImpl::HomeAddressLocality:
145 return Addressee::homeAddressLocalityLabel(); 146 return Addressee::homeAddressLocalityLabel();
146 case FieldImpl::HomeAddressRegion: 147 case FieldImpl::HomeAddressRegion:
147 return Addressee::homeAddressRegionLabel(); 148 return Addressee::homeAddressRegionLabel();
148 case FieldImpl::HomeAddressPostalCode: 149 case FieldImpl::HomeAddressPostalCode:
149 return Addressee::homeAddressPostalCodeLabel(); 150 return Addressee::homeAddressPostalCodeLabel();
150 case FieldImpl::HomeAddressCountry: 151 case FieldImpl::HomeAddressCountry:
151 return Addressee::homeAddressCountryLabel(); 152 return Addressee::homeAddressCountryLabel();
152 case FieldImpl::HomeAddressLabel: 153 case FieldImpl::HomeAddressLabel:
153 return Addressee::homeAddressLabelLabel(); 154 return Addressee::homeAddressLabelLabel();
154 case FieldImpl::BusinessAddressStreet: 155 case FieldImpl::BusinessAddressStreet:
155 return Addressee::businessAddressStreetLabel(); 156 return Addressee::businessAddressStreetLabel();
156 case FieldImpl::BusinessAddressLocality: 157 case FieldImpl::BusinessAddressLocality:
157 return Addressee::businessAddressLocalityLabel(); 158 return Addressee::businessAddressLocalityLabel();
158 case FieldImpl::BusinessAddressRegion: 159 case FieldImpl::BusinessAddressRegion:
159 return Addressee::businessAddressRegionLabel(); 160 return Addressee::businessAddressRegionLabel();
160 case FieldImpl::BusinessAddressPostalCode: 161 case FieldImpl::BusinessAddressPostalCode:
161 return Addressee::businessAddressPostalCodeLabel(); 162 return Addressee::businessAddressPostalCodeLabel();
162 case FieldImpl::BusinessAddressCountry: 163 case FieldImpl::BusinessAddressCountry:
163 return Addressee::businessAddressCountryLabel(); 164 return Addressee::businessAddressCountryLabel();
164 case FieldImpl::BusinessAddressLabel: 165 case FieldImpl::BusinessAddressLabel:
165 return Addressee::businessAddressLabelLabel(); 166 return Addressee::businessAddressLabelLabel();
166 case FieldImpl::HomePhone: 167 case FieldImpl::HomePhone:
167 return Addressee::homePhoneLabel(); 168 return Addressee::homePhoneLabel();
168 case FieldImpl::BusinessPhone: 169 case FieldImpl::BusinessPhone:
169 return Addressee::businessPhoneLabel(); 170 return Addressee::businessPhoneLabel();
170 case FieldImpl::MobilePhone: 171 case FieldImpl::MobilePhone:
171 return Addressee::mobilePhoneLabel(); 172 return Addressee::mobilePhoneLabel();
172 case FieldImpl::HomeFax: 173 case FieldImpl::HomeFax:
173 return Addressee::homeFaxLabel(); 174 return Addressee::homeFaxLabel();
174 case FieldImpl::BusinessFax: 175 case FieldImpl::BusinessFax:
175 return Addressee::businessFaxLabel(); 176 return Addressee::businessFaxLabel();
176 case FieldImpl::CarPhone: 177 case FieldImpl::CarPhone:
177 return Addressee::carPhoneLabel(); 178 return Addressee::carPhoneLabel();
178 case FieldImpl::Isdn: 179 case FieldImpl::Isdn:
179 return Addressee::isdnLabel(); 180 return Addressee::isdnLabel();
180 case FieldImpl::Pager: 181 case FieldImpl::Pager:
181 return Addressee::pagerLabel(); 182 return Addressee::pagerLabel();
182 case FieldImpl::Email: 183 case FieldImpl::Email:
183 return Addressee::emailLabel(); 184 return Addressee::emailLabel();
184 case FieldImpl::Mailer: 185 case FieldImpl::Mailer:
185 return Addressee::mailerLabel(); 186 return Addressee::mailerLabel();
186 case FieldImpl::Title: 187 case FieldImpl::Title:
187 return Addressee::titleLabel(); 188 return Addressee::titleLabel();
188 case FieldImpl::Role: 189 case FieldImpl::Role:
189 return Addressee::roleLabel(); 190 return Addressee::roleLabel();
190 case FieldImpl::Organization: 191 case FieldImpl::Organization:
191 return Addressee::organizationLabel(); 192 return Addressee::organizationLabel();
192 case FieldImpl::Note: 193 case FieldImpl::Note:
193 return Addressee::noteLabel(); 194 return Addressee::noteLabel();
194 case FieldImpl::Url: 195 case FieldImpl::Url:
195 return Addressee::urlLabel(); 196 return Addressee::urlLabel();
196 case FieldImpl::Resource: 197 case FieldImpl::Resource:
197 return Addressee::resourceLabel(); 198 return Addressee::resourceLabel();
199 case FieldImpl::Category:
200 return Addressee::categoryLabel();
198 case FieldImpl::Sip: 201 case FieldImpl::Sip:
199 return Addressee::sipLabel(); 202 return Addressee::sipLabel();
200 case FieldImpl::CustomField: 203 case FieldImpl::CustomField:
201 return mImpl->label(); 204 return mImpl->label();
202 default: 205 default:
203 return i18n("Unknown Field"); 206 return i18n("Unknown Field");
204 } 207 }
205} 208}
206 209
207int Field::category() 210int Field::category()
208{ 211{
209 return mImpl->category(); 212 return mImpl->category();
210} 213}
211 214
212QString Field::categoryLabel( int category ) 215QString Field::categoryLabel( int category )
213{ 216{
214 switch ( category ) { 217 switch ( category ) {
215 case All: 218 case All:
216 return i18n("All"); 219 return i18n("All");
217 case Frequent: 220 case Frequent:
218 return i18n("Frequent"); 221 return i18n("Frequent");
219 case Address: 222 case Address:
220 return i18n("Address"); 223 return i18n("Address");
221 case Email: 224 case Email:
222 return i18n("Email"); 225 return i18n("Email");
223 case Personal: 226 case Personal:
224 return i18n("Personal"); 227 return i18n("Personal");
225 case Organization: 228 case Organization:
226 return i18n("Organization"); 229 return i18n("Organization");
227 case CustomCategory: 230 case CustomCategory:
228 return i18n("Custom"); 231 return i18n("Custom");
229 default: 232 default:
230 return i18n("Undefined"); 233 return i18n("Undefined");
231 } 234 }
232} 235}
233 236
234QString Field::value( const KABC::Addressee &a ) 237QString Field::value( const KABC::Addressee &a )
235{ 238{
236 switch ( mImpl->fieldId() ) { 239 switch ( mImpl->fieldId() ) {
237 case FieldImpl::FormattedName: 240 case FieldImpl::FormattedName:
238 return a.formattedName(); 241 return a.formattedName();
239 case FieldImpl::FamilyName: 242 case FieldImpl::FamilyName:
240 return a.familyName(); 243 return a.familyName();
241 case FieldImpl::GivenName: 244 case FieldImpl::GivenName:
242 return a.givenName(); 245 return a.givenName();
243 case FieldImpl::AdditionalName: 246 case FieldImpl::AdditionalName:
244 return a.additionalName(); 247 return a.additionalName();
245 case FieldImpl::Prefix: 248 case FieldImpl::Prefix:
246 return a.prefix(); 249 return a.prefix();
247 case FieldImpl::Suffix: 250 case FieldImpl::Suffix:
248 return a.suffix(); 251 return a.suffix();
249 case FieldImpl::NickName: 252 case FieldImpl::NickName:
250 return a.nickName(); 253 return a.nickName();
251 case FieldImpl::Mailer: 254 case FieldImpl::Mailer:
252 return a.mailer(); 255 return a.mailer();
253 case FieldImpl::Title: 256 case FieldImpl::Title:
254 return a.title(); 257 return a.title();
255 case FieldImpl::Role: 258 case FieldImpl::Role:
256 return a.role(); 259 return a.role();
257 case FieldImpl::Organization: 260 case FieldImpl::Organization:
258 return a.organization(); 261 return a.organization();
259 case FieldImpl::Note: 262 case FieldImpl::Note:
260 return a.note(); 263 return a.note();
261 case FieldImpl::Email: 264 case FieldImpl::Email:
262 return a.preferredEmail(); 265 return a.preferredEmail();
263 case FieldImpl::Birthday: 266 case FieldImpl::Birthday:
264 if ( a.birthday().isValid() ) { 267 if ( a.birthday().isValid() ) {
265//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 268//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
266// But Qt::IsoDate was not specified. 269// But Qt::IsoDate was not specified.
267// QString _oldFormat = KGlobal::locale()->dateFormat(); 270// QString _oldFormat = KGlobal::locale()->dateFormat();
268// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 271// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
269 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 272 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
270// KGlobal::locale()->setDateFormat(_oldFormat); 273// KGlobal::locale()->setDateFormat(_oldFormat);
271 return dt; 274 return dt;
272 } 275 }
273 else 276 else
274 return QString::null; 277 return QString::null;
275 case FieldImpl::Url: 278 case FieldImpl::Url:
276 return a.url().prettyURL(); 279 return a.url().prettyURL();
277//US 280//US
278 case FieldImpl::Resource: 281 case FieldImpl::Resource:
279 return a.resource()->resourceName(); 282 return a.resource()->resourceName();
283 case FieldImpl::Category:
284 return a.categories().join(",");
280 case FieldImpl::HomePhone: 285 case FieldImpl::HomePhone:
281 return a.phoneNumber( PhoneNumber::Home ).number(); 286 return a.phoneNumber( PhoneNumber::Home ).number();
282 case FieldImpl::BusinessPhone: 287 case FieldImpl::BusinessPhone:
283 return a.phoneNumber( PhoneNumber::Work ).number(); 288 return a.phoneNumber( PhoneNumber::Work ).number();
284 case FieldImpl::MobilePhone: 289 case FieldImpl::MobilePhone:
285 return a.phoneNumber( PhoneNumber::Cell ).number(); 290 return a.phoneNumber( PhoneNumber::Cell ).number();
286 case FieldImpl::HomeFax: 291 case FieldImpl::HomeFax:
287 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 292 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
288 case FieldImpl::BusinessFax: 293 case FieldImpl::BusinessFax:
289 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 294 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
290 case FieldImpl::CarPhone: 295 case FieldImpl::CarPhone:
291 return a.phoneNumber( PhoneNumber::Car ).number(); 296 return a.phoneNumber( PhoneNumber::Car ).number();
292 case FieldImpl::Isdn: 297 case FieldImpl::Isdn:
293 return a.phoneNumber( PhoneNumber::Isdn ).number(); 298 return a.phoneNumber( PhoneNumber::Isdn ).number();
294 case FieldImpl::Pager: 299 case FieldImpl::Pager:
295 return a.phoneNumber( PhoneNumber::Pager ).number(); 300 return a.phoneNumber( PhoneNumber::Pager ).number();
296 case FieldImpl::Sip: 301 case FieldImpl::Sip:
297 return a.phoneNumber( PhoneNumber::Sip ).number(); 302 return a.phoneNumber( PhoneNumber::Sip ).number();
298 case FieldImpl::HomeAddressStreet: 303 case FieldImpl::HomeAddressStreet:
299 return a.address( Address::Home ).street(); 304 return a.address( Address::Home ).street();
300 case FieldImpl::HomeAddressLocality: 305 case FieldImpl::HomeAddressLocality:
301 return a.address( Address::Home ).locality(); 306 return a.address( Address::Home ).locality();
302 case FieldImpl::HomeAddressRegion: 307 case FieldImpl::HomeAddressRegion:
303 return a.address( Address::Home ).region(); 308 return a.address( Address::Home ).region();
304 case FieldImpl::HomeAddressPostalCode: 309 case FieldImpl::HomeAddressPostalCode:
305 return a.address( Address::Home ).postalCode(); 310 return a.address( Address::Home ).postalCode();
306 case FieldImpl::HomeAddressCountry: 311 case FieldImpl::HomeAddressCountry:
307 return a.address( Address::Home ).country(); 312 return a.address( Address::Home ).country();
308 case FieldImpl::BusinessAddressStreet: 313 case FieldImpl::BusinessAddressStreet:
309 return a.address( Address::Work ).street(); 314 return a.address( Address::Work ).street();
310 case FieldImpl::BusinessAddressLocality: 315 case FieldImpl::BusinessAddressLocality:
311 return a.address( Address::Work ).locality(); 316 return a.address( Address::Work ).locality();
312 case FieldImpl::BusinessAddressRegion: 317 case FieldImpl::BusinessAddressRegion:
313 return a.address( Address::Work ).region(); 318 return a.address( Address::Work ).region();
314 case FieldImpl::BusinessAddressPostalCode: 319 case FieldImpl::BusinessAddressPostalCode:
315 return a.address( Address::Work ).postalCode(); 320 return a.address( Address::Work ).postalCode();
316 case FieldImpl::BusinessAddressCountry: 321 case FieldImpl::BusinessAddressCountry:
317 return a.address( Address::Work ).country(); 322 return a.address( Address::Work ).country();
318 case FieldImpl::CustomField: 323 case FieldImpl::CustomField:
319 return a.custom( mImpl->app(), mImpl->key() ); 324 return a.custom( mImpl->app(), mImpl->key() );
320 default: 325 default:
321 return QString::null; 326 return QString::null;
322 } 327 }
323} 328}
324 329
325bool Field::setValue( KABC::Addressee &a, const QString &value ) 330bool Field::setValue( KABC::Addressee &a, const QString &value )
326{ 331{
327 switch ( mImpl->fieldId() ) { 332 switch ( mImpl->fieldId() ) {
328 case FieldImpl::FormattedName: 333 case FieldImpl::FormattedName:
329 a.setFormattedName( value ); 334 a.setFormattedName( value );
330 return true; 335 return true;
331 case FieldImpl::FamilyName: 336 case FieldImpl::FamilyName:
332 a.setFamilyName( value ); 337 a.setFamilyName( value );
333 return true; 338 return true;
334 case FieldImpl::GivenName: 339 case FieldImpl::GivenName:
335 a.setGivenName( value ); 340 a.setGivenName( value );
336 return true; 341 return true;
337 case FieldImpl::AdditionalName: 342 case FieldImpl::AdditionalName:
338 a.setAdditionalName( value ); 343 a.setAdditionalName( value );
339 return true; 344 return true;
340 case FieldImpl::Prefix: 345 case FieldImpl::Prefix:
341 a.setPrefix( value ); 346 a.setPrefix( value );
342 return true; 347 return true;
343 case FieldImpl::Suffix: 348 case FieldImpl::Suffix:
344 a.setSuffix( value ); 349 a.setSuffix( value );
345 return true; 350 return true;
346 case FieldImpl::NickName: 351 case FieldImpl::NickName:
347 a.setNickName( value ); 352 a.setNickName( value );
348 return true; 353 return true;
349 case FieldImpl::Mailer: 354 case FieldImpl::Mailer:
350 a.setMailer( value ); 355 a.setMailer( value );
351 return true; 356 return true;
352 case FieldImpl::Title: 357 case FieldImpl::Title:
353 a.setTitle( value ); 358 a.setTitle( value );
354 return true; 359 return true;
355 case FieldImpl::Role: 360 case FieldImpl::Role:
356 a.setRole( value ); 361 a.setRole( value );
357 return true; 362 return true;
358 case FieldImpl::Organization: 363 case FieldImpl::Organization:
359 a.setOrganization( value ); 364 a.setOrganization( value );
360 return true; 365 return true;
361 case FieldImpl::Note: 366 case FieldImpl::Note:
362 a.setNote( value ); 367 a.setNote( value );
363 return true; 368 return true;
364 case FieldImpl::Birthday: 369 case FieldImpl::Birthday:
365//US 370//US
366//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 371//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
367// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 372// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
368 { 373 {
369 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 374 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
370 a.setBirthday(dt); 375 a.setBirthday(dt);
371 } 376 }
372 return true; 377 return true;
373 case FieldImpl::CustomField: 378 case FieldImpl::CustomField:
374 a.insertCustom( mImpl->app(), mImpl->key(), value ); 379 a.insertCustom( mImpl->app(), mImpl->key(), value );
375//US never copy the resourcename back to the adressee. 380//US never copy the resourcename back to the adressee.
376 case FieldImpl::Resource: 381 case FieldImpl::Resource:
377 default: 382 default:
378 return false; 383 return false;
379 } 384 }
380} 385}
381 386
382bool Field::isCustom() 387bool Field::isCustom()
383{ 388{
384 return mImpl->fieldId() == FieldImpl::CustomField; 389 return mImpl->fieldId() == FieldImpl::CustomField;
385} 390}
386 391
387Field::List Field::allFields() 392Field::List Field::allFields()
388{ 393{
389 if ( mAllFields.isEmpty() ) { 394 if ( mAllFields.isEmpty() ) {
390 createField( FieldImpl::FormattedName, Frequent ); 395 createField( FieldImpl::FormattedName, Frequent );
391 createField( FieldImpl::FamilyName, Frequent ); 396 createField( FieldImpl::FamilyName, Frequent );
392 createField( FieldImpl::GivenName, Frequent ); 397 createField( FieldImpl::GivenName, Frequent );
393 createField( FieldImpl::AdditionalName ); 398 createField( FieldImpl::AdditionalName );
394 createField( FieldImpl::Prefix ); 399 createField( FieldImpl::Prefix );
395 createField( FieldImpl::Suffix ); 400 createField( FieldImpl::Suffix );
396 createField( FieldImpl::NickName, Personal ); 401 createField( FieldImpl::NickName, Personal );
397 createField( FieldImpl::Birthday, Personal ); 402 createField( FieldImpl::Birthday, Personal );
403 createField( FieldImpl::Category );
398 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 404 createField( FieldImpl::HomeAddressStreet, Address|Personal );
399 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 405 createField( FieldImpl::HomeAddressLocality, Address|Personal );
400 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 406 createField( FieldImpl::HomeAddressRegion, Address|Personal );
401 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 407 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
402 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 408 createField( FieldImpl::HomeAddressCountry, Address|Personal );
403 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 409 createField( FieldImpl::HomeAddressLabel, Address|Personal );
404 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 410 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
405 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 411 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
406 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 412 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
407 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 413 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
408 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 414 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
409 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 415 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
410 createField( FieldImpl::HomePhone, Personal|Frequent ); 416 createField( FieldImpl::HomePhone, Personal|Frequent );
411 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 417 createField( FieldImpl::BusinessPhone, Organization|Frequent );
412 createField( FieldImpl::MobilePhone, Frequent ); 418 createField( FieldImpl::MobilePhone, Frequent );
413 createField( FieldImpl::HomeFax ); 419 createField( FieldImpl::HomeFax );
414 createField( FieldImpl::BusinessFax ); 420 createField( FieldImpl::BusinessFax );
415 createField( FieldImpl::CarPhone ); 421 createField( FieldImpl::CarPhone );
416 createField( FieldImpl::Isdn ); 422 createField( FieldImpl::Isdn );
417 createField( FieldImpl::Pager ); 423 createField( FieldImpl::Pager );
418 createField( FieldImpl::Email, Email|Frequent ); 424 createField( FieldImpl::Email, Email|Frequent );
419 createField( FieldImpl::Mailer, Email ); 425 createField( FieldImpl::Mailer, Email );
420 createField( FieldImpl::Title, Organization ); 426 createField( FieldImpl::Title, Organization );
421 createField( FieldImpl::Role, Organization ); 427 createField( FieldImpl::Role, Organization );
422 createField( FieldImpl::Organization, Organization ); 428 createField( FieldImpl::Organization, Organization );
423 createField( FieldImpl::Note ); 429 createField( FieldImpl::Note );
424 createField( FieldImpl::Url ); 430 createField( FieldImpl::Url );
425 createField( FieldImpl::Resource ); 431 createField( FieldImpl::Resource );
426 createField( FieldImpl::Sip ); 432 createField( FieldImpl::Sip );
427 } 433 }
428 434
429 return mAllFields; 435 return mAllFields;
430} 436}
431 437
432Field::List Field::defaultFields() 438Field::List Field::defaultFields()
433{ 439{
434 if ( mDefaultFields.isEmpty() ) { 440 if ( mDefaultFields.isEmpty() ) {
435 createDefaultField( FieldImpl::GivenName ); 441 createDefaultField( FieldImpl::GivenName );
436 createDefaultField( FieldImpl::FamilyName ); 442 createDefaultField( FieldImpl::FamilyName );
437 createDefaultField( FieldImpl::Email ); 443 createDefaultField( FieldImpl::Email );
438 } 444 }
439 445
440 return mDefaultFields; 446 return mDefaultFields;
441} 447}
442 448
443void Field::createField( int id, int category ) 449void Field::createField( int id, int category )
444{ 450{
445 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 451 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
446} 452}
447 453
448void Field::createDefaultField( int id, int category ) 454void Field::createDefaultField( int id, int category )
449{ 455{
450 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 456 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
451} 457}
452 458
453void Field::deleteFields() 459void Field::deleteFields()
454{ 460{
455 Field::List::ConstIterator it; 461 Field::List::ConstIterator it;
456 462
457 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 463 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
458 delete (*it); 464 delete (*it);
459 } 465 }
460 mAllFields.clear(); 466 mAllFields.clear();
461 467
462 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 468 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
463 delete (*it); 469 delete (*it);
464 } 470 }
465 mDefaultFields.clear(); 471 mDefaultFields.clear();
466 472
467 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 473 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
468 delete (*it); 474 delete (*it);
469 } 475 }
470 mCustomFields.clear(); 476 mCustomFields.clear();
471} 477}
472 478
473void Field::saveFields( const QString &identifier, 479void Field::saveFields( const QString &identifier,
474 const Field::List &fields ) 480 const Field::List &fields )
475{ 481{
476 KConfig *cfg = KGlobal::config(); 482 KConfig *cfg = KGlobal::config();
477 KConfigGroupSaver( cfg, "KABCFields" ); 483 KConfigGroupSaver( cfg, "KABCFields" );
478 saveFields( cfg, identifier, fields ); 484 saveFields( cfg, identifier, fields );
479} 485}
480 486
481void Field::saveFields( KConfig *cfg, const QString &identifier, 487void Field::saveFields( KConfig *cfg, const QString &identifier,
482 const Field::List &fields ) 488 const Field::List &fields )
483{ 489{
484 QValueList<int> fieldIds; 490 QValueList<int> fieldIds;
485 491
486//US 492//US
487// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); 493// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
488 494
489 int custom = 0; 495 int custom = 0;
490 Field::List::ConstIterator it; 496 Field::List::ConstIterator it;
491 for( it = fields.begin(); it != fields.end(); ++it ) { 497 for( it = fields.begin(); it != fields.end(); ++it ) {
492//US 498//US
493// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); 499// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId());
494 500
495 fieldIds.append( (*it)->mImpl->fieldId() ); 501 fieldIds.append( (*it)->mImpl->fieldId() );
496 if( (*it)->isCustom() ) { 502 if( (*it)->isCustom() ) {
497 QStringList customEntry; 503 QStringList customEntry;
498 customEntry << (*it)->mImpl->label(); 504 customEntry << (*it)->mImpl->label();
499 customEntry << (*it)->mImpl->key(); 505 customEntry << (*it)->mImpl->key();
500 customEntry << (*it)->mImpl->app(); 506 customEntry << (*it)->mImpl->app();
501 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + 507 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" +
502 QString::number( custom++ ), customEntry ); 508 QString::number( custom++ ), customEntry );
503 } 509 }
504 } 510 }
505 cfg->writeEntry( identifier, fieldIds ); 511 cfg->writeEntry( identifier, fieldIds );
506} 512}
507 513
508Field::List Field::restoreFields( const QString &identifier ) 514Field::List Field::restoreFields( const QString &identifier )
509{ 515{
510//US 516//US
511// qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); 517// qDebug("Field::restoreFields, identifier: %s", identifier.latin1());
512 518
513 KConfig *cfg = KGlobal::config(); 519 KConfig *cfg = KGlobal::config();
514 KConfigGroupSaver( cfg, "KABCFields" ); 520 KConfigGroupSaver( cfg, "KABCFields" );
515 cfg->setGroup( "KABCFields" ); 521 cfg->setGroup( "KABCFields" );
516 522
517 Field::List l = restoreFields( cfg, identifier ); 523 Field::List l = restoreFields( cfg, identifier );
518 524
519 return l; 525 return l;
520} 526}
521 527
522Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) 528Field::List Field::restoreFields( KConfig *cfg, const QString &identifier )
523{ 529{
524 QValueList<int> fieldIds = cfg->readIntListEntry( identifier); 530 QValueList<int> fieldIds = cfg->readIntListEntry( identifier);
525//US 531//US
526// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); 532// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1());
527 533
528 Field::List fields; 534 Field::List fields;
529 535
530 int custom = 0; 536 int custom = 0;
531 QValueList<int>::ConstIterator it; 537 QValueList<int>::ConstIterator it;
532 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { 538 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
533 FieldImpl *f = 0; 539 FieldImpl *f = 0;
534 if ( (*it) == FieldImpl::CustomField ) { 540 if ( (*it) == FieldImpl::CustomField ) {
535 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + 541 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" +
536 identifier + "_" + 542 identifier + "_" +
537 QString::number( custom++ ) ); 543 QString::number( custom++ ) );
538 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], 544 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ],
539 customEntry[ 1 ], customEntry[ 2 ] ); 545 customEntry[ 1 ], customEntry[ 2 ] );
540 } else { 546 } else {
541 f = new FieldImpl( *it ); 547 f = new FieldImpl( *it );
542 } 548 }
543 fields.append( new Field( f ) ); 549 fields.append( new Field( f ) );
544 } 550 }
545 551
546 return fields; 552 return fields;
547} 553}
548 554
549bool Field::equals( Field *field ) 555bool Field::equals( Field *field )
550{ 556{
551 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); 557 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() );
552 558
553 if ( !sameId ) return false; 559 if ( !sameId ) return false;
554 560
555 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; 561 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true;
556 562
557 return mImpl->key() == field->mImpl->key(); 563 return mImpl->key() == field->mImpl->key();
558} 564}
559 565
560Field *Field::createCustomField( const QString &label, int category, 566Field *Field::createCustomField( const QString &label, int category,
561 const QString &key, const QString &app ) 567 const QString &key, const QString &app )
562{ 568{
563 Field *field = new Field( new FieldImpl( FieldImpl::CustomField, 569 Field *field = new Field( new FieldImpl( FieldImpl::CustomField,
564 category | CustomCategory, 570 category | CustomCategory,
565 label, key, app ) ); 571 label, key, app ) );
566//US 572//US
567// qDebug("Field::createCustomField label %s", label.latin1() ); 573// qDebug("Field::createCustomField label %s", label.latin1() );
568 574
569 mCustomFields.append( field ); 575 mCustomFields.append( field );
570 576
571 return field; 577 return field;
572} 578}