summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-12 12:43:54 (UTC)
committer zautrix <zautrix>2004-07-12 12:43:54 (UTC)
commitcbc789907408fa3359444c464ba5a86be892f301 (patch) (side-by-side diff)
tree82d02fc50134c1e64acf4ea9f5388ac3396602b3
parenta55fa40fa32b115c7f7803fb6af0da5184cd7dff (diff)
downloadkdepimpi-cbc789907408fa3359444c464ba5a86be892f301.zip
kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.gz
kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.bz2
Windows import fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp28
-rw-r--r--kaddressbook/kaimportoldialog.cpp8
-rw-r--r--kaddressbook/undocmds.cpp3
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
@@ -22,192 +22,193 @@
*/
#include "kabcore.h"
#include <stdaddressbook.h>
#include <klocale.h>
#ifndef KAB_EMBEDDED
#include <qclipboard.h>
#include <qdir.h>
#include <qfile.h>
#include <qapplicaton.h>
#include <qlayout.h>
#include <qregexp.h>
#include <qvbox.h>
#include <kabc/addresseelist.h>
#include <kabc/errorhandler.h>
#include <kabc/resource.h>
#include <kabc/vcardconverter.h>
#include <kapplication.h>
#include <kactionclasses.h>
#include <kcmultidialog.h>
#include <kdebug.h>
#include <kdeversion.h>
#include <kkeydialog.h>
#include <kmessagebox.h>
#include <kprinter.h>
#include <kprotocolinfo.h>
#include <kresources/selectdialog.h>
#include <kstandarddirs.h>
#include <ktempfile.h>
#include <kxmlguiclient.h>
#include <kaboutdata.h>
#include <libkdepim/categoryselectdialog.h>
#include "addresseeutil.h"
#include "addresseeeditordialog.h"
#include "extensionmanager.h"
#include "kstdaction.h"
#include "kaddressbookservice.h"
#include "ldapsearchdialog.h"
#include "printing/printingwizard.h"
#else // KAB_EMBEDDED
#include <kapplication.h>
#include "KDGanttMinimizeSplitter.h"
#include "kaddressbookmain.h"
#include "kactioncollection.h"
#include <qapp.h>
#include <qmenubar.h>
//#include <qtoolbar.h>
#include <qmessagebox.h>
#include <kdebug.h>
#include <kiconloader.h> // needed for SmallIcon
#include <kresources/kcmkresources.h>
#include <ktoolbar.h>
#include <kcmkabconfig.h>
//US#include <qpe/resource.h> // needed for Resource::loadPixmap
//#include <qlabel.h>
#endif // KAB_EMBEDDED
#include <kcmkabconfig.h>
#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" );
mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
"X-Profession", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
"X-AssistantsName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
"X-ManagersName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
"X-SpousesName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
"X-Office", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
"X-IMAddress", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
"X-Anniversary", "KADDRESSBOOK" );
//US added this field to become compatible with Opie addressbook
mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
"X-Gender", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
"X-Children", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
"X-FreeBusyUrl", "KADDRESSBOOK" );
initGUI();
mIncSearchWidget->setFocus();
connect( mViewManager, SIGNAL( selected( const QString& ) ),
SLOT( setContactSelected( const QString& ) ) );
connect( mViewManager, SIGNAL( executed( const QString& ) ),
SLOT( editContact( const QString& ) ) );
connect( mViewManager, SIGNAL( deleteRequest( ) ),
SLOT( deleteContacts( ) ) );
connect( mViewManager, SIGNAL( modified() ),
SLOT( setModified() ) );
connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
connect( mXXPortManager, SIGNAL( modified() ),
SLOT( setModified() ) );
connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
mJumpButtonBar, SLOT( recreateButtons() ) );
#ifndef KAB_EMBEDDED
connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
mXXPortManager, SLOT( importVCard( const KURL& ) ) );
connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
SLOT( sendMail( const QString& ) ) );
connect( mDetails, SIGNAL( browse( const QString& ) ),
SLOT( browse( const QString& ) ) );
mAddressBookService = new KAddressBookService( this );
#endif //KAB_EMBEDDED
mEditorDialog = 0;
createAddresseeEditorDialog( this );
setModified( false );
}
@@ -305,193 +306,197 @@ KABC::AddressBook *KABCore::addressBook() const
KConfig *KABCore::config()
{
#ifndef KAB_EMBEDDED
return KABPrefs::instance()->config();
#else //KAB_EMBEDDED
return KABPrefs::instance()->getConfig();
#endif //KAB_EMBEDDED
}
KActionCollection *KABCore::actionCollection() const
{
return mGUIClient->actionCollection();
}
KABC::Field *KABCore::currentSearchField() const
{
if (mIncSearchWidget)
return mIncSearchWidget->currentField();
else
return 0;
}
QStringList KABCore::selectedUIDs() const
{
return mViewManager->selectedUids();
}
KABC::Resource *KABCore::requestResource( QWidget *parent )
{
QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
QPtrList<KRES::Resource> kresResources;
QPtrListIterator<KABC::Resource> resIt( kabcResources );
KABC::Resource *resource;
while ( ( resource = resIt.current() ) != 0 ) {
++resIt;
if ( !resource->readOnly() ) {
KRES::Resource *res = static_cast<KRES::Resource*>( resource );
if ( res )
kresResources.append( res );
}
}
KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
return static_cast<KABC::Resource*>( res );
}
#ifndef KAB_EMBEDDED
KAboutData *KABCore::createAboutData()
#else //KAB_EMBEDDED
void KABCore::createAboutData()
#endif //KAB_EMBEDDED
{
#ifndef KAB_EMBEDDED
KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
"3.1", I18N_NOOP( "The KDE Address Book" ),
KAboutData::License_GPL_V2,
I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
about->addAuthor( "Cornelius Schumacher",
I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
"schumacher@kde.org" );
about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
"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 );
mActionPaste->setEnabled( selected );
}
mActionCopy->setEnabled( selected );
mActionDelete->setEnabled( selected );
mActionEditAddressee->setEnabled( selected );
mActionMail->setEnabled( selected );
mActionMailVCard->setEnabled( selected );
mActionWhoAmI->setEnabled( selected );
mActionCategories->setEnabled( selected );
}
void KABCore::sendMail()
{
#ifndef KAB_EMBEDDED
sendMail( mViewManager->selectedEmails().join( ", " ) );
#else //KAB_EMBEDDED
qDebug("KABCore::sendMail() ust be fixed");
#endif //KAB_EMBEDDED
}
void KABCore::sendMail( const QString& email )
{
#ifndef KAB_EMBEDDED
kapp->invokeMailer( email, "" );
#else //KAB_EMBEDDED
qDebug("KABCore::sendMail(const QString& email) ust be fixed");
#endif //KAB_EMBEDDED
}
void KABCore::mailVCard()
{
#ifndef KAB_EMBEDDED
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
mailVCard( uids );
#else //KAB_EMBEDDED
qDebug("KABCore::mailVCard() must be fixed");
#endif //KAB_EMBEDDED
}
void KABCore::mailVCard( const QStringList& uids )
{
#ifndef KAB_EMBEDDED
QStringList urls;
// Create a temp dir, so that we can put the files in it with proper names
KTempFile tempDir;
if ( tempDir.status() != 0 ) {
kdWarning() << strerror( tempDir.status() ) << endl;
return;
}
QString dirName = tempDir.name();
tempDir.unlink();
QDir().mkdir( dirName, true );
for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
KABC::Addressee a = mAddressBook->findByUid( *it );
if ( a.isEmpty() )
continue;
QString name = a.givenName() + "_" + a.familyName() + ".vcf";
@@ -761,194 +766,211 @@ void KABCore::contactModified( const KABC::Addressee &addr )
QString uid;
// check if it exists already
KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
if ( origAddr.isEmpty() )
command = new PwNewCommand( mAddressBook, addr );
else {
command = new PwEditCommand( mAddressBook, origAddr, addr );
uid = addr.uid();
}
UndoStack::instance()->push( command );
RedoStack::instance()->clear();
setModified( true );
}
void KABCore::newContact()
{
QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
QPtrList<KRES::Resource> kresResources;
QPtrListIterator<KABC::Resource> it( kabcResources );
KABC::Resource *resource;
while ( ( resource = it.current() ) != 0 ) {
++it;
if ( !resource->readOnly() ) {
KRES::Resource *res = static_cast<KRES::Resource*>( resource );
if ( res )
kresResources.append( res );
}
}
KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
resource = static_cast<KABC::Resource*>( res );
if ( resource ) {
KABC::Addressee addr;
addr.setResource( resource );
mEditorDialog->setAddressee( addr );
KApplication::execDialog ( mEditorDialog );
} else
return;
// mEditorDict.insert( dialog->addressee().uid(), dialog );
}
void KABCore::addEmail( QString aStr )
{
#ifndef KAB_EMBEDDED
QString fullName, email;
KABC::Addressee::parseEmailAddress( aStr, fullName, email );
// Try to lookup the addressee matching the email address
bool found = false;
QStringList emailList;
KABC::AddressBook::Iterator it;
for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
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 );
}
}
void KABCore::save()
{
if ( !mModified )
return;
QString text = i18n( "There was an error while attempting to save\n the "
"address book. Please check that some \nother application is "
"not using it. " );
statusMessage(i18n("Saving addressbook ... "));
#ifndef KAB_EMBEDDED
KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
if ( !b || !b->save() ) {
KMessageBox::error( this, text, i18n( "Unable to Save" ) );
}
#else //KAB_EMBEDDED
KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
if ( !b || !b->save() ) {
QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
}
#endif //KAB_EMBEDDED
statusMessage(i18n("Addressbook saved!"));
setModified( false );
}
void KABCore::statusMessage(QString mess , int time )
{
//topLevelWidget()->setCaption( mess );
// pending setting timer to revome message
}
void KABCore::undo()
{
UndoStack::instance()->undo();
// Refresh the view
mViewManager->refreshView();
}
void KABCore::redo()
{
RedoStack::instance()->redo();
// Refresh the view
mViewManager->refreshView();
}
void KABCore::setJumpButtonBarVisible( bool visible )
{
if ( visible )
mJumpButtonBar->show();
else
mJumpButtonBar->hide();
}
void KABCore::setDetailsToState()
{
setDetailsVisible( mActionDetails->isChecked() );
}
void KABCore::setDetailsVisible( bool visible )
{
if ( visible )
mDetails->show();
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 5e7d7c4..ef949e7 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -155,193 +155,193 @@ void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent
folders = mfParent.GetFolders();
for(int i=1; i <= folders.GetCount(); ++i)
{
fndx = (long)i;
mfChild = folders.Item(fndx.Detach());
mfChild.m_lpDispatch->AddRef();
szName = mfChild.GetName();
iType = mfChild.GetDefaultItemType();
hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
if ( iType != 2)
hChild->setEnabled( false );
QString ts;
switch( iType ) {
case 0:
ts = i18n("Mail");
break;
case 1:
ts = i18n("Calendar");
break;
case 2:
ts = i18n("Contacts");
break;
case 3:
ts = i18n("Todos");
break;
case 4:
ts = i18n("Journals");
break;
case 5:
ts = i18n("Notes");
break;
default:
ts = i18n("Unknown");
}
hChild->setText( 1,ts);
hChild->setData( (DWORD) mfChild.m_lpDispatch );
mfChild.m_lpDispatch->AddRef();
addFolder(hChild, mfChild.m_lpDispatch);
}
}
void KAImportOLdialog::slotApply()
{
importedItems = 0;
OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
while ( child ) {
if ( child->isOn() )
readContactData( child->data() );
child = (OLEListViewItem*) child->itemBelow();
}
QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
KMessageBox::information(this,mes);
}
void KAImportOLdialog::readContactData( DWORD folder )
{
LPDISPATCH dispItem = (LPDISPATCH)folder;
dispItem->AddRef();
MAPIFolder mf(dispItem);
mf.m_lpDispatch->AddRef();
_Items folderItems;
_variant_t indx((long)0);
LPDISPATCH itm;
int i;
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() )
addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
dtb = mDdate2Qdtr(aItem->GetAnniversary());
if (dtb.isValid() ) {
QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
int sec = aItem->GetSensitivity() ;
if ( sec > 1 )// mapping pers -> private
--sec;
addressee.setSecrecy( sec );
//addressee.setLogo( const Picture &logo );
//addressee.setPhoto( const Picture &photo );
//addressee.setSound( const Sound &sound );
//addressee.setAgent( const Agent &agent );
QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
addressee.setCategories( QStringList::split( ";", cat ));
QString phoneS;
phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) );
phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) );
phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) );
phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) );
phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) );
phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
if ( ! phoneS.isEmpty())
addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) );
@@ -536,100 +536,104 @@ void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
if ( ! phoneS.isEmpty()) {
addressAdd->setLocality(phoneS );
insert = true;
}
phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
if ( ! phoneS.isEmpty()) {
addressAdd->setPostalCode(phoneS );
insert = true;
}
phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
if ( ! phoneS.isEmpty()) {
addressAdd->setPostOfficeBox(phoneS );
insert = true;
}
phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
if ( ! phoneS.isEmpty()) {
addressAdd->setStreet(phoneS );
insert = true;
}
phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
if ( ! phoneS.isEmpty()) {
// redundant ! addressAdd->setExtended(phoneS );
// insert = true;
}
addressAdd->setType( KABC::Address::Postal );
if ( insert ) {
addressee.insertAddress( *addressAdd );
}
// the following code is disabled
// it does not seem to be useful
#if 0
if ( insert ) {
addressAdd->setType( KABC::Address::Home );
if ( addressMail == addressHome ) {
addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
addressee.insertAddress( addressHome );
} else {
addressAdd->setType( KABC::Address::Work );
if ( addressMail == addressWork ){
addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
addressee.insertAddress( addressWork );
} else {
addressAdd->setType( 0 );
if ( addressOther == addressMail ){
addressOther.setType( KABC::Address::Postal );
addressee.insertAddress( addressOther );
} else {
addressee.insertAddress( *addressAdd );
}
}
}
}
#endif
// ++++++++++++++++++++++ end of ALL addresses
//GetUserProperties();
tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
int gen = aItem->GetGender();
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
@@ -1,210 +1,211 @@
/*
This file is part of KAddressBook.
Copyright (C) 1999 Don Sanders <sanders@kde.org>
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 <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()
{
// Just remove it from the document. This is enough to make the user
// Think the item has been deleted
KABC::Addressee a;
QStringList::Iterator iter;
for (iter = mUidList.begin(); iter != mUidList.end(); ++iter)
{
a = mDocument->findByUid(*iter);
mDocument->removeAddressee(a);
mAddresseeList.append(a);
AddresseeConfig::instance()->remove(a.uid());
}
}
/////////////////////////////////
// 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 );
}
void PwNewCommand::redo()
{
mDocument->insertAddressee( mA );
}
/////////////////////////////////
// PwEdit Methods
PwEditCommand::PwEditCommand(KABC::AddressBook *doc,
const KABC::Addressee &oldA,
const KABC::Addressee &newA )
: Command(), mDocument(doc), mOldA(oldA), mNewA(newA)
{
redo();
}
PwEditCommand::~PwEditCommand()
{
}
QString PwEditCommand::name()
{
return i18n( "Entry Edit" );
}
void PwEditCommand::undo()
{
mDocument->insertAddressee(mOldA);
}
void PwEditCommand::redo()
{
mDocument->insertAddressee(mNewA);
}
/////////////////////////////////
// PwCut Methods
PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList)
: Command(), mDocument(doc), mAddresseeList(), mUidList(uidList),
mClipText(), mOldText()
{
redo();
}
QString PwCutCommand::name()
{
return i18n( "Cut" );
}
void PwCutCommand::undo()
{
KABC::Addressee::List::Iterator iter;
for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter)
{
mDocument->insertAddressee(*iter);
}
mAddresseeList.clear();
QClipboard *cb = QApplication::clipboard();
//US
#ifndef KAB_EMBEDDED