summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp460
-rw-r--r--kaddressbook/kabcore.h24
-rw-r--r--kaddressbook/kabprefs.h18
3 files changed, 496 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 32dd43a..49c3b19 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,225 +1,232 @@
/*
This file is part of KAddressbook.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include "kabcore.h"
#include <stdaddressbook.h>
#include <klocale.h>
+#include <kfiledialog.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 "addresseedialog.h"
//US
#include <addresseeview.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 <qlabel.h>
#ifndef DESKTOP_VERSION
#include <qpe/ir.h>
#include <qpe/qpemenubar.h>
#include <qtopia/qcopenvelope_qws.h>
#else
#include <qmenubar.h>
#endif
#endif // KAB_EMBEDDED
#include "kcmconfigs/kcmkabconfig.h"
#include "kcmconfigs/kcmkdepimconfig.h"
#include "kpimglobalprefs.h"
#include "externalapphandler.h"
#include <kresources/selectdialog.h>
#include <kmessagebox.h>
#include <picture.h>
#include <resource.h>
//US#include <qsplitter.h>
#include <qmap.h>
#include <qdir.h>
#include <qfile.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qclipboard.h>
#include <qtextstream.h>
#include <libkdepim/categoryselectdialog.h>
#include <kabc/vcardconverter.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"
+#else
+#include <unistd.h>
#endif
+// sync includes
+#include <libkdepim/ksyncprofile.h>
+
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
{
+ mBlockSaveFlag = false;
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/qtopia addressbook
// values can be "female" or "male" or "". An empty field represents undefined.
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( executeContact( 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( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
connect( mXXPortManager, SIGNAL( modified() ),
SLOT( setModified() ) );
connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
mJumpButtonBar, SLOT( recreateButtons() ) );
@@ -1000,148 +1007,152 @@ void KABCore::importFromOL()
}
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 );
}
}
/**
Shows or edits the detail view for the given uid. If the uid is QString::null,
the method will try to find a selected addressee in the view.
*/
void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
{
if ( mMultipleViewsAtOnce )
{
editContact( uid );
}
else
{
setDetailsVisible( true );
mActionDetails->setChecked(true);
}
}
void KABCore::save()
{
+ if (mBlockSaveFlag)
+ return;
+ mBlockSaveFlag = true;
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 );
+ mBlockSaveFlag = 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 (mMultipleViewsAtOnce)
{
if ( visible )
mJumpButtonBar->show();
else
mJumpButtonBar->hide();
}
else
{
// show the jumpbar only if "the details are hidden" == "viewmanager are shown"
if (mViewManager->isVisible())
{
if ( visible )
mJumpButtonBar->show();
else
mJumpButtonBar->hide();
}
else
{
mJumpButtonBar->hide();
}
}
}
void KABCore::setDetailsToState()
{
setDetailsVisible( mActionDetails->isChecked() );
}
void KABCore::setDetailsVisible( bool visible )
{
if (visible && mDetails->isHidden())
{
KABC::Addressee::List addrList = mViewManager->selectedAddressees();
if ( addrList.count() > 0 )
mDetails->setAddressee( addrList[ 0 ] );
@@ -1375,129 +1386,129 @@ void KABCore::addressBookChanged()
AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
const char *name )
{
if ( mEditorDialog == 0 ) {
mEditorDialog = new AddresseeEditorDialog( this, parent,
name ? name : "editorDialog" );
connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
SLOT( contactModified( const KABC::Addressee& ) ) );
//connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
// SLOT( slotEditorDestroyed( const QString& ) ) ;
}
return mEditorDialog;
}
void KABCore::slotEditorDestroyed( const QString &uid )
{
//mEditorDict.remove( uid );
}
void KABCore::initGUI()
{
#ifndef KAB_EMBEDDED
QHBoxLayout *topLayout = new QHBoxLayout( this );
topLayout->setSpacing( KDialogBase::spacingHint() );
mExtensionBarSplitter = new QSplitter( this );
mExtensionBarSplitter->setOrientation( Qt::Vertical );
mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
QVBox *viewSpace = new QVBox( mDetailsSplitter );
mIncSearchWidget = new IncSearchWidget( viewSpace );
connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
mViewManager = new ViewManager( this, viewSpace );
viewSpace->setStretchFactor( mViewManager, 1 );
mDetails = new ViewContainer( mDetailsSplitter );
mJumpButtonBar = new JumpButtonBar( this, this );
mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
topLayout->addWidget( mExtensionBarSplitter );
topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
topLayout->addWidget( mJumpButtonBar );
topLayout->setStretchFactor( mJumpButtonBar, 1 );
mXXPortManager = new XXPortManager( this, this );
#else //KAB_EMBEDDED
//US initialize viewMenu before settingup viewmanager.
// Viewmanager needs this menu to plugin submenues.
viewMenu = new QPopupMenu( this );
settingsMenu = new QPopupMenu( this );
//filterMenu = new QPopupMenu( this );
ImportMenu = new QPopupMenu( this );
ExportMenu = new QPopupMenu( this );
-
+ syncMenu = new QPopupMenu( this );
changeMenu= new QPopupMenu( this );
//US since we have no splitter for the embedded system, setup
// a layout with two frames. One left and one right.
QBoxLayout *topLayout;
// = new QHBoxLayout( this );
// QBoxLayout *topLayout = (QBoxLayout*)layout();
// QWidget *mainBox = new QWidget( this );
// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
#ifdef DESKTOP_VERSION
topLayout = new QHBoxLayout( this );
mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
topLayout->addWidget(mMiniSplitter );
mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
mViewManager = new ViewManager( this, mExtensionBarSplitter );
mDetails = new ViewContainer( mMiniSplitter );
mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
#else
if ( QApplication::desktop()->width() > 480 ) {
topLayout = new QHBoxLayout( this );
mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
} else {
topLayout = new QHBoxLayout( this );
mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
}
topLayout->addWidget(mMiniSplitter );
mViewManager = new ViewManager( this, mMiniSplitter );
mDetails = new ViewContainer( mMiniSplitter );
mExtensionManager = new ExtensionManager( this, mMiniSplitter );
#endif
//eh->hide();
// topLayout->addWidget(mExtensionManager );
/*US
#ifndef KAB_NOSPLITTER
QHBoxLayout *topLayout = new QHBoxLayout( this );
//US topLayout->setSpacing( KDialogBase::spacingHint() );
topLayout->setSpacing( 10 );
mDetailsSplitter = new QSplitter( this );
QVBox *viewSpace = new QVBox( mDetailsSplitter );
mViewManager = new ViewManager( this, viewSpace );
viewSpace->setStretchFactor( mViewManager, 1 );
mDetails = new ViewContainer( mDetailsSplitter );
@@ -1693,257 +1704,263 @@ void KABCore::initActions()
"ldap_lookup" );
}
#else //KAB_EMBEDDED
//qDebug("KABCore::initActions() LDAP has to be implemented");
#endif //KAB_EMBEDDED
mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
SLOT( setWhoAmI() ), actionCollection(),
"set_personal" );
mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
SLOT( setCategories() ), actionCollection(),
"edit_set_categories" );
mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
SLOT( removeVoice() ), actionCollection(),
"remove_voice" );
mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
SLOT( importFromOL() ), actionCollection(),
"import_OL" );
#ifdef KAB_EMBEDDED
mActionLicence = new KAction( i18n( "Licence" ), 0,
this, SLOT( showLicence() ), actionCollection(),
"licence_about_data" );
mActionFaq = new KAction( i18n( "Faq" ), 0,
this, SLOT( faq() ), actionCollection(),
"faq_about_data" );
mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
this, SLOT( createAboutData() ), actionCollection(),
"kaddressbook_about_data" );
#endif //KAB_EMBEDDED
clipboardDataChanged();
connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
}
//US we need this function, to plug all actions into the correct menues.
// KDE uses a XML format to plug the actions, but we work her without this overhead.
void KABCore::addActionsManually()
{
//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
#ifdef KAB_EMBEDDED
QPopupMenu *fileMenu = new QPopupMenu( this );
QPopupMenu *editMenu = new QPopupMenu( this );
QPopupMenu *helpMenu = new QPopupMenu( this );
KToolBar* tb = mMainWindow->toolBar();
#ifdef DESKTOP_VERSION
QMenuBar* mb = mMainWindow->menuBar();
//US setup menubar.
//Disable the following block if you do not want to have a menubar.
mb->insertItem( "&File", fileMenu );
mb->insertItem( "&Edit", editMenu );
mb->insertItem( "&View", viewMenu );
mb->insertItem( "&Settings", settingsMenu );
+ mb->insertItem( i18n("Synchronize"), syncMenu );
mb->insertItem( "&Change selected", changeMenu );
mb->insertItem( "&Help", helpMenu );
mIncSearchWidget = new IncSearchWidget( tb );
// tb->insertWidget(-1, 0, mIncSearchWidget);
#else
//US setup toolbar
QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
QPopupMenu *popupBarTB = new QPopupMenu( this );
menuBarTB->insertItem( "ME", popupBarTB);
tb->insertWidget(-1, 0, menuBarTB);
mIncSearchWidget = new IncSearchWidget( tb );
tb->enableMoving(false);
popupBarTB->insertItem( "&File", fileMenu );
popupBarTB->insertItem( "&Edit", editMenu );
popupBarTB->insertItem( "&View", viewMenu );
popupBarTB->insertItem( "&Settings", settingsMenu );
+ popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
mViewManager->getFilterAction()->plug ( popupBarTB);
popupBarTB->insertItem( "&Change selected", changeMenu );
popupBarTB->insertItem( "&Help", helpMenu );
if (QApplication::desktop()->width() > 320 ) {
// mViewManager->getFilterAction()->plug ( tb);
}
#endif
// mActionQuit->plug ( mMainWindow->toolBar());
//US Now connect the actions with the menue entries.
mActionPrint->plug( fileMenu );
mActionMail->plug( fileMenu );
fileMenu->insertSeparator();
mActionNewContact->plug( fileMenu );
mActionNewContact->plug( tb );
mActionEditAddressee->plug( fileMenu );
if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
(!KABPrefs::instance()->mMultipleViewsAtOnce ))
mActionEditAddressee->plug( tb );
fileMenu->insertSeparator();
mActionSave->plug( fileMenu );
fileMenu->insertItem( "&Import", ImportMenu );
fileMenu->insertItem( "&Export", ExportMenu );
fileMenu->insertSeparator();
mActionMailVCard->plug( fileMenu );
#ifndef DESKTOP_VERSION
if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
if ( Ir::supported() ) mActionBeam->plug(fileMenu );
#endif
fileMenu->insertSeparator();
mActionQuit->plug( fileMenu );
#ifdef _WIN32_
mActionImportOL->plug( ImportMenu );
#endif
// edit menu
mActionUndo->plug( editMenu );
mActionRedo->plug( editMenu );
editMenu->insertSeparator();
mActionCut->plug( editMenu );
mActionCopy->plug( editMenu );
mActionPaste->plug( editMenu );
mActionDelete->plug( editMenu );
editMenu->insertSeparator();
mActionSelectAll->plug( editMenu );
mActionRemoveVoice->plug( changeMenu );
// settings menu
//US special menuentry to configure the addressbook resources. On KDE
// you do that through the control center !!!
mActionConfigResources->plug( settingsMenu );
settingsMenu->insertSeparator();
mActionConfigKAddressbook->plug( settingsMenu );
if ( mIsPart ) {
mActionConfigShortcuts->plug( settingsMenu );
mActionConfigureToolbars->plug( settingsMenu );
} else {
mActionKeyBindings->plug( settingsMenu );
}
settingsMenu->insertSeparator();
mActionJumpBar->plug( settingsMenu );
mActionDetails->plug( settingsMenu );
if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
mActionDetails->plug( tb );
settingsMenu->insertSeparator();
mActionWhoAmI->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
mActionLicence->plug( helpMenu );
mActionFaq->plug( helpMenu );
mActionAboutKAddressbook->plug( helpMenu );
if (KGlobal::getDesktopSize() > KGlobal::Small ) {
mActionSave->plug( tb );
mViewManager->getFilterAction()->plug ( tb);
if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
mActionUndo->plug( tb );
mActionDelete->plug( tb );
mActionRedo->plug( tb );
}
}
//mActionQuit->plug ( tb );
// tb->insertWidget(-1, 0, mIncSearchWidget, 6);
//US link the searchwidget first to this.
// The real linkage to the toolbar happens later.
//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
//US tb->insertItem( mIncSearchWidget );
/*US
mIncSearchWidget = new IncSearchWidget( tb );
connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
mJumpButtonBar = new JumpButtonBar( this, this );
//US topLayout->addWidget( mJumpButtonBar );
this->layout()->add( mJumpButtonBar );
*/
#endif //KAB_EMBEDDED
+
+ connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
+ fillSyncMenu();
+
}
void KABCore::showLicence()
{
KApplication::showLicence();
}
void KABCore::removeVoice()
{
if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
return;
KABC::Addressee::List list = mViewManager->selectedAddressees();
KABC::Addressee::List::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
PhoneNumber::List::Iterator phoneIt;
bool found = false;
for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
if ((*phoneIt).type() - PhoneNumber::Voice ) {
(*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
(*it).insertPhoneNumber( (*phoneIt) );
found = true;
}
}
}
if ( found )
contactModified((*it) );
}
}
void KABCore::clipboardDataChanged()
{
if ( mReadWrite )
mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
}
void KABCore::updateActionMenu()
{
UndoStack *undo = UndoStack::instance();
RedoStack *redo = RedoStack::instance();
if ( undo->isEmpty() )
mActionUndo->setText( i18n( "Undo" ) );
else
mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
mActionUndo->setEnabled( !undo->isEmpty() );
if ( !redo->top() )
mActionRedo->setText( i18n( "Redo" ) );
else
mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
mActionRedo->setEnabled( !redo->isEmpty() );
}
void KABCore::configureKeyBindings()
{
#ifndef KAB_EMBEDDED
KKeyDialog::configure( actionCollection(), true );
@@ -2023,69 +2040,504 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
if (!name.isEmpty())
namelist = mAddressBook->findByName( name );
if (!email.isEmpty())
emaillist = mAddressBook->findByEmail( email );
qDebug("count %d %d ", namelist.count(),emaillist.count() );
//check if we have a match in Namelist and Emaillist
if ((namelist.count() == 0) && (emaillist.count() > 0)) {
foundUid = emaillist[0].uid();
}
else if ((namelist.count() > 0) && (emaillist.count() == 0))
foundUid = namelist[0].uid();
else
{
for (int i = 0; i < namelist.count(); i++)
{
for (int j = 0; j < emaillist.count(); j++)
{
if (namelist[i] == emaillist[j])
{
foundUid = namelist[i].uid();
}
}
}
}
}
else
{
foundUid = uid;
}
if (!foundUid.isEmpty())
{
// raise Ka/Pi if it is in the background
#ifndef DESKTOP_VERSION
#ifndef KORG_NODCOP
//QCopEnvelope e("QPE/Application/kapi", "raise()");
#endif
#endif
mMainWindow->showMaximized();
mMainWindow-> raise();
mViewManager->setSelected( "", false);
mViewManager->refreshView( "" );
mViewManager->setSelected( foundUid, true );
mViewManager->refreshView( foundUid );
if ( !mMultipleViewsAtOnce )
{
setDetailsVisible( true );
mActionDetails->setChecked(true);
}
}
}
void KABCore::faq()
{
KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
}
+void KABCore::fillSyncMenu()
+{
+ if ( syncMenu->count() )
+ syncMenu->clear();
+ syncMenu->insertItem( i18n("Configure..."), 0 );
+ syncMenu->insertSeparator();
+ syncMenu->insertItem( i18n("Multiple sync"), 1 );
+ syncMenu->insertSeparator();
+ KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
+ config.setGroup("General");
+ QStringList prof = config.readListEntry("SyncProfileNames");
+ KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
+ if ( prof.count() < 3 ) {
+ prof.clear();
+ prof << i18n("Sharp_DTM");
+ prof << i18n("Local_file");
+ prof << i18n("Last_file");
+ KSyncProfile* temp = new KSyncProfile ();
+ temp->setName( prof[0] );
+ temp->writeConfig(&config);
+ temp->setName( prof[1] );
+ temp->writeConfig(&config);
+ temp->setName( prof[2] );
+ temp->writeConfig(&config);
+ config.setGroup("General");
+ config.writeEntry("SyncProfileNames",prof);
+ config.writeEntry("ExternSyncProfiles","Sharp_DTM");
+ config.sync();
+ delete temp;
+ }
+ KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
+ KABPrefs::instance()->mSyncProfileNames = prof;
+ int i;
+ for ( i = 0; i < prof.count(); ++i ) {
+
+ syncMenu->insertItem( prof[i], 1000+i );
+ if ( i == 2 )
+ syncMenu->insertSeparator();
+ }
+ QDir app_dir;
+ if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
+ syncMenu->setItemEnabled( false , 1000 );
+ }
+ //probaly useless
+ //mView->setupExternSyncProfiles();
+}
+void KABCore::slotSyncMenu( int action )
+{
+ //qDebug("syncaction %d ", action);
+ if ( action == 0 ) {
+
+ // seems to be a Qt2 event handling bug
+ // syncmenu.clear causes a segfault at first time
+ // when we call it after the main event loop, it is ok
+ // same behaviour when calling OM/Pi via QCOP for the first time
+ QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
+ //confSync();
+ return;
+ }
+ if ( action == 1 ) {
+ multiSync( true );
+ return;
+ }
-#ifndef KAB_EMBEDDED
-#include "kabcore.moc"
-#endif //KAB_EMBEDDED
+ if (mBlockSaveFlag)
+ return;
+ mBlockSaveFlag = true;
+ mCurrentSyncProfile = action - 1000 ;
+ mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
+ mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
+ KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
+ KSyncProfile* temp = new KSyncProfile ();
+ temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
+ temp->readConfig(&config);
+ KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
+ KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
+ KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
+ KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ KABPrefs::instance()->mWriteBackInFuture = 0;
+ if ( temp->getWriteBackFuture() )
+ KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
+ KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
+ if ( action == 1000 ) {
+ syncSharp();
+
+ } else if ( action == 1001 ) {
+ syncLocalFile();
+
+ } else if ( action == 1002 ) {
+ quickSyncLocalFile();
+
+ } else if ( action >= 1003 ) {
+ if ( temp->getIsLocalFileSync() ) {
+ if ( syncWithFile( temp->getRemoteFileName( ), false ) )
+ KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
+ } else {
+ if ( temp->getIsPhoneSync() ) {
+ KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
+ KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
+ KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
+ syncPhone();
+ } else
+ syncRemote( temp );
+
+ }
+ }
+ delete temp;
+ mBlockSaveFlag = false;
+}
+
+void KABCore::syncLocalFile()
+{
+
+ QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
+
+ fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
+ if ( fn == "" )
+ return;
+ if ( syncWithFile( fn, false ) ) {
+ qDebug("syncLocalFile() successful ");
+ }
+
+}
+bool KABCore::syncWithFile( QString fn , bool quick )
+{
+ bool ret = false;
+ QFileInfo info;
+ info.setFile( fn );
+ QString mess;
+ bool loadbup = true;
+ if ( !info. exists() ) {
+ mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
+ int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
+ mess );
+ return ret;
+ }
+ int result = 0;
+ if ( !quick ) {
+ mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
+ result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
+ mess,
+ i18n("Sync"), i18n("Cancel"), 0,
+ 0, 1 );
+ if ( result )
+ return false;
+ }
+ if ( KABPrefs::instance()->mAskForPreferences )
+ edit_sync_options();
+ if ( result == 0 ) {
+ //qDebug("Now sycing ... ");
+ if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
+ setCaption( i18n("Synchronization successful") );
+ else
+ setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
+ if ( ! quick )
+ KABPrefs::instance()->mLastSyncedLocalFile = fn;
+ setModified();
+ }
+ return ret;
+}
+void KABCore::quickSyncLocalFile()
+{
+
+ if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
+ qDebug("quick syncLocalFile() successful ");
+
+ }
+}
+void KABCore::multiSync( bool askforPrefs )
+{
+ if (mBlockSaveFlag)
+ return;
+ mBlockSaveFlag = true;
+ QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
+ if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
+ question,
+ i18n("Yes"), i18n("No"),
+ 0, 0 ) != 0 ) {
+ mBlockSaveFlag = false;
+ setCaption(i18n("Aborted! Nothing synced!"));
+ return;
+ }
+ mCurrentSyncDevice = i18n("Multiple profiles") ;
+ KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
+ if ( askforPrefs ) {
+ edit_sync_options();
+ KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
+ }
+ setCaption(i18n("Multiple sync started.") );
+ qApp->processEvents();
+ int num = ringSync() ;
+ if ( num > 1 )
+ ringSync();
+ mBlockSaveFlag = false;
+ if ( num )
+ save();
+ if ( num )
+ setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
+ else
+ setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
+ return;
+}
+int KABCore::ringSync()
+{
+ int syncedProfiles = 0;
+ int i;
+ QTime timer;
+ KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
+ QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
+ KSyncProfile* temp = new KSyncProfile ();
+ KABPrefs::instance()->mAskForPreferences = false;
+ for ( i = 0; i < syncProfileNames.count(); ++i ) {
+ mCurrentSyncProfile = i;
+ temp->setName(syncProfileNames[mCurrentSyncProfile]);
+ temp->readConfig(&config);
+ if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
+ setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
+ ++syncedProfiles;
+ // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
+ KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
+ KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ KABPrefs::instance()->mWriteBackInFuture = 0;
+ if ( temp->getWriteBackFuture() )
+ KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
+ KABPrefs::instance()->mShowSyncSummary = false;
+ mCurrentSyncDevice = syncProfileNames[i] ;
+ mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
+ if ( i == 0 ) {
+ syncSharp();
+ } else {
+ if ( temp->getIsLocalFileSync() ) {
+ if ( syncWithFile( temp->getRemoteFileName( ), true ) )
+ KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
+ } else {
+ if ( temp->getIsPhoneSync() ) {
+ KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
+ KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
+ KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
+ syncPhone();
+ } else
+ syncRemote( temp, false );
+
+ }
+ }
+ timer.start();
+ setCaption(i18n("Multiple sync in progress ... please wait!") );
+ while ( timer.elapsed () < 2000 ) {
+ qApp->processEvents();
+#ifndef _WIN32_
+ sleep (1);
+#endif
+ }
+
+ }
+
+ }
+ delete temp;
+ return syncedProfiles;
+}
+
+void KABCore::syncRemote( KSyncProfile* prof, bool ask)
+{
+ QString question;
+ if ( ask ) {
+ question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
+ if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
+ question,
+ i18n("Yes"), i18n("No"),
+ 0, 0 ) != 0 )
+ return;
+ }
+ QString command = prof->getPreSyncCommand();
+ int fi;
+ if ( (fi = command.find("$PWD$")) > 0 ) {
+ QString pwd = getPassword();
+ command = command.left( fi )+ pwd + command.mid( fi+5 );
+
+ }
+ int maxlen = 30;
+ if ( QApplication::desktop()->width() > 320 )
+ maxlen += 25;
+ setCaption ( i18n( "Copy remote file to local machine..." ) );
+ int fileSize = 0;
+ int result = system ( command );
+ // 0 : okay
+ // 256: no such file or dir
+ //
+ qDebug("KO: Remote copy result(0 = okay): %d ",result );
+ if ( result != 0 ) {
+ int len = maxlen;
+ while ( len < command.length() ) {
+ command.insert( len , "\n" );
+ len += maxlen +2;
+ }
+ question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
+ QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
+ question,
+ i18n("Okay!")) ;
+ setCaption ("KO/Pi");
+ return;
+ }
+ setCaption ( i18n( "Copying succeed." ) );
+ //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
+ if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
+// Event* e = mView->getLastSyncEvent();
+// e->setReadOnly( false );
+// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
+// e->setReadOnly( true );
+ if ( KABPrefs::instance()->mWriteBackFile ) {
+ command = prof->getPostSyncCommand();
+ int fi;
+ if ( (fi = command.find("$PWD$")) > 0 ) {
+ QString pwd = getPassword();
+ command = command.left( fi )+ pwd + command.mid( fi+5 );
+
+ }
+ setCaption ( i18n( "Writing back file ..." ) );
+ result = system ( command );
+ qDebug("KO: Writing back file result: %d ", result);
+ if ( result != 0 ) {
+ setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
+ return;
+ } else {
+ setCaption ( i18n( "Syncronization sucessfully completed" ) );
+ }
+ }
+ }
+ return;
+}
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+void KABCore::edit_sync_options()
+{
+ //mDialogManager->showSyncOptions();
+ //KABPrefs::instance()->mSyncAlgoPrefs
+ QDialog dia( this, "dia", true );
+ dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
+ QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
+ QVBoxLayout lay ( &dia );
+ lay.setSpacing( 2 );
+ lay.setMargin( 3 );
+ lay.addWidget(&gr);
+ QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
+ QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
+ QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
+ QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
+ QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
+ QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
+ //QRadioButton both( i18n("Take both on conflict"), &gr );
+ QPushButton pb ( "OK", &dia);
+ lay.addWidget( &pb );
+ connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
+ switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
+ case 0:
+ loc.setChecked( true);
+ break;
+ case 1:
+ rem.setChecked( true );
+ break;
+ case 2:
+ newest.setChecked( true);
+ break;
+ case 3:
+ ask.setChecked( true);
+ break;
+ case 4:
+ f_loc.setChecked( true);
+ break;
+ case 5:
+ f_rem.setChecked( true);
+ break;
+ case 6:
+ // both.setChecked( true);
+ break;
+ default:
+ break;
+ }
+ if ( dia.exec() ) {
+ KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
+ }
+
+
+}
+QString KABCore::getPassword( )
+{
+ QString retfile = "";
+ QDialog dia ( this, "input-dialog", true );
+ QLineEdit lab ( &dia );
+ lab.setEchoMode( QLineEdit::Password );
+ QVBoxLayout lay( &dia );
+ lay.setMargin(7);
+ lay.setSpacing(7);
+ lay.addWidget( &lab);
+ dia.setFixedSize( 230,50 );
+ dia.setCaption( i18n("Enter password") );
+ QPushButton pb ( "OK", &dia);
+ lay.addWidget( &pb );
+ connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
+ dia.show();
+ int res = dia.exec();
+ if ( res )
+ retfile = lab.text();
+ dia.hide();
+ qApp->processEvents();
+ return retfile;
+
+}
+
+bool KABCore::syncAB(QString filename, int mode)
+{
+
+}
+
+
+void KABCore::confSync()
+{
+ //mView->confSync();
+ qDebug("pending KABCore::confSync() ");
+ fillSyncMenu();
+}
+void KABCore::syncSharp()
+{
+ if ( mModified )
+ save();
+ qDebug("pending syncSharp() ");
+ //mView->syncSharp();
+ mModified = true ;
+
+}
+void KABCore::syncPhone()
+{
+ if ( mModified )
+ save();
+ qDebug("pending syncPhone(); ");
+ //mView->syncPhone();
+ setModified();
+
+}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 39d043f..10ce8f4 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,123 +1,124 @@
/*
This file is part of KAddressbook.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
*/
#ifndef KABCORE_H
#define KABCORE_H
#include <kabc/field.h>
#ifndef KAB_EMBEDDED
#endif //KAB_EMBEDDED
#include <qdict.h>
#include <qwidget.h>
#include <qpopupmenu.h>
namespace KABC {
class AddressBook;
}
#ifndef KAB_EMBEDDED
class KAboutData;
class KConfig;
class KAddressBookService;
class LDAPSearchDialog;
#else //KAB_EMBEDDED
class KAddressBookMain;
//US class QAction;
#endif //KAB_EMBEDDED
class KCMultiDialog;
class KXMLGUIClient;
class ExtensionManager;
class XXPortManager;
class JumpButtonBar;
class IncSearchWidget;
class KDGanttMinimizeSplitter;
class KAction;
class KActionCollection;
class KToggleAction;
+class KSyncProfile;
class QAction;
class QMenuBar;
class QSplitter;
class ViewContainer;
class ViewManager;
class AddresseeEditorDialog;
class Ir;
class KABCore : public QWidget
{
Q_OBJECT
public:
KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
~KABCore();
#ifdef KAB_EMBEDDED
//US added functionality
QPopupMenu* getViewMenu() {return viewMenu;}
QPopupMenu* getFilterMenu() {return filterMenu;}
QPopupMenu* getSettingsMenu() {return settingsMenu;}
void addActionsManually();
#endif //KAB_EMBEDDED
/**
Restores the global settings.
*/
void restoreSettings();
/**
Saves the global settings.
*/
void saveSettings();
/**
Returns a pointer to the StdAddressBook of the application.
*/
KABC::AddressBook *addressBook() const;
/**
Returns a pointer to the KConfig object of the application.
*/
static KConfig *config();
/**
Returns a pointer to the global KActionCollection object. So
other classes can register their actions easily.
*/
KActionCollection *actionCollection() const;
/**
Returns the current search field of the Incremental Search Widget.
*/
KABC::Field *currentSearchField() const;
/**
Returns the uid list of the currently selected contacts.
*/
QStringList selectedUIDs() const;
/**
@@ -279,178 +280,199 @@ class KABCore : public QWidget
/**
END DCOP METHODS
*/
/**
Saves the contents of the AddressBook back to disk.
*/
void save();
/**
Undos the last command using the undo stack.
*/
void undo();
/**
Redos the last command that was undone, using the redo stack.
*/
void redo();
/**
Shows the edit dialog for the given uid. If the uid is QString::null,
the method will try to find a selected addressee in the view.
*/
void editContact( const QString &uid /*US = QString::null*/ );
//US added a second method without defaultparameter
void editContact2();
/**
Shows or edits the detail view for the given uid. If the uid is QString::null,
the method will try to find a selected addressee in the view.
*/
void executeContact( const QString &uid /*US = QString::null*/ );
/**
Launches the configuration dialog.
*/
void openConfigDialog();
/**
Launches the ldap search dialog.
*/
void openLDAPDialog();
/**
Creates a KAddressBookPrinter, which will display the print
dialog and do the printing.
*/
void print();
/**
Registers a new GUI client, so plugins can register its actions.
*/
void addGUIClient( KXMLGUIClient *client );
void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
signals:
void contactSelected( const QString &name );
void contactSelected( const QPixmap &pixmap );
public slots:
void setDetailsVisible( bool visible );
void setDetailsToState();
+ void slotSyncMenu( int );
private slots:
void setJumpButtonBarVisible( bool visible );
void importFromOL();
void extensionModified( const KABC::Addressee::List &list );
void extensionChanged( int id );
void clipboardDataChanged();
void updateActionMenu();
void configureKeyBindings();
void removeVoice();
#ifdef KAB_EMBEDDED
void configureResources();
#endif //KAB_EMBEDDED
void slotEditorDestroyed( const QString &uid );
void configurationChanged();
void addressBookChanged();
private:
void initGUI();
void initActions();
AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
const char *name = 0 );
KXMLGUIClient *mGUIClient;
KABC::AddressBook *mAddressBook;
ViewManager *mViewManager;
// QSplitter *mDetailsSplitter;
KDGanttMinimizeSplitter *mExtensionBarSplitter;
ViewContainer *mDetails;
KDGanttMinimizeSplitter* mMiniSplitter;
XXPortManager *mXXPortManager;
JumpButtonBar *mJumpButtonBar;
IncSearchWidget *mIncSearchWidget;
ExtensionManager *mExtensionManager;
KCMultiDialog *mConfigureDialog;
#ifndef KAB_EMBEDDED
LDAPSearchDialog *mLdapSearchDialog;
#endif //KAB_EMBEDDED
// QDict<AddresseeEditorDialog> mEditorDict;
AddresseeEditorDialog *mEditorDialog;
bool mReadWrite;
bool mModified;
bool mIsPart;
bool mMultipleViewsAtOnce;
//US file menu
KAction *mActionMail;
KAction *mActionBeam;
KAction* mActionPrint;
KAction* mActionNewContact;
KAction *mActionSave;
KAction *mActionEditAddressee;
KAction *mActionMailVCard;
KAction *mActionBeamVCard;
KAction *mActionQuit;
//US edit menu
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//US settings menu
KAction *mActionConfigResources;
KAction *mActionConfigKAddressbook;
KAction *mActionConfigShortcuts;
KAction *mActionConfigureToolbars;
KAction *mActionKeyBindings;
KToggleAction *mActionJumpBar;
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionLicence;
KAction *mActionFaq;
KAction *mActionDeleteView;
QPopupMenu *viewMenu;
QPopupMenu *filterMenu;
QPopupMenu *settingsMenu;
QPopupMenu *changeMenu;
-
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
KAction * mActionImportOL;
#ifndef KAB_EMBEDDED
KAddressBookService *mAddressBookService;
#endif //KAB_EMBEDDED
class KABCorePrivate;
KABCorePrivate *d;
+ bool mBlockSaveFlag;
#ifdef KAB_EMBEDDED
KAddressBookMain *mMainWindow; // should be the same like mGUIClient
#endif //KAB_EMBEDDED
+ // LR *******************************
+ // sync stuff!
+ QPopupMenu *syncMenu;
+ void fillSyncMenu();
+ void confSync();
+ QString mCurrentSyncDevice;
+ QString mCurrentSyncName;
+ void quickSyncLocalFile();
+ bool syncWithFile( QString fn , bool quick );
+ void KABCore::syncLocalFile();
+ void KABCore::syncPhone();
+ void KABCore::syncSharp();
+ void multiSync( bool askforPrefs );
+ int mCurrentSyncProfile ;
+ void syncRemote( KSyncProfile* prof, bool ask = true);
+ void edit_sync_options();
+ bool syncAB(QString filename, int mode);
+ int ringSync();
+ QString getPassword( );
+ // *********************
};
#endif
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index e4f359c..9926aa0 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -21,72 +21,88 @@
without including the source code for Qt in the source distribution.
*/
#ifndef KABPREFS_H
#define KABPREFS_H
#include <qstringlist.h>
#include <libkdepim/kpimprefs.h>
class KConfig;
class KABPrefs : public KPimPrefs
{
public:
virtual ~KABPrefs();
static KABPrefs *instance();
// General
bool mHonorSingleClick;
bool mAutomaticNameParsing;
int mCurrentIncSearchField;
#ifdef KAB_EMBEDDED
// US introduce a nonconst way to return the config object.
KConfig* getConfig();
bool mToolBarHor;
bool mToolBarUp;
bool mAskForQuit;
/** Set preferences to default values */
// void usrSetDefaults();
/** Read preferences from config file */
// void usrReadConfig();
/** Write preferences to config file */
// void usrWriteConfig();
#endif //KAB_EMBEDDED
// GUI
bool mJumpButtonBarVisible;
bool mDetailsPageVisible;
bool mMultipleViewsAtOnce;
bool mSearchWithReturn;
QValueList<int> mExtensionsSplitter;
QValueList<int> mDetailsSplitter;
// Extensions stuff
int mCurrentExtension;
QStringList mActiveExtensions;
// Views stuff
QString mCurrentView;
QStringList mViewNames;
// Filter
int mCurrentFilter;
void setCategoryDefaults();
-
+ // sync stuff
+ QString mLocalMachineName;
+ QStringList mExternSyncProfiles;
+ QStringList mSyncProfileNames;
+ bool mAskForPreferences;
+ bool mShowSyncSummary;
+ bool mShowSyncEvents;
+ bool mShowTodoInAgenda;
+ bool mWriteBackExistingOnly;
+ int mSyncAlgoPrefs;
+ int mRingSyncAlgoPrefs;
+ bool mWriteBackFile;
+ int mWriteBackInFuture;
+ QString mPhoneDevice;
+ QString mPhoneConnection;
+ QString mPhoneModel;
+ QString mLastSyncedLocalFile; // save!
private:
KABPrefs();
static KABPrefs *sInstance;
};
#endif