author | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
commit | cbc789907408fa3359444c464ba5a86be892f301 (patch) (side-by-side diff) | |
tree | 82d02fc50134c1e64acf4ea9f5388ac3396602b3 | |
parent | a55fa40fa32b115c7f7803fb6af0da5184cd7dff (diff) | |
download | kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.zip kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.gz kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.bz2 |
Windows import fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 28 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/undocmds.cpp | 3 |
3 files changed, 33 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f4263c4..1a34e4d 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -86,64 +86,65 @@ #include <kresources/selectdialog.h> #include <kmessagebox.h> #include <picture.h> #include <resource.h> //US#include <qsplitter.h> #include <qvbox.h> #include <qlayout.h> #include <qclipboard.h> #include <libkdepim/categoryselectdialog.h> #include "addresseeutil.h" #include "undocmds.h" #include "addresseeeditordialog.h" #include "viewmanager.h" #include "details/detailsviewcontainer.h" #include "kabprefs.h" #include "xxportmanager.h" #include "incsearchwidget.h" #include "jumpbuttonbar.h" #include "extensionmanager.h" #include "addresseeconfig.h" #include <kcmultidialog.h> #ifdef _WIN32_ #include "kaimportoldialog.h" #endif +bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ mReadWrite( readWrite ), mModified( false ), mMainWindow(client) #else //KAB_EMBEDDED KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ), mModified( false ) #endif //KAB_EMBEDDED { #ifdef KAB_EMBEDDED //US we define here our own global actioncollection. //mActionCollection = new KActionCollection(this); #endif //KAB_EMBEDDED mExtensionBarSplitter = 0; mIsPart = !parent->inherits( "KAddressBookMain" ); mAddressBook = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false ); #ifndef KAB_EMBEDDED mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); #endif //KAB_EMBEDDED connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), SLOT( addressBookChanged() ) ); mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); @@ -369,65 +370,69 @@ void KABCore::createAboutData() "mpilone@slac.com" ); about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), "michel@klaralvdalens-datakonsult.se" ); about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), "hansen@kde.org" ); return about; #endif //KAB_EMBEDDED QString version; #include <../version> QMessageBox::about( this, "About KAddressbook/Pi", "KAddressbook/Platform-independent\n" "(KA/Pi) " +version + " - " + #ifdef DESKTOP_VERSION "Desktop Edition\n" #else "PDA-Edition\n" "for: Zaurus 5500 / 7x0 / 8x0\n" #endif "(c) 2004 Ulf Schenk\n" "(c) 1997-2003, The KDE PIM Team\n" "Tobias Koenig Current maintainer tokoe@kde.org\n" "Don Sanders Original author\n" "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" "Mike Pilone GUI and framework redesign mpilone@slac.com\n" "Greg Stern DCOP interface\n" "Mark Westcot Contact pinning\n" "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" - "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); + "Steffen Hansen LDAP Lookup hansen@kde.org\n" +#ifdef _WIN32_ + "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" +#endif + ); } void KABCore::setContactSelected( const QString &uid ) { KABC::Addressee addr = mAddressBook->findByUid( uid ); if ( !mDetails->isHidden() ) mDetails->setAddressee( addr ); if ( !addr.isEmpty() ) { emit contactSelected( addr.formattedName() ); KABC::Picture pic = addr.photo(); if ( pic.isIntern() ) { //US emit contactSelected( pic.data() ); //US instead use: QPixmap px; if (pic.data().isNull() != true) { px.convertFromImage(pic.data()); } emit contactSelected( px ); } } mExtensionManager->setSelectionChanged(); // update the actions bool selected = !uid.isEmpty(); if ( mReadWrite ) { mActionCut->setEnabled( selected ); @@ -825,66 +830,83 @@ void KABCore::addEmail( QString aStr ) emailList = (*it).emails(); if ( emailList.contains( email ) > 0 ) { found = true; (*it).setNameFromString( fullName ); editContact( (*it).uid() ); } } if ( !found ) { KABC::Addressee addr; addr.setNameFromString( fullName ); addr.insertEmail( email, true ); mAddressBook->insertAddressee( addr ); mViewManager->refreshView( addr.uid() ); editContact( addr.uid() ); } #else //KAB_EMBEDDED qDebug("KABCore::addEmail finsih method"); #endif //KAB_EMBEDDED } void KABCore::importVCard( const KURL &url, bool showPreview ) { mXXPortManager->importVCard( url, showPreview ); } void KABCore::importFromOL() { #ifdef _WIN32_ KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); idgl->exec(); KABC::Addressee::List list = idgl->getAddressList(); - if ( list.count() > 0 ) - pasteContacts( list ); + if ( list.count() > 0 ) { + KABC::Addressee::List listNew; + KABC::Addressee::List listExisting; + KABC::Addressee::List::Iterator it; + KABC::AddressBook::Iterator iter; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) + listNew.append( (*it) ); + else + listExisting.append( (*it) ); + } + if ( listExisting.count() > 0 ) + KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); + if ( listNew.count() > 0 ) { + pasteWithNewUid = false; + pasteContacts( listNew ); + pasteWithNewUid = true; + } + } delete idgl; #endif } void KABCore::importVCard( const QString &vCard, bool showPreview ) { mXXPortManager->importVCard( vCard, showPreview ); } //US added a second method without defaultparameter void KABCore::editContact2() { editContact( QString::null ); } void KABCore::editContact( const QString &uid ) { if ( mExtensionManager->isQuickEditVisible() ) return; // First, locate the contact entry QString localUID = uid; if ( localUID.isNull() ) { QStringList uidList = mViewManager->selectedUids(); if ( uidList.count() > 0 ) localUID = *( uidList.at( 0 ) ); } KABC::Addressee addr = mAddressBook->findByUid( localUID ); if ( !addr.isEmpty() ) { mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 5e7d7c4..ef949e7 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp @@ -219,65 +219,65 @@ void KAImportOLdialog::readContactData( DWORD folder ) folderItems = mf.GetItems(); QProgressBar bar( folderItems.GetCount(),0 ); bar.setCaption (i18n("Importing - close to abort!") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _ContactItem * pItem = (_ContactItem *)&itm; ol2kapiContact( pItem ); itm->Release(); } } void KAImportOLdialog::slotOk() { QDialog::accept(); } void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) { KABC::Addressee addressee; addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); - + //GetLastModificationTime() //addressee.setName( const QString &name ); //addressee.setFormattedName( const QString &formattedName ); addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); if ( dtb.isValid() ) addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); //QString::fromUcs2(aItem->.GetBuffer()) //addressee.setMailer( const QString &mailer ); //addressee.setTimeZone( const TimeZone &timeZone ); //addressee.setGeo( const Geo &geo ); //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) ); addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); //addressee.setRevision( const QDateTime &revision ); // addressee.setSortString( const QString &sortString ); addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); QString tempS; tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); if ( tempS.length() > 12 ) addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); if ( !tempS.isEmpty() ) @@ -600,36 +600,40 @@ void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) if ( gen != 0 ) { // 0 undef - 1 female - 2 male if ( gen == 1 ) addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); else addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); } #if 0 // pending - IM address: no clue where to get info about the helper ID -custom fields: difficult to implement - not implemented -keys: makes no sense #endif if ( addAddressee( addressee )) ++importedItems; } void KAImportOLdialog::slotCancel() { reject(); } bool KAImportOLdialog::addAddressee( KABC::Addressee a ) { bool add = true; KABC::Addressee::List::Iterator it; for ( it = mAList.begin(); it != mAList.end(); ++it ) { if ( (*it).uid() == a.uid() ) { add = false; break; } } - if ( add ) + if ( add ) { + if ( mABook->findByUid(a.uid() ).isEmpty()) mAList.append ( a ); + else + add = false; + } return add; } diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp index 5fbeec3..5807dc0 100644 --- a/kaddressbook/undocmds.cpp +++ b/kaddressbook/undocmds.cpp @@ -7,65 +7,65 @@ 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 <qtextstream.h> #include <qapplication.h> #include <qclipboard.h> #include <klocale.h> #include <kdebug.h> #include <kapplication.h> #include <kabc/addressbook.h> #include "addresseeutil.h" #include "addresseeconfig.h" #include "kabcore.h" #include "undocmds.h" - +extern bool pasteWithNewUid; ///////////////////////////////// // PwDelete Methods PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, const QStringList &uidList) : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) { redo(); } PwDeleteCommand::~PwDeleteCommand() { } QString PwDeleteCommand::name() { return i18n( "Delete" ); } void PwDeleteCommand::undo() { // Put it back in the document KABC::Addressee::List::Iterator iter; for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) { mDocument->insertAddressee(*iter); } mAddresseeList.clear(); } void PwDeleteCommand::redo() @@ -83,64 +83,65 @@ void PwDeleteCommand::redo() } } ///////////////////////////////// // PwPaste Methods PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) : Command(), mCore( core ), mAddresseeList( list ) { redo(); } QString PwPasteCommand::name() { return i18n( "Paste" ); } void PwPasteCommand::undo() { KABC::Addressee::List::Iterator it; for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) mCore->addressBook()->removeAddressee( *it ); } void PwPasteCommand::redo() { QStringList uids; KABC::Addressee::List::Iterator it; for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { /* we have to set a new uid for the contact, otherwise insertAddressee() ignore it. */ + if ( pasteWithNewUid ) (*it).setUid( KApplication::randomString( 10 ) ); uids.append( (*it).uid() ); mCore->addressBook()->insertAddressee( *it ); } if ( uids.count() < 4 ) { QStringList::Iterator uidIt; for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) mCore->editContact( *uidIt ); } } ///////////////////////////////// // PwNew Methods PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) : Command(), mDocument( doc ), mA( a ) { mDocument->insertAddressee(mA); } PwNewCommand::~PwNewCommand() { } QString PwNewCommand::name() { return i18n( "New Contact" ); } void PwNewCommand::undo() { mDocument->removeAddressee( mA ); |