summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp3
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp2
-rw-r--r--microkde/kdecore/kstandarddirs.cpp10
3 files changed, 13 insertions, 2 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 18b4d58..39d14bb 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1242,513 +1242,514 @@ void Addressee::setSecrecy( const Secrecy &secrecy )
1242 mData->secrecy = secrecy; 1242 mData->secrecy = secrecy;
1243} 1243}
1244 1244
1245Secrecy Addressee::secrecy() const 1245Secrecy Addressee::secrecy() const
1246{ 1246{
1247 return mData->secrecy; 1247 return mData->secrecy;
1248} 1248}
1249 1249
1250QString Addressee::secrecyLabel() 1250QString Addressee::secrecyLabel()
1251{ 1251{
1252 return i18n("Security Class"); 1252 return i18n("Security Class");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setLogo( const Picture &logo ) 1256void Addressee::setLogo( const Picture &logo )
1257{ 1257{
1258 if ( logo == mData->logo ) return; 1258 if ( logo == mData->logo ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->logo = logo; 1261 mData->logo = logo;
1262} 1262}
1263 1263
1264Picture Addressee::logo() const 1264Picture Addressee::logo() const
1265{ 1265{
1266 return mData->logo; 1266 return mData->logo;
1267} 1267}
1268 1268
1269QString Addressee::logoLabel() 1269QString Addressee::logoLabel()
1270{ 1270{
1271 return i18n("Logo"); 1271 return i18n("Logo");
1272} 1272}
1273 1273
1274 1274
1275void Addressee::setPhoto( const Picture &photo ) 1275void Addressee::setPhoto( const Picture &photo )
1276{ 1276{
1277 if ( photo == mData->photo ) return; 1277 if ( photo == mData->photo ) return;
1278 detach(); 1278 detach();
1279 mData->empty = false; 1279 mData->empty = false;
1280 mData->photo = photo; 1280 mData->photo = photo;
1281} 1281}
1282 1282
1283Picture Addressee::photo() const 1283Picture Addressee::photo() const
1284{ 1284{
1285 return mData->photo; 1285 return mData->photo;
1286} 1286}
1287 1287
1288QString Addressee::photoLabel() 1288QString Addressee::photoLabel()
1289{ 1289{
1290 return i18n("Photo"); 1290 return i18n("Photo");
1291} 1291}
1292 1292
1293 1293
1294void Addressee::setSound( const Sound &sound ) 1294void Addressee::setSound( const Sound &sound )
1295{ 1295{
1296 if ( sound == mData->sound ) return; 1296 if ( sound == mData->sound ) return;
1297 detach(); 1297 detach();
1298 mData->empty = false; 1298 mData->empty = false;
1299 mData->sound = sound; 1299 mData->sound = sound;
1300} 1300}
1301 1301
1302Sound Addressee::sound() const 1302Sound Addressee::sound() const
1303{ 1303{
1304 return mData->sound; 1304 return mData->sound;
1305} 1305}
1306 1306
1307QString Addressee::soundLabel() 1307QString Addressee::soundLabel()
1308{ 1308{
1309 return i18n("Sound"); 1309 return i18n("Sound");
1310} 1310}
1311 1311
1312 1312
1313void Addressee::setAgent( const Agent &agent ) 1313void Addressee::setAgent( const Agent &agent )
1314{ 1314{
1315 if ( agent == mData->agent ) return; 1315 if ( agent == mData->agent ) return;
1316 detach(); 1316 detach();
1317 mData->empty = false; 1317 mData->empty = false;
1318 mData->agent = agent; 1318 mData->agent = agent;
1319} 1319}
1320 1320
1321Agent Addressee::agent() const 1321Agent Addressee::agent() const
1322{ 1322{
1323 return mData->agent; 1323 return mData->agent;
1324} 1324}
1325 1325
1326QString Addressee::agentLabel() 1326QString Addressee::agentLabel()
1327{ 1327{
1328 return i18n("Agent"); 1328 return i18n("Agent");
1329} 1329}
1330 1330
1331 1331
1332 1332
1333void Addressee::setNameFromString( const QString &str ) 1333void Addressee::setNameFromString( const QString &str )
1334{ 1334{
1335 setFormattedName( str ); 1335 setFormattedName( str );
1336 setName( str ); 1336 setName( str );
1337 1337
1338 static bool first = true; 1338 static bool first = true;
1339 static QStringList titles; 1339 static QStringList titles;
1340 static QStringList suffixes; 1340 static QStringList suffixes;
1341 static QStringList prefixes; 1341 static QStringList prefixes;
1342 1342
1343 if ( first ) { 1343 if ( first ) {
1344 first = false; 1344 first = false;
1345 titles += i18n( "Dr." ); 1345 titles += i18n( "Dr." );
1346 titles += i18n( "Miss" ); 1346 titles += i18n( "Miss" );
1347 titles += i18n( "Mr." ); 1347 titles += i18n( "Mr." );
1348 titles += i18n( "Mrs." ); 1348 titles += i18n( "Mrs." );
1349 titles += i18n( "Ms." ); 1349 titles += i18n( "Ms." );
1350 titles += i18n( "Prof." ); 1350 titles += i18n( "Prof." );
1351 1351
1352 suffixes += i18n( "I" ); 1352 suffixes += i18n( "I" );
1353 suffixes += i18n( "II" ); 1353 suffixes += i18n( "II" );
1354 suffixes += i18n( "III" ); 1354 suffixes += i18n( "III" );
1355 suffixes += i18n( "Jr." ); 1355 suffixes += i18n( "Jr." );
1356 suffixes += i18n( "Sr." ); 1356 suffixes += i18n( "Sr." );
1357 1357
1358 prefixes += "van"; 1358 prefixes += "van";
1359 prefixes += "von"; 1359 prefixes += "von";
1360 prefixes += "de"; 1360 prefixes += "de";
1361 1361
1362 KConfig config( locateLocal( "config", "kabcrc") ); 1362 KConfig config( locateLocal( "config", "kabcrc") );
1363 config.setGroup( "General" ); 1363 config.setGroup( "General" );
1364 titles += config.readListEntry( "Prefixes" ); 1364 titles += config.readListEntry( "Prefixes" );
1365 titles.remove( "" ); 1365 titles.remove( "" );
1366 prefixes += config.readListEntry( "Inclusions" ); 1366 prefixes += config.readListEntry( "Inclusions" );
1367 prefixes.remove( "" ); 1367 prefixes.remove( "" );
1368 suffixes += config.readListEntry( "Suffixes" ); 1368 suffixes += config.readListEntry( "Suffixes" );
1369 suffixes.remove( "" ); 1369 suffixes.remove( "" );
1370 } 1370 }
1371 1371
1372 // clear all name parts 1372 // clear all name parts
1373 setPrefix( "" ); 1373 setPrefix( "" );
1374 setGivenName( "" ); 1374 setGivenName( "" );
1375 setAdditionalName( "" ); 1375 setAdditionalName( "" );
1376 setFamilyName( "" ); 1376 setFamilyName( "" );
1377 setSuffix( "" ); 1377 setSuffix( "" );
1378 1378
1379 if ( str.isEmpty() ) 1379 if ( str.isEmpty() )
1380 return; 1380 return;
1381 1381
1382 int i = str.find(','); 1382 int i = str.find(',');
1383 if( i < 0 ) { 1383 if( i < 0 ) {
1384 QStringList parts = QStringList::split( " ", str ); 1384 QStringList parts = QStringList::split( " ", str );
1385 int leftOffset = 0; 1385 int leftOffset = 0;
1386 int rightOffset = parts.count() - 1; 1386 int rightOffset = parts.count() - 1;
1387 1387
1388 QString suffix; 1388 QString suffix;
1389 while ( rightOffset >= 0 ) { 1389 while ( rightOffset >= 0 ) {
1390 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1390 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1392 rightOffset--; 1392 rightOffset--;
1393 } else 1393 } else
1394 break; 1394 break;
1395 } 1395 }
1396 setSuffix( suffix ); 1396 setSuffix( suffix );
1397 1397
1398 if ( rightOffset < 0 ) 1398 if ( rightOffset < 0 )
1399 return; 1399 return;
1400 1400
1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1403 rightOffset--; 1403 rightOffset--;
1404 } else 1404 } else
1405 setFamilyName( parts[ rightOffset ] ); 1405 setFamilyName( parts[ rightOffset ] );
1406 1406
1407 QString prefix; 1407 QString prefix;
1408 while ( leftOffset < rightOffset ) { 1408 while ( leftOffset < rightOffset ) {
1409 if ( titles.contains( parts[ leftOffset ] ) ) { 1409 if ( titles.contains( parts[ leftOffset ] ) ) {
1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1411 leftOffset++; 1411 leftOffset++;
1412 } else 1412 } else
1413 break; 1413 break;
1414 } 1414 }
1415 setPrefix( prefix ); 1415 setPrefix( prefix );
1416 1416
1417 if ( leftOffset < rightOffset ) { 1417 if ( leftOffset < rightOffset ) {
1418 setGivenName( parts[ leftOffset ] ); 1418 setGivenName( parts[ leftOffset ] );
1419 leftOffset++; 1419 leftOffset++;
1420 } 1420 }
1421 1421
1422 QString additionalName; 1422 QString additionalName;
1423 while ( leftOffset < rightOffset ) { 1423 while ( leftOffset < rightOffset ) {
1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1425 leftOffset++; 1425 leftOffset++;
1426 } 1426 }
1427 setAdditionalName( additionalName ); 1427 setAdditionalName( additionalName );
1428 } else { 1428 } else {
1429 QString part1 = str.left( i ); 1429 QString part1 = str.left( i );
1430 QString part2 = str.mid( i + 1 ); 1430 QString part2 = str.mid( i + 1 );
1431 1431
1432 QStringList parts = QStringList::split( " ", part1 ); 1432 QStringList parts = QStringList::split( " ", part1 );
1433 int leftOffset = 0; 1433 int leftOffset = 0;
1434 int rightOffset = parts.count() - 1; 1434 int rightOffset = parts.count() - 1;
1435 1435
1436 QString suffix; 1436 QString suffix;
1437 while ( rightOffset >= 0 ) { 1437 while ( rightOffset >= 0 ) {
1438 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1438 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1440 rightOffset--; 1440 rightOffset--;
1441 } else 1441 } else
1442 break; 1442 break;
1443 } 1443 }
1444 setSuffix( suffix ); 1444 setSuffix( suffix );
1445 1445
1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1448 rightOffset--; 1448 rightOffset--;
1449 } else 1449 } else
1450 setFamilyName( parts[ rightOffset ] ); 1450 setFamilyName( parts[ rightOffset ] );
1451 1451
1452 QString prefix; 1452 QString prefix;
1453 while ( leftOffset < rightOffset ) { 1453 while ( leftOffset < rightOffset ) {
1454 if ( titles.contains( parts[ leftOffset ] ) ) { 1454 if ( titles.contains( parts[ leftOffset ] ) ) {
1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1456 leftOffset++; 1456 leftOffset++;
1457 } else 1457 } else
1458 break; 1458 break;
1459 } 1459 }
1460 1460
1461 parts = QStringList::split( " ", part2 ); 1461 parts = QStringList::split( " ", part2 );
1462 1462
1463 leftOffset = 0; 1463 leftOffset = 0;
1464 rightOffset = parts.count(); 1464 rightOffset = parts.count();
1465 1465
1466 while ( leftOffset < rightOffset ) { 1466 while ( leftOffset < rightOffset ) {
1467 if ( titles.contains( parts[ leftOffset ] ) ) { 1467 if ( titles.contains( parts[ leftOffset ] ) ) {
1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1469 leftOffset++; 1469 leftOffset++;
1470 } else 1470 } else
1471 break; 1471 break;
1472 } 1472 }
1473 setPrefix( prefix ); 1473 setPrefix( prefix );
1474 1474
1475 if ( leftOffset < rightOffset ) { 1475 if ( leftOffset < rightOffset ) {
1476 setGivenName( parts[ leftOffset ] ); 1476 setGivenName( parts[ leftOffset ] );
1477 leftOffset++; 1477 leftOffset++;
1478 } 1478 }
1479 1479
1480 QString additionalName; 1480 QString additionalName;
1481 while ( leftOffset < rightOffset ) { 1481 while ( leftOffset < rightOffset ) {
1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1483 leftOffset++; 1483 leftOffset++;
1484 } 1484 }
1485 setAdditionalName( additionalName ); 1485 setAdditionalName( additionalName );
1486 } 1486 }
1487} 1487}
1488 1488
1489QString Addressee::realName() const 1489QString Addressee::realName() const
1490{ 1490{
1491 if ( !formattedName().isEmpty() ) 1491 if ( !formattedName().isEmpty() )
1492 return formattedName(); 1492 return formattedName();
1493 1493
1494 QString n = assembledName(); 1494 QString n = assembledName();
1495 1495
1496 if ( n.isEmpty() ) 1496 if ( n.isEmpty() )
1497 n = name(); 1497 n = name();
1498 1498 if ( n.isEmpty() )
1499 n = organization();
1499 return n; 1500 return n;
1500} 1501}
1501 1502
1502QString Addressee::assembledName() const 1503QString Addressee::assembledName() const
1503{ 1504{
1504 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1505 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1505 familyName() + " " + suffix(); 1506 familyName() + " " + suffix();
1506 1507
1507 return name.simplifyWhiteSpace(); 1508 return name.simplifyWhiteSpace();
1508} 1509}
1509 1510
1510QString Addressee::fullEmail( const QString &email ) const 1511QString Addressee::fullEmail( const QString &email ) const
1511{ 1512{
1512 QString e; 1513 QString e;
1513 if ( email.isNull() ) { 1514 if ( email.isNull() ) {
1514 e = preferredEmail(); 1515 e = preferredEmail();
1515 } else { 1516 } else {
1516 e = email; 1517 e = email;
1517 } 1518 }
1518 if ( e.isEmpty() ) return QString::null; 1519 if ( e.isEmpty() ) return QString::null;
1519 1520
1520 QString text; 1521 QString text;
1521 if ( realName().isEmpty() ) 1522 if ( realName().isEmpty() )
1522 text = e; 1523 text = e;
1523 else 1524 else
1524 text = assembledName() + " <" + e + ">"; 1525 text = assembledName() + " <" + e + ">";
1525 1526
1526 return text; 1527 return text;
1527} 1528}
1528 1529
1529void Addressee::insertEmail( const QString &email, bool preferred ) 1530void Addressee::insertEmail( const QString &email, bool preferred )
1530{ 1531{
1531 detach(); 1532 detach();
1532 1533
1533 QStringList::Iterator it = mData->emails.find( email ); 1534 QStringList::Iterator it = mData->emails.find( email );
1534 1535
1535 if ( it != mData->emails.end() ) { 1536 if ( it != mData->emails.end() ) {
1536 if ( !preferred || it == mData->emails.begin() ) return; 1537 if ( !preferred || it == mData->emails.begin() ) return;
1537 mData->emails.remove( it ); 1538 mData->emails.remove( it );
1538 mData->emails.prepend( email ); 1539 mData->emails.prepend( email );
1539 } else { 1540 } else {
1540 if ( preferred ) { 1541 if ( preferred ) {
1541 mData->emails.prepend( email ); 1542 mData->emails.prepend( email );
1542 } else { 1543 } else {
1543 mData->emails.append( email ); 1544 mData->emails.append( email );
1544 } 1545 }
1545 } 1546 }
1546} 1547}
1547 1548
1548void Addressee::removeEmail( const QString &email ) 1549void Addressee::removeEmail( const QString &email )
1549{ 1550{
1550 detach(); 1551 detach();
1551 1552
1552 QStringList::Iterator it = mData->emails.find( email ); 1553 QStringList::Iterator it = mData->emails.find( email );
1553 if ( it == mData->emails.end() ) return; 1554 if ( it == mData->emails.end() ) return;
1554 1555
1555 mData->emails.remove( it ); 1556 mData->emails.remove( it );
1556} 1557}
1557 1558
1558QString Addressee::preferredEmail() const 1559QString Addressee::preferredEmail() const
1559{ 1560{
1560 if ( mData->emails.count() == 0 ) return QString::null; 1561 if ( mData->emails.count() == 0 ) return QString::null;
1561 else return mData->emails.first(); 1562 else return mData->emails.first();
1562} 1563}
1563 1564
1564QStringList Addressee::emails() const 1565QStringList Addressee::emails() const
1565{ 1566{
1566 return mData->emails; 1567 return mData->emails;
1567} 1568}
1568void Addressee::setEmails( const QStringList& emails ) { 1569void Addressee::setEmails( const QStringList& emails ) {
1569 detach(); 1570 detach();
1570 mData->emails = emails; 1571 mData->emails = emails;
1571} 1572}
1572void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1573void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1573{ 1574{
1574 detach(); 1575 detach();
1575 mData->empty = false; 1576 mData->empty = false;
1576 1577
1577 PhoneNumber::List::Iterator it; 1578 PhoneNumber::List::Iterator it;
1578 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1579 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1579 if ( (*it).id() == phoneNumber.id() ) { 1580 if ( (*it).id() == phoneNumber.id() ) {
1580 *it = phoneNumber; 1581 *it = phoneNumber;
1581 return; 1582 return;
1582 } 1583 }
1583 } 1584 }
1584 mData->phoneNumbers.append( phoneNumber ); 1585 mData->phoneNumbers.append( phoneNumber );
1585} 1586}
1586 1587
1587void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1588void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1588{ 1589{
1589 detach(); 1590 detach();
1590 1591
1591 PhoneNumber::List::Iterator it; 1592 PhoneNumber::List::Iterator it;
1592 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1593 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1593 if ( (*it).id() == phoneNumber.id() ) { 1594 if ( (*it).id() == phoneNumber.id() ) {
1594 mData->phoneNumbers.remove( it ); 1595 mData->phoneNumbers.remove( it );
1595 return; 1596 return;
1596 } 1597 }
1597 } 1598 }
1598} 1599}
1599 1600
1600PhoneNumber Addressee::phoneNumber( int type ) const 1601PhoneNumber Addressee::phoneNumber( int type ) const
1601{ 1602{
1602 PhoneNumber phoneNumber( "", type ); 1603 PhoneNumber phoneNumber( "", type );
1603 PhoneNumber::List::ConstIterator it; 1604 PhoneNumber::List::ConstIterator it;
1604 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1605 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1605 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1606 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1606 if ( (*it).type() & PhoneNumber::Pref ) 1607 if ( (*it).type() & PhoneNumber::Pref )
1607 return (*it); 1608 return (*it);
1608 else if ( phoneNumber.number().isEmpty() ) 1609 else if ( phoneNumber.number().isEmpty() )
1609 phoneNumber = (*it); 1610 phoneNumber = (*it);
1610 } 1611 }
1611 } 1612 }
1612 1613
1613 return phoneNumber; 1614 return phoneNumber;
1614} 1615}
1615 1616
1616PhoneNumber::List Addressee::phoneNumbers() const 1617PhoneNumber::List Addressee::phoneNumbers() const
1617{ 1618{
1618 return mData->phoneNumbers; 1619 return mData->phoneNumbers;
1619} 1620}
1620 1621
1621PhoneNumber::List Addressee::phoneNumbers( int type ) const 1622PhoneNumber::List Addressee::phoneNumbers( int type ) const
1622{ 1623{
1623 PhoneNumber::List list; 1624 PhoneNumber::List list;
1624 1625
1625 PhoneNumber::List::ConstIterator it; 1626 PhoneNumber::List::ConstIterator it;
1626 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1627 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1627 if ( matchBinaryPattern( (*it).type(), type ) ) { 1628 if ( matchBinaryPattern( (*it).type(), type ) ) {
1628 list.append( *it ); 1629 list.append( *it );
1629 } 1630 }
1630 } 1631 }
1631 return list; 1632 return list;
1632} 1633}
1633 1634
1634PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1635PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1635{ 1636{
1636 PhoneNumber::List::ConstIterator it; 1637 PhoneNumber::List::ConstIterator it;
1637 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1638 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1638 if ( (*it).id() == id ) { 1639 if ( (*it).id() == id ) {
1639 return *it; 1640 return *it;
1640 } 1641 }
1641 } 1642 }
1642 return PhoneNumber(); 1643 return PhoneNumber();
1643} 1644}
1644 1645
1645void Addressee::insertKey( const Key &key ) 1646void Addressee::insertKey( const Key &key )
1646{ 1647{
1647 detach(); 1648 detach();
1648 mData->empty = false; 1649 mData->empty = false;
1649 1650
1650 Key::List::Iterator it; 1651 Key::List::Iterator it;
1651 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1652 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1652 if ( (*it).id() == key.id() ) { 1653 if ( (*it).id() == key.id() ) {
1653 *it = key; 1654 *it = key;
1654 return; 1655 return;
1655 } 1656 }
1656 } 1657 }
1657 mData->keys.append( key ); 1658 mData->keys.append( key );
1658} 1659}
1659 1660
1660void Addressee::removeKey( const Key &key ) 1661void Addressee::removeKey( const Key &key )
1661{ 1662{
1662 detach(); 1663 detach();
1663 1664
1664 Key::List::Iterator it; 1665 Key::List::Iterator it;
1665 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1666 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1666 if ( (*it).id() == key.id() ) { 1667 if ( (*it).id() == key.id() ) {
1667 mData->keys.remove( key ); 1668 mData->keys.remove( key );
1668 return; 1669 return;
1669 } 1670 }
1670 } 1671 }
1671} 1672}
1672 1673
1673Key Addressee::key( int type, QString customTypeString ) const 1674Key Addressee::key( int type, QString customTypeString ) const
1674{ 1675{
1675 Key::List::ConstIterator it; 1676 Key::List::ConstIterator it;
1676 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1677 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1677 if ( (*it).type() == type ) { 1678 if ( (*it).type() == type ) {
1678 if ( type == Key::Custom ) { 1679 if ( type == Key::Custom ) {
1679 if ( customTypeString.isEmpty() ) { 1680 if ( customTypeString.isEmpty() ) {
1680 return *it; 1681 return *it;
1681 } else { 1682 } else {
1682 if ( (*it).customTypeString() == customTypeString ) 1683 if ( (*it).customTypeString() == customTypeString )
1683 return (*it); 1684 return (*it);
1684 } 1685 }
1685 } else { 1686 } else {
1686 return *it; 1687 return *it;
1687 } 1688 }
1688 } 1689 }
1689 } 1690 }
1690 return Key( QString(), type ); 1691 return Key( QString(), type );
1691} 1692}
1692void Addressee::setKeys( const Key::List& list ) { 1693void Addressee::setKeys( const Key::List& list ) {
1693 detach(); 1694 detach();
1694 mData->keys = list; 1695 mData->keys = list;
1695} 1696}
1696 1697
1697Key::List Addressee::keys() const 1698Key::List Addressee::keys() const
1698{ 1699{
1699 return mData->keys; 1700 return mData->keys;
1700} 1701}
1701 1702
1702Key::List Addressee::keys( int type, QString customTypeString ) const 1703Key::List Addressee::keys( int type, QString customTypeString ) const
1703{ 1704{
1704 Key::List list; 1705 Key::List list;
1705 1706
1706 Key::List::ConstIterator it; 1707 Key::List::ConstIterator it;
1707 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1708 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1708 if ( (*it).type() == type ) { 1709 if ( (*it).type() == type ) {
1709 if ( type == Key::Custom ) { 1710 if ( type == Key::Custom ) {
1710 if ( customTypeString.isEmpty() ) { 1711 if ( customTypeString.isEmpty() ) {
1711 list.append(*it); 1712 list.append(*it);
1712 } else { 1713 } else {
1713 if ( (*it).customTypeString() == customTypeString ) 1714 if ( (*it).customTypeString() == customTypeString )
1714 list.append(*it); 1715 list.append(*it);
1715 } 1716 }
1716 } else { 1717 } else {
1717 list.append(*it); 1718 list.append(*it);
1718 } 1719 }
1719 } 1720 }
1720 } 1721 }
1721 return list; 1722 return list;
1722} 1723}
1723 1724
1724Key Addressee::findKey( const QString &id ) const 1725Key Addressee::findKey( const QString &id ) const
1725{ 1726{
1726 Key::List::ConstIterator it; 1727 Key::List::ConstIterator it;
1727 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1728 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1728 if ( (*it).id() == id ) { 1729 if ( (*it).id() == id ) {
1729 return *it; 1730 return *it;
1730 } 1731 }
1731 } 1732 }
1732 return Key(); 1733 return Key();
1733} 1734}
1734 1735
1735QString Addressee::asString() const 1736QString Addressee::asString() const
1736{ 1737{
1737 return "Smith, agent Smith..."; 1738 return "Smith, agent Smith...";
1738} 1739}
1739 1740
1740void Addressee::dump() const 1741void Addressee::dump() const
1741{ 1742{
1742 return; 1743 return;
1743#if 0 1744#if 0
1744 kdDebug(5700) << "Addressee {" << endl; 1745 kdDebug(5700) << "Addressee {" << endl;
1745 1746
1746 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1747 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1747 1748
1748 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1749 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1749 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1750 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1750 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1751 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1751 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1752 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1752 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1753 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1753 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1754 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1754 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1755 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 2b40909..cce68b9 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,318 +1,318 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qdragobject.h> 24#include <qdragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <qiconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kabc/addressee.h> 33#include <kabc/addressee.h>
34#include <kconfig.h> 34#include <kconfig.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabprefs.h" 38#include "kabprefs.h"
39#include "viewmanager.h" 39#include "viewmanager.h"
40 40
41 41
42#include "kaddressbookcardview.h" 42#include "kaddressbookcardview.h"
43 43
44#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
45extern "C" { 45extern "C" {
46 void *init_libkaddrbk_cardview() 46 void *init_libkaddrbk_cardview()
47 { 47 {
48 return ( new CardViewFactory ); 48 return ( new CardViewFactory );
49 } 49 }
50} 50}
51#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
52 52
53//////////////////////////////// 53////////////////////////////////
54// AddresseeCardViewItem (internal class) 54// AddresseeCardViewItem (internal class)
55class AddresseeCardViewItem : public CardViewItem 55class AddresseeCardViewItem : public CardViewItem
56{ 56{
57 public: 57 public:
58 AddresseeCardViewItem(const KABC::Field::List &fields, 58 AddresseeCardViewItem(const KABC::Field::List &fields,
59 bool showEmptyFields, 59 bool showEmptyFields,
60 KABC::AddressBook *doc, const KABC::Addressee &a, 60 KABC::AddressBook *doc, const KABC::Addressee &a,
61 CardView *parent) 61 CardView *parent)
62 : CardViewItem(parent, a.formattedName()), 62 : CardViewItem(parent, a.realName() ),
63 mFields( fields ), mShowEmptyFields(showEmptyFields), 63 mFields( fields ), mShowEmptyFields(showEmptyFields),
64 mDocument(doc), mAddressee(a) 64 mDocument(doc), mAddressee(a)
65 { 65 {
66 if ( mFields.isEmpty() ) { 66 if ( mFields.isEmpty() ) {
67 mFields = KABC::Field::defaultFields(); 67 mFields = KABC::Field::defaultFields();
68 } 68 }
69 refresh(); 69 refresh();
70 } 70 }
71 71
72 const KABC::Addressee &addressee() const { return mAddressee; } 72 const KABC::Addressee &addressee() const { return mAddressee; }
73 73
74 void refresh() 74 void refresh()
75 { 75 {
76 // Update our addressee, since it may have changed elsewhere 76 // Update our addressee, since it may have changed elsewhere
77 mAddressee = mDocument->findByUid(mAddressee.uid()); 77 mAddressee = mDocument->findByUid(mAddressee.uid());
78 78
79 if (!mAddressee.isEmpty()) 79 if (!mAddressee.isEmpty())
80 { 80 {
81 clearFields(); 81 clearFields();
82 82
83 // Try all the selected fields until we find one with text. 83 // Try all the selected fields until we find one with text.
84 // This will limit the number of unlabeled icons in the view 84 // This will limit the number of unlabeled icons in the view
85 KABC::Field::List::Iterator iter; 85 KABC::Field::List::Iterator iter;
86 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 86 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
87 { 87 {
88 // insert empty fields or not? not doing so saves a bit of memory and CPU 88 // insert empty fields or not? not doing so saves a bit of memory and CPU
89 // (during geometry calculations), but prevents having equally 89 // (during geometry calculations), but prevents having equally
90 // wide label columns in all cards, unless CardViewItem/CardView search 90 // wide label columns in all cards, unless CardViewItem/CardView search
91 // globally for the widest label. (anders) 91 // globally for the widest label. (anders)
92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
93 insertField((*iter)->label(), (*iter)->value( mAddressee )); 93 insertField((*iter)->label(), (*iter)->value( mAddressee ));
94 } 94 }
95 95
96 // We might want to make this the first field. hmm... -mpilone 96 // We might want to make this the first field. hmm... -mpilone
97 setCaption( mAddressee.realName() ); 97 setCaption( mAddressee.realName() );
98 } 98 }
99 } 99 }
100 100
101 private: 101 private:
102 KABC::Field::List mFields; 102 KABC::Field::List mFields;
103 bool mShowEmptyFields; 103 bool mShowEmptyFields;
104 KABC::AddressBook *mDocument; 104 KABC::AddressBook *mDocument;
105 KABC::Addressee mAddressee; 105 KABC::Addressee mAddressee;
106}; 106};
107 107
108/////////////////////////////// 108///////////////////////////////
109// AddresseeCardView 109// AddresseeCardView
110 110
111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
112 : CardView(parent, name) 112 : CardView(parent, name)
113{ 113{
114 setAcceptDrops(true); 114 setAcceptDrops(true);
115} 115}
116 116
117AddresseeCardView::~AddresseeCardView() 117AddresseeCardView::~AddresseeCardView()
118{ 118{
119} 119}
120void AddresseeCardView::printMe() 120void AddresseeCardView::printMe()
121{ 121{
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 QPrinter printer; 123 QPrinter printer;
124 if (!printer.setup() ) 124 if (!printer.setup() )
125 return; 125 return;
126 QPainter p; 126 QPainter p;
127 p.begin ( &printer ); 127 p.begin ( &printer );
128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
129 float dx, dy; 129 float dx, dy;
130 int wid = (m.width() * 9)/10; 130 int wid = (m.width() * 9)/10;
131 dx = (float) wid/(float)contentsWidth (); 131 dx = (float) wid/(float)contentsWidth ();
132 dy = (float)(m.height()) / (float)contentsHeight (); 132 dy = (float)(m.height()) / (float)contentsHeight ();
133 float scale; 133 float scale;
134 // scale to fit the width or height of the paper 134 // scale to fit the width or height of the paper
135 if ( dx < dy ) 135 if ( dx < dy )
136 scale = dx; 136 scale = dx;
137 else 137 else
138 scale = dy; 138 scale = dy;
139 p.translate( m.width()/10,0 ); 139 p.translate( m.width()/10,0 );
140 p.scale( scale, scale ); 140 p.scale( scale, scale );
141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
142 p.end(); 142 p.end();
143 repaint(); 143 repaint();
144#endif 144#endif
145} 145}
146 146
147 147
148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
149{ 149{
150#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
151 if (QTextDrag::canDecode(e)) 151 if (QTextDrag::canDecode(e))
152 e->accept(); 152 e->accept();
153#else //KAB_EMBEDDED 153#else //KAB_EMBEDDED
154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
155#endif //KAB_EMBEDDED 155#endif //KAB_EMBEDDED
156} 156}
157 157
158void AddresseeCardView::dropEvent(QDropEvent *e) 158void AddresseeCardView::dropEvent(QDropEvent *e)
159{ 159{
160 emit addresseeDropped(e); 160 emit addresseeDropped(e);
161} 161}
162 162
163void AddresseeCardView::startDrag() 163void AddresseeCardView::startDrag()
164{ 164{
165 emit startAddresseeDrag(); 165 emit startAddresseeDrag();
166} 166}
167 167
168 168
169/////////////////////////////// 169///////////////////////////////
170// KAddressBookCardView 170// KAddressBookCardView
171 171
172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
173 QWidget *parent, const char *name ) 173 QWidget *parent, const char *name )
174 : KAddressBookView( ab, parent, name ) 174 : KAddressBookView( ab, parent, name )
175{ 175{
176 mShowEmptyFields = false; 176 mShowEmptyFields = false;
177 177
178 // Init the GUI 178 // Init the GUI
179 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 179 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
180 180
181 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 181 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
182 mCardView->setSelectionMode(CardView::Extended); 182 mCardView->setSelectionMode(CardView::Extended);
183 layout->addWidget(mCardView); 183 layout->addWidget(mCardView);
184 184
185 // Connect up the signals 185 // Connect up the signals
186 connect(mCardView, SIGNAL(executed(CardViewItem *)), 186 connect(mCardView, SIGNAL(executed(CardViewItem *)),
187 this, SLOT(addresseeExecuted(CardViewItem *))); 187 this, SLOT(addresseeExecuted(CardViewItem *)));
188 connect(mCardView, SIGNAL(selectionChanged()), 188 connect(mCardView, SIGNAL(selectionChanged()),
189 this, SLOT(addresseeSelected())); 189 this, SLOT(addresseeSelected()));
190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
191 this, SIGNAL(dropped(QDropEvent*))); 191 this, SIGNAL(dropped(QDropEvent*)));
192 connect(mCardView, SIGNAL(startAddresseeDrag()), 192 connect(mCardView, SIGNAL(startAddresseeDrag()),
193 this, SIGNAL(startDrag())); 193 this, SIGNAL(startDrag()));
194 connect(this, SIGNAL(printView()), 194 connect(this, SIGNAL(printView()),
195 mCardView , SLOT(printMe())); 195 mCardView , SLOT(printMe()));
196} 196}
197 197
198KAddressBookCardView::~KAddressBookCardView() 198KAddressBookCardView::~KAddressBookCardView()
199{ 199{
200} 200}
201void KAddressBookCardView::setFocusAV() 201void KAddressBookCardView::setFocusAV()
202{ 202{
203 if ( mCardView ) 203 if ( mCardView )
204 mCardView->setFocus(); 204 mCardView->setFocus();
205 205
206} 206}
207void KAddressBookCardView::scrollUP() 207void KAddressBookCardView::scrollUP()
208{ 208{
209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
210 QApplication::postEvent( mCardView, ev ); 210 QApplication::postEvent( mCardView, ev );
211 211
212} 212}
213void KAddressBookCardView::scrollDOWN() 213void KAddressBookCardView::scrollDOWN()
214{ 214{
215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
216 QApplication::postEvent( mCardView, ev ); 216 QApplication::postEvent( mCardView, ev );
217} 217}
218void KAddressBookCardView::readConfig(KConfig *config) 218void KAddressBookCardView::readConfig(KConfig *config)
219{ 219{
220 KAddressBookView::readConfig(config); 220 KAddressBookView::readConfig(config);
221 221
222 // costum colors? 222 // costum colors?
223 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 223 if ( config->readBoolEntry( "EnableCustomColors", false ) )
224 { 224 {
225 QPalette p( mCardView->palette() ); 225 QPalette p( mCardView->palette() );
226 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 226 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
228 c = p.color(QPalette::Normal, QColorGroup::Text ); 228 c = p.color(QPalette::Normal, QColorGroup::Text );
229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
230 c = p.color(QPalette::Normal, QColorGroup::Button ); 230 c = p.color(QPalette::Normal, QColorGroup::Button );
231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 232 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 234 c = p.color(QPalette::Normal, QColorGroup::Highlight );
235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
238 mCardView->viewport()->setPalette( p ); 238 mCardView->viewport()->setPalette( p );
239 } 239 }
240 else 240 else
241 { 241 {
242 // needed if turned off during a session. 242 // needed if turned off during a session.
243 mCardView->viewport()->setPalette( mCardView->palette() ); 243 mCardView->viewport()->setPalette( mCardView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 } 253 }
254 else 254 else
255 { 255 {
256 mCardView->setFont( f ); 256 mCardView->setFont( f );
257 f.setBold( true ); 257 f.setBold( true );
258 mCardView->setHeaderFont( f ); 258 mCardView->setHeaderFont( f );
259 } 259 }
260 260
261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
263 true)); 263 true));
264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
266 266
267 mCardView->setShowEmptyFields( mShowEmptyFields ); 267 mCardView->setShowEmptyFields( mShowEmptyFields );
268 268
269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
273 273
274#if 0 274#if 0
275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
277 this, SLOT(addresseeExecuted(CardViewItem *))); 277 this, SLOT(addresseeExecuted(CardViewItem *)));
278 278
279 if (KABPrefs::instance()->mHonorSingleClick) 279 if (KABPrefs::instance()->mHonorSingleClick)
280 connect(mCardView, SIGNAL(executed(CardViewItem *)), 280 connect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
282 else 282 else
283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
284 this, SLOT(addresseeExecuted(CardViewItem *))); 284 this, SLOT(addresseeExecuted(CardViewItem *)));
285#endif 285#endif
286 286
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 288 this, SLOT(addresseeExecuted(CardViewItem *)));
289} 289}
290 290
291void KAddressBookCardView::writeConfig( KConfig *config ) 291void KAddressBookCardView::writeConfig( KConfig *config )
292{ 292{
293 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 293 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
294 KAddressBookView::writeConfig( config ); 294 KAddressBookView::writeConfig( config );
295} 295}
296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
297{ 297{
298 mCardView->clear(); 298 mCardView->clear();
299 if ( s.isEmpty() || s == "*" ) { 299 if ( s.isEmpty() || s == "*" ) {
300 refresh(); 300 refresh();
301 return; 301 return;
302 } 302 }
303 QRegExp re = getRegExp( s ); 303 QRegExp re = getRegExp( s );
304 if (!re.isValid()) 304 if (!re.isValid())
305 return; 305 return;
306 mCardView->viewport()->setUpdatesEnabled( false ); 306 mCardView->viewport()->setUpdatesEnabled( false );
307 KABC::Addressee::List addresseeList = addressees(); 307 KABC::Addressee::List addresseeList = addressees();
308 KABC::Addressee::List::Iterator it; 308 KABC::Addressee::List::Iterator it;
309 if ( field ) { 309 if ( field ) {
310 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 310 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
311 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 311 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
312 continue; 312 continue;
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 if (re.search(field->value( *it ).lower()) != -1) 314 if (re.search(field->value( *it ).lower()) != -1)
315#else 315#else
316 if (re.match(field->value( *it ).lower()) != -1) 316 if (re.match(field->value( *it ).lower()) != -1)
317#endif 317#endif
318 new AddresseeCardViewItem(fields(), mShowEmptyFields, 318 new AddresseeCardViewItem(fields(), mShowEmptyFields,
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index cf0d1ee..810c889 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1045,512 +1045,522 @@ QString KStandardDirs::saveLocation(const char *type,
1045 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1045 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1046 1046
1047 1047
1048 { 1048 {
1049 if(!create) { 1049 if(!create) {
1050#ifndef NDEBUG 1050#ifndef NDEBUG
1051 qDebug("save location %s doesn't exist", fullPath.latin1()); 1051 qDebug("save location %s doesn't exist", fullPath.latin1());
1052#endif 1052#endif
1053 return fullPath; 1053 return fullPath;
1054 } 1054 }
1055 if(!makeDir(fullPath, 0700)) { 1055 if(!makeDir(fullPath, 0700)) {
1056 qWarning("failed to create %s", fullPath.latin1()); 1056 qWarning("failed to create %s", fullPath.latin1());
1057 return fullPath; 1057 return fullPath;
1058 } 1058 }
1059 dircache.remove(type); 1059 dircache.remove(type);
1060 } 1060 }
1061 return fullPath; 1061 return fullPath;
1062} 1062}
1063 1063
1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1065{ 1065{
1066 QString fullPath = absPath; 1066 QString fullPath = absPath;
1067 int i = absPath.findRev('/'); 1067 int i = absPath.findRev('/');
1068 if (i != -1) 1068 if (i != -1)
1069 { 1069 {
1070 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1070 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1071 } 1071 }
1072 1072
1073 QStringList candidates = resourceDirs(type); 1073 QStringList candidates = resourceDirs(type);
1074 1074
1075 for (QStringList::ConstIterator it = candidates.begin(); 1075 for (QStringList::ConstIterator it = candidates.begin();
1076 it != candidates.end(); it++) 1076 it != candidates.end(); it++)
1077 if (fullPath.startsWith(*it)) 1077 if (fullPath.startsWith(*it))
1078 { 1078 {
1079 return fullPath.mid((*it).length()); 1079 return fullPath.mid((*it).length());
1080 } 1080 }
1081 1081
1082 return absPath; 1082 return absPath;
1083} 1083}
1084 1084
1085 1085
1086bool KStandardDirs::makeDir(const QString& dir2, int mode) 1086bool KStandardDirs::makeDir(const QString& dir2, int mode)
1087{ 1087{
1088 QString dir = QDir::convertSeparators( dir2 ); 1088 QString dir = QDir::convertSeparators( dir2 );
1089#if 0 1089#if 0
1090 //LR 1090 //LR
1091 1091
1092 // we want an absolute path 1092 // we want an absolute path
1093 if (dir.at(0) != '/') 1093 if (dir.at(0) != '/')
1094 return false; 1094 return false;
1095 1095
1096 QString target = dir; 1096 QString target = dir;
1097 uint len = target.length(); 1097 uint len = target.length();
1098 1098
1099 // append trailing slash if missing 1099 // append trailing slash if missing
1100 if (dir.at(len - 1) != '/') 1100 if (dir.at(len - 1) != '/')
1101 target += '/'; 1101 target += '/';
1102 1102
1103 QString base(""); 1103 QString base("");
1104 uint i = 1; 1104 uint i = 1;
1105 1105
1106 while( i < len ) 1106 while( i < len )
1107 { 1107 {
1108//US struct stat st; 1108//US struct stat st;
1109 int pos = target.find('/', i); 1109 int pos = target.find('/', i);
1110 base += target.mid(i - 1, pos - i + 1); 1110 base += target.mid(i - 1, pos - i + 1);
1111 QCString baseEncoded = QFile::encodeName(base); 1111 QCString baseEncoded = QFile::encodeName(base);
1112 // bail out if we encountered a problem 1112 // bail out if we encountered a problem
1113//US if (stat(baseEncoded, &st) != 0) 1113//US if (stat(baseEncoded, &st) != 0)
1114 QFileInfo baseEncodedInfo(baseEncoded); 1114 QFileInfo baseEncodedInfo(baseEncoded);
1115 if (!baseEncodedInfo.exists()) 1115 if (!baseEncodedInfo.exists())
1116 { 1116 {
1117 // Directory does not exist.... 1117 // Directory does not exist....
1118 // Or maybe a dangling symlink ? 1118 // Or maybe a dangling symlink ?
1119//US if (lstat(baseEncoded, &st) == 0) 1119//US if (lstat(baseEncoded, &st) == 0)
1120 if (baseEncodedInfo.isSymLink()) { 1120 if (baseEncodedInfo.isSymLink()) {
1121//US (void)unlink(baseEncoded); // try removing 1121//US (void)unlink(baseEncoded); // try removing
1122 QFile(baseEncoded).remove(); 1122 QFile(baseEncoded).remove();
1123 } 1123 }
1124 1124
1125 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1125 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1126 QDir dirObj; 1126 QDir dirObj;
1127 if ( dirObj.mkdir(baseEncoded) != true ) 1127 if ( dirObj.mkdir(baseEncoded) != true )
1128 { 1128 {
1129 //US perror("trying to create local folder"); 1129 //US perror("trying to create local folder");
1130 return false; // Couldn't create it :-( 1130 return false; // Couldn't create it :-(
1131 } 1131 }
1132 } 1132 }
1133 i = pos + 1; 1133 i = pos + 1;
1134 } 1134 }
1135 return true; 1135 return true;
1136#endif 1136#endif
1137 1137
1138 // ******************************************** 1138 // ********************************************
1139 // new code for WIN32 1139 // new code for WIN32
1140 QDir dirObj; 1140 QDir dirObj;
1141 1141
1142 1142
1143 // we want an absolute path 1143 // we want an absolute path
1144#ifndef _WIN32_ 1144#ifndef _WIN32_
1145 if (dir.at(0) != '/') 1145 if (dir.at(0) != '/')
1146 return false; 1146 return false;
1147#endif 1147#endif
1148 1148
1149 QString target = dir; 1149 QString target = dir;
1150 uint len = target.length(); 1150 uint len = target.length();
1151#ifndef _WIN32_ 1151#ifndef _WIN32_
1152 // append trailing slash if missing 1152 // append trailing slash if missing
1153 if (dir.at(len - 1) != '/') 1153 if (dir.at(len - 1) != '/')
1154 target += '/'; 1154 target += '/';
1155#endif 1155#endif
1156 1156
1157 QString base(""); 1157 QString base("");
1158 uint i = 1; 1158 uint i = 1;
1159 1159
1160 while( i < len ) 1160 while( i < len )
1161 { 1161 {
1162//US struct stat st; 1162//US struct stat st;
1163#ifndef _WIN32_ 1163#ifndef _WIN32_
1164 int pos = target.find('/', i); 1164 int pos = target.find('/', i);
1165#else 1165#else
1166 int pos = target.find('\\', i); 1166 int pos = target.find('\\', i);
1167#endif 1167#endif
1168 if ( pos < 0 ) 1168 if ( pos < 0 )
1169 return true; 1169 return true;
1170 base += target.mid(i - 1, pos - i + 1); 1170 base += target.mid(i - 1, pos - i + 1);
1171 //QMessageBox::information( 0,"cap111", base, 1 ); 1171 //QMessageBox::information( 0,"cap111", base, 1 );
1172/*US 1172/*US
1173 QCString baseEncoded = QFile::encodeName(base); 1173 QCString baseEncoded = QFile::encodeName(base);
1174 // bail out if we encountered a problem 1174 // bail out if we encountered a problem
1175 if (stat(baseEncoded, &st) != 0) 1175 if (stat(baseEncoded, &st) != 0)
1176 { 1176 {
1177 // Directory does not exist.... 1177 // Directory does not exist....
1178 // Or maybe a dangling symlink ? 1178 // Or maybe a dangling symlink ?
1179 if (lstat(baseEncoded, &st) == 0) 1179 if (lstat(baseEncoded, &st) == 0)
1180 (void)unlink(baseEncoded); // try removing 1180 (void)unlink(baseEncoded); // try removing
1181 1181
1182 1182
1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1184 perror("trying to create local folder"); 1184 perror("trying to create local folder");
1185 return false; // Couldn't create it :-( 1185 return false; // Couldn't create it :-(
1186 } 1186 }
1187 } 1187 }
1188*/ 1188*/
1189 1189
1190 if (dirObj.exists(base) == false) 1190 if (dirObj.exists(base) == false)
1191 { 1191 {
1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1193 if (dirObj.mkdir(base) != true) 1193 if (dirObj.mkdir(base) != true)
1194 { 1194 {
1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1196 return false; 1196 return false;
1197 } 1197 }
1198 } 1198 }
1199 1199
1200 i = pos + 1; 1200 i = pos + 1;
1201 } 1201 }
1202 return true; 1202 return true;
1203 1203
1204} 1204}
1205 1205
1206static QString readEnvPath(const char *env) 1206static QString readEnvPath(const char *env)
1207{ 1207{
1208 //#ifdef _WIN32_ 1208 //#ifdef _WIN32_
1209 // return ""; 1209 // return "";
1210 //#else 1210 //#else
1211 QCString c_path; 1211 QCString c_path;
1212 if ( getenv(env) != NULL ) 1212 if ( getenv(env) != NULL )
1213 c_path = QString ( getenv(env) ); 1213 c_path = QString ( getenv(env) );
1214 if (c_path.isEmpty()) 1214 if (c_path.isEmpty())
1215 return QString::null; 1215 return QString::null;
1216 return QFile::decodeName(c_path); 1216 return QFile::decodeName(c_path);
1217 //#endif 1217 //#endif
1218 1218
1219} 1219}
1220 1220
1221void KStandardDirs::addKDEDefaults() 1221void KStandardDirs::addKDEDefaults()
1222{ 1222{
1223 1223
1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1225 //return; 1225 //return;
1226 QStringList kdedirList; 1226 QStringList kdedirList;
1227 1227
1228 // begin KDEDIRS 1228 // begin KDEDIRS
1229 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1229 QString kdedirs = readEnvPath("MICROKDEDIRS");
1230 if (!kdedirs.isEmpty()) 1230 if (!kdedirs.isEmpty())
1231 { 1231 {
1232 tokenize(kdedirList, kdedirs, ":"); 1232 tokenize(kdedirList, kdedirs, ":");
1233 } 1233 }
1234 else 1234 else
1235 { 1235 {
1236 QString kdedir = readEnvPath("MICROKDEDIR"); 1236 QString kdedir = readEnvPath("MICROKDEDIR");
1237 if (!kdedir.isEmpty()) 1237 if (!kdedir.isEmpty())
1238 { 1238 {
1239 kdedir = KShell::tildeExpand(kdedir); 1239 kdedir = KShell::tildeExpand(kdedir);
1240 kdedirList.append(kdedir); 1240 kdedirList.append(kdedir);
1241 } 1241 }
1242 } 1242 }
1243//US kdedirList.append(KDEDIR); 1243//US kdedirList.append(KDEDIR);
1244//US for embedded, add qtopia dir as kdedir 1244//US for embedded, add qtopia dir as kdedir
1245 1245
1246#ifndef DESKTOP_VERSION 1246#ifndef DESKTOP_VERSION
1247 QString tmp = readEnvPath("QPEDIR"); 1247 QString tmp = readEnvPath("QPEDIR");
1248 if (!tmp.isEmpty()) 1248 if (!tmp.isEmpty())
1249 kdedirList.append(tmp); 1249 kdedirList.append(tmp);
1250 1250
1251 tmp = readEnvPath("QTDIR"); 1251 tmp = readEnvPath("QTDIR");
1252 if (!tmp.isEmpty()) 1252 if (!tmp.isEmpty())
1253 kdedirList.append(tmp); 1253 kdedirList.append(tmp);
1254 1254
1255 tmp = readEnvPath("OPIEDIR"); 1255 tmp = readEnvPath("OPIEDIR");
1256 if (!tmp.isEmpty()) 1256 if (!tmp.isEmpty())
1257 kdedirList.append(tmp); 1257 kdedirList.append(tmp);
1258 1258
1259#endif 1259#endif
1260 1260
1261#ifdef __KDE_EXECPREFIX 1261#ifdef __KDE_EXECPREFIX
1262 QString execPrefix(__KDE_EXECPREFIX); 1262 QString execPrefix(__KDE_EXECPREFIX);
1263 if (execPrefix!="NONE") 1263 if (execPrefix!="NONE")
1264 kdedirList.append(execPrefix); 1264 kdedirList.append(execPrefix);
1265#endif 1265#endif
1266 1266
1267 QString localKdeDir; 1267 QString localKdeDir;
1268 1268
1269//US if (getuid()) 1269//US if (getuid())
1270 if (true) 1270 if (true)
1271 { 1271 {
1272 localKdeDir = readEnvPath("MICROKDEHOME"); 1272 localKdeDir = readEnvPath("MICROKDEHOME");
1273 if (!localKdeDir.isEmpty()) 1273 if (!localKdeDir.isEmpty())
1274 { 1274 {
1275#ifdef _WIN32_ 1275#ifdef _WIN32_
1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\') 1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\')
1277 localKdeDir += '\\'; 1277 localKdeDir += '\\';
1278#else 1278#else
1279 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1279 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1280 localKdeDir += '/'; 1280 localKdeDir += '/';
1281#endif 1281#endif
1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); 1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
1283 } 1283 }
1284 else 1284 else
1285 { 1285 {
1286 QString confFile; 1286 QString confFile;
1287#ifdef DESKTOP_VERSION 1287#ifdef DESKTOP_VERSION
1288 confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; 1288 confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
1289 QFileInfo fi ( confFile ); 1289 QFileInfo fi ( confFile );
1290 if ( !fi.exists() ) 1290 if ( !fi.exists() )
1291 confFile = QDir::homeDirPath() + "/.microkdehome"; 1291 confFile = QDir::homeDirPath() + "/.microkdehome";
1292 else 1292 else
1293 qDebug("Loading path info from " + confFile ); 1293 qDebug("Loading path info from " + confFile );
1294 1294
1295#else 1295#else
1296 confFile = QDir::homeDirPath() + "/.microkdehome"; 1296 confFile = QDir::homeDirPath() + "/.microkdehome";
1297#endif 1297#endif
1298 KConfig cfg ( confFile ); 1298 KConfig cfg ( confFile );
1299 cfg.setGroup("Global"); 1299 cfg.setGroup("Global");
1300 localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); 1300 localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" );
1301#ifdef DESKTOP_VERSION
1302 if ( localKdeDir.startsWith( "LOCAL:" ) ) {
1303#ifdef _WIN32_
1304 localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 );
1305#else
1306 localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 );
1307#endif
1308 qDebug("Using local conf dir %s ",localKdeDir.latin1() );
1309 }
1310#endif
1301 } 1311 }
1302 } 1312 }
1303 else 1313 else
1304 { 1314 {
1305 // We treat root different to prevent root messing up the 1315 // We treat root different to prevent root messing up the
1306 // file permissions in the users home directory. 1316 // file permissions in the users home directory.
1307 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1317 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1308 if (!localKdeDir.isEmpty()) 1318 if (!localKdeDir.isEmpty())
1309 { 1319 {
1310 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1320 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1311 localKdeDir += '/'; 1321 localKdeDir += '/';
1312 } 1322 }
1313 else 1323 else
1314 { 1324 {
1315//US struct passwd *pw = getpwuid(0); 1325//US struct passwd *pw = getpwuid(0);
1316//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1326//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1317 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1327 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1318 } 1328 }
1319 1329
1320 } 1330 }
1321 1331
1322//US localKdeDir = appDir(); 1332//US localKdeDir = appDir();
1323 1333
1324//US 1334//US
1325// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1335// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1326 if (localKdeDir != "-/") 1336 if (localKdeDir != "-/")
1327 { 1337 {
1328 localKdeDir = KShell::tildeExpand(localKdeDir); 1338 localKdeDir = KShell::tildeExpand(localKdeDir);
1329 addPrefix(localKdeDir); 1339 addPrefix(localKdeDir);
1330 } 1340 }
1331 1341
1332 for (QStringList::ConstIterator it = kdedirList.begin(); 1342 for (QStringList::ConstIterator it = kdedirList.begin();
1333 it != kdedirList.end(); it++) 1343 it != kdedirList.end(); it++)
1334 { 1344 {
1335 QString dir = KShell::tildeExpand(*it); 1345 QString dir = KShell::tildeExpand(*it);
1336 addPrefix(dir); 1346 addPrefix(dir);
1337 } 1347 }
1338 // end KDEDIRS 1348 // end KDEDIRS
1339 1349
1340 // begin XDG_CONFIG_XXX 1350 // begin XDG_CONFIG_XXX
1341 QStringList xdgdirList; 1351 QStringList xdgdirList;
1342 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1352 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1343 if (!xdgdirs.isEmpty()) 1353 if (!xdgdirs.isEmpty())
1344 { 1354 {
1345 tokenize(xdgdirList, xdgdirs, ":"); 1355 tokenize(xdgdirList, xdgdirs, ":");
1346 } 1356 }
1347 else 1357 else
1348 { 1358 {
1349 xdgdirList.clear(); 1359 xdgdirList.clear();
1350 xdgdirList.append("/etc/xdg"); 1360 xdgdirList.append("/etc/xdg");
1351 } 1361 }
1352 1362
1353 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1363 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1354 if (!localXdgDir.isEmpty()) 1364 if (!localXdgDir.isEmpty())
1355 { 1365 {
1356 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1366 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1357 localXdgDir += '/'; 1367 localXdgDir += '/';
1358 } 1368 }
1359 else 1369 else
1360 { 1370 {
1361//US if (getuid()) 1371//US if (getuid())
1362 if (true) 1372 if (true)
1363 { 1373 {
1364 localXdgDir = QDir::homeDirPath() + "/.config/"; 1374 localXdgDir = QDir::homeDirPath() + "/.config/";
1365 } 1375 }
1366 else 1376 else
1367 { 1377 {
1368//US struct passwd *pw = getpwuid(0); 1378//US struct passwd *pw = getpwuid(0);
1369//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1379//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1370 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1380 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1371 } 1381 }
1372 } 1382 }
1373 1383
1374 localXdgDir = KShell::tildeExpand(localXdgDir); 1384 localXdgDir = KShell::tildeExpand(localXdgDir);
1375 addXdgConfigPrefix(localXdgDir); 1385 addXdgConfigPrefix(localXdgDir);
1376 1386
1377 for (QStringList::ConstIterator it = xdgdirList.begin(); 1387 for (QStringList::ConstIterator it = xdgdirList.begin();
1378 it != xdgdirList.end(); it++) 1388 it != xdgdirList.end(); it++)
1379 { 1389 {
1380 QString dir = KShell::tildeExpand(*it); 1390 QString dir = KShell::tildeExpand(*it);
1381 addXdgConfigPrefix(dir); 1391 addXdgConfigPrefix(dir);
1382 } 1392 }
1383 // end XDG_CONFIG_XXX 1393 // end XDG_CONFIG_XXX
1384 1394
1385 // begin XDG_DATA_XXX 1395 // begin XDG_DATA_XXX
1386 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1396 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1387 if (!xdgdirs.isEmpty()) 1397 if (!xdgdirs.isEmpty())
1388 { 1398 {
1389 tokenize(xdgdirList, xdgdirs, ":"); 1399 tokenize(xdgdirList, xdgdirs, ":");
1390 } 1400 }
1391 else 1401 else
1392 { 1402 {
1393 xdgdirList.clear(); 1403 xdgdirList.clear();
1394 for (QStringList::ConstIterator it = kdedirList.begin(); 1404 for (QStringList::ConstIterator it = kdedirList.begin();
1395 it != kdedirList.end(); it++) 1405 it != kdedirList.end(); it++)
1396 { 1406 {
1397 QString dir = *it; 1407 QString dir = *it;
1398 if (dir.at(dir.length()-1) != '/') 1408 if (dir.at(dir.length()-1) != '/')
1399 dir += '/'; 1409 dir += '/';
1400 xdgdirList.append(dir+"share/"); 1410 xdgdirList.append(dir+"share/");
1401 } 1411 }
1402 1412
1403 xdgdirList.append("/usr/local/share/"); 1413 xdgdirList.append("/usr/local/share/");
1404 xdgdirList.append("/usr/share/"); 1414 xdgdirList.append("/usr/share/");
1405 } 1415 }
1406 1416
1407 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1417 localXdgDir = readEnvPath("XDG_DATA_HOME");
1408 if (!localXdgDir.isEmpty()) 1418 if (!localXdgDir.isEmpty())
1409 { 1419 {
1410 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1420 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1411 localXdgDir += '/'; 1421 localXdgDir += '/';
1412 } 1422 }
1413 else 1423 else
1414 { 1424 {
1415//US if (getuid()) 1425//US if (getuid())
1416 if (true) 1426 if (true)
1417 { 1427 {
1418 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1428 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1419 } 1429 }
1420 else 1430 else
1421 { 1431 {
1422//US struct passwd *pw = getpwuid(0); 1432//US struct passwd *pw = getpwuid(0);
1423//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1433//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1424 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1434 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1425 } 1435 }
1426 } 1436 }
1427 1437
1428 localXdgDir = KShell::tildeExpand(localXdgDir); 1438 localXdgDir = KShell::tildeExpand(localXdgDir);
1429 addXdgDataPrefix(localXdgDir); 1439 addXdgDataPrefix(localXdgDir);
1430 1440
1431 for (QStringList::ConstIterator it = xdgdirList.begin(); 1441 for (QStringList::ConstIterator it = xdgdirList.begin();
1432 it != xdgdirList.end(); it++) 1442 it != xdgdirList.end(); it++)
1433 { 1443 {
1434 QString dir = KShell::tildeExpand(*it); 1444 QString dir = KShell::tildeExpand(*it);
1435 1445
1436 addXdgDataPrefix(dir); 1446 addXdgDataPrefix(dir);
1437 } 1447 }
1438 // end XDG_DATA_XXX 1448 // end XDG_DATA_XXX
1439 1449
1440 1450
1441 uint index = 0; 1451 uint index = 0;
1442 while (types[index] != 0) { 1452 while (types[index] != 0) {
1443 addResourceType(types[index], kde_default(types[index])); 1453 addResourceType(types[index], kde_default(types[index]));
1444 index++; 1454 index++;
1445 } 1455 }
1446 1456
1447 addResourceDir("home", QDir::homeDirPath()); 1457 addResourceDir("home", QDir::homeDirPath());
1448} 1458}
1449 1459
1450void KStandardDirs::checkConfig() const 1460void KStandardDirs::checkConfig() const
1451{ 1461{
1452/*US 1462/*US
1453 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1463 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1454 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1464 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1455*/ 1465*/
1456 if (!addedCustoms && KGlobal::config()) 1466 if (!addedCustoms && KGlobal::config())
1457 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1467 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1458} 1468}
1459 1469
1460bool KStandardDirs::addCustomized(KConfig *config) 1470bool KStandardDirs::addCustomized(KConfig *config)
1461{ 1471{
1462 if (addedCustoms) // there are already customized entries 1472 if (addedCustoms) // there are already customized entries
1463 return false; // we just quite and hope they are the right ones 1473 return false; // we just quite and hope they are the right ones
1464 1474
1465 // save the numbers of config directories. If this changes, 1475 // save the numbers of config directories. If this changes,
1466 // we will return true to give KConfig a chance to reparse 1476 // we will return true to give KConfig a chance to reparse
1467 uint configdirs = resourceDirs("config").count(); 1477 uint configdirs = resourceDirs("config").count();
1468 1478
1469 // reading the prefixes in 1479 // reading the prefixes in
1470 QString oldGroup = config->group(); 1480 QString oldGroup = config->group();
1471 config->setGroup("Directories"); 1481 config->setGroup("Directories");
1472 1482
1473 QStringList list; 1483 QStringList list;
1474 QStringList::ConstIterator it; 1484 QStringList::ConstIterator it;
1475 list = config->readListEntry("prefixes"); 1485 list = config->readListEntry("prefixes");
1476 for (it = list.begin(); it != list.end(); it++) 1486 for (it = list.begin(); it != list.end(); it++)
1477 addPrefix(*it); 1487 addPrefix(*it);
1478 1488
1479 // iterating over all entries in the group Directories 1489 // iterating over all entries in the group Directories
1480 // to find entries that start with dir_$type 1490 // to find entries that start with dir_$type
1481/*US 1491/*US
1482 QMap<QString, QString> entries = config->entryMap("Directories"); 1492 QMap<QString, QString> entries = config->entryMap("Directories");
1483 1493
1484 QMap<QString, QString>::ConstIterator it2; 1494 QMap<QString, QString>::ConstIterator it2;
1485 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1495 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1486 { 1496 {
1487 QString key = it2.key(); 1497 QString key = it2.key();
1488 if (key.left(4) == "dir_") { 1498 if (key.left(4) == "dir_") {
1489 // generate directory list, there may be more than 1. 1499 // generate directory list, there may be more than 1.
1490 QStringList dirs = QStringList::split(',', *it2); 1500 QStringList dirs = QStringList::split(',', *it2);
1491 QStringList::Iterator sIt(dirs.begin()); 1501 QStringList::Iterator sIt(dirs.begin());
1492 QString resType = key.mid(4, key.length()); 1502 QString resType = key.mid(4, key.length());
1493 for (; sIt != dirs.end(); ++sIt) { 1503 for (; sIt != dirs.end(); ++sIt) {
1494 addResourceDir(resType.latin1(), *sIt); 1504 addResourceDir(resType.latin1(), *sIt);
1495 } 1505 }
1496 } 1506 }
1497 } 1507 }
1498 1508
1499 // Process KIOSK restrictions. 1509 // Process KIOSK restrictions.
1500 config->setGroup("KDE Resource Restrictions"); 1510 config->setGroup("KDE Resource Restrictions");
1501 entries = config->entryMap("KDE Resource Restrictions"); 1511 entries = config->entryMap("KDE Resource Restrictions");
1502 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1512 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1503 { 1513 {
1504 QString key = it2.key(); 1514 QString key = it2.key();
1505 if (!config->readBoolEntry(key, true)) 1515 if (!config->readBoolEntry(key, true))
1506 { 1516 {
1507 d->restrictionsActive = true; 1517 d->restrictionsActive = true;
1508 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1518 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1509 dircache.remove(key.latin1()); 1519 dircache.remove(key.latin1());
1510 } 1520 }
1511 } 1521 }
1512*/ 1522*/
1513 // save it for future calls - that will return 1523 // save it for future calls - that will return
1514 addedCustoms = true; 1524 addedCustoms = true;
1515 config->setGroup(oldGroup); 1525 config->setGroup(oldGroup);
1516 1526
1517 // return true if the number of config dirs changed 1527 // return true if the number of config dirs changed
1518 return (resourceDirs("config").count() != configdirs); 1528 return (resourceDirs("config").count() != configdirs);
1519} 1529}
1520 1530
1521QString KStandardDirs::localkdedir() const 1531QString KStandardDirs::localkdedir() const
1522{ 1532{
1523 // Return the prefix to use for saving 1533 // Return the prefix to use for saving
1524 return prefixes.first(); 1534 return prefixes.first();
1525} 1535}
1526 1536
1527QString KStandardDirs::localxdgdatadir() const 1537QString KStandardDirs::localxdgdatadir() const
1528{ 1538{
1529 // Return the prefix to use for saving 1539 // Return the prefix to use for saving
1530 return d->xdgdata_prefixes.first(); 1540 return d->xdgdata_prefixes.first();
1531} 1541}
1532 1542
1533QString KStandardDirs::localxdgconfdir() const 1543QString KStandardDirs::localxdgconfdir() const
1534{ 1544{
1535 // Return the prefix to use for saving 1545 // Return the prefix to use for saving
1536 return d->xdgconf_prefixes.first(); 1546 return d->xdgconf_prefixes.first();
1537} 1547}
1538 1548
1539void KStandardDirs::setAppDir( const QString &appDir ) 1549void KStandardDirs::setAppDir( const QString &appDir )
1540{ 1550{
1541 mAppDir = appDir; 1551 mAppDir = appDir;
1542 1552
1543 if ( mAppDir.right( 1 ) != "/" ) 1553 if ( mAppDir.right( 1 ) != "/" )
1544 mAppDir += "/"; 1554 mAppDir += "/";
1545} 1555}
1546 1556
1547QString KStandardDirs::appDir() 1557QString KStandardDirs::appDir()
1548{ 1558{
1549 return mAppDir; 1559 return mAppDir;
1550} 1560}
1551 1561
1552// just to make code more readable without macros 1562// just to make code more readable without macros
1553QString locate( const char *type, 1563QString locate( const char *type,
1554 const QString& filename/*US , const KInstance* inst*/ ) 1564 const QString& filename/*US , const KInstance* inst*/ )
1555{ 1565{
1556//US return inst->dirs()->findResource(type, filename); 1566//US return inst->dirs()->findResource(type, filename);