summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-17 19:45:31 (UTC)
committer zautrix <zautrix>2004-09-17 19:45:31 (UTC)
commitdf03bd8c7ff6a738dd386001679542ae4b493a07 (patch) (unidiff)
treef785901b1edbd1fd3075660ab2b556e3692b79b2
parent603ad0a623dc72b8ccb9535f9907e0f2aa536328 (diff)
downloadkdepimpi-df03bd8c7ff6a738dd386001679542ae4b493a07.zip
kdepimpi-df03bd8c7ff6a738dd386001679542ae4b493a07.tar.gz
kdepimpi-df03bd8c7ff6a738dd386001679542ae4b493a07.tar.bz2
first sync stuff in kaddressbook
Diffstat (more/less context) (ignore 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,82 +1,83 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h>
35 36
36#ifndef KAB_EMBEDDED 37#ifndef KAB_EMBEDDED
37#include <qclipboard.h> 38#include <qclipboard.h>
38#include <qdir.h> 39#include <qdir.h>
39#include <qfile.h> 40#include <qfile.h>
40#include <qapplicaton.h> 41#include <qapplicaton.h>
41#include <qlayout.h> 42#include <qlayout.h>
42#include <qregexp.h> 43#include <qregexp.h>
43#include <qvbox.h> 44#include <qvbox.h>
44#include <kabc/addresseelist.h> 45#include <kabc/addresseelist.h>
45#include <kabc/errorhandler.h> 46#include <kabc/errorhandler.h>
46#include <kabc/resource.h> 47#include <kabc/resource.h>
47#include <kabc/vcardconverter.h> 48#include <kabc/vcardconverter.h>
48#include <kapplication.h> 49#include <kapplication.h>
49#include <kactionclasses.h> 50#include <kactionclasses.h>
50#include <kcmultidialog.h> 51#include <kcmultidialog.h>
51#include <kdebug.h> 52#include <kdebug.h>
52#include <kdeversion.h> 53#include <kdeversion.h>
53#include <kkeydialog.h> 54#include <kkeydialog.h>
54#include <kmessagebox.h> 55#include <kmessagebox.h>
55#include <kprinter.h> 56#include <kprinter.h>
56#include <kprotocolinfo.h> 57#include <kprotocolinfo.h>
57#include <kresources/selectdialog.h> 58#include <kresources/selectdialog.h>
58#include <kstandarddirs.h> 59#include <kstandarddirs.h>
59#include <ktempfile.h> 60#include <ktempfile.h>
60#include <kxmlguiclient.h> 61#include <kxmlguiclient.h>
61#include <kaboutdata.h> 62#include <kaboutdata.h>
62#include <libkdepim/categoryselectdialog.h> 63#include <libkdepim/categoryselectdialog.h>
63 64
64#include "addresseeutil.h" 65#include "addresseeutil.h"
65#include "addresseeeditordialog.h" 66#include "addresseeeditordialog.h"
66#include "extensionmanager.h" 67#include "extensionmanager.h"
67#include "kstdaction.h" 68#include "kstdaction.h"
68#include "kaddressbookservice.h" 69#include "kaddressbookservice.h"
69#include "ldapsearchdialog.h" 70#include "ldapsearchdialog.h"
70#include "printing/printingwizard.h" 71#include "printing/printingwizard.h"
71#else // KAB_EMBEDDED 72#else // KAB_EMBEDDED
72 73
73#include <kapplication.h> 74#include <kapplication.h>
74#include "KDGanttMinimizeSplitter.h" 75#include "KDGanttMinimizeSplitter.h"
75#include "kaddressbookmain.h" 76#include "kaddressbookmain.h"
76#include "kactioncollection.h" 77#include "kactioncollection.h"
77#include "addresseedialog.h" 78#include "addresseedialog.h"
78//US 79//US
79#include <addresseeview.h> 80#include <addresseeview.h>
80 81
81#include <qapp.h> 82#include <qapp.h>
82#include <qmenubar.h> 83#include <qmenubar.h>
@@ -97,113 +98,119 @@ $Id$
97#include <qtopia/qcopenvelope_qws.h> 98#include <qtopia/qcopenvelope_qws.h>
98#else 99#else
99 100
100#include <qmenubar.h> 101#include <qmenubar.h>
101#endif 102#endif
102 103
103#endif // KAB_EMBEDDED 104#endif // KAB_EMBEDDED
104#include "kcmconfigs/kcmkabconfig.h" 105#include "kcmconfigs/kcmkabconfig.h"
105#include "kcmconfigs/kcmkdepimconfig.h" 106#include "kcmconfigs/kcmkdepimconfig.h"
106#include "kpimglobalprefs.h" 107#include "kpimglobalprefs.h"
107#include "externalapphandler.h" 108#include "externalapphandler.h"
108 109
109 110
110#include <kresources/selectdialog.h> 111#include <kresources/selectdialog.h>
111#include <kmessagebox.h> 112#include <kmessagebox.h>
112 113
113#include <picture.h> 114#include <picture.h>
114#include <resource.h> 115#include <resource.h>
115 116
116//US#include <qsplitter.h> 117//US#include <qsplitter.h>
117#include <qmap.h> 118#include <qmap.h>
118#include <qdir.h> 119#include <qdir.h>
119#include <qfile.h> 120#include <qfile.h>
120#include <qvbox.h> 121#include <qvbox.h>
121#include <qlayout.h> 122#include <qlayout.h>
122#include <qclipboard.h> 123#include <qclipboard.h>
123#include <qtextstream.h> 124#include <qtextstream.h>
124 125
125#include <libkdepim/categoryselectdialog.h> 126#include <libkdepim/categoryselectdialog.h>
126#include <kabc/vcardconverter.h> 127#include <kabc/vcardconverter.h>
127 128
128 129
129#include "addresseeutil.h" 130#include "addresseeutil.h"
130#include "undocmds.h" 131#include "undocmds.h"
131#include "addresseeeditordialog.h" 132#include "addresseeeditordialog.h"
132#include "viewmanager.h" 133#include "viewmanager.h"
133#include "details/detailsviewcontainer.h" 134#include "details/detailsviewcontainer.h"
134#include "kabprefs.h" 135#include "kabprefs.h"
135#include "xxportmanager.h" 136#include "xxportmanager.h"
136#include "incsearchwidget.h" 137#include "incsearchwidget.h"
137#include "jumpbuttonbar.h" 138#include "jumpbuttonbar.h"
138#include "extensionmanager.h" 139#include "extensionmanager.h"
139#include "addresseeconfig.h" 140#include "addresseeconfig.h"
140#include <kcmultidialog.h> 141#include <kcmultidialog.h>
141 142
142#ifdef _WIN32_ 143#ifdef _WIN32_
143 144
144#include "kaimportoldialog.h" 145#include "kaimportoldialog.h"
146#else
147#include <unistd.h>
145#endif 148#endif
149// sync includes
150#include <libkdepim/ksyncprofile.h>
151
146 152
147bool pasteWithNewUid = true; 153bool pasteWithNewUid = true;
148 154
149#ifdef KAB_EMBEDDED 155#ifdef KAB_EMBEDDED
150KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 156KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
151 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 157 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
152 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 158 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
153 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 159 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
154#else //KAB_EMBEDDED 160#else //KAB_EMBEDDED
155KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 161KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
156 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 162 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
157 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 163 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
158 mReadWrite( readWrite ), mModified( false ) 164 mReadWrite( readWrite ), mModified( false )
159#endif //KAB_EMBEDDED 165#endif //KAB_EMBEDDED
160{ 166{
161 167
168 mBlockSaveFlag = false;
162 mExtensionBarSplitter = 0; 169 mExtensionBarSplitter = 0;
163 mIsPart = !parent->inherits( "KAddressBookMain" ); 170 mIsPart = !parent->inherits( "KAddressBookMain" );
164 171
165 mAddressBook = KABC::StdAddressBook::self(); 172 mAddressBook = KABC::StdAddressBook::self();
166 KABC::StdAddressBook::setAutomaticSave( false ); 173 KABC::StdAddressBook::setAutomaticSave( false );
167 174
168#ifndef KAB_EMBEDDED 175#ifndef KAB_EMBEDDED
169 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 176 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
170#endif //KAB_EMBEDDED 177#endif //KAB_EMBEDDED
171 178
172 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 179 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
173 SLOT( addressBookChanged() ) ); 180 SLOT( addressBookChanged() ) );
174 181
175 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 182 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
176 "X-Department", "KADDRESSBOOK" ); 183 "X-Department", "KADDRESSBOOK" );
177 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 184 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
178 "X-Profession", "KADDRESSBOOK" ); 185 "X-Profession", "KADDRESSBOOK" );
179 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 186 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
180 "X-AssistantsName", "KADDRESSBOOK" ); 187 "X-AssistantsName", "KADDRESSBOOK" );
181 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 188 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
182 "X-ManagersName", "KADDRESSBOOK" ); 189 "X-ManagersName", "KADDRESSBOOK" );
183 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 190 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
184 "X-SpousesName", "KADDRESSBOOK" ); 191 "X-SpousesName", "KADDRESSBOOK" );
185 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 192 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
186 "X-Office", "KADDRESSBOOK" ); 193 "X-Office", "KADDRESSBOOK" );
187 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 194 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
188 "X-IMAddress", "KADDRESSBOOK" ); 195 "X-IMAddress", "KADDRESSBOOK" );
189 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
190 "X-Anniversary", "KADDRESSBOOK" ); 197 "X-Anniversary", "KADDRESSBOOK" );
191 198
192 //US added this field to become compatible with Opie/qtopia addressbook 199 //US added this field to become compatible with Opie/qtopia addressbook
193 // values can be "female" or "male" or "". An empty field represents undefined. 200 // values can be "female" or "male" or "". An empty field represents undefined.
194 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 201 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
195 "X-Gender", "KADDRESSBOOK" ); 202 "X-Gender", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 203 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
197 "X-Children", "KADDRESSBOOK" ); 204 "X-Children", "KADDRESSBOOK" );
198 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 205 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
199 "X-FreeBusyUrl", "KADDRESSBOOK" ); 206 "X-FreeBusyUrl", "KADDRESSBOOK" );
200 207
201 initGUI(); 208 initGUI();
202 209
203 mIncSearchWidget->setFocus(); 210 mIncSearchWidget->setFocus();
204 211
205 212
206 connect( mViewManager, SIGNAL( selected( const QString& ) ), 213 connect( mViewManager, SIGNAL( selected( const QString& ) ),
207 SLOT( setContactSelected( const QString& ) ) ); 214 SLOT( setContactSelected( const QString& ) ) );
208 connect( mViewManager, SIGNAL( executed( const QString& ) ), 215 connect( mViewManager, SIGNAL( executed( const QString& ) ),
209 SLOT( executeContact( const QString& ) ) ); 216 SLOT( executeContact( const QString& ) ) );
@@ -1016,116 +1023,120 @@ void KABCore::importVCard( const QString &vCard, bool showPreview )
1016} 1023}
1017 1024
1018//US added a second method without defaultparameter 1025//US added a second method without defaultparameter
1019void KABCore::editContact2() { 1026void KABCore::editContact2() {
1020 editContact( QString::null ); 1027 editContact( QString::null );
1021} 1028}
1022 1029
1023void KABCore::editContact( const QString &uid ) 1030void KABCore::editContact( const QString &uid )
1024{ 1031{
1025 1032
1026 if ( mExtensionManager->isQuickEditVisible() ) 1033 if ( mExtensionManager->isQuickEditVisible() )
1027 return; 1034 return;
1028 1035
1029 // First, locate the contact entry 1036 // First, locate the contact entry
1030 QString localUID = uid; 1037 QString localUID = uid;
1031 if ( localUID.isNull() ) { 1038 if ( localUID.isNull() ) {
1032 QStringList uidList = mViewManager->selectedUids(); 1039 QStringList uidList = mViewManager->selectedUids();
1033 if ( uidList.count() > 0 ) 1040 if ( uidList.count() > 0 )
1034 localUID = *( uidList.at( 0 ) ); 1041 localUID = *( uidList.at( 0 ) );
1035 } 1042 }
1036 1043
1037 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1044 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1038 if ( !addr.isEmpty() ) { 1045 if ( !addr.isEmpty() ) {
1039 mEditorDialog->setAddressee( addr ); 1046 mEditorDialog->setAddressee( addr );
1040 KApplication::execDialog ( mEditorDialog ); 1047 KApplication::execDialog ( mEditorDialog );
1041 } 1048 }
1042} 1049}
1043 1050
1044/** 1051/**
1045 Shows or edits the detail view for the given uid. If the uid is QString::null, 1052 Shows or edits the detail view for the given uid. If the uid is QString::null,
1046 the method will try to find a selected addressee in the view. 1053 the method will try to find a selected addressee in the view.
1047 */ 1054 */
1048void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1055void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1049{ 1056{
1050 if ( mMultipleViewsAtOnce ) 1057 if ( mMultipleViewsAtOnce )
1051 { 1058 {
1052 editContact( uid ); 1059 editContact( uid );
1053 } 1060 }
1054 else 1061 else
1055 { 1062 {
1056 setDetailsVisible( true ); 1063 setDetailsVisible( true );
1057 mActionDetails->setChecked(true); 1064 mActionDetails->setChecked(true);
1058 } 1065 }
1059 1066
1060} 1067}
1061 1068
1062void KABCore::save() 1069void KABCore::save()
1063{ 1070{
1071 if (mBlockSaveFlag)
1072 return;
1073 mBlockSaveFlag = true;
1064 if ( !mModified ) 1074 if ( !mModified )
1065 return; 1075 return;
1066 QString text = i18n( "There was an error while attempting to save\n the " 1076 QString text = i18n( "There was an error while attempting to save\n the "
1067 "address book. Please check that some \nother application is " 1077 "address book. Please check that some \nother application is "
1068 "not using it. " ); 1078 "not using it. " );
1069 statusMessage(i18n("Saving addressbook ... ")); 1079 statusMessage(i18n("Saving addressbook ... "));
1070#ifndef KAB_EMBEDDED 1080#ifndef KAB_EMBEDDED
1071 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1081 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1072 if ( !b || !b->save() ) { 1082 if ( !b || !b->save() ) {
1073 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1083 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1074 } 1084 }
1075#else //KAB_EMBEDDED 1085#else //KAB_EMBEDDED
1076 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1086 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1077 if ( !b || !b->save() ) { 1087 if ( !b || !b->save() ) {
1078 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1088 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1079 } 1089 }
1080#endif //KAB_EMBEDDED 1090#endif //KAB_EMBEDDED
1081 1091
1082 statusMessage(i18n("Addressbook saved!")); 1092 statusMessage(i18n("Addressbook saved!"));
1083 setModified( false ); 1093 setModified( false );
1094 mBlockSaveFlag = false;
1084} 1095}
1085 1096
1086void KABCore::statusMessage(QString mess , int time ) 1097void KABCore::statusMessage(QString mess , int time )
1087{ 1098{
1088 //topLevelWidget()->setCaption( mess ); 1099 //topLevelWidget()->setCaption( mess );
1089 // pending setting timer to revome message 1100 // pending setting timer to revome message
1090} 1101}
1091void KABCore::undo() 1102void KABCore::undo()
1092{ 1103{
1093 UndoStack::instance()->undo(); 1104 UndoStack::instance()->undo();
1094 1105
1095 // Refresh the view 1106 // Refresh the view
1096 mViewManager->refreshView(); 1107 mViewManager->refreshView();
1097} 1108}
1098 1109
1099void KABCore::redo() 1110void KABCore::redo()
1100{ 1111{
1101 RedoStack::instance()->redo(); 1112 RedoStack::instance()->redo();
1102 1113
1103 // Refresh the view 1114 // Refresh the view
1104 mViewManager->refreshView(); 1115 mViewManager->refreshView();
1105} 1116}
1106 1117
1107void KABCore::setJumpButtonBarVisible( bool visible ) 1118void KABCore::setJumpButtonBarVisible( bool visible )
1108{ 1119{
1109 if (mMultipleViewsAtOnce) 1120 if (mMultipleViewsAtOnce)
1110 { 1121 {
1111 if ( visible ) 1122 if ( visible )
1112 mJumpButtonBar->show(); 1123 mJumpButtonBar->show();
1113 else 1124 else
1114 mJumpButtonBar->hide(); 1125 mJumpButtonBar->hide();
1115 } 1126 }
1116 else 1127 else
1117 { 1128 {
1118 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1129 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1119 if (mViewManager->isVisible()) 1130 if (mViewManager->isVisible())
1120 { 1131 {
1121 if ( visible ) 1132 if ( visible )
1122 mJumpButtonBar->show(); 1133 mJumpButtonBar->show();
1123 else 1134 else
1124 mJumpButtonBar->hide(); 1135 mJumpButtonBar->hide();
1125 } 1136 }
1126 else 1137 else
1127 { 1138 {
1128 mJumpButtonBar->hide(); 1139 mJumpButtonBar->hide();
1129 } 1140 }
1130 } 1141 }
1131} 1142}
@@ -1391,97 +1402,97 @@ AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1391 return mEditorDialog; 1402 return mEditorDialog;
1392} 1403}
1393 1404
1394void KABCore::slotEditorDestroyed( const QString &uid ) 1405void KABCore::slotEditorDestroyed( const QString &uid )
1395{ 1406{
1396 //mEditorDict.remove( uid ); 1407 //mEditorDict.remove( uid );
1397} 1408}
1398 1409
1399void KABCore::initGUI() 1410void KABCore::initGUI()
1400{ 1411{
1401#ifndef KAB_EMBEDDED 1412#ifndef KAB_EMBEDDED
1402 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1413 QHBoxLayout *topLayout = new QHBoxLayout( this );
1403 topLayout->setSpacing( KDialogBase::spacingHint() ); 1414 topLayout->setSpacing( KDialogBase::spacingHint() );
1404 1415
1405 mExtensionBarSplitter = new QSplitter( this ); 1416 mExtensionBarSplitter = new QSplitter( this );
1406 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1417 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1407 1418
1408 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1419 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1409 1420
1410 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1421 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1411 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1422 mIncSearchWidget = new IncSearchWidget( viewSpace );
1412 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1423 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1413 SLOT( incrementalSearch( const QString& ) ) ); 1424 SLOT( incrementalSearch( const QString& ) ) );
1414 1425
1415 mViewManager = new ViewManager( this, viewSpace ); 1426 mViewManager = new ViewManager( this, viewSpace );
1416 viewSpace->setStretchFactor( mViewManager, 1 ); 1427 viewSpace->setStretchFactor( mViewManager, 1 );
1417 1428
1418 mDetails = new ViewContainer( mDetailsSplitter ); 1429 mDetails = new ViewContainer( mDetailsSplitter );
1419 1430
1420 mJumpButtonBar = new JumpButtonBar( this, this ); 1431 mJumpButtonBar = new JumpButtonBar( this, this );
1421 1432
1422 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1433 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1423 1434
1424 topLayout->addWidget( mExtensionBarSplitter ); 1435 topLayout->addWidget( mExtensionBarSplitter );
1425 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1436 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1426 topLayout->addWidget( mJumpButtonBar ); 1437 topLayout->addWidget( mJumpButtonBar );
1427 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1438 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1428 1439
1429 mXXPortManager = new XXPortManager( this, this ); 1440 mXXPortManager = new XXPortManager( this, this );
1430 1441
1431#else //KAB_EMBEDDED 1442#else //KAB_EMBEDDED
1432 //US initialize viewMenu before settingup viewmanager. 1443 //US initialize viewMenu before settingup viewmanager.
1433 // Viewmanager needs this menu to plugin submenues. 1444 // Viewmanager needs this menu to plugin submenues.
1434 viewMenu = new QPopupMenu( this ); 1445 viewMenu = new QPopupMenu( this );
1435 settingsMenu = new QPopupMenu( this ); 1446 settingsMenu = new QPopupMenu( this );
1436 //filterMenu = new QPopupMenu( this ); 1447 //filterMenu = new QPopupMenu( this );
1437 ImportMenu = new QPopupMenu( this ); 1448 ImportMenu = new QPopupMenu( this );
1438 ExportMenu = new QPopupMenu( this ); 1449 ExportMenu = new QPopupMenu( this );
1439 1450 syncMenu = new QPopupMenu( this );
1440 changeMenu= new QPopupMenu( this ); 1451 changeMenu= new QPopupMenu( this );
1441 1452
1442//US since we have no splitter for the embedded system, setup 1453//US since we have no splitter for the embedded system, setup
1443// a layout with two frames. One left and one right. 1454// a layout with two frames. One left and one right.
1444 1455
1445 QBoxLayout *topLayout; 1456 QBoxLayout *topLayout;
1446 1457
1447 // = new QHBoxLayout( this ); 1458 // = new QHBoxLayout( this );
1448// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1459// QBoxLayout *topLayout = (QBoxLayout*)layout();
1449 1460
1450// QWidget *mainBox = new QWidget( this ); 1461// QWidget *mainBox = new QWidget( this );
1451// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1462// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1452 1463
1453#ifdef DESKTOP_VERSION 1464#ifdef DESKTOP_VERSION
1454 topLayout = new QHBoxLayout( this ); 1465 topLayout = new QHBoxLayout( this );
1455 1466
1456 1467
1457 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1468 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1458 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1469 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1459 1470
1460 topLayout->addWidget(mMiniSplitter ); 1471 topLayout->addWidget(mMiniSplitter );
1461 1472
1462 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1473 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1463 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1474 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1464 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1475 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1465 mDetails = new ViewContainer( mMiniSplitter ); 1476 mDetails = new ViewContainer( mMiniSplitter );
1466 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1477 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1467#else 1478#else
1468 if ( QApplication::desktop()->width() > 480 ) { 1479 if ( QApplication::desktop()->width() > 480 ) {
1469 topLayout = new QHBoxLayout( this ); 1480 topLayout = new QHBoxLayout( this );
1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1481 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1482 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1472 } else { 1483 } else {
1473 1484
1474 topLayout = new QHBoxLayout( this ); 1485 topLayout = new QHBoxLayout( this );
1475 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1486 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1476 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1487 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1477 } 1488 }
1478 1489
1479 topLayout->addWidget(mMiniSplitter ); 1490 topLayout->addWidget(mMiniSplitter );
1480 mViewManager = new ViewManager( this, mMiniSplitter ); 1491 mViewManager = new ViewManager( this, mMiniSplitter );
1481 mDetails = new ViewContainer( mMiniSplitter ); 1492 mDetails = new ViewContainer( mMiniSplitter );
1482 1493
1483 1494
1484 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1495 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1485#endif 1496#endif
1486 //eh->hide(); 1497 //eh->hide();
1487 // topLayout->addWidget(mExtensionManager ); 1498 // topLayout->addWidget(mExtensionManager );
@@ -1709,114 +1720,116 @@ void KABCore::initActions()
1709 "edit_set_categories" ); 1720 "edit_set_categories" );
1710 1721
1711 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1722 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1712 SLOT( removeVoice() ), actionCollection(), 1723 SLOT( removeVoice() ), actionCollection(),
1713 "remove_voice" ); 1724 "remove_voice" );
1714 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1725 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1715 SLOT( importFromOL() ), actionCollection(), 1726 SLOT( importFromOL() ), actionCollection(),
1716 "import_OL" ); 1727 "import_OL" );
1717#ifdef KAB_EMBEDDED 1728#ifdef KAB_EMBEDDED
1718 mActionLicence = new KAction( i18n( "Licence" ), 0, 1729 mActionLicence = new KAction( i18n( "Licence" ), 0,
1719 this, SLOT( showLicence() ), actionCollection(), 1730 this, SLOT( showLicence() ), actionCollection(),
1720 "licence_about_data" ); 1731 "licence_about_data" );
1721 mActionFaq = new KAction( i18n( "Faq" ), 0, 1732 mActionFaq = new KAction( i18n( "Faq" ), 0,
1722 this, SLOT( faq() ), actionCollection(), 1733 this, SLOT( faq() ), actionCollection(),
1723 "faq_about_data" ); 1734 "faq_about_data" );
1724 1735
1725 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1736 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1726 this, SLOT( createAboutData() ), actionCollection(), 1737 this, SLOT( createAboutData() ), actionCollection(),
1727 "kaddressbook_about_data" ); 1738 "kaddressbook_about_data" );
1728#endif //KAB_EMBEDDED 1739#endif //KAB_EMBEDDED
1729 1740
1730 clipboardDataChanged(); 1741 clipboardDataChanged();
1731 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1742 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1732 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1743 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1733} 1744}
1734 1745
1735//US we need this function, to plug all actions into the correct menues. 1746//US we need this function, to plug all actions into the correct menues.
1736// KDE uses a XML format to plug the actions, but we work her without this overhead. 1747// KDE uses a XML format to plug the actions, but we work her without this overhead.
1737void KABCore::addActionsManually() 1748void KABCore::addActionsManually()
1738{ 1749{
1739//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1750//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1740 1751
1741#ifdef KAB_EMBEDDED 1752#ifdef KAB_EMBEDDED
1742 QPopupMenu *fileMenu = new QPopupMenu( this ); 1753 QPopupMenu *fileMenu = new QPopupMenu( this );
1743 QPopupMenu *editMenu = new QPopupMenu( this ); 1754 QPopupMenu *editMenu = new QPopupMenu( this );
1744 QPopupMenu *helpMenu = new QPopupMenu( this ); 1755 QPopupMenu *helpMenu = new QPopupMenu( this );
1745 1756
1746 KToolBar* tb = mMainWindow->toolBar(); 1757 KToolBar* tb = mMainWindow->toolBar();
1747 1758
1748#ifdef DESKTOP_VERSION 1759#ifdef DESKTOP_VERSION
1749 QMenuBar* mb = mMainWindow->menuBar(); 1760 QMenuBar* mb = mMainWindow->menuBar();
1750 1761
1751 //US setup menubar. 1762 //US setup menubar.
1752 //Disable the following block if you do not want to have a menubar. 1763 //Disable the following block if you do not want to have a menubar.
1753 mb->insertItem( "&File", fileMenu ); 1764 mb->insertItem( "&File", fileMenu );
1754 mb->insertItem( "&Edit", editMenu ); 1765 mb->insertItem( "&Edit", editMenu );
1755 mb->insertItem( "&View", viewMenu ); 1766 mb->insertItem( "&View", viewMenu );
1756 mb->insertItem( "&Settings", settingsMenu ); 1767 mb->insertItem( "&Settings", settingsMenu );
1768 mb->insertItem( i18n("Synchronize"), syncMenu );
1757 mb->insertItem( "&Change selected", changeMenu ); 1769 mb->insertItem( "&Change selected", changeMenu );
1758 mb->insertItem( "&Help", helpMenu ); 1770 mb->insertItem( "&Help", helpMenu );
1759 mIncSearchWidget = new IncSearchWidget( tb ); 1771 mIncSearchWidget = new IncSearchWidget( tb );
1760 // tb->insertWidget(-1, 0, mIncSearchWidget); 1772 // tb->insertWidget(-1, 0, mIncSearchWidget);
1761 1773
1762#else 1774#else
1763 //US setup toolbar 1775 //US setup toolbar
1764 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1776 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1765 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1777 QPopupMenu *popupBarTB = new QPopupMenu( this );
1766 menuBarTB->insertItem( "ME", popupBarTB); 1778 menuBarTB->insertItem( "ME", popupBarTB);
1767 tb->insertWidget(-1, 0, menuBarTB); 1779 tb->insertWidget(-1, 0, menuBarTB);
1768 mIncSearchWidget = new IncSearchWidget( tb ); 1780 mIncSearchWidget = new IncSearchWidget( tb );
1769 1781
1770 tb->enableMoving(false); 1782 tb->enableMoving(false);
1771 popupBarTB->insertItem( "&File", fileMenu ); 1783 popupBarTB->insertItem( "&File", fileMenu );
1772 popupBarTB->insertItem( "&Edit", editMenu ); 1784 popupBarTB->insertItem( "&Edit", editMenu );
1773 popupBarTB->insertItem( "&View", viewMenu ); 1785 popupBarTB->insertItem( "&View", viewMenu );
1774 popupBarTB->insertItem( "&Settings", settingsMenu ); 1786 popupBarTB->insertItem( "&Settings", settingsMenu );
1787 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1775 mViewManager->getFilterAction()->plug ( popupBarTB); 1788 mViewManager->getFilterAction()->plug ( popupBarTB);
1776 popupBarTB->insertItem( "&Change selected", changeMenu ); 1789 popupBarTB->insertItem( "&Change selected", changeMenu );
1777 popupBarTB->insertItem( "&Help", helpMenu ); 1790 popupBarTB->insertItem( "&Help", helpMenu );
1778 if (QApplication::desktop()->width() > 320 ) { 1791 if (QApplication::desktop()->width() > 320 ) {
1779 // mViewManager->getFilterAction()->plug ( tb); 1792 // mViewManager->getFilterAction()->plug ( tb);
1780 } 1793 }
1781#endif 1794#endif
1782 // mActionQuit->plug ( mMainWindow->toolBar()); 1795 // mActionQuit->plug ( mMainWindow->toolBar());
1783 1796
1784 1797
1785 1798
1786 //US Now connect the actions with the menue entries. 1799 //US Now connect the actions with the menue entries.
1787 mActionPrint->plug( fileMenu ); 1800 mActionPrint->plug( fileMenu );
1788 mActionMail->plug( fileMenu ); 1801 mActionMail->plug( fileMenu );
1789 fileMenu->insertSeparator(); 1802 fileMenu->insertSeparator();
1790 1803
1791 mActionNewContact->plug( fileMenu ); 1804 mActionNewContact->plug( fileMenu );
1792 mActionNewContact->plug( tb ); 1805 mActionNewContact->plug( tb );
1793 1806
1794 mActionEditAddressee->plug( fileMenu ); 1807 mActionEditAddressee->plug( fileMenu );
1795 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1808 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1796 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1809 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1797 mActionEditAddressee->plug( tb ); 1810 mActionEditAddressee->plug( tb );
1798 1811
1799 fileMenu->insertSeparator(); 1812 fileMenu->insertSeparator();
1800 mActionSave->plug( fileMenu ); 1813 mActionSave->plug( fileMenu );
1801 fileMenu->insertItem( "&Import", ImportMenu ); 1814 fileMenu->insertItem( "&Import", ImportMenu );
1802 fileMenu->insertItem( "&Export", ExportMenu ); 1815 fileMenu->insertItem( "&Export", ExportMenu );
1803 fileMenu->insertSeparator(); 1816 fileMenu->insertSeparator();
1804 mActionMailVCard->plug( fileMenu ); 1817 mActionMailVCard->plug( fileMenu );
1805#ifndef DESKTOP_VERSION 1818#ifndef DESKTOP_VERSION
1806 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1819 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1807 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1820 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1808#endif 1821#endif
1809 fileMenu->insertSeparator(); 1822 fileMenu->insertSeparator();
1810 mActionQuit->plug( fileMenu ); 1823 mActionQuit->plug( fileMenu );
1811#ifdef _WIN32_ 1824#ifdef _WIN32_
1812 mActionImportOL->plug( ImportMenu ); 1825 mActionImportOL->plug( ImportMenu );
1813#endif 1826#endif
1814 // edit menu 1827 // edit menu
1815 mActionUndo->plug( editMenu ); 1828 mActionUndo->plug( editMenu );
1816 mActionRedo->plug( editMenu ); 1829 mActionRedo->plug( editMenu );
1817 editMenu->insertSeparator(); 1830 editMenu->insertSeparator();
1818 mActionCut->plug( editMenu ); 1831 mActionCut->plug( editMenu );
1819 mActionCopy->plug( editMenu ); 1832 mActionCopy->plug( editMenu );
1820 mActionPaste->plug( editMenu ); 1833 mActionPaste->plug( editMenu );
1821 mActionDelete->plug( editMenu ); 1834 mActionDelete->plug( editMenu );
1822 editMenu->insertSeparator(); 1835 editMenu->insertSeparator();
@@ -1838,96 +1851,100 @@ void KABCore::addActionsManually()
1838 } else { 1851 } else {
1839 mActionKeyBindings->plug( settingsMenu ); 1852 mActionKeyBindings->plug( settingsMenu );
1840 } 1853 }
1841 1854
1842 settingsMenu->insertSeparator(); 1855 settingsMenu->insertSeparator();
1843 1856
1844 mActionJumpBar->plug( settingsMenu ); 1857 mActionJumpBar->plug( settingsMenu );
1845 mActionDetails->plug( settingsMenu ); 1858 mActionDetails->plug( settingsMenu );
1846 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1859 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1847 mActionDetails->plug( tb ); 1860 mActionDetails->plug( tb );
1848 settingsMenu->insertSeparator(); 1861 settingsMenu->insertSeparator();
1849 1862
1850 mActionWhoAmI->plug( settingsMenu ); 1863 mActionWhoAmI->plug( settingsMenu );
1851 mActionCategories->plug( settingsMenu ); 1864 mActionCategories->plug( settingsMenu );
1852 1865
1853 mActionLicence->plug( helpMenu ); 1866 mActionLicence->plug( helpMenu );
1854 mActionFaq->plug( helpMenu ); 1867 mActionFaq->plug( helpMenu );
1855 mActionAboutKAddressbook->plug( helpMenu ); 1868 mActionAboutKAddressbook->plug( helpMenu );
1856 1869
1857 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1870 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1858 1871
1859 mActionSave->plug( tb ); 1872 mActionSave->plug( tb );
1860 mViewManager->getFilterAction()->plug ( tb); 1873 mViewManager->getFilterAction()->plug ( tb);
1861 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1874 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1862 mActionUndo->plug( tb ); 1875 mActionUndo->plug( tb );
1863 mActionDelete->plug( tb ); 1876 mActionDelete->plug( tb );
1864 mActionRedo->plug( tb ); 1877 mActionRedo->plug( tb );
1865 } 1878 }
1866 } 1879 }
1867 //mActionQuit->plug ( tb ); 1880 //mActionQuit->plug ( tb );
1868 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1881 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1869 1882
1870 //US link the searchwidget first to this. 1883 //US link the searchwidget first to this.
1871 // The real linkage to the toolbar happens later. 1884 // The real linkage to the toolbar happens later.
1872//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1885//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1873//US tb->insertItem( mIncSearchWidget ); 1886//US tb->insertItem( mIncSearchWidget );
1874/*US 1887/*US
1875 mIncSearchWidget = new IncSearchWidget( tb ); 1888 mIncSearchWidget = new IncSearchWidget( tb );
1876 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1889 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1877 SLOT( incrementalSearch( const QString& ) ) ); 1890 SLOT( incrementalSearch( const QString& ) ) );
1878 1891
1879 mJumpButtonBar = new JumpButtonBar( this, this ); 1892 mJumpButtonBar = new JumpButtonBar( this, this );
1880 1893
1881//US topLayout->addWidget( mJumpButtonBar ); 1894//US topLayout->addWidget( mJumpButtonBar );
1882 this->layout()->add( mJumpButtonBar ); 1895 this->layout()->add( mJumpButtonBar );
1883*/ 1896*/
1884 1897
1885#endif //KAB_EMBEDDED 1898#endif //KAB_EMBEDDED
1899
1900 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
1901 fillSyncMenu();
1902
1886} 1903}
1887void KABCore::showLicence() 1904void KABCore::showLicence()
1888{ 1905{
1889 KApplication::showLicence(); 1906 KApplication::showLicence();
1890} 1907}
1891void KABCore::removeVoice() 1908void KABCore::removeVoice()
1892{ 1909{
1893 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 ) 1910 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 )
1894 return; 1911 return;
1895 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1912 KABC::Addressee::List list = mViewManager->selectedAddressees();
1896 KABC::Addressee::List::Iterator it; 1913 KABC::Addressee::List::Iterator it;
1897 for ( it = list.begin(); it != list.end(); ++it ) { 1914 for ( it = list.begin(); it != list.end(); ++it ) {
1898 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1915 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1899 PhoneNumber::List::Iterator phoneIt; 1916 PhoneNumber::List::Iterator phoneIt;
1900 bool found = false; 1917 bool found = false;
1901 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1918 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1902 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1919 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1903 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1920 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1904 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1921 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1905 (*it).insertPhoneNumber( (*phoneIt) ); 1922 (*it).insertPhoneNumber( (*phoneIt) );
1906 found = true; 1923 found = true;
1907 } 1924 }
1908 } 1925 }
1909 1926
1910 } 1927 }
1911 if ( found ) 1928 if ( found )
1912 contactModified((*it) ); 1929 contactModified((*it) );
1913 } 1930 }
1914} 1931}
1915 1932
1916 1933
1917 1934
1918void KABCore::clipboardDataChanged() 1935void KABCore::clipboardDataChanged()
1919{ 1936{
1920 1937
1921 if ( mReadWrite ) 1938 if ( mReadWrite )
1922 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1939 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1923 1940
1924} 1941}
1925 1942
1926void KABCore::updateActionMenu() 1943void KABCore::updateActionMenu()
1927{ 1944{
1928 UndoStack *undo = UndoStack::instance(); 1945 UndoStack *undo = UndoStack::instance();
1929 RedoStack *redo = RedoStack::instance(); 1946 RedoStack *redo = RedoStack::instance();
1930 1947
1931 if ( undo->isEmpty() ) 1948 if ( undo->isEmpty() )
1932 mActionUndo->setText( i18n( "Undo" ) ); 1949 mActionUndo->setText( i18n( "Undo" ) );
1933 else 1950 else
@@ -2039,53 +2056,488 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
2039 for (int j = 0; j < emaillist.count(); j++) 2056 for (int j = 0; j < emaillist.count(); j++)
2040 { 2057 {
2041 if (namelist[i] == emaillist[j]) 2058 if (namelist[i] == emaillist[j])
2042 { 2059 {
2043 foundUid = namelist[i].uid(); 2060 foundUid = namelist[i].uid();
2044 } 2061 }
2045 } 2062 }
2046 } 2063 }
2047 } 2064 }
2048 } 2065 }
2049 else 2066 else
2050 { 2067 {
2051 foundUid = uid; 2068 foundUid = uid;
2052 } 2069 }
2053 2070
2054 if (!foundUid.isEmpty()) 2071 if (!foundUid.isEmpty())
2055 { 2072 {
2056 2073
2057 // raise Ka/Pi if it is in the background 2074 // raise Ka/Pi if it is in the background
2058#ifndef DESKTOP_VERSION 2075#ifndef DESKTOP_VERSION
2059#ifndef KORG_NODCOP 2076#ifndef KORG_NODCOP
2060 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2077 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2061#endif 2078#endif
2062#endif 2079#endif
2063 2080
2064 mMainWindow->showMaximized(); 2081 mMainWindow->showMaximized();
2065 mMainWindow-> raise(); 2082 mMainWindow-> raise();
2066 2083
2067 mViewManager->setSelected( "", false); 2084 mViewManager->setSelected( "", false);
2068 mViewManager->refreshView( "" ); 2085 mViewManager->refreshView( "" );
2069 mViewManager->setSelected( foundUid, true ); 2086 mViewManager->setSelected( foundUid, true );
2070 mViewManager->refreshView( foundUid ); 2087 mViewManager->refreshView( foundUid );
2071 2088
2072 if ( !mMultipleViewsAtOnce ) 2089 if ( !mMultipleViewsAtOnce )
2073 { 2090 {
2074 setDetailsVisible( true ); 2091 setDetailsVisible( true );
2075 mActionDetails->setChecked(true); 2092 mActionDetails->setChecked(true);
2076 } 2093 }
2077 } 2094 }
2078} 2095}
2079 2096
2080 2097
2081void KABCore::faq() 2098void KABCore::faq()
2082{ 2099{
2083 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2100 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2084} 2101}
2085 2102
2086 2103
2104void KABCore::fillSyncMenu()
2105{
2106 if ( syncMenu->count() )
2107 syncMenu->clear();
2108 syncMenu->insertItem( i18n("Configure..."), 0 );
2109 syncMenu->insertSeparator();
2110 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2111 syncMenu->insertSeparator();
2112 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2113 config.setGroup("General");
2114 QStringList prof = config.readListEntry("SyncProfileNames");
2115 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2116 if ( prof.count() < 3 ) {
2117 prof.clear();
2118 prof << i18n("Sharp_DTM");
2119 prof << i18n("Local_file");
2120 prof << i18n("Last_file");
2121 KSyncProfile* temp = new KSyncProfile ();
2122 temp->setName( prof[0] );
2123 temp->writeConfig(&config);
2124 temp->setName( prof[1] );
2125 temp->writeConfig(&config);
2126 temp->setName( prof[2] );
2127 temp->writeConfig(&config);
2128 config.setGroup("General");
2129 config.writeEntry("SyncProfileNames",prof);
2130 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2131 config.sync();
2132 delete temp;
2133 }
2134 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2135 KABPrefs::instance()->mSyncProfileNames = prof;
2136 int i;
2137 for ( i = 0; i < prof.count(); ++i ) {
2138
2139 syncMenu->insertItem( prof[i], 1000+i );
2140 if ( i == 2 )
2141 syncMenu->insertSeparator();
2142 }
2143 QDir app_dir;
2144 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2145 syncMenu->setItemEnabled( false , 1000 );
2146 }
2147 //probaly useless
2148 //mView->setupExternSyncProfiles();
2149}
2150void KABCore::slotSyncMenu( int action )
2151{
2152 //qDebug("syncaction %d ", action);
2153 if ( action == 0 ) {
2087 2154
2155 // seems to be a Qt2 event handling bug
2156 // syncmenu.clear causes a segfault at first time
2157 // when we call it after the main event loop, it is ok
2158 // same behaviour when calling OM/Pi via QCOP for the first time
2159 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2160 //confSync();
2088 2161
2089#ifndef KAB_EMBEDDED 2162 return;
2090#include "kabcore.moc" 2163 }
2091#endif //KAB_EMBEDDED 2164 if ( action == 1 ) {
2165 multiSync( true );
2166 return;
2167 }
2168
2169 if (mBlockSaveFlag)
2170 return;
2171 mBlockSaveFlag = true;
2172 mCurrentSyncProfile = action - 1000 ;
2173 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2174 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2176 KSyncProfile* temp = new KSyncProfile ();
2177 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2178 temp->readConfig(&config);
2179 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2180 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2181 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2182 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2183 KABPrefs::instance()->mWriteBackInFuture = 0;
2184 if ( temp->getWriteBackFuture() )
2185 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2186 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2187 if ( action == 1000 ) {
2188 syncSharp();
2189
2190 } else if ( action == 1001 ) {
2191 syncLocalFile();
2192
2193 } else if ( action == 1002 ) {
2194 quickSyncLocalFile();
2195
2196 } else if ( action >= 1003 ) {
2197 if ( temp->getIsLocalFileSync() ) {
2198 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
2199 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
2200 } else {
2201 if ( temp->getIsPhoneSync() ) {
2202 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2203 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2204 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2205 syncPhone();
2206 } else
2207 syncRemote( temp );
2208
2209 }
2210 }
2211 delete temp;
2212 mBlockSaveFlag = false;
2213}
2214
2215void KABCore::syncLocalFile()
2216{
2217
2218 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2219
2220 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2221 if ( fn == "" )
2222 return;
2223 if ( syncWithFile( fn, false ) ) {
2224 qDebug("syncLocalFile() successful ");
2225 }
2226
2227}
2228bool KABCore::syncWithFile( QString fn , bool quick )
2229{
2230 bool ret = false;
2231 QFileInfo info;
2232 info.setFile( fn );
2233 QString mess;
2234 bool loadbup = true;
2235 if ( !info. exists() ) {
2236 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2237 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2238 mess );
2239 return ret;
2240 }
2241 int result = 0;
2242 if ( !quick ) {
2243 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2244 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2245 mess,
2246 i18n("Sync"), i18n("Cancel"), 0,
2247 0, 1 );
2248 if ( result )
2249 return false;
2250 }
2251 if ( KABPrefs::instance()->mAskForPreferences )
2252 edit_sync_options();
2253 if ( result == 0 ) {
2254 //qDebug("Now sycing ... ");
2255 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2256 setCaption( i18n("Synchronization successful") );
2257 else
2258 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2259 if ( ! quick )
2260 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2261 setModified();
2262 }
2263 return ret;
2264}
2265void KABCore::quickSyncLocalFile()
2266{
2267
2268 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2269 qDebug("quick syncLocalFile() successful ");
2270
2271 }
2272}
2273void KABCore::multiSync( bool askforPrefs )
2274{
2275 if (mBlockSaveFlag)
2276 return;
2277 mBlockSaveFlag = true;
2278 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
2279 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2280 question,
2281 i18n("Yes"), i18n("No"),
2282 0, 0 ) != 0 ) {
2283 mBlockSaveFlag = false;
2284 setCaption(i18n("Aborted! Nothing synced!"));
2285 return;
2286 }
2287 mCurrentSyncDevice = i18n("Multiple profiles") ;
2288 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2289 if ( askforPrefs ) {
2290 edit_sync_options();
2291 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2292 }
2293 setCaption(i18n("Multiple sync started.") );
2294 qApp->processEvents();
2295 int num = ringSync() ;
2296 if ( num > 1 )
2297 ringSync();
2298 mBlockSaveFlag = false;
2299 if ( num )
2300 save();
2301 if ( num )
2302 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2303 else
2304 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2305 return;
2306}
2307int KABCore::ringSync()
2308{
2309 int syncedProfiles = 0;
2310 int i;
2311 QTime timer;
2312 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2313 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2314 KSyncProfile* temp = new KSyncProfile ();
2315 KABPrefs::instance()->mAskForPreferences = false;
2316 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2317 mCurrentSyncProfile = i;
2318 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2319 temp->readConfig(&config);
2320 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
2321 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2322 ++syncedProfiles;
2323 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2324 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2325 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2326 KABPrefs::instance()->mWriteBackInFuture = 0;
2327 if ( temp->getWriteBackFuture() )
2328 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2329 KABPrefs::instance()->mShowSyncSummary = false;
2330 mCurrentSyncDevice = syncProfileNames[i] ;
2331 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2332 if ( i == 0 ) {
2333 syncSharp();
2334 } else {
2335 if ( temp->getIsLocalFileSync() ) {
2336 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
2337 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
2338 } else {
2339 if ( temp->getIsPhoneSync() ) {
2340 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2341 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2342 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2343 syncPhone();
2344 } else
2345 syncRemote( temp, false );
2346
2347 }
2348 }
2349 timer.start();
2350 setCaption(i18n("Multiple sync in progress ... please wait!") );
2351 while ( timer.elapsed () < 2000 ) {
2352 qApp->processEvents();
2353#ifndef _WIN32_
2354 sleep (1);
2355#endif
2356 }
2357
2358 }
2359
2360 }
2361 delete temp;
2362 return syncedProfiles;
2363}
2364
2365void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2366{
2367 QString question;
2368 if ( ask ) {
2369 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2370 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2371 question,
2372 i18n("Yes"), i18n("No"),
2373 0, 0 ) != 0 )
2374 return;
2375 }
2376 QString command = prof->getPreSyncCommand();
2377 int fi;
2378 if ( (fi = command.find("$PWD$")) > 0 ) {
2379 QString pwd = getPassword();
2380 command = command.left( fi )+ pwd + command.mid( fi+5 );
2381
2382 }
2383 int maxlen = 30;
2384 if ( QApplication::desktop()->width() > 320 )
2385 maxlen += 25;
2386 setCaption ( i18n( "Copy remote file to local machine..." ) );
2387 int fileSize = 0;
2388 int result = system ( command );
2389 // 0 : okay
2390 // 256: no such file or dir
2391 //
2392 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2393 if ( result != 0 ) {
2394 int len = maxlen;
2395 while ( len < command.length() ) {
2396 command.insert( len , "\n" );
2397 len += maxlen +2;
2398 }
2399 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) ;
2400 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2401 question,
2402 i18n("Okay!")) ;
2403 setCaption ("KO/Pi");
2404 return;
2405 }
2406 setCaption ( i18n( "Copying succeed." ) );
2407 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2408 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2409// Event* e = mView->getLastSyncEvent();
2410// e->setReadOnly( false );
2411// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2412// e->setReadOnly( true );
2413 if ( KABPrefs::instance()->mWriteBackFile ) {
2414 command = prof->getPostSyncCommand();
2415 int fi;
2416 if ( (fi = command.find("$PWD$")) > 0 ) {
2417 QString pwd = getPassword();
2418 command = command.left( fi )+ pwd + command.mid( fi+5 );
2419
2420 }
2421 setCaption ( i18n( "Writing back file ..." ) );
2422 result = system ( command );
2423 qDebug("KO: Writing back file result: %d ", result);
2424 if ( result != 0 ) {
2425 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2426 return;
2427 } else {
2428 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2429 }
2430 }
2431 }
2432 return;
2433}
2434#include <qpushbutton.h>
2435#include <qradiobutton.h>
2436#include <qbuttongroup.h>
2437void KABCore::edit_sync_options()
2438{
2439 //mDialogManager->showSyncOptions();
2440 //KABPrefs::instance()->mSyncAlgoPrefs
2441 QDialog dia( this, "dia", true );
2442 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2443 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2444 QVBoxLayout lay ( &dia );
2445 lay.setSpacing( 2 );
2446 lay.setMargin( 3 );
2447 lay.addWidget(&gr);
2448 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2449 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2450 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2451 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2452 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2453 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2454 //QRadioButton both( i18n("Take both on conflict"), &gr );
2455 QPushButton pb ( "OK", &dia);
2456 lay.addWidget( &pb );
2457 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2458 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2459 case 0:
2460 loc.setChecked( true);
2461 break;
2462 case 1:
2463 rem.setChecked( true );
2464 break;
2465 case 2:
2466 newest.setChecked( true);
2467 break;
2468 case 3:
2469 ask.setChecked( true);
2470 break;
2471 case 4:
2472 f_loc.setChecked( true);
2473 break;
2474 case 5:
2475 f_rem.setChecked( true);
2476 break;
2477 case 6:
2478 // both.setChecked( true);
2479 break;
2480 default:
2481 break;
2482 }
2483 if ( dia.exec() ) {
2484 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2485 }
2486
2487
2488}
2489QString KABCore::getPassword( )
2490{
2491 QString retfile = "";
2492 QDialog dia ( this, "input-dialog", true );
2493 QLineEdit lab ( &dia );
2494 lab.setEchoMode( QLineEdit::Password );
2495 QVBoxLayout lay( &dia );
2496 lay.setMargin(7);
2497 lay.setSpacing(7);
2498 lay.addWidget( &lab);
2499 dia.setFixedSize( 230,50 );
2500 dia.setCaption( i18n("Enter password") );
2501 QPushButton pb ( "OK", &dia);
2502 lay.addWidget( &pb );
2503 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2504 dia.show();
2505 int res = dia.exec();
2506 if ( res )
2507 retfile = lab.text();
2508 dia.hide();
2509 qApp->processEvents();
2510 return retfile;
2511
2512}
2513
2514bool KABCore::syncAB(QString filename, int mode)
2515{
2516
2517}
2518
2519
2520void KABCore::confSync()
2521{
2522 //mView->confSync();
2523 qDebug("pending KABCore::confSync() ");
2524 fillSyncMenu();
2525}
2526void KABCore::syncSharp()
2527{
2528 if ( mModified )
2529 save();
2530 qDebug("pending syncSharp() ");
2531 //mView->syncSharp();
2532 mModified = true ;
2533
2534}
2535void KABCore::syncPhone()
2536{
2537 if ( mModified )
2538 save();
2539 qDebug("pending syncPhone(); ");
2540 //mView->syncPhone();
2541 setModified();
2542
2543}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 39d043f..10ce8f4 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -12,96 +12,97 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36namespace KABC { 36namespace KABC {
37class AddressBook; 37class AddressBook;
38} 38}
39 39
40#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
41class KAboutData; 41class KAboutData;
42class KConfig; 42class KConfig;
43 43
44class KAddressBookService; 44class KAddressBookService;
45class LDAPSearchDialog; 45class LDAPSearchDialog;
46#else //KAB_EMBEDDED 46#else //KAB_EMBEDDED
47class KAddressBookMain; 47class KAddressBookMain;
48//US class QAction; 48//US class QAction;
49#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
50class KCMultiDialog; 50class KCMultiDialog;
51class KXMLGUIClient; 51class KXMLGUIClient;
52class ExtensionManager; 52class ExtensionManager;
53class XXPortManager; 53class XXPortManager;
54class JumpButtonBar; 54class JumpButtonBar;
55class IncSearchWidget; 55class IncSearchWidget;
56class KDGanttMinimizeSplitter; 56class KDGanttMinimizeSplitter;
57class KAction; 57class KAction;
58class KActionCollection; 58class KActionCollection;
59class KToggleAction; 59class KToggleAction;
60class KSyncProfile;
60 61
61class QAction; 62class QAction;
62class QMenuBar; 63class QMenuBar;
63class QSplitter; 64class QSplitter;
64class ViewContainer; 65class ViewContainer;
65class ViewManager; 66class ViewManager;
66class AddresseeEditorDialog; 67class AddresseeEditorDialog;
67class Ir; 68class Ir;
68 69
69class KABCore : public QWidget 70class KABCore : public QWidget
70{ 71{
71 Q_OBJECT 72 Q_OBJECT
72 73
73 public: 74 public:
74 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 75 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
75 76
76 77
77 ~KABCore(); 78 ~KABCore();
78 79
79 80
80#ifdef KAB_EMBEDDED 81#ifdef KAB_EMBEDDED
81 //US added functionality 82 //US added functionality
82 QPopupMenu* getViewMenu() {return viewMenu;} 83 QPopupMenu* getViewMenu() {return viewMenu;}
83 QPopupMenu* getFilterMenu() {return filterMenu;} 84 QPopupMenu* getFilterMenu() {return filterMenu;}
84 QPopupMenu* getSettingsMenu() {return settingsMenu;} 85 QPopupMenu* getSettingsMenu() {return settingsMenu;}
85 void addActionsManually(); 86 void addActionsManually();
86#endif //KAB_EMBEDDED 87#endif //KAB_EMBEDDED
87 /** 88 /**
88 Restores the global settings. 89 Restores the global settings.
89 */ 90 */
90 void restoreSettings(); 91 void restoreSettings();
91 92
92 /** 93 /**
93 Saves the global settings. 94 Saves the global settings.
94 */ 95 */
95 void saveSettings(); 96 void saveSettings();
96 97
97 /** 98 /**
98 Returns a pointer to the StdAddressBook of the application. 99 Returns a pointer to the StdAddressBook of the application.
99 */ 100 */
100 KABC::AddressBook *addressBook() const; 101 KABC::AddressBook *addressBook() const;
101 102
102 /** 103 /**
103 Returns a pointer to the KConfig object of the application. 104 Returns a pointer to the KConfig object of the application.
104 */ 105 */
105 static KConfig *config(); 106 static KConfig *config();
106 107
107 /** 108 /**
@@ -295,162 +296,183 @@ class KABCore : public QWidget
295 */ 296 */
296 void redo(); 297 void redo();
297 298
298 /** 299 /**
299 Shows the edit dialog for the given uid. If the uid is QString::null, 300 Shows the edit dialog for the given uid. If the uid is QString::null,
300 the method will try to find a selected addressee in the view. 301 the method will try to find a selected addressee in the view.
301 */ 302 */
302 void editContact( const QString &uid /*US = QString::null*/ ); 303 void editContact( const QString &uid /*US = QString::null*/ );
303//US added a second method without defaultparameter 304//US added a second method without defaultparameter
304 void editContact2(); 305 void editContact2();
305 306
306 /** 307 /**
307 Shows or edits the detail view for the given uid. If the uid is QString::null, 308 Shows or edits the detail view for the given uid. If the uid is QString::null,
308 the method will try to find a selected addressee in the view. 309 the method will try to find a selected addressee in the view.
309 */ 310 */
310 void executeContact( const QString &uid /*US = QString::null*/ ); 311 void executeContact( const QString &uid /*US = QString::null*/ );
311 312
312 /** 313 /**
313 Launches the configuration dialog. 314 Launches the configuration dialog.
314 */ 315 */
315 void openConfigDialog(); 316 void openConfigDialog();
316 317
317 /** 318 /**
318 Launches the ldap search dialog. 319 Launches the ldap search dialog.
319 */ 320 */
320 void openLDAPDialog(); 321 void openLDAPDialog();
321 322
322 /** 323 /**
323 Creates a KAddressBookPrinter, which will display the print 324 Creates a KAddressBookPrinter, which will display the print
324 dialog and do the printing. 325 dialog and do the printing.
325 */ 326 */
326 void print(); 327 void print();
327 328
328 /** 329 /**
329 Registers a new GUI client, so plugins can register its actions. 330 Registers a new GUI client, so plugins can register its actions.
330 */ 331 */
331 void addGUIClient( KXMLGUIClient *client ); 332 void addGUIClient( KXMLGUIClient *client );
332 333
333 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 334 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
334 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 335 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
335 336
336 337
337 signals: 338 signals:
338 void contactSelected( const QString &name ); 339 void contactSelected( const QString &name );
339 void contactSelected( const QPixmap &pixmap ); 340 void contactSelected( const QPixmap &pixmap );
340 public slots: 341 public slots:
341 void setDetailsVisible( bool visible ); 342 void setDetailsVisible( bool visible );
342 void setDetailsToState(); 343 void setDetailsToState();
344 void slotSyncMenu( int );
343 private slots: 345 private slots:
344 void setJumpButtonBarVisible( bool visible ); 346 void setJumpButtonBarVisible( bool visible );
345 void importFromOL(); 347 void importFromOL();
346 void extensionModified( const KABC::Addressee::List &list ); 348 void extensionModified( const KABC::Addressee::List &list );
347 void extensionChanged( int id ); 349 void extensionChanged( int id );
348 void clipboardDataChanged(); 350 void clipboardDataChanged();
349 void updateActionMenu(); 351 void updateActionMenu();
350 void configureKeyBindings(); 352 void configureKeyBindings();
351 void removeVoice(); 353 void removeVoice();
352#ifdef KAB_EMBEDDED 354#ifdef KAB_EMBEDDED
353 void configureResources(); 355 void configureResources();
354#endif //KAB_EMBEDDED 356#endif //KAB_EMBEDDED
355 357
356 void slotEditorDestroyed( const QString &uid ); 358 void slotEditorDestroyed( const QString &uid );
357 void configurationChanged(); 359 void configurationChanged();
358 void addressBookChanged(); 360 void addressBookChanged();
359 361
360 private: 362 private:
361 void initGUI(); 363 void initGUI();
362 void initActions(); 364 void initActions();
363 365
364 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 366 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
365 const char *name = 0 ); 367 const char *name = 0 );
366 368
367 KXMLGUIClient *mGUIClient; 369 KXMLGUIClient *mGUIClient;
368 370
369 KABC::AddressBook *mAddressBook; 371 KABC::AddressBook *mAddressBook;
370 372
371 ViewManager *mViewManager; 373 ViewManager *mViewManager;
372 // QSplitter *mDetailsSplitter; 374 // QSplitter *mDetailsSplitter;
373 KDGanttMinimizeSplitter *mExtensionBarSplitter; 375 KDGanttMinimizeSplitter *mExtensionBarSplitter;
374 ViewContainer *mDetails; 376 ViewContainer *mDetails;
375 KDGanttMinimizeSplitter* mMiniSplitter; 377 KDGanttMinimizeSplitter* mMiniSplitter;
376 XXPortManager *mXXPortManager; 378 XXPortManager *mXXPortManager;
377 JumpButtonBar *mJumpButtonBar; 379 JumpButtonBar *mJumpButtonBar;
378 IncSearchWidget *mIncSearchWidget; 380 IncSearchWidget *mIncSearchWidget;
379 ExtensionManager *mExtensionManager; 381 ExtensionManager *mExtensionManager;
380 382
381 KCMultiDialog *mConfigureDialog; 383 KCMultiDialog *mConfigureDialog;
382 384
383#ifndef KAB_EMBEDDED 385#ifndef KAB_EMBEDDED
384 LDAPSearchDialog *mLdapSearchDialog; 386 LDAPSearchDialog *mLdapSearchDialog;
385#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
386 // QDict<AddresseeEditorDialog> mEditorDict; 388 // QDict<AddresseeEditorDialog> mEditorDict;
387 AddresseeEditorDialog *mEditorDialog; 389 AddresseeEditorDialog *mEditorDialog;
388 bool mReadWrite; 390 bool mReadWrite;
389 bool mModified; 391 bool mModified;
390 bool mIsPart; 392 bool mIsPart;
391 bool mMultipleViewsAtOnce; 393 bool mMultipleViewsAtOnce;
392 394
393 395
394 //US file menu 396 //US file menu
395 KAction *mActionMail; 397 KAction *mActionMail;
396 KAction *mActionBeam; 398 KAction *mActionBeam;
397 KAction* mActionPrint; 399 KAction* mActionPrint;
398 KAction* mActionNewContact; 400 KAction* mActionNewContact;
399 KAction *mActionSave; 401 KAction *mActionSave;
400 KAction *mActionEditAddressee; 402 KAction *mActionEditAddressee;
401 KAction *mActionMailVCard; 403 KAction *mActionMailVCard;
402 KAction *mActionBeamVCard; 404 KAction *mActionBeamVCard;
403 405
404 KAction *mActionQuit; 406 KAction *mActionQuit;
405 407
406 //US edit menu 408 //US edit menu
407 KAction *mActionCopy; 409 KAction *mActionCopy;
408 KAction *mActionCut; 410 KAction *mActionCut;
409 KAction *mActionPaste; 411 KAction *mActionPaste;
410 KAction *mActionSelectAll; 412 KAction *mActionSelectAll;
411 KAction *mActionUndo; 413 KAction *mActionUndo;
412 KAction *mActionRedo; 414 KAction *mActionRedo;
413 KAction *mActionDelete; 415 KAction *mActionDelete;
414 416
415 //US settings menu 417 //US settings menu
416 KAction *mActionConfigResources; 418 KAction *mActionConfigResources;
417 KAction *mActionConfigKAddressbook; 419 KAction *mActionConfigKAddressbook;
418 KAction *mActionConfigShortcuts; 420 KAction *mActionConfigShortcuts;
419 KAction *mActionConfigureToolbars; 421 KAction *mActionConfigureToolbars;
420 KAction *mActionKeyBindings; 422 KAction *mActionKeyBindings;
421 KToggleAction *mActionJumpBar; 423 KToggleAction *mActionJumpBar;
422 KToggleAction *mActionDetails; 424 KToggleAction *mActionDetails;
423 KAction *mActionWhoAmI; 425 KAction *mActionWhoAmI;
424 KAction *mActionCategories; 426 KAction *mActionCategories;
425 KAction *mActionAboutKAddressbook; 427 KAction *mActionAboutKAddressbook;
426 KAction *mActionLicence; 428 KAction *mActionLicence;
427 KAction *mActionFaq; 429 KAction *mActionFaq;
428 430
429 KAction *mActionDeleteView; 431 KAction *mActionDeleteView;
430 432
431 QPopupMenu *viewMenu; 433 QPopupMenu *viewMenu;
432 QPopupMenu *filterMenu; 434 QPopupMenu *filterMenu;
433 QPopupMenu *settingsMenu; 435 QPopupMenu *settingsMenu;
434 QPopupMenu *changeMenu; 436 QPopupMenu *changeMenu;
435
436//US QAction *mActionSave; 437//US QAction *mActionSave;
437 QPopupMenu *ImportMenu; 438 QPopupMenu *ImportMenu;
438 QPopupMenu *ExportMenu; 439 QPopupMenu *ExportMenu;
439 //LR additional methods 440 //LR additional methods
440 KAction *mActionRemoveVoice; 441 KAction *mActionRemoveVoice;
441 KAction * mActionImportOL; 442 KAction * mActionImportOL;
442 443
443#ifndef KAB_EMBEDDED 444#ifndef KAB_EMBEDDED
444 KAddressBookService *mAddressBookService; 445 KAddressBookService *mAddressBookService;
445#endif //KAB_EMBEDDED 446#endif //KAB_EMBEDDED
446 447
447 class KABCorePrivate; 448 class KABCorePrivate;
448 KABCorePrivate *d; 449 KABCorePrivate *d;
450 bool mBlockSaveFlag;
449 451
450#ifdef KAB_EMBEDDED 452#ifdef KAB_EMBEDDED
451 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
452#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
455 // LR *******************************
456 // sync stuff!
457 QPopupMenu *syncMenu;
458 void fillSyncMenu();
459 void confSync();
460 QString mCurrentSyncDevice;
461 QString mCurrentSyncName;
462 void quickSyncLocalFile();
463 bool syncWithFile( QString fn , bool quick );
464 void KABCore::syncLocalFile();
465 void KABCore::syncPhone();
466 void KABCore::syncSharp();
467 void multiSync( bool askforPrefs );
468 int mCurrentSyncProfile ;
469 void syncRemote( KSyncProfile* prof, bool ask = true);
470 void edit_sync_options();
471 bool syncAB(QString filename, int mode);
472 int ringSync();
473 QString getPassword( );
474 // *********************
453 475
454}; 476};
455 477
456#endif 478#endif
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index e4f359c..9926aa0 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -37,56 +37,72 @@ class KABPrefs : public KPimPrefs
37 37
38 static KABPrefs *instance(); 38 static KABPrefs *instance();
39 39
40 // General 40 // General
41 bool mHonorSingleClick; 41 bool mHonorSingleClick;
42 bool mAutomaticNameParsing; 42 bool mAutomaticNameParsing;
43 int mCurrentIncSearchField; 43 int mCurrentIncSearchField;
44 44
45#ifdef KAB_EMBEDDED 45#ifdef KAB_EMBEDDED
46 // US introduce a nonconst way to return the config object. 46 // US introduce a nonconst way to return the config object.
47 KConfig* getConfig(); 47 KConfig* getConfig();
48 48
49 bool mToolBarHor; 49 bool mToolBarHor;
50 bool mToolBarUp; 50 bool mToolBarUp;
51 bool mAskForQuit; 51 bool mAskForQuit;
52 52
53 53
54 /** Set preferences to default values */ 54 /** Set preferences to default values */
55// void usrSetDefaults(); 55// void usrSetDefaults();
56 56
57 /** Read preferences from config file */ 57 /** Read preferences from config file */
58// void usrReadConfig(); 58// void usrReadConfig();
59 59
60 /** Write preferences to config file */ 60 /** Write preferences to config file */
61// void usrWriteConfig(); 61// void usrWriteConfig();
62#endif //KAB_EMBEDDED 62#endif //KAB_EMBEDDED
63 63
64 64
65 // GUI 65 // GUI
66 bool mJumpButtonBarVisible; 66 bool mJumpButtonBarVisible;
67 bool mDetailsPageVisible; 67 bool mDetailsPageVisible;
68 bool mMultipleViewsAtOnce; 68 bool mMultipleViewsAtOnce;
69 bool mSearchWithReturn; 69 bool mSearchWithReturn;
70 QValueList<int> mExtensionsSplitter; 70 QValueList<int> mExtensionsSplitter;
71 QValueList<int> mDetailsSplitter; 71 QValueList<int> mDetailsSplitter;
72 72
73 // Extensions stuff 73 // Extensions stuff
74 int mCurrentExtension; 74 int mCurrentExtension;
75 QStringList mActiveExtensions; 75 QStringList mActiveExtensions;
76 76
77 // Views stuff 77 // Views stuff
78 QString mCurrentView; 78 QString mCurrentView;
79 QStringList mViewNames; 79 QStringList mViewNames;
80 80
81 // Filter 81 // Filter
82 int mCurrentFilter; 82 int mCurrentFilter;
83 83
84 void setCategoryDefaults(); 84 void setCategoryDefaults();
85 85 // sync stuff
86 QString mLocalMachineName;
87 QStringList mExternSyncProfiles;
88 QStringList mSyncProfileNames;
89 bool mAskForPreferences;
90 bool mShowSyncSummary;
91 bool mShowSyncEvents;
92 bool mShowTodoInAgenda;
93 bool mWriteBackExistingOnly;
94 int mSyncAlgoPrefs;
95 int mRingSyncAlgoPrefs;
96 bool mWriteBackFile;
97 int mWriteBackInFuture;
98 QString mPhoneDevice;
99 QString mPhoneConnection;
100 QString mPhoneModel;
101 QString mLastSyncedLocalFile; // save!
86 private: 102 private:
87 KABPrefs(); 103 KABPrefs();
88 104
89 static KABPrefs *sInstance; 105 static KABPrefs *sInstance;
90}; 106};
91 107
92#endif 108#endif