summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-30 10:41:33 (UTC)
committer zautrix <zautrix>2005-03-30 10:41:33 (UTC)
commit597cad3a63e6c22855704bf8435db70e3c2b184f (patch) (unidiff)
treef7093b331be9a52a07d01a6f2f5c1f26daf42d50
parent889d2102fcfe2fb0786b3f8f406dc32b42e38c7a (diff)
downloadkdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.zip
kdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.tar.gz
kdepimpi-597cad3a63e6c22855704bf8435db70e3c2b184f.tar.bz2
fix
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
@@ -1402,193 +1402,194 @@ void Addressee::setNameFromString( const QString &str )
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 );
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,158 +1,158 @@
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)
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
@@ -1205,192 +1205,202 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
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 {