-rw-r--r-- | kaddressbook/kabcore.cpp | 254 |
1 files changed, 143 insertions, 111 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index a7ca0ce..2a54900 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -23,3 +23,3 @@ -#include "kabcore.h" +#include "kabcore.h" @@ -80,4 +80,10 @@ -//US#include <qpe/resource.h> // needed for Resource::loadPixmap //#include <qlabel.h> + + +#ifdef Q_WS_QWS +#include <qtopia/services.h> +#include <qtopia/qcopenvelope_qws.h> +#endif + #endif // KAB_EMBEDDED @@ -93,2 +99,5 @@ //US#include <qsplitter.h> +#include <qmap.h> +#include <qdir.h> +#include <qfile.h> #include <qvbox.h> @@ -96,4 +105,7 @@ #include <qclipboard.h> +#include <qtextstream.h> #include <libkdepim/categoryselectdialog.h> +#include <kabc/vcardconverter.h> + @@ -131,6 +143,3 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const { -#ifdef KAB_EMBEDDED - //US we define here our own global actioncollection. - //mActionCollection = new KActionCollection(this); -#endif //KAB_EMBEDDED + mExtensionBarSplitter = 0; @@ -144,3 +153,3 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const #endif //KAB_EMBEDDED - + connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), @@ -164,4 +173,4 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const "X-Anniversary", "KADDRESSBOOK" ); - - //US added this field to become compatible with Opie/qtopia addressbook + + //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. @@ -197,3 +206,6 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const mJumpButtonBar, SLOT( recreateButtons() ) ); - + + connect( mDetails, SIGNAL( sendEmail( const QString& ) ), + SLOT( sendMail( const QString& ) ) ); + #ifndef KAB_EMBEDDED @@ -202,4 +214,2 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const - connect( mDetails, SIGNAL( sendEmail( const QString& ) ), - SLOT( sendMail( const QString& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), @@ -223,8 +233,2 @@ KABCore::~KABCore() KABC::StdAddressBook::close(); - -#ifdef KAB_EMBEDDED - //US we define here our own global actioncollection. - // delete mActionCollection; -#endif //KAB_EMBEDDED - } @@ -237,3 +241,3 @@ void KABCore::restoreSettings() setJumpButtonBarVisible( state ); - + state = KABPrefs::instance()->mDetailsPageVisible; @@ -296,5 +300,5 @@ void KABCore::saveSettings() mViewManager->saveSettings(); - + KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); - + } @@ -380,5 +384,5 @@ void KABCore::createAboutData() #endif //KAB_EMBEDDED - + QString version; -#include <../version> +#include <../version> QMessageBox::about( this, "About KAddressbook/Pi", @@ -392,3 +396,3 @@ void KABCore::createAboutData() #endif - + "(c) 2004 Ulf Schenk\n" @@ -420,3 +424,3 @@ void KABCore::setContactSelected( const QString &uid ) //US emit contactSelected( pic.data() ); -//US instead use: +//US instead use: QPixmap px; @@ -426,3 +430,3 @@ void KABCore::setContactSelected( const QString &uid ) } - + emit contactSelected( px ); @@ -453,7 +457,3 @@ void KABCore::sendMail() { -#ifndef KAB_EMBEDDED sendMail( mViewManager->selectedEmails().join( ", " ) ); -#else //KAB_EMBEDDED - qDebug("KABCore::sendMail() ust be fixed"); -#endif //KAB_EMBEDDED } @@ -462,7 +462,25 @@ 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 +//US original kde implementation : kapp->invokeMailer( email, "" ); + +/*US original qtopia implementation + PimContact c = abList->currentEntry(); + QString name = c.fileAs(); + QString email = c.defaultEmail(); +#ifndef QT_NO_COP + QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)"); + e << name << email; +#else +*/ + + +#ifndef QT_NO_COP + QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); + qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); + + QCopEnvelope e(channel, "writeMail(QString,QString)"); + //US we need no names in the To field. The emailadresses are enough + e << "" << email; +#else + KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); +#endif } @@ -471,3 +489,2 @@ void KABCore::mailVCard() { -#ifndef KAB_EMBEDDED QStringList uids = mViewManager->selectedUids(); @@ -475,5 +492,2 @@ void KABCore::mailVCard() mailVCard( uids ); -#else //KAB_EMBEDDED - qDebug("KABCore::mailVCard() must be fixed"); -#endif //KAB_EMBEDDED } @@ -482,5 +496,7 @@ void KABCore::mailVCard( const QStringList& uids ) { -#ifndef KAB_EMBEDDED QStringList urls; + QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); + +/*US // Create a temp dir, so that we can put the files in it with proper names @@ -494,2 +510,7 @@ void KABCore::mailVCard( const QStringList& uids ) tempDir.unlink(); +*/ + QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); + + + QDir().mkdir( dirName, true ); @@ -522,3 +543,3 @@ void KABCore::mailVCard( const QStringList& uids ) } - +/*US kapp->invokeMailer( QString::null, QString::null, QString::null, @@ -528,5 +549,16 @@ void KABCore::mailVCard( const QStringList& uids ) urls ); // attachments -#else //KAB_EMBEDDED - qDebug("KABCore::mailVCard( must be fixed"); -#endif //KAB_EMBEDDED +*/ +#ifndef QT_NO_COP + QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); + qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); + + QMap<QString, QString> parameterMap; + parameterMap.insert("ATTACHMENT<n>", urls.join(", ")); + + QCopEnvelope e(channel, "writeMail(QMap(QString,QString))"); + e << parameterMap; +#else + KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); +#endif + @@ -754,3 +786,3 @@ void KABCore::setModified( bool modified ) mDetails->refreshView(); - + } @@ -764,3 +796,3 @@ void KABCore::contactModified( const KABC::Addressee &addr ) { - + Command *command = 0; @@ -808,10 +840,10 @@ void KABCore::newContact() mEditorDialog->setAddressee( addr ); - KApplication::execDialog ( mEditorDialog ); - + KApplication::execDialog ( mEditorDialog ); + } else return; - + // mEditorDict.insert( dialog->addressee().uid(), dialog ); - + } @@ -890,3 +922,3 @@ void KABCore::importVCard( const QString &vCard, bool showPreview ) -//US added a second method without defaultparameter +//US added a second method without defaultparameter void KABCore::editContact2() { @@ -983,3 +1015,3 @@ void KABCore::extensionModified( const KABC::Addressee::List &list ) { - + if ( list.count() != 0 ) { @@ -990,3 +1022,3 @@ void KABCore::extensionModified( const KABC::Addressee::List &list ) setModified(); - else + else setModifiedWOrefresh(); @@ -998,3 +1030,3 @@ void KABCore::extensionModified( const KABC::Addressee::List &list ) - + @@ -1030,3 +1062,3 @@ QString KABCore::getNameByPhone( const QString &phone ) #endif //KAB_EMBEDDED - + } @@ -1187,3 +1219,3 @@ void KABCore::initGUI() #else //KAB_EMBEDDED - //US initialize viewMenu before settingup viewmanager. + //US initialize viewMenu before settingup viewmanager. // Viewmanager needs this menu to plugin submenues. @@ -1204,3 +1236,3 @@ void KABCore::initGUI() // QBoxLayout *topLayout = (QBoxLayout*)layout(); - + // QWidget *mainBox = new QWidget( this ); @@ -1211,6 +1243,6 @@ void KABCore::initGUI() - + mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); - + topLayout->addWidget(mMiniSplitter ); @@ -1233,3 +1265,3 @@ void KABCore::initGUI() } - + topLayout->addWidget(mMiniSplitter ); @@ -1237,4 +1269,4 @@ void KABCore::initGUI() mDetails = new ViewContainer( mMiniSplitter ); - - + + mExtensionManager = new ExtensionManager( this, mMiniSplitter ); @@ -1243,4 +1275,4 @@ void KABCore::initGUI() // topLayout->addWidget(mExtensionManager ); - - + + /*US @@ -1259,3 +1291,3 @@ void KABCore::initGUI() mDetails = new ViewContainer( mDetailsSplitter ); - + topLayout->addWidget( mDetailsSplitter ); @@ -1282,3 +1314,3 @@ void KABCore::initGUI() - + #endif //KAB_EMBEDDED @@ -1300,3 +1332,3 @@ void KABCore::initGUI() - + mJumpButtonBar = new JumpButtonBar( this, this ); @@ -1305,3 +1337,3 @@ void KABCore::initGUI() //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); - + // mMainWindow->getIconToolBar()->raise(); @@ -1309,3 +1341,3 @@ void KABCore::initGUI() #endif //KAB_EMBEDDED - + } @@ -1314,3 +1346,3 @@ void KABCore::initActions() //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); - + #ifndef KAB_EMBEDDED @@ -1319,3 +1351,3 @@ void KABCore::initActions() #endif //KAB_EMBEDDED - + // file menu @@ -1332,9 +1364,9 @@ void KABCore::initActions() } - + mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, SLOT( save() ), actionCollection(), "file_sync" ); - + mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, SLOT( newContact() ), actionCollection(), "file_new_contact" ); - + mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, @@ -1353,3 +1385,3 @@ void KABCore::initActions() #endif //KAB_EMBEDDED - + // edit menu @@ -1389,3 +1421,3 @@ void KABCore::initActions() mActionRedo->setEnabled( false ); - + // settings menu @@ -1398,3 +1430,3 @@ void KABCore::initActions() #endif //KAB_EMBEDDED - + if ( mIsPart ) { @@ -1403,3 +1435,3 @@ void KABCore::initActions() "kaddressbook_configure" ); - + mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, @@ -1411,9 +1443,9 @@ void KABCore::initActions() #endif //KAB_EMBEDDED - + } else { mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); - + mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); } - + mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, @@ -1421,3 +1453,3 @@ void KABCore::initActions() connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); - + mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, @@ -1425,6 +1457,6 @@ void KABCore::initActions() connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); - + // misc // only enable LDAP lookup if we can handle the protocol -#ifndef KAB_EMBEDDED +#ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { @@ -1434,6 +1466,6 @@ void KABCore::initActions() } -#else //KAB_EMBEDDED +#else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); -#endif //KAB_EMBEDDED - +#endif //KAB_EMBEDDED + @@ -1459,3 +1491,3 @@ void KABCore::initActions() #endif //KAB_EMBEDDED - + clipboardDataChanged(); @@ -1480,3 +1512,3 @@ void KABCore::addActionsManually() QMenuBar* mb = mMainWindow->menuBar(); - + //US setup menubar. @@ -1491,4 +1523,4 @@ void KABCore::addActionsManually() // tb->insertWidget(-1, 0, mIncSearchWidget); - -#else + +#else //US setup toolbar @@ -1499,3 +1531,3 @@ void KABCore::addActionsManually() mIncSearchWidget = new IncSearchWidget( tb ); - + tb->enableMoving(false); @@ -1520,6 +1552,6 @@ void KABCore::addActionsManually() fileMenu->insertSeparator(); - + mActionNewContact->plug( fileMenu ); mActionNewContact->plug( tb ); - + mActionEditAddressee->plug( fileMenu ); @@ -1535,3 +1567,3 @@ void KABCore::addActionsManually() mActionImportOL->plug( ImportMenu ); -#endif +#endif // edit menu @@ -1546,3 +1578,3 @@ void KABCore::addActionsManually() mActionSelectAll->plug( editMenu ); - + mActionRemoveVoice->plug( changeMenu ); @@ -1555,3 +1587,3 @@ void KABCore::addActionsManually() mActionConfigKAddressbook->plug( settingsMenu ); - + if ( mIsPart ) { @@ -1559,3 +1591,3 @@ void KABCore::addActionsManually() mActionConfigureToolbars->plug( settingsMenu ); - + } else { @@ -1563,5 +1595,5 @@ void KABCore::addActionsManually() } - + settingsMenu->insertSeparator(); - + mActionJumpBar->plug( settingsMenu ); @@ -1572,6 +1604,6 @@ void KABCore::addActionsManually() mActionCategories->plug( settingsMenu ); - + mActionAboutKAddressbook->plug( helpMenu ); - + if (QApplication::desktop()->width() > 320 ) { @@ -1580,3 +1612,3 @@ void KABCore::addActionsManually() mActionSave->plug( tb ); - mViewManager->getFilterAction()->plug ( tb); + mViewManager->getFilterAction()->plug ( tb); if (QApplication::desktop()->width() > 480 ) { @@ -1589,3 +1621,3 @@ void KABCore::addActionsManually() // tb->insertWidget(-1, 0, mIncSearchWidget, 6); - + //US link the searchwidget first to this. @@ -1594,3 +1626,3 @@ void KABCore::addActionsManually() //US tb->insertItem( mIncSearchWidget ); -/*US +/*US mIncSearchWidget = new IncSearchWidget( tb ); @@ -1598,5 +1630,5 @@ void KABCore::addActionsManually() SLOT( incrementalSearch( const QString& ) ) ); - + mJumpButtonBar = new JumpButtonBar( this, this ); - + //US topLayout->addWidget( mJumpButtonBar ); @@ -1604,3 +1636,3 @@ void KABCore::addActionsManually() */ - + #endif //KAB_EMBEDDED @@ -1625,3 +1657,3 @@ void KABCore::removeVoice() } - + } @@ -1636,3 +1668,3 @@ void KABCore::clipboardDataChanged() { - + if ( mReadWrite ) @@ -1675,3 +1707,3 @@ void KABCore::configureResources() KRES::KCMKResources dlg( this, "" , 0 ); - + if ( !dlg.exec() ) |