-rw-r--r-- | kabc/addressee.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 2 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 10 |
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 ) setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); rightOffset--; } else setFamilyName( parts[ rightOffset ] ); QString prefix; while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } setPrefix( prefix ); if ( leftOffset < rightOffset ) { setGivenName( parts[ leftOffset ] ); leftOffset++; } QString additionalName; while ( leftOffset < rightOffset ) { additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } setAdditionalName( additionalName ); } else { QString part1 = str.left( i ); QString part2 = str.mid( i + 1 ); QStringList parts = QStringList::split( " ", part1 ); int leftOffset = 0; int rightOffset = parts.count() - 1; QString suffix; while ( rightOffset >= 0 ) { if ( suffixes.contains( parts[ rightOffset ] ) ) { suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); rightOffset--; } else break; } setSuffix( suffix ); if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); rightOffset--; } else setFamilyName( parts[ rightOffset ] ); QString prefix; while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } parts = QStringList::split( " ", part2 ); leftOffset = 0; rightOffset = parts.count(); while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } setPrefix( prefix ); if ( leftOffset < rightOffset ) { setGivenName( parts[ leftOffset ] ); leftOffset++; } QString additionalName; while ( leftOffset < rightOffset ) { additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } setAdditionalName( additionalName ); } } QString Addressee::realName() const { if ( !formattedName().isEmpty() ) return formattedName(); QString n = assembledName(); if ( n.isEmpty() ) n = name(); - + if ( n.isEmpty() ) + n = organization(); return n; } QString Addressee::assembledName() const { QString name = prefix() + " " + givenName() + " " + additionalName() + " " + familyName() + " " + suffix(); return name.simplifyWhiteSpace(); } QString Addressee::fullEmail( const QString &email ) const { QString e; if ( email.isNull() ) { e = preferredEmail(); } else { e = email; } if ( e.isEmpty() ) return QString::null; QString text; if ( realName().isEmpty() ) text = e; else text = assembledName() + " <" + e + ">"; return text; } void Addressee::insertEmail( const QString &email, bool preferred ) { detach(); QStringList::Iterator it = mData->emails.find( email ); if ( it != mData->emails.end() ) { if ( !preferred || it == mData->emails.begin() ) return; mData->emails.remove( it ); mData->emails.prepend( email ); } else { if ( preferred ) { mData->emails.prepend( email ); } else { mData->emails.append( email ); } } } void Addressee::removeEmail( const QString &email ) { detach(); QStringList::Iterator it = mData->emails.find( email ); if ( it == mData->emails.end() ) return; mData->emails.remove( it ); } QString Addressee::preferredEmail() const { if ( mData->emails.count() == 0 ) return QString::null; else return mData->emails.first(); } QStringList Addressee::emails() const { return mData->emails; } void Addressee::setEmails( const QStringList& emails ) { detach(); mData->emails = emails; } void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) { detach(); mData->empty = false; PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( (*it).id() == phoneNumber.id() ) { *it = phoneNumber; return; } } mData->phoneNumbers.append( phoneNumber ); } void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) { detach(); PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( (*it).id() == phoneNumber.id() ) { 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 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qdragobject.h> #include <qevent.h> #include <qiconview.h> #include <qlayout.h> #include <qstringlist.h> #include <qregexp.h> #include <qapplication.h> #include <kabc/addressbook.h> #include <kabc/addressee.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> #include "kabprefs.h" #include "viewmanager.h" #include "kaddressbookcardview.h" #ifndef KAB_EMBEDDED extern "C" { void *init_libkaddrbk_cardview() { return ( new CardViewFactory ); } } #endif //KAB_EMBEDDED //////////////////////////////// // AddresseeCardViewItem (internal class) class AddresseeCardViewItem : public CardViewItem { public: AddresseeCardViewItem(const KABC::Field::List &fields, bool showEmptyFields, KABC::AddressBook *doc, const KABC::Addressee &a, CardView *parent) - : CardViewItem(parent, a.formattedName()), + : CardViewItem(parent, a.realName() ), mFields( fields ), mShowEmptyFields(showEmptyFields), mDocument(doc), mAddressee(a) { if ( mFields.isEmpty() ) { mFields = KABC::Field::defaultFields(); } refresh(); } const KABC::Addressee &addressee() const { return mAddressee; } void refresh() { // Update our addressee, since it may have changed elsewhere mAddressee = mDocument->findByUid(mAddressee.uid()); if (!mAddressee.isEmpty()) { clearFields(); // Try all the selected fields until we find one with text. // This will limit the number of unlabeled icons in the view KABC::Field::List::Iterator iter; for (iter = mFields.begin(); iter != mFields.end(); ++iter) { // insert empty fields or not? not doing so saves a bit of memory and CPU // (during geometry calculations), but prevents having equally // wide label columns in all cards, unless CardViewItem/CardView search // globally for the widest label. (anders) //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) insertField((*iter)->label(), (*iter)->value( mAddressee )); } // We might want to make this the first field. hmm... -mpilone setCaption( mAddressee.realName() ); } } private: KABC::Field::List mFields; bool mShowEmptyFields; KABC::AddressBook *mDocument; KABC::Addressee mAddressee; }; /////////////////////////////// // AddresseeCardView AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) : CardView(parent, name) { setAcceptDrops(true); } AddresseeCardView::~AddresseeCardView() { } void AddresseeCardView::printMe() { #ifdef DESKTOP_VERSION QPrinter printer; if (!printer.setup() ) return; QPainter p; p.begin ( &printer ); QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); float dx, dy; int wid = (m.width() * 9)/10; dx = (float) wid/(float)contentsWidth (); dy = (float)(m.height()) / (float)contentsHeight (); float scale; // scale to fit the width or height of the paper if ( dx < dy ) scale = dx; else scale = dy; p.translate( m.width()/10,0 ); p.scale( scale, scale ); drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); p.end(); repaint(); #endif } void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) { #ifndef KAB_EMBEDDED if (QTextDrag::canDecode(e)) e->accept(); #else //KAB_EMBEDDED qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); #endif //KAB_EMBEDDED } void 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) static QString readEnvPath(const char *env) { //#ifdef _WIN32_ // return ""; //#else QCString c_path; if ( getenv(env) != NULL ) c_path = QString ( getenv(env) ); if (c_path.isEmpty()) return QString::null; return QFile::decodeName(c_path); //#endif } void KStandardDirs::addKDEDefaults() { //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); //return; QStringList kdedirList; // begin KDEDIRS QString kdedirs = readEnvPath("MICROKDEDIRS"); if (!kdedirs.isEmpty()) { tokenize(kdedirList, kdedirs, ":"); } else { QString kdedir = readEnvPath("MICROKDEDIR"); if (!kdedir.isEmpty()) { kdedir = KShell::tildeExpand(kdedir); kdedirList.append(kdedir); } } //US kdedirList.append(KDEDIR); //US for embedded, add qtopia dir as kdedir #ifndef DESKTOP_VERSION QString tmp = readEnvPath("QPEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("QTDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("OPIEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); #endif #ifdef __KDE_EXECPREFIX QString execPrefix(__KDE_EXECPREFIX); if (execPrefix!="NONE") kdedirList.append(execPrefix); #endif QString localKdeDir; //US if (getuid()) if (true) { localKdeDir = readEnvPath("MICROKDEHOME"); if (!localKdeDir.isEmpty()) { #ifdef _WIN32_ if (localKdeDir.at(localKdeDir.length()-1) != '\\') localKdeDir += '\\'; #else if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; #endif //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); } else { QString confFile; #ifdef DESKTOP_VERSION confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( !fi.exists() ) confFile = QDir::homeDirPath() + "/.microkdehome"; else qDebug("Loading path info from " + confFile ); #else confFile = QDir::homeDirPath() + "/.microkdehome"; #endif KConfig cfg ( confFile ); cfg.setGroup("Global"); localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); +#ifdef DESKTOP_VERSION + if ( localKdeDir.startsWith( "LOCAL:" ) ) { +#ifdef _WIN32_ + localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); +#else + localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); +#endif + qDebug("Using local conf dir %s ",localKdeDir.latin1() ); + } +#endif } } else { // We treat root different to prevent root messing up the // file permissions in the users home directory. localKdeDir = readEnvPath("MICROKDEROOTHOME"); if (!localKdeDir.isEmpty()) { if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; } else { //US struct passwd *pw = getpwuid(0); //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); } } //US localKdeDir = appDir(); //US // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); if (localKdeDir != "-/") { localKdeDir = KShell::tildeExpand(localKdeDir); addPrefix(localKdeDir); } for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addPrefix(dir); } // end KDEDIRS // begin XDG_CONFIG_XXX QStringList xdgdirList; QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); xdgdirList.append("/etc/xdg"); } QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.config/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgConfigPrefix(localXdgDir); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgConfigPrefix(dir); } // end XDG_CONFIG_XXX // begin XDG_DATA_XXX xdgdirs = readEnvPath("XDG_DATA_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { |