summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp11
-rw-r--r--kaddressbook/viewmanager.cpp11
2 files changed, 16 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index b7edccd..f6bdda4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3178 +1,3181 @@
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/*s 24/*s
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#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include <kcmultidialog.h> 154#include <kcmultidialog.h>
155 155
156#ifdef _WIN32_ 156#ifdef _WIN32_
157 157
158#include "kaimportoldialog.h" 158#include "kaimportoldialog.h"
159#else 159#else
160#include <unistd.h> 160#include <unistd.h>
161#endif 161#endif
162// sync includes 162// sync includes
163#include <libkdepim/ksyncprofile.h> 163#include <libkdepim/ksyncprofile.h>
164#include <libkdepim/ksyncprefsdialog.h> 164#include <libkdepim/ksyncprefsdialog.h>
165 165
166 166
167class KABCatPrefs : public QDialog 167class KABCatPrefs : public QDialog
168{ 168{
169 public: 169 public:
170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
171 QDialog( parent, name, true ) 171 QDialog( parent, name, true )
172 { 172 {
173 setCaption( i18n("Manage new Categories") ); 173 setCaption( i18n("Manage new Categories") );
174 QVBoxLayout* lay = new QVBoxLayout( this ); 174 QVBoxLayout* lay = new QVBoxLayout( this );
175 lay->setSpacing( 3 ); 175 lay->setSpacing( 3 );
176 lay->setMargin( 3 ); 176 lay->setMargin( 3 );
177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
178 lay->addWidget( lab ); 178 lay->addWidget( lab );
179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
180 lay->addWidget( format ); 180 lay->addWidget( format );
181 format->setExclusive ( true ) ; 181 format->setExclusive ( true ) ;
182 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 182 addCatBut = new QRadioButton(i18n("Add to category list"), format );
183 new QRadioButton(i18n("Remove from addressees"), format ); 183 new QRadioButton(i18n("Remove from addressees"), format );
184 addCatBut->setChecked( true ); 184 addCatBut->setChecked( true );
185 QPushButton * ok = new QPushButton( i18n("OK"), this ); 185 QPushButton * ok = new QPushButton( i18n("OK"), this );
186 lay->addWidget( ok ); 186 lay->addWidget( ok );
187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
188 lay->addWidget( cancel ); 188 lay->addWidget( cancel );
189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
191 resize( 200, 200 ); 191 resize( 200, 200 );
192 } 192 }
193 193
194 bool addCat() { return addCatBut->isChecked(); } 194 bool addCat() { return addCatBut->isChecked(); }
195private: 195private:
196 QRadioButton* addCatBut; 196 QRadioButton* addCatBut;
197}; 197};
198 198
199 199
200 200
201class KAex2phonePrefs : public QDialog 201class KAex2phonePrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Export to phone options") ); 207 setCaption( i18n("Export to phone options") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel *lab; 211 QLabel *lab;
212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
213 lab->setAlignment (AlignHCenter ); 213 lab->setAlignment (AlignHCenter );
214 QHBox* temphb; 214 QHBox* temphb;
215 temphb = new QHBox( this ); 215 temphb = new QHBox( this );
216 new QLabel( i18n("I/O device: "), temphb ); 216 new QLabel( i18n("I/O device: "), temphb );
217 mPhoneDevice = new QLineEdit( temphb); 217 mPhoneDevice = new QLineEdit( temphb);
218 lay->addWidget( temphb ); 218 lay->addWidget( temphb );
219 temphb = new QHBox( this ); 219 temphb = new QHBox( this );
220 new QLabel( i18n("Connection: "), temphb ); 220 new QLabel( i18n("Connection: "), temphb );
221 mPhoneConnection = new QLineEdit( temphb); 221 mPhoneConnection = new QLineEdit( temphb);
222 lay->addWidget( temphb ); 222 lay->addWidget( temphb );
223 temphb = new QHBox( this ); 223 temphb = new QHBox( this );
224 new QLabel( i18n("Model(opt.): "), temphb ); 224 new QLabel( i18n("Model(opt.): "), temphb );
225 mPhoneModel = new QLineEdit( temphb); 225 mPhoneModel = new QLineEdit( temphb);
226 lay->addWidget( temphb ); 226 lay->addWidget( temphb );
227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
228 // lay->addWidget( mWriteToSim ); 228 // lay->addWidget( mWriteToSim );
229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
230 lab->setAlignment (AlignHCenter ); 230 lab->setAlignment (AlignHCenter );
231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
232 lay->addWidget( ok ); 232 lay->addWidget( ok );
233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
234 lay->addWidget( cancel ); 234 lay->addWidget( cancel );
235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
237 resize( 220, 240 ); 237 resize( 220, 240 );
238 238
239 } 239 }
240 240
241public: 241public:
242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
243 QCheckBox* mWriteToSim; 243 QCheckBox* mWriteToSim;
244}; 244};
245 245
246 246
247bool pasteWithNewUid = true; 247bool pasteWithNewUid = true;
248 248
249#ifdef KAB_EMBEDDED 249#ifdef KAB_EMBEDDED
250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
254#else //KAB_EMBEDDED 254#else //KAB_EMBEDDED
255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
258 mReadWrite( readWrite ), mModified( false ) 258 mReadWrite( readWrite ), mModified( false )
259#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
260{ 260{
261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
262 // syncManager->setBlockSave(false); 262 // syncManager->setBlockSave(false);
263 mMiniSplitter = 0; 263 mMiniSplitter = 0;
264 mExtensionBarSplitter = 0; 264 mExtensionBarSplitter = 0;
265 mIsPart = !parent->inherits( "KAddressBookMain" ); 265 mIsPart = !parent->inherits( "KAddressBookMain" );
266 mAddressBook = KABC::StdAddressBook::self(); 266 mAddressBook = KABC::StdAddressBook::self();
267 KABC::StdAddressBook::setAutomaticSave( false ); 267 KABC::StdAddressBook::setAutomaticSave( false );
268 268
269#ifndef KAB_EMBEDDED 269#ifndef KAB_EMBEDDED
270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
271#endif //KAB_EMBEDDED 271#endif //KAB_EMBEDDED
272 272
273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
274 SLOT( addressBookChanged() ) ); 274 SLOT( addressBookChanged() ) );
275 275
276#if 0 276#if 0
277 // LP moved to addressbook init method 277 // LP moved to addressbook init method
278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
279 "X-Department", "KADDRESSBOOK" ); 279 "X-Department", "KADDRESSBOOK" );
280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
281 "X-Profession", "KADDRESSBOOK" ); 281 "X-Profession", "KADDRESSBOOK" );
282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
283 "X-AssistantsName", "KADDRESSBOOK" ); 283 "X-AssistantsName", "KADDRESSBOOK" );
284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
285 "X-ManagersName", "KADDRESSBOOK" ); 285 "X-ManagersName", "KADDRESSBOOK" );
286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
287 "X-SpousesName", "KADDRESSBOOK" ); 287 "X-SpousesName", "KADDRESSBOOK" );
288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
289 "X-Office", "KADDRESSBOOK" ); 289 "X-Office", "KADDRESSBOOK" );
290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
291 "X-IMAddress", "KADDRESSBOOK" ); 291 "X-IMAddress", "KADDRESSBOOK" );
292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
293 "X-Anniversary", "KADDRESSBOOK" ); 293 "X-Anniversary", "KADDRESSBOOK" );
294 294
295 //US added this field to become compatible with Opie/qtopia addressbook 295 //US added this field to become compatible with Opie/qtopia addressbook
296 // values can be "female" or "male" or "". An empty field represents undefined. 296 // values can be "female" or "male" or "". An empty field represents undefined.
297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
298 "X-Gender", "KADDRESSBOOK" ); 298 "X-Gender", "KADDRESSBOOK" );
299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
300 "X-Children", "KADDRESSBOOK" ); 300 "X-Children", "KADDRESSBOOK" );
301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
302 "X-FreeBusyUrl", "KADDRESSBOOK" ); 302 "X-FreeBusyUrl", "KADDRESSBOOK" );
303#endif 303#endif
304 initGUI(); 304 initGUI();
305 305
306 mIncSearchWidget->setFocus(); 306 mIncSearchWidget->setFocus();
307 307
308 308
309 connect( mViewManager, SIGNAL( selected( const QString& ) ), 309 connect( mViewManager, SIGNAL( selected( const QString& ) ),
310 SLOT( setContactSelected( const QString& ) ) ); 310 SLOT( setContactSelected( const QString& ) ) );
311 connect( mViewManager, SIGNAL( executed( const QString& ) ), 311 connect( mViewManager, SIGNAL( executed( const QString& ) ),
312 SLOT( executeContact( const QString& ) ) ); 312 SLOT( executeContact( const QString& ) ) );
313 313
314 connect( mViewManager, SIGNAL( deleteRequest( ) ), 314 connect( mViewManager, SIGNAL( deleteRequest( ) ),
315 SLOT( deleteContacts( ) ) ); 315 SLOT( deleteContacts( ) ) );
316 connect( mViewManager, SIGNAL( modified() ), 316 connect( mViewManager, SIGNAL( modified() ),
317 SLOT( setModified() ) ); 317 SLOT( setModified() ) );
318 318
319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
321 321
322 connect( mXXPortManager, SIGNAL( modified() ), 322 connect( mXXPortManager, SIGNAL( modified() ),
323 SLOT( setModified() ) ); 323 SLOT( setModified() ) );
324 324
325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
326 SLOT( incrementalSearch( const QString& ) ) ); 326 SLOT( incrementalSearch( const QString& ) ) );
327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
328 mJumpButtonBar, SLOT( recreateButtons() ) ); 328 mJumpButtonBar, SLOT( recreateButtons() ) );
329 329
330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
331 SLOT( sendMail( const QString& ) ) ); 331 SLOT( sendMail( const QString& ) ) );
332 332
333 333
334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
338 338
339 339
340#ifndef KAB_EMBEDDED 340#ifndef KAB_EMBEDDED
341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
342 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 342 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
343 343
344 connect( mDetails, SIGNAL( browse( const QString& ) ), 344 connect( mDetails, SIGNAL( browse( const QString& ) ),
345 SLOT( browse( const QString& ) ) ); 345 SLOT( browse( const QString& ) ) );
346 346
347 347
348 mAddressBookService = new KAddressBookService( this ); 348 mAddressBookService = new KAddressBookService( this );
349 349
350#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
351 351
352 mMessageTimer = new QTimer( this ); 352 mMessageTimer = new QTimer( this );
353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
354 mEditorDialog = 0; 354 mEditorDialog = 0;
355 createAddresseeEditorDialog( this ); 355 createAddresseeEditorDialog( this );
356 setModified( false ); 356 setModified( false );
357 mBRdisabled = false; 357 mBRdisabled = false;
358#ifndef DESKTOP_VERSION 358#ifndef DESKTOP_VERSION
359 infrared = 0; 359 infrared = 0;
360#endif 360#endif
361 //toggleBeamReceive( ); 361 //toggleBeamReceive( );
362 //mMainWindow->toolBar()->show(); 362 //mMainWindow->toolBar()->show();
363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
364 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 364 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
365} 365}
366 366
367void KABCore::updateToolBar() 367void KABCore::updateToolBar()
368{ 368{
369 static int iii = 0; 369 static int iii = 0;
370 ++iii; 370 ++iii;
371 mMainWindow->toolBar()->repaintMe(); 371 mMainWindow->toolBar()->repaintMe();
372 if ( iii < 5 ) 372 if ( iii < 5 )
373 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 373 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
374} 374}
375KABCore::~KABCore() 375KABCore::~KABCore()
376{ 376{
377 // save(); 377 // save();
378 //saveSettings(); 378 //saveSettings();
379 //KABPrefs::instance()->writeConfig(); 379 //KABPrefs::instance()->writeConfig();
380 delete AddresseeConfig::instance(); 380 delete AddresseeConfig::instance();
381 mAddressBook = 0; 381 mAddressBook = 0;
382 KABC::StdAddressBook::close(); 382 KABC::StdAddressBook::close();
383 383
384 delete syncManager; 384 delete syncManager;
385#ifndef DESKTOP_VERSION 385#ifndef DESKTOP_VERSION
386 if ( infrared ) 386 if ( infrared )
387 delete infrared; 387 delete infrared;
388#endif 388#endif
389} 389}
390void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 390void KABCore::receive( const QCString& cmsg, const QByteArray& data )
391{ 391{
392 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 392 qDebug("KA: QCOP message received: %s ", cmsg.data() );
393 if ( cmsg == "setDocument(QString)" ) { 393 if ( cmsg == "setDocument(QString)" ) {
394 QDataStream stream( data, IO_ReadOnly ); 394 QDataStream stream( data, IO_ReadOnly );
395 QString fileName; 395 QString fileName;
396 stream >> fileName; 396 stream >> fileName;
397 recieve( fileName ); 397 recieve( fileName );
398 return; 398 return;
399 } 399 }
400} 400}
401void KABCore::toggleBeamReceive( ) 401void KABCore::toggleBeamReceive( )
402{ 402{
403 if ( mBRdisabled ) 403 if ( mBRdisabled )
404 return; 404 return;
405#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
406 if ( infrared ) { 406 if ( infrared ) {
407 qDebug("AB disable BeamReceive "); 407 qDebug("AB disable BeamReceive ");
408 delete infrared; 408 delete infrared;
409 infrared = 0; 409 infrared = 0;
410 mActionBR->setChecked(false); 410 mActionBR->setChecked(false);
411 return; 411 return;
412 } 412 }
413 qDebug("AB enable BeamReceive "); 413 qDebug("AB enable BeamReceive ");
414 mActionBR->setChecked(true); 414 mActionBR->setChecked(true);
415 415
416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
418#endif 418#endif
419} 419}
420 420
421 421
422void KABCore::disableBR(bool b) 422void KABCore::disableBR(bool b)
423{ 423{
424#ifndef DESKTOP_VERSION 424#ifndef DESKTOP_VERSION
425 if ( b ) { 425 if ( b ) {
426 if ( infrared ) { 426 if ( infrared ) {
427 toggleBeamReceive( ); 427 toggleBeamReceive( );
428 } 428 }
429 mBRdisabled = true; 429 mBRdisabled = true;
430 } else { 430 } else {
431 if ( mBRdisabled ) { 431 if ( mBRdisabled ) {
432 mBRdisabled = false; 432 mBRdisabled = false;
433 //toggleBeamReceive( ); 433 //toggleBeamReceive( );
434 } 434 }
435 } 435 }
436#endif 436#endif
437 437
438} 438}
439void KABCore::recieve( QString fn ) 439void KABCore::recieve( QString fn )
440{ 440{
441 //qDebug("KABCore::recieve "); 441 //qDebug("KABCore::recieve ");
442 int count = mAddressBook->importFromFile( fn, true ); 442 int count = mAddressBook->importFromFile( fn, true );
443 if ( count ) 443 if ( count )
444 setModified( true ); 444 setModified( true );
445 mViewManager->refreshView(); 445 mViewManager->refreshView();
446 message(i18n("%1 contact(s) received!").arg( count )); 446 message(i18n("%1 contact(s) received!").arg( count ));
447 topLevelWidget()->showMaximized(); 447 topLevelWidget()->showMaximized();
448 topLevelWidget()->raise(); 448 topLevelWidget()->raise();
449} 449}
450void KABCore::restoreSettings() 450void KABCore::restoreSettings()
451{ 451{
452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
453 453
454 bool state; 454 bool state;
455 455
456 if (mMultipleViewsAtOnce) 456 if (mMultipleViewsAtOnce)
457 state = KABPrefs::instance()->mDetailsPageVisible; 457 state = KABPrefs::instance()->mDetailsPageVisible;
458 else 458 else
459 state = false; 459 state = false;
460 460
461 mActionDetails->setChecked( state ); 461 mActionDetails->setChecked( state );
462 setDetailsVisible( state ); 462 setDetailsVisible( state );
463 463
464 state = KABPrefs::instance()->mJumpButtonBarVisible; 464 state = KABPrefs::instance()->mJumpButtonBarVisible;
465 465
466 mActionJumpBar->setChecked( state ); 466 mActionJumpBar->setChecked( state );
467 setJumpButtonBarVisible( state ); 467 setJumpButtonBarVisible( state );
468/*US 468/*US
469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
470 if ( splitterSize.count() == 0 ) { 470 if ( splitterSize.count() == 0 ) {
471 splitterSize.append( width() / 2 ); 471 splitterSize.append( width() / 2 );
472 splitterSize.append( width() / 2 ); 472 splitterSize.append( width() / 2 );
473 } 473 }
474 mMiniSplitter->setSizes( splitterSize ); 474 mMiniSplitter->setSizes( splitterSize );
475 if ( mExtensionBarSplitter ) { 475 if ( mExtensionBarSplitter ) {
476 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 476 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
477 if ( splitterSize.count() == 0 ) { 477 if ( splitterSize.count() == 0 ) {
478 splitterSize.append( width() / 2 ); 478 splitterSize.append( width() / 2 );
479 splitterSize.append( width() / 2 ); 479 splitterSize.append( width() / 2 );
480 } 480 }
481 mExtensionBarSplitter->setSizes( splitterSize ); 481 mExtensionBarSplitter->setSizes( splitterSize );
482 482
483 } 483 }
484*/ 484*/
485 mViewManager->restoreSettings(); 485 mViewManager->restoreSettings();
486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
487 mExtensionManager->restoreSettings(); 487 mExtensionManager->restoreSettings();
488#ifdef DESKTOP_VERSION 488#ifdef DESKTOP_VERSION
489 int wid = width(); 489 int wid = width();
490 if ( wid < 10 ) 490 if ( wid < 10 )
491 wid = 400; 491 wid = 400;
492#else 492#else
493 int wid = QApplication::desktop()->width(); 493 int wid = QApplication::desktop()->width();
494 if ( wid < 640 ) 494 if ( wid < 640 )
495 wid = QApplication::desktop()->height(); 495 wid = QApplication::desktop()->height();
496#endif 496#endif
497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
498 if ( true /*splitterSize.count() == 0*/ ) { 498 if ( true /*splitterSize.count() == 0*/ ) {
499 splitterSize.append( wid / 2 ); 499 splitterSize.append( wid / 2 );
500 splitterSize.append( wid / 2 ); 500 splitterSize.append( wid / 2 );
501 } 501 }
502 mMiniSplitter->setSizes( splitterSize ); 502 mMiniSplitter->setSizes( splitterSize );
503 if ( mExtensionBarSplitter ) { 503 if ( mExtensionBarSplitter ) {
504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
505 if ( true /*splitterSize.count() == 0*/ ) { 505 if ( true /*splitterSize.count() == 0*/ ) {
506 splitterSize.append( wid / 2 ); 506 splitterSize.append( wid / 2 );
507 splitterSize.append( wid / 2 ); 507 splitterSize.append( wid / 2 );
508 } 508 }
509 mExtensionBarSplitter->setSizes( splitterSize ); 509 mExtensionBarSplitter->setSizes( splitterSize );
510 510
511 } 511 }
512 512
513 513
514} 514}
515 515
516void KABCore::saveSettings() 516void KABCore::saveSettings()
517{ 517{
518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
519 if ( mExtensionBarSplitter ) 519 if ( mExtensionBarSplitter )
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
523#ifndef KAB_EMBEDDED 523#ifndef KAB_EMBEDDED
524 524
525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
527#endif //KAB_EMBEDDED 527#endif //KAB_EMBEDDED
528 mExtensionManager->saveSettings(); 528 mExtensionManager->saveSettings();
529 mViewManager->saveSettings(); 529 mViewManager->saveSettings();
530 530
531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
532} 532}
533 533
534KABC::AddressBook *KABCore::addressBook() const 534KABC::AddressBook *KABCore::addressBook() const
535{ 535{
536 return mAddressBook; 536 return mAddressBook;
537} 537}
538 538
539KConfig *KABCore::config() 539KConfig *KABCore::config()
540{ 540{
541#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
542 return KABPrefs::instance()->config(); 542 return KABPrefs::instance()->config();
543#else //KAB_EMBEDDED 543#else //KAB_EMBEDDED
544 return KABPrefs::instance()->getConfig(); 544 return KABPrefs::instance()->getConfig();
545#endif //KAB_EMBEDDED 545#endif //KAB_EMBEDDED
546} 546}
547 547
548KActionCollection *KABCore::actionCollection() const 548KActionCollection *KABCore::actionCollection() const
549{ 549{
550 return mGUIClient->actionCollection(); 550 return mGUIClient->actionCollection();
551} 551}
552 552
553KABC::Field *KABCore::currentSearchField() const 553KABC::Field *KABCore::currentSearchField() const
554{ 554{
555 if (mIncSearchWidget) 555 if (mIncSearchWidget)
556 return mIncSearchWidget->currentField(); 556 return mIncSearchWidget->currentField();
557 else 557 else
558 return 0; 558 return 0;
559} 559}
560 560
561QStringList KABCore::selectedUIDs() const 561QStringList KABCore::selectedUIDs() const
562{ 562{
563 return mViewManager->selectedUids(); 563 return mViewManager->selectedUids();
564} 564}
565 565
566KABC::Resource *KABCore::requestResource( QWidget *parent ) 566KABC::Resource *KABCore::requestResource( QWidget *parent )
567{ 567{
568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
569 569
570 QPtrList<KRES::Resource> kresResources; 570 QPtrList<KRES::Resource> kresResources;
571 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 571 QPtrListIterator<KABC::Resource> resIt( kabcResources );
572 KABC::Resource *resource; 572 KABC::Resource *resource;
573 while ( ( resource = resIt.current() ) != 0 ) { 573 while ( ( resource = resIt.current() ) != 0 ) {
574 ++resIt; 574 ++resIt;
575 if ( !resource->readOnly() ) { 575 if ( !resource->readOnly() ) {
576 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 576 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
577 if ( res ) 577 if ( res )
578 kresResources.append( res ); 578 kresResources.append( res );
579 } 579 }
580 } 580 }
581 581
582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
583 return static_cast<KABC::Resource*>( res ); 583 return static_cast<KABC::Resource*>( res );
584} 584}
585 585
586#ifndef KAB_EMBEDDED 586#ifndef KAB_EMBEDDED
587KAboutData *KABCore::createAboutData() 587KAboutData *KABCore::createAboutData()
588#else //KAB_EMBEDDED 588#else //KAB_EMBEDDED
589void KABCore::createAboutData() 589void KABCore::createAboutData()
590#endif //KAB_EMBEDDED 590#endif //KAB_EMBEDDED
591{ 591{
592#ifndef KAB_EMBEDDED 592#ifndef KAB_EMBEDDED
593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
594 "3.1", I18N_NOOP( "The KDE Address Book" ), 594 "3.1", I18N_NOOP( "The KDE Address Book" ),
595 KAboutData::License_GPL_V2, 595 KAboutData::License_GPL_V2,
596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
599 about->addAuthor( "Cornelius Schumacher", 599 about->addAuthor( "Cornelius Schumacher",
600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
601 "schumacher@kde.org" ); 601 "schumacher@kde.org" );
602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
603 "mpilone@slac.com" ); 603 "mpilone@slac.com" );
604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
607 "michel@klaralvdalens-datakonsult.se" ); 607 "michel@klaralvdalens-datakonsult.se" );
608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
609 "hansen@kde.org" ); 609 "hansen@kde.org" );
610 610
611 return about; 611 return about;
612#endif //KAB_EMBEDDED 612#endif //KAB_EMBEDDED
613 613
614 QString version; 614 QString version;
615#include <../version> 615#include <../version>
616 QMessageBox::about( this, "About KAddressbook/Pi", 616 QMessageBox::about( this, "About KAddressbook/Pi",
617 "KAddressbook/Platform-independent\n" 617 "KAddressbook/Platform-independent\n"
618 "(KA/Pi) " +version + " - " + 618 "(KA/Pi) " +version + " - " +
619#ifdef DESKTOP_VERSION 619#ifdef DESKTOP_VERSION
620 "Desktop Edition\n" 620 "Desktop Edition\n"
621#else 621#else
622 "PDA-Edition\n" 622 "PDA-Edition\n"
623 "for: Zaurus 5500 / 7x0 / 8x0\n" 623 "for: Zaurus 5500 / 7x0 / 8x0\n"
624#endif 624#endif
625 625
626 "(c) 2004 Ulf Schenk\n" 626 "(c) 2004 Ulf Schenk\n"
627 "(c) 2004 Lutz Rogowski\n" 627 "(c) 2004 Lutz Rogowski\n"
628 "(c) 1997-2003, The KDE PIM Team\n" 628 "(c) 1997-2003, The KDE PIM Team\n"
629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
630 "Don Sanders Original author\n" 630 "Don Sanders Original author\n"
631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
633 "Greg Stern DCOP interface\n" 633 "Greg Stern DCOP interface\n"
634 "Mark Westcot Contact pinning\n" 634 "Mark Westcot Contact pinning\n"
635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
637#ifdef _WIN32_ 637#ifdef _WIN32_
638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
639#endif 639#endif
640 ); 640 );
641} 641}
642 642
643void KABCore::setContactSelected( const QString &uid ) 643void KABCore::setContactSelected( const QString &uid )
644{ 644{
645 KABC::Addressee addr = mAddressBook->findByUid( uid ); 645 KABC::Addressee addr = mAddressBook->findByUid( uid );
646 if ( !mDetails->isHidden() ) 646 if ( !mDetails->isHidden() )
647 mDetails->setAddressee( addr ); 647 mDetails->setAddressee( addr );
648 648
649 if ( !addr.isEmpty() ) { 649 if ( !addr.isEmpty() ) {
650 emit contactSelected( addr.formattedName() ); 650 emit contactSelected( addr.formattedName() );
651 KABC::Picture pic = addr.photo(); 651 KABC::Picture pic = addr.photo();
652 if ( pic.isIntern() ) { 652 if ( pic.isIntern() ) {
653//US emit contactSelected( pic.data() ); 653//US emit contactSelected( pic.data() );
654//US instead use: 654//US instead use:
655 QPixmap px; 655 QPixmap px;
656 if (pic.data().isNull() != true) 656 if (pic.data().isNull() != true)
657 { 657 {
658 px.convertFromImage(pic.data()); 658 px.convertFromImage(pic.data());
659 } 659 }
660 660
661 emit contactSelected( px ); 661 emit contactSelected( px );
662 } 662 }
663 } 663 }
664 664
665 665
666 mExtensionManager->setSelectionChanged(); 666 mExtensionManager->setSelectionChanged();
667 667
668 // update the actions 668 // update the actions
669 bool selected = !uid.isEmpty(); 669 bool selected = !uid.isEmpty();
670 670
671 if ( mReadWrite ) { 671 if ( mReadWrite ) {
672 mActionCut->setEnabled( selected ); 672 mActionCut->setEnabled( selected );
673 mActionPaste->setEnabled( selected ); 673 mActionPaste->setEnabled( selected );
674 } 674 }
675 675
676 mActionCopy->setEnabled( selected ); 676 mActionCopy->setEnabled( selected );
677 mActionDelete->setEnabled( selected ); 677 mActionDelete->setEnabled( selected );
678 mActionEditAddressee->setEnabled( selected ); 678 mActionEditAddressee->setEnabled( selected );
679 mActionMail->setEnabled( selected ); 679 mActionMail->setEnabled( selected );
680 mActionMailVCard->setEnabled( selected ); 680 mActionMailVCard->setEnabled( selected );
681 //if (mActionBeam) 681 //if (mActionBeam)
682 //mActionBeam->setEnabled( selected ); 682 //mActionBeam->setEnabled( selected );
683 mActionWhoAmI->setEnabled( selected ); 683 mActionWhoAmI->setEnabled( selected );
684} 684}
685 685
686void KABCore::sendMail() 686void KABCore::sendMail()
687{ 687{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 688 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 689}
690 690
691void KABCore::sendMail( const QString& emaillist ) 691void KABCore::sendMail( const QString& emaillist )
692{ 692{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 694 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 696 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 697 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 698}
699 699
700 700
701 701
702void KABCore::mailVCard() 702void KABCore::mailVCard()
703{ 703{
704 QStringList uids = mViewManager->selectedUids(); 704 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 705 if ( !uids.isEmpty() )
706 mailVCard( uids ); 706 mailVCard( uids );
707} 707}
708 708
709void KABCore::mailVCard( const QStringList& uids ) 709void KABCore::mailVCard( const QStringList& uids )
710{ 710{
711 QStringList urls; 711 QStringList urls;
712 712
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 714
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 715 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 716
717 717
718 718
719 QDir().mkdir( dirName, true ); 719 QDir().mkdir( dirName, true );
720 720
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 722 KABC::Addressee a = mAddressBook->findByUid( *it );
723 723
724 if ( a.isEmpty() ) 724 if ( a.isEmpty() )
725 continue; 725 continue;
726 726
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 727 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 728
729 QString fileName = dirName + "/" + name; 729 QString fileName = dirName + "/" + name;
730 730
731 QFile outFile(fileName); 731 QFile outFile(fileName);
732 732
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 734 KABC::VCardConverter converter;
735 QString vcard; 735 QString vcard;
736 736
737 converter.addresseeToVCard( a, vcard ); 737 converter.addresseeToVCard( a, vcard );
738 738
739 QTextStream t( &outFile ); // use a text stream 739 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 740 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 741 t << vcard;
742 742
743 outFile.close(); 743 outFile.close();
744 744
745 urls.append( fileName ); 745 urls.append( fileName );
746 } 746 }
747 } 747 }
748 748
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 750
751 751
752/*US 752/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 753 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 754 QString::null, // subject
755 QString::null, // body 755 QString::null, // body
756 QString::null, 756 QString::null,
757 urls ); // attachments 757 urls ); // attachments
758*/ 758*/
759 759
760} 760}
761 761
762/** 762/**
763 Beams the "WhoAmI contact. 763 Beams the "WhoAmI contact.
764*/ 764*/
765void KABCore::beamMySelf() 765void KABCore::beamMySelf()
766{ 766{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 768 if (!a.isEmpty())
769 { 769 {
770 QStringList uids; 770 QStringList uids;
771 uids << a.uid(); 771 uids << a.uid();
772 772
773 beamVCard(uids); 773 beamVCard(uids);
774 } else { 774 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 776
777 777
778 } 778 }
779} 779}
780void KABCore::updateMainWindow() 780void KABCore::updateMainWindow()
781{ 781{
782 782
783 mMainWindow->showMaximized(); 783 mMainWindow->showMaximized();
784 mMainWindow->update(); 784 mMainWindow->update();
785} 785}
786void KABCore::resizeEvent(QResizeEvent* e ) 786void KABCore::resizeEvent(QResizeEvent* e )
787{ 787{
788 if ( !mMiniSplitter ) 788 if ( !mMiniSplitter )
789 return; 789 return;
790 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
790 if ( QApplication::desktop()->width() >= 480 ) { 791 if ( QApplication::desktop()->width() >= 480 ) {
791 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 792 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
792 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 793 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
793 mMiniSplitter->setOrientation( Qt::Horizontal); 794 mMiniSplitter->setOrientation( Qt::Horizontal);
794 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
795 if ( QApplication::desktop()->width() <= 640 ) { 796 if ( QApplication::desktop()->width() <= 640 ) {
796 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 797 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
797 mViewManager->getFilterAction()->setComboWidth( 150 ); 798 mViewManager->getFilterAction()->setComboWidth( 150 );
798 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 799 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
799 } 800 }
800 } 801 }
801 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 802 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
802 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 803 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
803 mMiniSplitter->setOrientation( Qt::Vertical ); 804 mMiniSplitter->setOrientation( Qt::Vertical );
804 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 805 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
805 if ( QApplication::desktop()->width() <= 640 ) { 806 if ( QApplication::desktop()->width() <= 640 ) {
806 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 807 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
807 mMainWindow->showMinimized(); 808 mMainWindow->showMinimized();
808 mViewManager->getFilterAction()->setComboWidth( 0 ); 809 mViewManager->getFilterAction()->setComboWidth( 0 );
809 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 810 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
810 } 811 }
811 } 812 }
812 } 813 }
813 } 814 }
814 815
815} 816}
816void KABCore::export2phone() 817void KABCore::export2phone()
817{ 818{
818 819
819 QStringList uids; 820 QStringList uids;
820 XXPortSelectDialog dlg( this, false, this ); 821 XXPortSelectDialog dlg( this, false, this );
821 if ( dlg.exec() ) 822 if ( dlg.exec() )
822 uids = dlg.uids(); 823 uids = dlg.uids();
823 else 824 else
824 return; 825 return;
825 if ( uids.isEmpty() ) 826 if ( uids.isEmpty() )
826 return; 827 return;
827 // qDebug("count %d ", uids.count()); 828 // qDebug("count %d ", uids.count());
828 829
829 KAex2phonePrefs ex2phone; 830 KAex2phonePrefs ex2phone;
830 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 831 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
831 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 832 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
832 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 833 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
833 834
834 if ( !ex2phone.exec() ) { 835 if ( !ex2phone.exec() ) {
835 return; 836 return;
836 } 837 }
837 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 838 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
838 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 839 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
839 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 840 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
840 841
841 842
842 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 843 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
843 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 844 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
844 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 845 KPimGlobalPrefs::instance()->mEx2PhoneModel );
845 846
846 QString fileName = getPhoneFile(); 847 QString fileName = getPhoneFile();
847 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 848 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
848 return; 849 return;
849 850
850 message(i18n("Exporting to phone...")); 851 message(i18n("Exporting to phone..."));
851 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 852 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
852 853
853} 854}
854QString KABCore::getPhoneFile() 855QString KABCore::getPhoneFile()
855{ 856{
856#ifdef DESKTOP_VERSION 857#ifdef DESKTOP_VERSION
857 return locateLocal("tmp", "phonefile.vcf"); 858 return locateLocal("tmp", "phonefile.vcf");
858#else 859#else
859 return "/tmp/phonefile.vcf"; 860 return "/tmp/phonefile.vcf";
860#endif 861#endif
861 862
862} 863}
863void KABCore::writeToPhone( ) 864void KABCore::writeToPhone( )
864{ 865{
865 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 866 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
866 message(i18n("Export to phone finished!")); 867 message(i18n("Export to phone finished!"));
867 else 868 else
868 qDebug(i18n("Error exporting to phone")); 869 qDebug(i18n("Error exporting to phone"));
869} 870}
870void KABCore::beamVCard() 871void KABCore::beamVCard()
871{ 872{
872 QStringList uids; 873 QStringList uids;
873 XXPortSelectDialog dlg( this, false, this ); 874 XXPortSelectDialog dlg( this, false, this );
874 if ( dlg.exec() ) 875 if ( dlg.exec() )
875 uids = dlg.uids(); 876 uids = dlg.uids();
876 else 877 else
877 return; 878 return;
878 if ( uids.isEmpty() ) 879 if ( uids.isEmpty() )
879 return; 880 return;
880 beamVCard( uids ); 881 beamVCard( uids );
881} 882}
882 883
883 884
884void KABCore::beamVCard(const QStringList& uids) 885void KABCore::beamVCard(const QStringList& uids)
885{ 886{
886 887
887 // LR: we should use the /tmp dir on the Zaurus, 888 // LR: we should use the /tmp dir on the Zaurus,
888 // because: /tmp = RAM, (HOME)/kdepim = flash memory 889 // because: /tmp = RAM, (HOME)/kdepim = flash memory
889 890
890#ifdef DESKTOP_VERSION 891#ifdef DESKTOP_VERSION
891 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 892 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
892#else 893#else
893 QString fileName = "/tmp/kapibeamfile.vcf"; 894 QString fileName = "/tmp/kapibeamfile.vcf";
894#endif 895#endif
895 896
896 KABC::VCardConverter converter; 897 KABC::VCardConverter converter;
897 QString description; 898 QString description;
898 QString datastream; 899 QString datastream;
899 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 900 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
900 KABC::Addressee a = mAddressBook->findByUid( *it ); 901 KABC::Addressee a = mAddressBook->findByUid( *it );
901 902
902 if ( a.isEmpty() ) 903 if ( a.isEmpty() )
903 continue; 904 continue;
904 905
905 if (description.isEmpty()) 906 if (description.isEmpty())
906 description = a.formattedName(); 907 description = a.formattedName();
907 908
908 QString vcard; 909 QString vcard;
909 converter.addresseeToVCard( a, vcard ); 910 converter.addresseeToVCard( a, vcard );
910 int start = 0; 911 int start = 0;
911 int next; 912 int next;
912 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 913 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
913 int semi = vcard.find(";", next); 914 int semi = vcard.find(";", next);
914 int dopp = vcard.find(":", next); 915 int dopp = vcard.find(":", next);
915 int sep; 916 int sep;
916 if ( semi < dopp && semi >= 0 ) 917 if ( semi < dopp && semi >= 0 )
917 sep = semi ; 918 sep = semi ;
918 else 919 else
919 sep = dopp; 920 sep = dopp;
920 datastream +=vcard.mid( start, next - start); 921 datastream +=vcard.mid( start, next - start);
921 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 922 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
922 start = sep; 923 start = sep;
923 } 924 }
924 datastream += vcard.mid( start,vcard.length() ); 925 datastream += vcard.mid( start,vcard.length() );
925 } 926 }
926#ifndef DESKTOP_VERSION 927#ifndef DESKTOP_VERSION
927 QFile outFile(fileName); 928 QFile outFile(fileName);
928 if ( outFile.open(IO_WriteOnly) ) { 929 if ( outFile.open(IO_WriteOnly) ) {
929 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 930 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
930 QTextStream t( &outFile ); // use a text stream 931 QTextStream t( &outFile ); // use a text stream
931 //t.setEncoding( QTextStream::UnicodeUTF8 ); 932 //t.setEncoding( QTextStream::UnicodeUTF8 );
932 t.setEncoding( QTextStream::Latin1 ); 933 t.setEncoding( QTextStream::Latin1 );
933 t <<datastream.latin1(); 934 t <<datastream.latin1();
934 outFile.close(); 935 outFile.close();
935 Ir *ir = new Ir( this ); 936 Ir *ir = new Ir( this );
936 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 937 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
937 ir->send( fileName, description, "text/x-vCard" ); 938 ir->send( fileName, description, "text/x-vCard" );
938 } else { 939 } else {
939 qDebug("Error open temp beam file "); 940 qDebug("Error open temp beam file ");
940 return; 941 return;
941 } 942 }
942#endif 943#endif
943 944
944} 945}
945 946
946void KABCore::beamDone( Ir *ir ) 947void KABCore::beamDone( Ir *ir )
947{ 948{
948#ifndef DESKTOP_VERSION 949#ifndef DESKTOP_VERSION
949 delete ir; 950 delete ir;
950#endif 951#endif
951 topLevelWidget()->raise(); 952 topLevelWidget()->raise();
952 message( i18n("Beaming finished!") ); 953 message( i18n("Beaming finished!") );
953} 954}
954 955
955 956
956void KABCore::browse( const QString& url ) 957void KABCore::browse( const QString& url )
957{ 958{
958#ifndef KAB_EMBEDDED 959#ifndef KAB_EMBEDDED
959 kapp->invokeBrowser( url ); 960 kapp->invokeBrowser( url );
960#else //KAB_EMBEDDED 961#else //KAB_EMBEDDED
961 qDebug("KABCore::browse must be fixed"); 962 qDebug("KABCore::browse must be fixed");
962#endif //KAB_EMBEDDED 963#endif //KAB_EMBEDDED
963} 964}
964 965
965void KABCore::selectAllContacts() 966void KABCore::selectAllContacts()
966{ 967{
967 mViewManager->setSelected( QString::null, true ); 968 mViewManager->setSelected( QString::null, true );
968} 969}
969 970
970void KABCore::deleteContacts() 971void KABCore::deleteContacts()
971{ 972{
972 QStringList uidList = mViewManager->selectedUids(); 973 QStringList uidList = mViewManager->selectedUids();
973 deleteContacts( uidList ); 974 deleteContacts( uidList );
974} 975}
975 976
976void KABCore::deleteContacts( const QStringList &uids ) 977void KABCore::deleteContacts( const QStringList &uids )
977{ 978{
978 if ( uids.count() > 0 ) { 979 if ( uids.count() > 0 ) {
979 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 980 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
980 UndoStack::instance()->push( command ); 981 UndoStack::instance()->push( command );
981 RedoStack::instance()->clear(); 982 RedoStack::instance()->clear();
982 983
983 // now if we deleted anything, refresh 984 // now if we deleted anything, refresh
984 setContactSelected( QString::null ); 985 setContactSelected( QString::null );
985 setModified( true ); 986 setModified( true );
986 } 987 }
987} 988}
988 989
989void KABCore::copyContacts() 990void KABCore::copyContacts()
990{ 991{
991 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 992 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
992 993
993 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 994 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
994 995
995 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 996 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
996 997
997 QClipboard *cb = QApplication::clipboard(); 998 QClipboard *cb = QApplication::clipboard();
998 cb->setText( clipText ); 999 cb->setText( clipText );
999} 1000}
1000 1001
1001void KABCore::cutContacts() 1002void KABCore::cutContacts()
1002{ 1003{
1003 QStringList uidList = mViewManager->selectedUids(); 1004 QStringList uidList = mViewManager->selectedUids();
1004 1005
1005//US if ( uidList.size() > 0 ) { 1006//US if ( uidList.size() > 0 ) {
1006 if ( uidList.count() > 0 ) { 1007 if ( uidList.count() > 0 ) {
1007 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1008 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1008 UndoStack::instance()->push( command ); 1009 UndoStack::instance()->push( command );
1009 RedoStack::instance()->clear(); 1010 RedoStack::instance()->clear();
1010 1011
1011 setModified( true ); 1012 setModified( true );
1012 } 1013 }
1013} 1014}
1014 1015
1015void KABCore::pasteContacts() 1016void KABCore::pasteContacts()
1016{ 1017{
1017 QClipboard *cb = QApplication::clipboard(); 1018 QClipboard *cb = QApplication::clipboard();
1018 1019
1019 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1020 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1020 1021
1021 pasteContacts( list ); 1022 pasteContacts( list );
1022} 1023}
1023 1024
1024void KABCore::pasteContacts( KABC::Addressee::List &list ) 1025void KABCore::pasteContacts( KABC::Addressee::List &list )
1025{ 1026{
1026 KABC::Resource *resource = requestResource( this ); 1027 KABC::Resource *resource = requestResource( this );
1027 KABC::Addressee::List::Iterator it; 1028 KABC::Addressee::List::Iterator it;
1028 for ( it = list.begin(); it != list.end(); ++it ) 1029 for ( it = list.begin(); it != list.end(); ++it )
1029 (*it).setResource( resource ); 1030 (*it).setResource( resource );
1030 1031
1031 PwPasteCommand *command = new PwPasteCommand( this, list ); 1032 PwPasteCommand *command = new PwPasteCommand( this, list );
1032 UndoStack::instance()->push( command ); 1033 UndoStack::instance()->push( command );
1033 RedoStack::instance()->clear(); 1034 RedoStack::instance()->clear();
1034 1035
1035 setModified( true ); 1036 setModified( true );
1036} 1037}
1037 1038
1038void KABCore::setWhoAmI() 1039void KABCore::setWhoAmI()
1039{ 1040{
1040 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1041 1042
1042 if ( addrList.count() > 1 ) { 1043 if ( addrList.count() > 1 ) {
1043 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1044 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1044 return; 1045 return;
1045 } 1046 }
1046 1047
1047 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1048 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1048 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1049 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1049 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1050 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1050} 1051}
1051void KABCore::editCategories() 1052void KABCore::editCategories()
1052{ 1053{
1053 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1054 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1054 dlg.exec(); 1055 dlg.exec();
1055} 1056}
1056void KABCore::setCategories() 1057void KABCore::setCategories()
1057{ 1058{
1058 1059
1059 QStringList uids; 1060 QStringList uids;
1060 XXPortSelectDialog dlgx( this, false, this ); 1061 XXPortSelectDialog dlgx( this, false, this );
1061 if ( dlgx.exec() ) 1062 if ( dlgx.exec() )
1062 uids = dlgx.uids(); 1063 uids = dlgx.uids();
1063 else 1064 else
1064 return; 1065 return;
1065 if ( uids.isEmpty() ) 1066 if ( uids.isEmpty() )
1066 return; 1067 return;
1067 // qDebug("count %d ", uids.count()); 1068 // qDebug("count %d ", uids.count());
1068 1069
1069 1070
1070 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1071 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1071 if ( !dlg.exec() ) { 1072 if ( !dlg.exec() ) {
1072 message( i18n("Setting categories cancelled") ); 1073 message( i18n("Setting categories cancelled") );
1073 return; 1074 return;
1074 } 1075 }
1075 bool merge = false; 1076 bool merge = false;
1076 QString msg = i18n( "Merge with existing categories?" ); 1077 QString msg = i18n( "Merge with existing categories?" );
1077 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1078 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1078 merge = true; 1079 merge = true;
1079 1080
1080 message( i18n("Setting categories ... please wait!") ); 1081 message( i18n("Setting categories ... please wait!") );
1081 QStringList categories = dlg.selectedCategories(); 1082 QStringList categories = dlg.selectedCategories();
1082 1083
1083 //QStringList uids = mViewManager->selectedUids(); 1084 //QStringList uids = mViewManager->selectedUids();
1084 QStringList::Iterator it; 1085 QStringList::Iterator it;
1085 for ( it = uids.begin(); it != uids.end(); ++it ) { 1086 for ( it = uids.begin(); it != uids.end(); ++it ) {
1086 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1087 KABC::Addressee addr = mAddressBook->findByUid( *it );
1087 if ( !addr.isEmpty() ) { 1088 if ( !addr.isEmpty() ) {
1088 if ( !merge ) 1089 if ( !merge )
1089 addr.setCategories( categories ); 1090 addr.setCategories( categories );
1090 else { 1091 else {
1091 QStringList addrCategories = addr.categories(); 1092 QStringList addrCategories = addr.categories();
1092 QStringList::Iterator catIt; 1093 QStringList::Iterator catIt;
1093 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1094 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1094 if ( !addrCategories.contains( *catIt ) ) 1095 if ( !addrCategories.contains( *catIt ) )
1095 addrCategories.append( *catIt ); 1096 addrCategories.append( *catIt );
1096 } 1097 }
1097 addr.setCategories( addrCategories ); 1098 addr.setCategories( addrCategories );
1098 } 1099 }
1099 mAddressBook->insertAddressee( addr ); 1100 mAddressBook->insertAddressee( addr );
1100 } 1101 }
1101 } 1102 }
1102 1103
1103 if ( uids.count() > 0 ) 1104 if ( uids.count() > 0 )
1104 setModified( true ); 1105 setModified( true );
1105 message( i18n("Setting categories completed!") ); 1106 message( i18n("Setting categories completed!") );
1106} 1107}
1107 1108
1108void KABCore::setSearchFields( const KABC::Field::List &fields ) 1109void KABCore::setSearchFields( const KABC::Field::List &fields )
1109{ 1110{
1110 mIncSearchWidget->setFields( fields ); 1111 mIncSearchWidget->setFields( fields );
1111} 1112}
1112 1113
1113void KABCore::incrementalSearch( const QString& text ) 1114void KABCore::incrementalSearch( const QString& text )
1114{ 1115{
1115 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1116 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1116} 1117}
1117 1118
1118void KABCore::setModified() 1119void KABCore::setModified()
1119{ 1120{
1120 setModified( true ); 1121 setModified( true );
1121} 1122}
1122 1123
1123void KABCore::setModifiedWOrefresh() 1124void KABCore::setModifiedWOrefresh()
1124{ 1125{
1125 // qDebug("KABCore::setModifiedWOrefresh() "); 1126 // qDebug("KABCore::setModifiedWOrefresh() ");
1126 mModified = true; 1127 mModified = true;
1127 mActionSave->setEnabled( mModified ); 1128 mActionSave->setEnabled( mModified );
1128#ifdef DESKTOP_VERSION 1129#ifdef DESKTOP_VERSION
1129 mDetails->refreshView(); 1130 mDetails->refreshView();
1130#endif 1131#endif
1131 1132
1132} 1133}
1133void KABCore::setModified( bool modified ) 1134void KABCore::setModified( bool modified )
1134{ 1135{
1135 mModified = modified; 1136 mModified = modified;
1136 mActionSave->setEnabled( mModified ); 1137 mActionSave->setEnabled( mModified );
1137 1138
1138 if ( modified ) 1139 if ( modified )
1139 mJumpButtonBar->recreateButtons(); 1140 mJumpButtonBar->recreateButtons();
1140 1141
1141 mViewManager->refreshView(); 1142 mViewManager->refreshView();
1142 mDetails->refreshView(); 1143 mDetails->refreshView();
1143 1144
1144} 1145}
1145 1146
1146bool KABCore::modified() const 1147bool KABCore::modified() const
1147{ 1148{
1148 return mModified; 1149 return mModified;
1149} 1150}
1150 1151
1151void KABCore::contactModified( const KABC::Addressee &addr ) 1152void KABCore::contactModified( const KABC::Addressee &addr )
1152{ 1153{
1153 1154
1154 Command *command = 0; 1155 Command *command = 0;
1155 QString uid; 1156 QString uid;
1156 1157
1157 // check if it exists already 1158 // check if it exists already
1158 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1159 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1159 if ( origAddr.isEmpty() ) 1160 if ( origAddr.isEmpty() )
1160 command = new PwNewCommand( mAddressBook, addr ); 1161 command = new PwNewCommand( mAddressBook, addr );
1161 else { 1162 else {
1162 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1163 command = new PwEditCommand( mAddressBook, origAddr, addr );
1163 uid = addr.uid(); 1164 uid = addr.uid();
1164 } 1165 }
1165 1166
1166 UndoStack::instance()->push( command ); 1167 UndoStack::instance()->push( command );
1167 RedoStack::instance()->clear(); 1168 RedoStack::instance()->clear();
1168 1169
1169 setModified( true ); 1170 setModified( true );
1170} 1171}
1171 1172
1172void KABCore::newContact() 1173void KABCore::newContact()
1173{ 1174{
1174 1175
1175 1176
1176 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1177 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1177 1178
1178 QPtrList<KRES::Resource> kresResources; 1179 QPtrList<KRES::Resource> kresResources;
1179 QPtrListIterator<KABC::Resource> it( kabcResources ); 1180 QPtrListIterator<KABC::Resource> it( kabcResources );
1180 KABC::Resource *resource; 1181 KABC::Resource *resource;
1181 while ( ( resource = it.current() ) != 0 ) { 1182 while ( ( resource = it.current() ) != 0 ) {
1182 ++it; 1183 ++it;
1183 if ( !resource->readOnly() ) { 1184 if ( !resource->readOnly() ) {
1184 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1185 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1185 if ( res ) 1186 if ( res )
1186 kresResources.append( res ); 1187 kresResources.append( res );
1187 } 1188 }
1188 } 1189 }
1189 1190
1190 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1191 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1191 resource = static_cast<KABC::Resource*>( res ); 1192 resource = static_cast<KABC::Resource*>( res );
1192 1193
1193 if ( resource ) { 1194 if ( resource ) {
1194 KABC::Addressee addr; 1195 KABC::Addressee addr;
1195 addr.setResource( resource ); 1196 addr.setResource( resource );
1196 mEditorDialog->setAddressee( addr ); 1197 mEditorDialog->setAddressee( addr );
1197 KApplication::execDialog ( mEditorDialog ); 1198 KApplication::execDialog ( mEditorDialog );
1198 1199
1199 } else 1200 } else
1200 return; 1201 return;
1201 1202
1202 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1203 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1203 1204
1204 1205
1205} 1206}
1206 1207
1207void KABCore::addEmail( QString aStr ) 1208void KABCore::addEmail( QString aStr )
1208{ 1209{
1209#ifndef KAB_EMBEDDED 1210#ifndef KAB_EMBEDDED
1210 QString fullName, email; 1211 QString fullName, email;
1211 1212
1212 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1213 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1213 1214
1214 // Try to lookup the addressee matching the email address 1215 // Try to lookup the addressee matching the email address
1215 bool found = false; 1216 bool found = false;
1216 QStringList emailList; 1217 QStringList emailList;
1217 KABC::AddressBook::Iterator it; 1218 KABC::AddressBook::Iterator it;
1218 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1219 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1219 emailList = (*it).emails(); 1220 emailList = (*it).emails();
1220 if ( emailList.contains( email ) > 0 ) { 1221 if ( emailList.contains( email ) > 0 ) {
1221 found = true; 1222 found = true;
1222 (*it).setNameFromString( fullName ); 1223 (*it).setNameFromString( fullName );
1223 editContact( (*it).uid() ); 1224 editContact( (*it).uid() );
1224 } 1225 }
1225 } 1226 }
1226 1227
1227 if ( !found ) { 1228 if ( !found ) {
1228 KABC::Addressee addr; 1229 KABC::Addressee addr;
1229 addr.setNameFromString( fullName ); 1230 addr.setNameFromString( fullName );
1230 addr.insertEmail( email, true ); 1231 addr.insertEmail( email, true );
1231 1232
1232 mAddressBook->insertAddressee( addr ); 1233 mAddressBook->insertAddressee( addr );
1233 mViewManager->refreshView( addr.uid() ); 1234 mViewManager->refreshView( addr.uid() );
1234 editContact( addr.uid() ); 1235 editContact( addr.uid() );
1235 } 1236 }
1236#else //KAB_EMBEDDED 1237#else //KAB_EMBEDDED
1237 qDebug("KABCore::addEmail finsih method"); 1238 qDebug("KABCore::addEmail finsih method");
1238#endif //KAB_EMBEDDED 1239#endif //KAB_EMBEDDED
1239} 1240}
1240 1241
1241void KABCore::importVCard( const KURL &url, bool showPreview ) 1242void KABCore::importVCard( const KURL &url, bool showPreview )
1242{ 1243{
1243 mXXPortManager->importVCard( url, showPreview ); 1244 mXXPortManager->importVCard( url, showPreview );
1244} 1245}
1245void KABCore::importFromOL() 1246void KABCore::importFromOL()
1246{ 1247{
1247#ifdef _WIN32_ 1248#ifdef _WIN32_
1248 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1249 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1249 idgl->exec(); 1250 idgl->exec();
1250 KABC::Addressee::List list = idgl->getAddressList(); 1251 KABC::Addressee::List list = idgl->getAddressList();
1251 if ( list.count() > 0 ) { 1252 if ( list.count() > 0 ) {
1252 KABC::Addressee::List listNew; 1253 KABC::Addressee::List listNew;
1253 KABC::Addressee::List listExisting; 1254 KABC::Addressee::List listExisting;
1254 KABC::Addressee::List::Iterator it; 1255 KABC::Addressee::List::Iterator it;
1255 KABC::AddressBook::Iterator iter; 1256 KABC::AddressBook::Iterator iter;
1256 for ( it = list.begin(); it != list.end(); ++it ) { 1257 for ( it = list.begin(); it != list.end(); ++it ) {
1257 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1258 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1258 listNew.append( (*it) ); 1259 listNew.append( (*it) );
1259 else 1260 else
1260 listExisting.append( (*it) ); 1261 listExisting.append( (*it) );
1261 } 1262 }
1262 if ( listExisting.count() > 0 ) 1263 if ( listExisting.count() > 0 )
1263 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1264 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1264 if ( listNew.count() > 0 ) { 1265 if ( listNew.count() > 0 ) {
1265 pasteWithNewUid = false; 1266 pasteWithNewUid = false;
1266 pasteContacts( listNew ); 1267 pasteContacts( listNew );
1267 pasteWithNewUid = true; 1268 pasteWithNewUid = true;
1268 } 1269 }
1269 } 1270 }
1270 delete idgl; 1271 delete idgl;
1271#endif 1272#endif
1272} 1273}
1273 1274
1274void KABCore::importVCard( const QString &vCard, bool showPreview ) 1275void KABCore::importVCard( const QString &vCard, bool showPreview )
1275{ 1276{
1276 mXXPortManager->importVCard( vCard, showPreview ); 1277 mXXPortManager->importVCard( vCard, showPreview );
1277} 1278}
1278 1279
1279//US added a second method without defaultparameter 1280//US added a second method without defaultparameter
1280void KABCore::editContact2() { 1281void KABCore::editContact2() {
1281 editContact( QString::null ); 1282 editContact( QString::null );
1282} 1283}
1283 1284
1284void KABCore::editContact( const QString &uid ) 1285void KABCore::editContact( const QString &uid )
1285{ 1286{
1286 1287
1287 if ( mExtensionManager->isQuickEditVisible() ) 1288 if ( mExtensionManager->isQuickEditVisible() )
1288 return; 1289 return;
1289 1290
1290 // First, locate the contact entry 1291 // First, locate the contact entry
1291 QString localUID = uid; 1292 QString localUID = uid;
1292 if ( localUID.isNull() ) { 1293 if ( localUID.isNull() ) {
1293 QStringList uidList = mViewManager->selectedUids(); 1294 QStringList uidList = mViewManager->selectedUids();
1294 if ( uidList.count() > 0 ) 1295 if ( uidList.count() > 0 )
1295 localUID = *( uidList.at( 0 ) ); 1296 localUID = *( uidList.at( 0 ) );
1296 } 1297 }
1297 1298
1298 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1299 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1299 if ( !addr.isEmpty() ) { 1300 if ( !addr.isEmpty() ) {
1300 mEditorDialog->setAddressee( addr ); 1301 mEditorDialog->setAddressee( addr );
1301 KApplication::execDialog ( mEditorDialog ); 1302 KApplication::execDialog ( mEditorDialog );
1302 } 1303 }
1303} 1304}
1304 1305
1305/** 1306/**
1306 Shows or edits the detail view for the given uid. If the uid is QString::null, 1307 Shows or edits the detail view for the given uid. If the uid is QString::null,
1307 the method will try to find a selected addressee in the view. 1308 the method will try to find a selected addressee in the view.
1308 */ 1309 */
1309void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1310void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1310{ 1311{
1311 if ( mMultipleViewsAtOnce ) 1312 if ( mMultipleViewsAtOnce )
1312 { 1313 {
1313 editContact( uid ); 1314 editContact( uid );
1314 } 1315 }
1315 else 1316 else
1316 { 1317 {
1317 setDetailsVisible( true ); 1318 setDetailsVisible( true );
1318 mActionDetails->setChecked(true); 1319 mActionDetails->setChecked(true);
1319 } 1320 }
1320 1321
1321} 1322}
1322 1323
1323void KABCore::save() 1324void KABCore::save()
1324{ 1325{
1325 if (syncManager->blockSave()) 1326 if (syncManager->blockSave())
1326 return; 1327 return;
1327 if ( !mModified ) 1328 if ( !mModified )
1328 return; 1329 return;
1329 1330
1330 syncManager->setBlockSave(true); 1331 syncManager->setBlockSave(true);
1331 QString text = i18n( "There was an error while attempting to save\n the " 1332 QString text = i18n( "There was an error while attempting to save\n the "
1332 "address book. Please check that some \nother application is " 1333 "address book. Please check that some \nother application is "
1333 "not using it. " ); 1334 "not using it. " );
1334 message(i18n("Saving addressbook ... ")); 1335 message(i18n("Saving addressbook ... "));
1335#ifndef KAB_EMBEDDED 1336#ifndef KAB_EMBEDDED
1336 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1337 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1337 if ( !b || !b->save() ) { 1338 if ( !b || !b->save() ) {
1338 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1339 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1339 } 1340 }
1340#else //KAB_EMBEDDED 1341#else //KAB_EMBEDDED
1341 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1342 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1342 if ( !b || !b->save() ) { 1343 if ( !b || !b->save() ) {
1343 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1344 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1344 } 1345 }
1345#endif //KAB_EMBEDDED 1346#endif //KAB_EMBEDDED
1346 1347
1347 message(i18n("Addressbook saved!")); 1348 message(i18n("Addressbook saved!"));
1348 setModified( false ); 1349 setModified( false );
1349 syncManager->setBlockSave(false); 1350 syncManager->setBlockSave(false);
1350} 1351}
1351 1352
1352 1353
1353void KABCore::undo() 1354void KABCore::undo()
1354{ 1355{
1355 UndoStack::instance()->undo(); 1356 UndoStack::instance()->undo();
1356 1357
1357 // Refresh the view 1358 // Refresh the view
1358 mViewManager->refreshView(); 1359 mViewManager->refreshView();
1359} 1360}
1360 1361
1361void KABCore::redo() 1362void KABCore::redo()
1362{ 1363{
1363 RedoStack::instance()->redo(); 1364 RedoStack::instance()->redo();
1364 1365
1365 // Refresh the view 1366 // Refresh the view
1366 mViewManager->refreshView(); 1367 mViewManager->refreshView();
1367} 1368}
1368 1369
1369void KABCore::setJumpButtonBarVisible( bool visible ) 1370void KABCore::setJumpButtonBarVisible( bool visible )
1370{ 1371{
1371 if (mMultipleViewsAtOnce) 1372 if (mMultipleViewsAtOnce)
1372 { 1373 {
1373 if ( visible ) 1374 if ( visible )
1374 mJumpButtonBar->show(); 1375 mJumpButtonBar->show();
1375 else 1376 else
1376 mJumpButtonBar->hide(); 1377 mJumpButtonBar->hide();
1377 } 1378 }
1378 else 1379 else
1379 { 1380 {
1380 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1381 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1381 if (mViewManager->isVisible()) 1382 if (mViewManager->isVisible())
1382 { 1383 {
1383 if ( visible ) 1384 if ( visible )
1384 mJumpButtonBar->show(); 1385 mJumpButtonBar->show();
1385 else 1386 else
1386 mJumpButtonBar->hide(); 1387 mJumpButtonBar->hide();
1387 } 1388 }
1388 else 1389 else
1389 { 1390 {
1390 mJumpButtonBar->hide(); 1391 mJumpButtonBar->hide();
1391 } 1392 }
1392 } 1393 }
1393} 1394}
1394 1395
1395 1396
1396void KABCore::setDetailsToState() 1397void KABCore::setDetailsToState()
1397{ 1398{
1398 setDetailsVisible( mActionDetails->isChecked() ); 1399 setDetailsVisible( mActionDetails->isChecked() );
1399} 1400}
1400void KABCore::setDetailsToggle() 1401void KABCore::setDetailsToggle()
1401{ 1402{
1402 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1403 mActionDetails->setChecked( !mActionDetails->isChecked() );
1403 setDetailsToState(); 1404 setDetailsToState();
1404} 1405}
1405 1406
1406 1407
1407 1408
1408void KABCore::setDetailsVisible( bool visible ) 1409void KABCore::setDetailsVisible( bool visible )
1409{ 1410{
1410 if (visible && mDetails->isHidden()) 1411 if (visible && mDetails->isHidden())
1411 { 1412 {
1412 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1413 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1413 if ( addrList.count() > 0 ) 1414 if ( addrList.count() > 0 )
1414 mDetails->setAddressee( addrList[ 0 ] ); 1415 mDetails->setAddressee( addrList[ 0 ] );
1415 } 1416 }
1416 1417
1417 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1418 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1418 // the listview and the detailview. We do that by changing the splitbar size. 1419 // the listview and the detailview. We do that by changing the splitbar size.
1419 if (mMultipleViewsAtOnce) 1420 if (mMultipleViewsAtOnce)
1420 { 1421 {
1421 if ( visible ) 1422 if ( visible )
1422 mDetails->show(); 1423 mDetails->show();
1423 else 1424 else
1424 mDetails->hide(); 1425 mDetails->hide();
1425 } 1426 }
1426 else 1427 else
1427 { 1428 {
1428 if ( visible ) { 1429 if ( visible ) {
1429 mViewManager->hide(); 1430 mViewManager->hide();
1430 mDetails->show(); 1431 mDetails->show();
1431 mIncSearchWidget->setFocus(); 1432 mIncSearchWidget->setFocus();
1432 } 1433 }
1433 else { 1434 else {
1434 mViewManager->show(); 1435 mViewManager->show();
1435 mDetails->hide(); 1436 mDetails->hide();
1436 mViewManager->setFocusAV(); 1437 mViewManager->setFocusAV();
1437 } 1438 }
1438 setJumpButtonBarVisible( !visible ); 1439 setJumpButtonBarVisible( !visible );
1439 } 1440 }
1440 1441
1441} 1442}
1442 1443
1443void KABCore::extensionChanged( int id ) 1444void KABCore::extensionChanged( int id )
1444{ 1445{
1445 //change the details view only for non desktop systems 1446 //change the details view only for non desktop systems
1446#ifndef DESKTOP_VERSION 1447#ifndef DESKTOP_VERSION
1447 1448
1448 if (id == 0) 1449 if (id == 0)
1449 { 1450 {
1450 //the user disabled the extension. 1451 //the user disabled the extension.
1451 1452
1452 if (mMultipleViewsAtOnce) 1453 if (mMultipleViewsAtOnce)
1453 { // enable detailsview again 1454 { // enable detailsview again
1454 setDetailsVisible( true ); 1455 setDetailsVisible( true );
1455 mActionDetails->setChecked( true ); 1456 mActionDetails->setChecked( true );
1456 } 1457 }
1457 else 1458 else
1458 { //go back to the listview 1459 { //go back to the listview
1459 setDetailsVisible( false ); 1460 setDetailsVisible( false );
1460 mActionDetails->setChecked( false ); 1461 mActionDetails->setChecked( false );
1461 mActionDetails->setEnabled(true); 1462 mActionDetails->setEnabled(true);
1462 } 1463 }
1463 1464
1464 } 1465 }
1465 else 1466 else
1466 { 1467 {
1467 //the user enabled the extension. 1468 //the user enabled the extension.
1468 setDetailsVisible( false ); 1469 setDetailsVisible( false );
1469 mActionDetails->setChecked( false ); 1470 mActionDetails->setChecked( false );
1470 1471
1471 if (!mMultipleViewsAtOnce) 1472 if (!mMultipleViewsAtOnce)
1472 { 1473 {
1473 mActionDetails->setEnabled(false); 1474 mActionDetails->setEnabled(false);
1474 } 1475 }
1475 1476
1476 mExtensionManager->setSelectionChanged(); 1477 mExtensionManager->setSelectionChanged();
1477 1478
1478 } 1479 }
1479 1480
1480#endif// DESKTOP_VERSION 1481#endif// DESKTOP_VERSION
1481 1482
1482} 1483}
1483 1484
1484 1485
1485void KABCore::extensionModified( const KABC::Addressee::List &list ) 1486void KABCore::extensionModified( const KABC::Addressee::List &list )
1486{ 1487{
1487 1488
1488 if ( list.count() != 0 ) { 1489 if ( list.count() != 0 ) {
1489 KABC::Addressee::List::ConstIterator it; 1490 KABC::Addressee::List::ConstIterator it;
1490 for ( it = list.begin(); it != list.end(); ++it ) 1491 for ( it = list.begin(); it != list.end(); ++it )
1491 mAddressBook->insertAddressee( *it ); 1492 mAddressBook->insertAddressee( *it );
1492 if ( list.count() > 1 ) 1493 if ( list.count() > 1 )
1493 setModified(); 1494 setModified();
1494 else 1495 else
1495 setModifiedWOrefresh(); 1496 setModifiedWOrefresh();
1496 } 1497 }
1497 if ( list.count() == 0 ) 1498 if ( list.count() == 0 )
1498 mViewManager->refreshView(); 1499 mViewManager->refreshView();
1499 else 1500 else
1500 mViewManager->refreshView( list[ 0 ].uid() ); 1501 mViewManager->refreshView( list[ 0 ].uid() );
1501 1502
1502 1503
1503 1504
1504} 1505}
1505 1506
1506QString KABCore::getNameByPhone( const QString &phone ) 1507QString KABCore::getNameByPhone( const QString &phone )
1507{ 1508{
1508#ifndef KAB_EMBEDDED 1509#ifndef KAB_EMBEDDED
1509 QRegExp r( "[/*/-/ ]" ); 1510 QRegExp r( "[/*/-/ ]" );
1510 QString localPhone( phone ); 1511 QString localPhone( phone );
1511 1512
1512 bool found = false; 1513 bool found = false;
1513 QString ownerName = ""; 1514 QString ownerName = "";
1514 KABC::AddressBook::Iterator iter; 1515 KABC::AddressBook::Iterator iter;
1515 KABC::PhoneNumber::List::Iterator phoneIter; 1516 KABC::PhoneNumber::List::Iterator phoneIter;
1516 KABC::PhoneNumber::List phoneList; 1517 KABC::PhoneNumber::List phoneList;
1517 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1518 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1518 phoneList = (*iter).phoneNumbers(); 1519 phoneList = (*iter).phoneNumbers();
1519 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1520 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1520 ++phoneIter) { 1521 ++phoneIter) {
1521 // Get rid of separator chars so just the numbers are compared. 1522 // Get rid of separator chars so just the numbers are compared.
1522 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1523 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1523 ownerName = (*iter).formattedName(); 1524 ownerName = (*iter).formattedName();
1524 found = true; 1525 found = true;
1525 } 1526 }
1526 } 1527 }
1527 } 1528 }
1528 1529
1529 return ownerName; 1530 return ownerName;
1530#else //KAB_EMBEDDED 1531#else //KAB_EMBEDDED
1531 qDebug("KABCore::getNameByPhone finsih method"); 1532 qDebug("KABCore::getNameByPhone finsih method");
1532 return ""; 1533 return "";
1533#endif //KAB_EMBEDDED 1534#endif //KAB_EMBEDDED
1534 1535
1535} 1536}
1536 1537
1537void KABCore::openConfigDialog() 1538void KABCore::openConfigDialog()
1538{ 1539{
1539 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1540 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1540 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1541 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1541 ConfigureDialog->addModule(kabcfg ); 1542 ConfigureDialog->addModule(kabcfg );
1542 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1543 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1543 ConfigureDialog->addModule(kdelibcfg ); 1544 ConfigureDialog->addModule(kdelibcfg );
1544 1545
1545 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1546 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1546 this, SLOT( configurationChanged() ) ); 1547 this, SLOT( configurationChanged() ) );
1547 connect( ConfigureDialog, SIGNAL( okClicked() ), 1548 connect( ConfigureDialog, SIGNAL( okClicked() ),
1548 this, SLOT( configurationChanged() ) ); 1549 this, SLOT( configurationChanged() ) );
1549 saveSettings(); 1550 saveSettings();
1550#ifndef DESKTOP_VERSION 1551#ifndef DESKTOP_VERSION
1551 ConfigureDialog->showMaximized(); 1552 ConfigureDialog->showMaximized();
1552#endif 1553#endif
1553 if ( ConfigureDialog->exec() ) 1554 if ( ConfigureDialog->exec() )
1554 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1555 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1555 delete ConfigureDialog; 1556 delete ConfigureDialog;
1556} 1557}
1557 1558
1558void KABCore::openLDAPDialog() 1559void KABCore::openLDAPDialog()
1559{ 1560{
1560#ifndef KAB_EMBEDDED 1561#ifndef KAB_EMBEDDED
1561 if ( !mLdapSearchDialog ) { 1562 if ( !mLdapSearchDialog ) {
1562 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1563 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1564 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1564 SLOT( refreshView() ) ); 1565 SLOT( refreshView() ) );
1565 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1566 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1566 SLOT( setModified() ) ); 1567 SLOT( setModified() ) );
1567 } else 1568 } else
1568 mLdapSearchDialog->restoreSettings(); 1569 mLdapSearchDialog->restoreSettings();
1569 1570
1570 if ( mLdapSearchDialog->isOK() ) 1571 if ( mLdapSearchDialog->isOK() )
1571 mLdapSearchDialog->exec(); 1572 mLdapSearchDialog->exec();
1572#else //KAB_EMBEDDED 1573#else //KAB_EMBEDDED
1573 qDebug("KABCore::openLDAPDialog() finsih method"); 1574 qDebug("KABCore::openLDAPDialog() finsih method");
1574#endif //KAB_EMBEDDED 1575#endif //KAB_EMBEDDED
1575} 1576}
1576 1577
1577void KABCore::print() 1578void KABCore::print()
1578{ 1579{
1579#ifndef KAB_EMBEDDED 1580#ifndef KAB_EMBEDDED
1580 KPrinter printer; 1581 KPrinter printer;
1581 if ( !printer.setup( this ) ) 1582 if ( !printer.setup( this ) )
1582 return; 1583 return;
1583 1584
1584 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1585 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1585 mViewManager->selectedUids(), this ); 1586 mViewManager->selectedUids(), this );
1586 1587
1587 wizard.exec(); 1588 wizard.exec();
1588#else //KAB_EMBEDDED 1589#else //KAB_EMBEDDED
1589 qDebug("KABCore::print() finsih method"); 1590 qDebug("KABCore::print() finsih method");
1590#endif //KAB_EMBEDDED 1591#endif //KAB_EMBEDDED
1591 1592
1592} 1593}
1593 1594
1594 1595
1595void KABCore::addGUIClient( KXMLGUIClient *client ) 1596void KABCore::addGUIClient( KXMLGUIClient *client )
1596{ 1597{
1597 if ( mGUIClient ) 1598 if ( mGUIClient )
1598 mGUIClient->insertChildClient( client ); 1599 mGUIClient->insertChildClient( client );
1599 else 1600 else
1600 KMessageBox::error( this, "no KXMLGUICLient"); 1601 KMessageBox::error( this, "no KXMLGUICLient");
1601} 1602}
1602 1603
1603 1604
1604void KABCore::configurationChanged() 1605void KABCore::configurationChanged()
1605{ 1606{
1606 mExtensionManager->reconfigure(); 1607 mExtensionManager->reconfigure();
1607} 1608}
1608 1609
1609void KABCore::addressBookChanged() 1610void KABCore::addressBookChanged()
1610{ 1611{
1611/*US 1612/*US
1612 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1613 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1613 while ( it.current() ) { 1614 while ( it.current() ) {
1614 if ( it.current()->dirty() ) { 1615 if ( it.current()->dirty() ) {
1615 QString text = i18n( "Data has been changed externally. Unsaved " 1616 QString text = i18n( "Data has been changed externally. Unsaved "
1616 "changes will be lost." ); 1617 "changes will be lost." );
1617 KMessageBox::information( this, text ); 1618 KMessageBox::information( this, text );
1618 } 1619 }
1619 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1620 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1620 ++it; 1621 ++it;
1621 } 1622 }
1622*/ 1623*/
1623 if (mEditorDialog) 1624 if (mEditorDialog)
1624 { 1625 {
1625 if (mEditorDialog->dirty()) 1626 if (mEditorDialog->dirty())
1626 { 1627 {
1627 QString text = i18n( "Data has been changed externally. Unsaved " 1628 QString text = i18n( "Data has been changed externally. Unsaved "
1628 "changes will be lost." ); 1629 "changes will be lost." );
1629 KMessageBox::information( this, text ); 1630 KMessageBox::information( this, text );
1630 } 1631 }
1631 QString currentuid = mEditorDialog->addressee().uid(); 1632 QString currentuid = mEditorDialog->addressee().uid();
1632 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1633 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1633 } 1634 }
1634 mViewManager->refreshView(); 1635 mViewManager->refreshView();
1635// mDetails->refreshView(); 1636// mDetails->refreshView();
1636 1637
1637 1638
1638} 1639}
1639 1640
1640AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1641AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1641 const char *name ) 1642 const char *name )
1642{ 1643{
1643 1644
1644 if ( mEditorDialog == 0 ) { 1645 if ( mEditorDialog == 0 ) {
1645 mEditorDialog = new AddresseeEditorDialog( this, parent, 1646 mEditorDialog = new AddresseeEditorDialog( this, parent,
1646 name ? name : "editorDialog" ); 1647 name ? name : "editorDialog" );
1647 1648
1648 1649
1649 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1650 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1650 SLOT( contactModified( const KABC::Addressee& ) ) ); 1651 SLOT( contactModified( const KABC::Addressee& ) ) );
1651 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1652 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1652 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1653 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1653 } 1654 }
1654 1655
1655 return mEditorDialog; 1656 return mEditorDialog;
1656} 1657}
1657 1658
1658void KABCore::slotEditorDestroyed( const QString &uid ) 1659void KABCore::slotEditorDestroyed( const QString &uid )
1659{ 1660{
1660 //mEditorDict.remove( uid ); 1661 //mEditorDict.remove( uid );
1661} 1662}
1662 1663
1663void KABCore::initGUI() 1664void KABCore::initGUI()
1664{ 1665{
1665#ifndef KAB_EMBEDDED 1666#ifndef KAB_EMBEDDED
1666 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1667 QHBoxLayout *topLayout = new QHBoxLayout( this );
1667 topLayout->setSpacing( KDialogBase::spacingHint() ); 1668 topLayout->setSpacing( KDialogBase::spacingHint() );
1668 1669
1669 mExtensionBarSplitter = new QSplitter( this ); 1670 mExtensionBarSplitter = new QSplitter( this );
1670 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1671 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1671 1672
1672 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1673 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1673 1674
1674 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1675 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1675 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1676 mIncSearchWidget = new IncSearchWidget( viewSpace );
1676 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1677 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1677 SLOT( incrementalSearch( const QString& ) ) ); 1678 SLOT( incrementalSearch( const QString& ) ) );
1678 1679
1679 mViewManager = new ViewManager( this, viewSpace ); 1680 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1681 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1682
1682 mDetails = new ViewContainer( mDetailsSplitter ); 1683 mDetails = new ViewContainer( mDetailsSplitter );
1683 1684
1684 mJumpButtonBar = new JumpButtonBar( this, this ); 1685 mJumpButtonBar = new JumpButtonBar( this, this );
1685 1686
1686 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1687 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1687 1688
1688 topLayout->addWidget( mExtensionBarSplitter ); 1689 topLayout->addWidget( mExtensionBarSplitter );
1689 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1690 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1690 topLayout->addWidget( mJumpButtonBar ); 1691 topLayout->addWidget( mJumpButtonBar );
1691 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1692 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1692 1693
1693 mXXPortManager = new XXPortManager( this, this ); 1694 mXXPortManager = new XXPortManager( this, this );
1694 1695
1695#else //KAB_EMBEDDED 1696#else //KAB_EMBEDDED
1696 //US initialize viewMenu before settingup viewmanager. 1697 //US initialize viewMenu before settingup viewmanager.
1697 // Viewmanager needs this menu to plugin submenues. 1698 // Viewmanager needs this menu to plugin submenues.
1698 viewMenu = new QPopupMenu( this ); 1699 viewMenu = new QPopupMenu( this );
1699 settingsMenu = new QPopupMenu( this ); 1700 settingsMenu = new QPopupMenu( this );
1700 //filterMenu = new QPopupMenu( this ); 1701 //filterMenu = new QPopupMenu( this );
1701 ImportMenu = new QPopupMenu( this ); 1702 ImportMenu = new QPopupMenu( this );
1702 ExportMenu = new QPopupMenu( this ); 1703 ExportMenu = new QPopupMenu( this );
1703 syncMenu = new QPopupMenu( this ); 1704 syncMenu = new QPopupMenu( this );
1704 changeMenu= new QPopupMenu( this ); 1705 changeMenu= new QPopupMenu( this );
1705 beamMenu= new QPopupMenu( this ); 1706 beamMenu= new QPopupMenu( this );
1706 1707
1707//US since we have no splitter for the embedded system, setup 1708//US since we have no splitter for the embedded system, setup
1708// a layout with two frames. One left and one right. 1709// a layout with two frames. One left and one right.
1709 1710
1710 QBoxLayout *topLayout; 1711 QBoxLayout *topLayout;
1711 1712
1712 // = new QHBoxLayout( this ); 1713 // = new QHBoxLayout( this );
1713// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1714// QBoxLayout *topLayout = (QBoxLayout*)layout();
1714 1715
1715// QWidget *mainBox = new QWidget( this ); 1716// QWidget *mainBox = new QWidget( this );
1716// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1717// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1717 1718
1718#ifdef DESKTOP_VERSION 1719#ifdef DESKTOP_VERSION
1719 topLayout = new QHBoxLayout( this ); 1720 topLayout = new QHBoxLayout( this );
1720 1721
1721 1722
1722 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1723 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1723 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1724 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1724 1725
1725 topLayout->addWidget(mMiniSplitter ); 1726 topLayout->addWidget(mMiniSplitter );
1726 1727
1727 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1728 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1728 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1729 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1729 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1730 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1730 mDetails = new ViewContainer( mMiniSplitter ); 1731 mDetails = new ViewContainer( mMiniSplitter );
1731 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1732 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1732#else 1733#else
1733 if ( QApplication::desktop()->width() > 480 ) { 1734 if ( QApplication::desktop()->width() > 480 ) {
1734 topLayout = new QHBoxLayout( this ); 1735 topLayout = new QHBoxLayout( this );
1735 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1736 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1736 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1737 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1737 } else { 1738 } else {
1738 1739
1739 topLayout = new QHBoxLayout( this ); 1740 topLayout = new QHBoxLayout( this );
1740 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1741 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1741 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1742 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1742 } 1743 }
1743 1744
1744 topLayout->addWidget(mMiniSplitter ); 1745 topLayout->addWidget(mMiniSplitter );
1745 mViewManager = new ViewManager( this, mMiniSplitter ); 1746 mViewManager = new ViewManager( this, mMiniSplitter );
1746 mDetails = new ViewContainer( mMiniSplitter ); 1747 mDetails = new ViewContainer( mMiniSplitter );
1747 1748
1748 1749
1749 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1750 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1750#endif 1751#endif
1751 //eh->hide(); 1752 //eh->hide();
1752 // topLayout->addWidget(mExtensionManager ); 1753 // topLayout->addWidget(mExtensionManager );
1753 1754
1754 1755
1755/*US 1756/*US
1756#ifndef KAB_NOSPLITTER 1757#ifndef KAB_NOSPLITTER
1757 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1758 QHBoxLayout *topLayout = new QHBoxLayout( this );
1758//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1759//US topLayout->setSpacing( KDialogBase::spacingHint() );
1759 topLayout->setSpacing( 10 ); 1760 topLayout->setSpacing( 10 );
1760 1761
1761 mDetailsSplitter = new QSplitter( this ); 1762 mDetailsSplitter = new QSplitter( this );
1762 1763
1763 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1764 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1764 1765
1765 mViewManager = new ViewManager( this, viewSpace ); 1766 mViewManager = new ViewManager( this, viewSpace );
1766 viewSpace->setStretchFactor( mViewManager, 1 ); 1767 viewSpace->setStretchFactor( mViewManager, 1 );
1767 1768
1768 mDetails = new ViewContainer( mDetailsSplitter ); 1769 mDetails = new ViewContainer( mDetailsSplitter );
1769 1770
1770 topLayout->addWidget( mDetailsSplitter ); 1771 topLayout->addWidget( mDetailsSplitter );
1771 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1772 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1772#else //KAB_NOSPLITTER 1773#else //KAB_NOSPLITTER
1773 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1774 QHBoxLayout *topLayout = new QHBoxLayout( this );
1774//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1775//US topLayout->setSpacing( KDialogBase::spacingHint() );
1775 topLayout->setSpacing( 10 ); 1776 topLayout->setSpacing( 10 );
1776 1777
1777// mDetailsSplitter = new QSplitter( this ); 1778// mDetailsSplitter = new QSplitter( this );
1778 1779
1779 QVBox *viewSpace = new QVBox( this ); 1780 QVBox *viewSpace = new QVBox( this );
1780 1781
1781 mViewManager = new ViewManager( this, viewSpace ); 1782 mViewManager = new ViewManager( this, viewSpace );
1782 viewSpace->setStretchFactor( mViewManager, 1 ); 1783 viewSpace->setStretchFactor( mViewManager, 1 );
1783 1784
1784 mDetails = new ViewContainer( this ); 1785 mDetails = new ViewContainer( this );
1785 1786
1786 topLayout->addWidget( viewSpace ); 1787 topLayout->addWidget( viewSpace );
1787// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1788// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1788 topLayout->addWidget( mDetails ); 1789 topLayout->addWidget( mDetails );
1789#endif //KAB_NOSPLITTER 1790#endif //KAB_NOSPLITTER
1790*/ 1791*/
1791 1792
1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1793 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1793 syncManager->setBlockSave(false); 1794 syncManager->setBlockSave(false);
1794 1795
1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1796 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1797 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1797 QString sync_file = sentSyncFile(); 1798 QString sync_file = sentSyncFile();
1798 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1799 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1799 syncManager->setDefaultFileName( sync_file ); 1800 syncManager->setDefaultFileName( sync_file );
1800 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1801 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1801 1802
1802#endif //KAB_EMBEDDED 1803#endif //KAB_EMBEDDED
1803 initActions(); 1804 initActions();
1804 1805
1805#ifdef KAB_EMBEDDED 1806#ifdef KAB_EMBEDDED
1806 addActionsManually(); 1807 addActionsManually();
1807 //US make sure the export and import menues are initialized before creating the xxPortManager. 1808 //US make sure the export and import menues are initialized before creating the xxPortManager.
1808 mXXPortManager = new XXPortManager( this, this ); 1809 mXXPortManager = new XXPortManager( this, this );
1809 1810
1810 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1811 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1811 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1812 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1812 // mActionQuit->plug ( mMainWindow->toolBar()); 1813 // mActionQuit->plug ( mMainWindow->toolBar());
1813 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1814 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1814 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1815 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1815 // mIncSearchWidget->hide(); 1816 // mIncSearchWidget->hide();
1816 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1817 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1817 SLOT( incrementalSearch( const QString& ) ) ); 1818 SLOT( incrementalSearch( const QString& ) ) );
1818 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1819 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1819 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1820 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1820 1821
1821 mJumpButtonBar = new JumpButtonBar( this, this ); 1822 mJumpButtonBar = new JumpButtonBar( this, this );
1822 1823
1823 topLayout->addWidget( mJumpButtonBar ); 1824 topLayout->addWidget( mJumpButtonBar );
1824//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1825//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1825 1826
1826// mMainWindow->getIconToolBar()->raise(); 1827// mMainWindow->getIconToolBar()->raise();
1827 1828
1828#endif //KAB_EMBEDDED 1829#endif //KAB_EMBEDDED
1829 1830
1830} 1831}
1831void KABCore::initActions() 1832void KABCore::initActions()
1832{ 1833{
1833//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1834//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1834 1835
1835#ifndef KAB_EMBEDDED 1836#ifndef KAB_EMBEDDED
1836 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1837 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1837 SLOT( clipboardDataChanged() ) ); 1838 SLOT( clipboardDataChanged() ) );
1838#endif //KAB_EMBEDDED 1839#endif //KAB_EMBEDDED
1839 1840
1840 // file menu 1841 // file menu
1841 if ( mIsPart ) { 1842 if ( mIsPart ) {
1842 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1843 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1843 SLOT( sendMail() ), actionCollection(), 1844 SLOT( sendMail() ), actionCollection(),
1844 "kaddressbook_mail" ); 1845 "kaddressbook_mail" );
1845 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1846 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1846 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1847 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1847 1848
1848 } else { 1849 } else {
1849 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1850 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1850 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1851 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1851 } 1852 }
1852 1853
1853 1854
1854 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1855 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1855 SLOT( save() ), actionCollection(), "file_sync" ); 1856 SLOT( save() ), actionCollection(), "file_sync" );
1856 1857
1857 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1858 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1858 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1859 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1859 1860
1860 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1861 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1861 this, SLOT( mailVCard() ), 1862 this, SLOT( mailVCard() ),
1862 actionCollection(), "file_mail_vcard"); 1863 actionCollection(), "file_mail_vcard");
1863 1864
1864 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1865 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1865 SLOT( export2phone() ), actionCollection(), 1866 SLOT( export2phone() ), actionCollection(),
1866 "kaddressbook_ex2phone" ); 1867 "kaddressbook_ex2phone" );
1867 1868
1868 mActionBeamVCard = 0; 1869 mActionBeamVCard = 0;
1869 mActionBeam = 0; 1870 mActionBeam = 0;
1870 1871
1871#ifndef DESKTOP_VERSION 1872#ifndef DESKTOP_VERSION
1872 if ( Ir::supported() ) { 1873 if ( Ir::supported() ) {
1873 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1874 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1874 SLOT( beamVCard() ), actionCollection(), 1875 SLOT( beamVCard() ), actionCollection(),
1875 "kaddressbook_beam_vcard" ); 1876 "kaddressbook_beam_vcard" );
1876 1877
1877 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1878 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1878 SLOT( beamMySelf() ), actionCollection(), 1879 SLOT( beamMySelf() ), actionCollection(),
1879 "kaddressbook_beam_myself" ); 1880 "kaddressbook_beam_myself" );
1880 } 1881 }
1881#endif 1882#endif
1882 1883
1883 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1884 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1884 this, SLOT( editContact2() ), 1885 this, SLOT( editContact2() ),
1885 actionCollection(), "file_properties" ); 1886 actionCollection(), "file_properties" );
1886 1887
1887#ifdef KAB_EMBEDDED 1888#ifdef KAB_EMBEDDED
1888 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1889 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1889 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1890 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1890 mMainWindow, SLOT( exit() ), 1891 mMainWindow, SLOT( exit() ),
1891 actionCollection(), "quit" ); 1892 actionCollection(), "quit" );
1892#endif //KAB_EMBEDDED 1893#endif //KAB_EMBEDDED
1893 1894
1894 // edit menu 1895 // edit menu
1895 if ( mIsPart ) { 1896 if ( mIsPart ) {
1896 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1897 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1897 SLOT( copyContacts() ), actionCollection(), 1898 SLOT( copyContacts() ), actionCollection(),
1898 "kaddressbook_copy" ); 1899 "kaddressbook_copy" );
1899 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1900 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1900 SLOT( cutContacts() ), actionCollection(), 1901 SLOT( cutContacts() ), actionCollection(),
1901 "kaddressbook_cut" ); 1902 "kaddressbook_cut" );
1902 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1903 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1903 SLOT( pasteContacts() ), actionCollection(), 1904 SLOT( pasteContacts() ), actionCollection(),
1904 "kaddressbook_paste" ); 1905 "kaddressbook_paste" );
1905 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1906 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1906 SLOT( selectAllContacts() ), actionCollection(), 1907 SLOT( selectAllContacts() ), actionCollection(),
1907 "kaddressbook_select_all" ); 1908 "kaddressbook_select_all" );
1908 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1909 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1909 SLOT( undo() ), actionCollection(), 1910 SLOT( undo() ), actionCollection(),
1910 "kaddressbook_undo" ); 1911 "kaddressbook_undo" );
1911 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1912 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1912 this, SLOT( redo() ), actionCollection(), 1913 this, SLOT( redo() ), actionCollection(),
1913 "kaddressbook_redo" ); 1914 "kaddressbook_redo" );
1914 } else { 1915 } else {
1915 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1916 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1916 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1917 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1917 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1918 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1918 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1919 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1919 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1920 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1920 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1921 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1921 } 1922 }
1922 1923
1923 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1924 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1924 Key_Delete, this, SLOT( deleteContacts() ), 1925 Key_Delete, this, SLOT( deleteContacts() ),
1925 actionCollection(), "edit_delete" ); 1926 actionCollection(), "edit_delete" );
1926 1927
1927 mActionUndo->setEnabled( false ); 1928 mActionUndo->setEnabled( false );
1928 mActionRedo->setEnabled( false ); 1929 mActionRedo->setEnabled( false );
1929 1930
1930 // settings menu 1931 // settings menu
1931#ifdef KAB_EMBEDDED 1932#ifdef KAB_EMBEDDED
1932//US special menuentry to configure the addressbook resources. On KDE 1933//US special menuentry to configure the addressbook resources. On KDE
1933// you do that through the control center !!! 1934// you do that through the control center !!!
1934 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1935 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1935 SLOT( configureResources() ), actionCollection(), 1936 SLOT( configureResources() ), actionCollection(),
1936 "kaddressbook_configure_resources" ); 1937 "kaddressbook_configure_resources" );
1937#endif //KAB_EMBEDDED 1938#endif //KAB_EMBEDDED
1938 1939
1939 if ( mIsPart ) { 1940 if ( mIsPart ) {
1940 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1941 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1941 SLOT( openConfigDialog() ), actionCollection(), 1942 SLOT( openConfigDialog() ), actionCollection(),
1942 "kaddressbook_configure" ); 1943 "kaddressbook_configure" );
1943 1944
1944 //US not implemented yet 1945 //US not implemented yet
1945 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1946 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1946 // this, SLOT( configureKeyBindings() ), actionCollection(), 1947 // this, SLOT( configureKeyBindings() ), actionCollection(),
1947 // "kaddressbook_configure_shortcuts" ); 1948 // "kaddressbook_configure_shortcuts" );
1948#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1949 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1950 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1950 mActionConfigureToolbars->setEnabled( false ); 1951 mActionConfigureToolbars->setEnabled( false );
1951#endif //KAB_EMBEDDED 1952#endif //KAB_EMBEDDED
1952 1953
1953 } else { 1954 } else {
1954 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1955 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1955 1956
1956 //US not implemented yet 1957 //US not implemented yet
1957 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1958 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1958 } 1959 }
1959 1960
1960 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1961 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1961 actionCollection(), "options_show_jump_bar" ); 1962 actionCollection(), "options_show_jump_bar" );
1962 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1963 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1963 1964
1964 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1965 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1965 actionCollection(), "options_show_details" ); 1966 actionCollection(), "options_show_details" );
1966 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1967 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1967 1968
1968 1969
1969 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1970 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1970 SLOT( toggleBeamReceive() ), actionCollection(), 1971 SLOT( toggleBeamReceive() ), actionCollection(),
1971 "kaddressbook_beam_rec" ); 1972 "kaddressbook_beam_rec" );
1972 1973
1973 1974
1974 // misc 1975 // misc
1975 // only enable LDAP lookup if we can handle the protocol 1976 // only enable LDAP lookup if we can handle the protocol
1976#ifndef KAB_EMBEDDED 1977#ifndef KAB_EMBEDDED
1977 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1978 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1978 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1979 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1979 this, SLOT( openLDAPDialog() ), actionCollection(), 1980 this, SLOT( openLDAPDialog() ), actionCollection(),
1980 "ldap_lookup" ); 1981 "ldap_lookup" );
1981 } 1982 }
1982#else //KAB_EMBEDDED 1983#else //KAB_EMBEDDED
1983 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1984 //qDebug("KABCore::initActions() LDAP has to be implemented");
1984#endif //KAB_EMBEDDED 1985#endif //KAB_EMBEDDED
1985 1986
1986 1987
1987 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1988 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1988 SLOT( setWhoAmI() ), actionCollection(), 1989 SLOT( setWhoAmI() ), actionCollection(),
1989 "set_personal" ); 1990 "set_personal" );
1990 1991
1991 1992
1992 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1993 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1993 SLOT( setCategories() ), actionCollection(), 1994 SLOT( setCategories() ), actionCollection(),
1994 "edit_set_categories" ); 1995 "edit_set_categories" );
1995 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1996 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1996 SLOT( editCategories() ), actionCollection(), 1997 SLOT( editCategories() ), actionCollection(),
1997 "edit__categories" ); 1998 "edit__categories" );
1998 1999
1999 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2000 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2000 SLOT( removeVoice() ), actionCollection(), 2001 SLOT( removeVoice() ), actionCollection(),
2001 "remove_voice" ); 2002 "remove_voice" );
2002 2003
2003 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2004 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2004 SLOT( manageCategories() ), actionCollection(), 2005 SLOT( manageCategories() ), actionCollection(),
2005 "remove_voice" ); 2006 "remove_voice" );
2006 2007
2007 2008
2008 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2009 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2009 SLOT( importFromOL() ), actionCollection(), 2010 SLOT( importFromOL() ), actionCollection(),
2010 "import_OL" ); 2011 "import_OL" );
2011#ifdef KAB_EMBEDDED 2012#ifdef KAB_EMBEDDED
2012 mActionLicence = new KAction( i18n( "Licence" ), 0, 2013 mActionLicence = new KAction( i18n( "Licence" ), 0,
2013 this, SLOT( showLicence() ), actionCollection(), 2014 this, SLOT( showLicence() ), actionCollection(),
2014 "licence_about_data" ); 2015 "licence_about_data" );
2015 mActionFaq = new KAction( i18n( "Faq" ), 0, 2016 mActionFaq = new KAction( i18n( "Faq" ), 0,
2016 this, SLOT( faq() ), actionCollection(), 2017 this, SLOT( faq() ), actionCollection(),
2017 "faq_about_data" ); 2018 "faq_about_data" );
2018 mActionWN = new KAction( i18n( "What's New?" ), 0, 2019 mActionWN = new KAction( i18n( "What's New?" ), 0,
2019 this, SLOT( whatsnew() ), actionCollection(), 2020 this, SLOT( whatsnew() ), actionCollection(),
2020 "wn" ); 2021 "wn" );
2021 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2022 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2022 this, SLOT( synchowto() ), actionCollection(), 2023 this, SLOT( synchowto() ), actionCollection(),
2023 "sync" ); 2024 "sync" );
2024 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2025 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2025 this, SLOT( kdesynchowto() ), actionCollection(), 2026 this, SLOT( kdesynchowto() ), actionCollection(),
2026 "kdesync" ); 2027 "kdesync" );
2027 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2028 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2028 this, SLOT( multisynchowto() ), actionCollection(), 2029 this, SLOT( multisynchowto() ), actionCollection(),
2029 "multisync" ); 2030 "multisync" );
2030 2031
2031 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2032 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2032 this, SLOT( createAboutData() ), actionCollection(), 2033 this, SLOT( createAboutData() ), actionCollection(),
2033 "kaddressbook_about_data" ); 2034 "kaddressbook_about_data" );
2034#endif //KAB_EMBEDDED 2035#endif //KAB_EMBEDDED
2035 2036
2036 clipboardDataChanged(); 2037 clipboardDataChanged();
2037 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2038 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2038 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2039 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2039} 2040}
2040 2041
2041//US we need this function, to plug all actions into the correct menues. 2042//US we need this function, to plug all actions into the correct menues.
2042// KDE uses a XML format to plug the actions, but we work her without this overhead. 2043// KDE uses a XML format to plug the actions, but we work her without this overhead.
2043void KABCore::addActionsManually() 2044void KABCore::addActionsManually()
2044{ 2045{
2045//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2046//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2046 2047
2047#ifdef KAB_EMBEDDED 2048#ifdef KAB_EMBEDDED
2048 QPopupMenu *fileMenu = new QPopupMenu( this ); 2049 QPopupMenu *fileMenu = new QPopupMenu( this );
2049 QPopupMenu *editMenu = new QPopupMenu( this ); 2050 QPopupMenu *editMenu = new QPopupMenu( this );
2050 QPopupMenu *helpMenu = new QPopupMenu( this ); 2051 QPopupMenu *helpMenu = new QPopupMenu( this );
2051 2052
2052 KToolBar* tb = mMainWindow->toolBar(); 2053 KToolBar* tb = mMainWindow->toolBar();
2053 2054
2054#ifndef DESKTOP_VERSION 2055#ifndef DESKTOP_VERSION
2055 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2056 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2056#endif 2057#endif
2057 QMenuBar* mb = mMainWindow->menuBar(); 2058 QMenuBar* mb = mMainWindow->menuBar();
2058 2059
2059 //US setup menubar. 2060 //US setup menubar.
2060 //Disable the following block if you do not want to have a menubar. 2061 //Disable the following block if you do not want to have a menubar.
2061 mb->insertItem( i18n("&File"), fileMenu ); 2062 mb->insertItem( i18n("&File"), fileMenu );
2062 mb->insertItem( i18n("&Edit"), editMenu ); 2063 mb->insertItem( i18n("&Edit"), editMenu );
2063 mb->insertItem( i18n("&View"), viewMenu ); 2064 mb->insertItem( i18n("&View"), viewMenu );
2064 mb->insertItem( i18n("&Settings"), settingsMenu ); 2065 mb->insertItem( i18n("&Settings"), settingsMenu );
2065 mb->insertItem( i18n("Synchronize"), syncMenu ); 2066 mb->insertItem( i18n("Synchronize"), syncMenu );
2066 //mb->insertItem( i18n("&Change"), changeMenu ); 2067 //mb->insertItem( i18n("&Change"), changeMenu );
2067 mb->insertItem( i18n("&Help"), helpMenu ); 2068 mb->insertItem( i18n("&Help"), helpMenu );
2068 mIncSearchWidget = new IncSearchWidget( tb ); 2069 mIncSearchWidget = new IncSearchWidget( tb );
2069 // tb->insertWidget(-1, 0, mIncSearchWidget); 2070 // tb->insertWidget(-1, 0, mIncSearchWidget);
2070#ifndef DESKTOP_VERSION 2071#ifndef DESKTOP_VERSION
2071 } else { 2072 } else {
2072 //US setup toolbar 2073 //US setup toolbar
2073 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2074 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2074 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2075 QPopupMenu *popupBarTB = new QPopupMenu( this );
2075 menuBarTB->insertItem( "ME", popupBarTB); 2076 menuBarTB->insertItem( "ME", popupBarTB);
2076 tb->insertWidget(-1, 0, menuBarTB); 2077 tb->insertWidget(-1, 0, menuBarTB);
2077 mIncSearchWidget = new IncSearchWidget( tb ); 2078 mIncSearchWidget = new IncSearchWidget( tb );
2078 2079
2079 tb->enableMoving(false); 2080 tb->enableMoving(false);
2080 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2081 popupBarTB->insertItem( i18n("&File"), fileMenu );
2081 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2082 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2082 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2083 popupBarTB->insertItem( i18n("&View"), viewMenu );
2083 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2084 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2084 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2085 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2085 mViewManager->getFilterAction()->plug ( popupBarTB); 2086 mViewManager->getFilterAction()->plug ( popupBarTB);
2086 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2087 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2087 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2088 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2088 if (QApplication::desktop()->width() > 320 ) { 2089 if (QApplication::desktop()->width() > 320 ) {
2089 // mViewManager->getFilterAction()->plug ( tb); 2090 // mViewManager->getFilterAction()->plug ( tb);
2090 } 2091 }
2091 } 2092 }
2092#endif 2093#endif
2093 // mActionQuit->plug ( mMainWindow->toolBar()); 2094 // mActionQuit->plug ( mMainWindow->toolBar());
2094 2095
2095 2096
2096 2097
2097 //US Now connect the actions with the menue entries. 2098 //US Now connect the actions with the menue entries.
2098 mActionPrint->plug( fileMenu ); 2099 mActionPrint->plug( fileMenu );
2099 mActionMail->plug( fileMenu ); 2100 mActionMail->plug( fileMenu );
2100 fileMenu->insertSeparator(); 2101 fileMenu->insertSeparator();
2101 2102
2102 mActionNewContact->plug( fileMenu ); 2103 mActionNewContact->plug( fileMenu );
2103 mActionNewContact->plug( tb ); 2104 mActionNewContact->plug( tb );
2104 2105
2105 mActionEditAddressee->plug( fileMenu ); 2106 mActionEditAddressee->plug( fileMenu );
2106 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2107 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2107 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2108 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2108 mActionEditAddressee->plug( tb ); 2109 mActionEditAddressee->plug( tb );
2109 2110
2110 fileMenu->insertSeparator(); 2111 fileMenu->insertSeparator();
2111 mActionSave->plug( fileMenu ); 2112 mActionSave->plug( fileMenu );
2112 fileMenu->insertItem( "&Import", ImportMenu ); 2113 fileMenu->insertItem( "&Import", ImportMenu );
2113 fileMenu->insertItem( "&Export", ExportMenu ); 2114 fileMenu->insertItem( "&Export", ExportMenu );
2114 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2115 fileMenu->insertItem( i18n("&Change"), changeMenu );
2115#ifndef DESKTOP_VERSION 2116#ifndef DESKTOP_VERSION
2116 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2117 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2117#endif 2118#endif
2118 2119
2119 fileMenu->insertSeparator(); 2120 fileMenu->insertSeparator();
2120 mActionMailVCard->plug( fileMenu ); 2121 mActionMailVCard->plug( fileMenu );
2121#ifndef DESKTOP_VERSION 2122#ifndef DESKTOP_VERSION
2122 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2123 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2123 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2124 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2124 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2125 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2125#endif 2126#endif
2126 fileMenu->insertSeparator(); 2127 fileMenu->insertSeparator();
2127 mActionQuit->plug( fileMenu ); 2128 mActionQuit->plug( fileMenu );
2128#ifdef _WIN32_ 2129#ifdef _WIN32_
2129 mActionImportOL->plug( ImportMenu ); 2130 mActionImportOL->plug( ImportMenu );
2130#endif 2131#endif
2131 // edit menu 2132 // edit menu
2132 mActionUndo->plug( editMenu ); 2133 mActionUndo->plug( editMenu );
2133 mActionRedo->plug( editMenu ); 2134 mActionRedo->plug( editMenu );
2134 editMenu->insertSeparator(); 2135 editMenu->insertSeparator();
2135 mActionCut->plug( editMenu ); 2136 mActionCut->plug( editMenu );
2136 mActionCopy->plug( editMenu ); 2137 mActionCopy->plug( editMenu );
2137 mActionPaste->plug( editMenu ); 2138 mActionPaste->plug( editMenu );
2138 mActionDelete->plug( editMenu ); 2139 mActionDelete->plug( editMenu );
2139 editMenu->insertSeparator(); 2140 editMenu->insertSeparator();
2140 mActionSelectAll->plug( editMenu ); 2141 mActionSelectAll->plug( editMenu );
2141 2142
2142 mActionRemoveVoice->plug( changeMenu ); 2143 mActionRemoveVoice->plug( changeMenu );
2143 // settings menu 2144 // settings menu
2144//US special menuentry to configure the addressbook resources. On KDE 2145//US special menuentry to configure the addressbook resources. On KDE
2145// you do that through the control center !!! 2146// you do that through the control center !!!
2146 mActionConfigResources->plug( settingsMenu ); 2147 mActionConfigResources->plug( settingsMenu );
2147 settingsMenu->insertSeparator(); 2148 settingsMenu->insertSeparator();
2148 2149
2149 mActionConfigKAddressbook->plug( settingsMenu ); 2150 mActionConfigKAddressbook->plug( settingsMenu );
2150 2151
2151 if ( mIsPart ) { 2152 if ( mIsPart ) {
2152 //US not implemented yet 2153 //US not implemented yet
2153 //mActionConfigShortcuts->plug( settingsMenu ); 2154 //mActionConfigShortcuts->plug( settingsMenu );
2154 //mActionConfigureToolbars->plug( settingsMenu ); 2155 //mActionConfigureToolbars->plug( settingsMenu );
2155 2156
2156 } else { 2157 } else {
2157 //US not implemented yet 2158 //US not implemented yet
2158 //mActionKeyBindings->plug( settingsMenu ); 2159 //mActionKeyBindings->plug( settingsMenu );
2159 } 2160 }
2160 2161
2161 settingsMenu->insertSeparator(); 2162 settingsMenu->insertSeparator();
2162 2163
2163 mActionJumpBar->plug( settingsMenu ); 2164 mActionJumpBar->plug( settingsMenu );
2164 mActionDetails->plug( settingsMenu ); 2165 mActionDetails->plug( settingsMenu );
2165 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2166 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2166 mActionDetails->plug( tb ); 2167 mActionDetails->plug( tb );
2167 settingsMenu->insertSeparator(); 2168 settingsMenu->insertSeparator();
2168#ifndef DESKTOP_VERSION 2169#ifndef DESKTOP_VERSION
2169 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2170 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2170#endif 2171#endif
2171 settingsMenu->insertSeparator(); 2172 settingsMenu->insertSeparator();
2172 2173
2173 mActionWhoAmI->plug( settingsMenu ); 2174 mActionWhoAmI->plug( settingsMenu );
2174 mActionEditCategories->plug( settingsMenu ); 2175 mActionEditCategories->plug( settingsMenu );
2175 mActionEditCategories->plug( changeMenu ); 2176 mActionEditCategories->plug( changeMenu );
2176 mActionCategories->plug( changeMenu ); 2177 mActionCategories->plug( changeMenu );
2177 mActionManageCategories->plug( changeMenu ); 2178 mActionManageCategories->plug( changeMenu );
2178 2179
2179 mActionCategories->plug( settingsMenu ); 2180 mActionCategories->plug( settingsMenu );
2180 mActionManageCategories->plug( settingsMenu ); 2181 mActionManageCategories->plug( settingsMenu );
2181 2182
2182 2183
2183 mActionWN->plug( helpMenu ); 2184 mActionWN->plug( helpMenu );
2184 mActionSyncHowto->plug( helpMenu ); 2185 mActionSyncHowto->plug( helpMenu );
2185 mActionKdeSyncHowto->plug( helpMenu ); 2186 mActionKdeSyncHowto->plug( helpMenu );
2186 mActionMultiSyncHowto->plug( helpMenu ); 2187 mActionMultiSyncHowto->plug( helpMenu );
2187 mActionFaq->plug( helpMenu ); 2188 mActionFaq->plug( helpMenu );
2188 mActionLicence->plug( helpMenu ); 2189 mActionLicence->plug( helpMenu );
2189 mActionAboutKAddressbook->plug( helpMenu ); 2190 mActionAboutKAddressbook->plug( helpMenu );
2190 2191
2191 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2192 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2192 2193
2193 mActionSave->plug( tb ); 2194 mActionSave->plug( tb );
2194 mViewManager->getFilterAction()->plug ( tb); 2195 mViewManager->getFilterAction()->plug ( tb);
2195 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2196 //LR hide filteraction on started in 480x640
2196 mActionUndo->plug( tb ); 2197 if (QApplication::desktop()->width() == 480 ) {
2197 mActionDelete->plug( tb ); 2198 mViewManager->getFilterAction()->setComboWidth( 0 );
2198 mActionRedo->plug( tb );
2199 } 2199 }
2200 mActionUndo->plug( tb );
2201 mActionDelete->plug( tb );
2202 mActionRedo->plug( tb );
2200 } else { 2203 } else {
2201 mActionSave->plug( tb ); 2204 mActionSave->plug( tb );
2202 tb->enableMoving(false); 2205 tb->enableMoving(false);
2203 } 2206 }
2204 //mActionQuit->plug ( tb ); 2207 //mActionQuit->plug ( tb );
2205 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2208 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2206 2209
2207 //US link the searchwidget first to this. 2210 //US link the searchwidget first to this.
2208 // The real linkage to the toolbar happens later. 2211 // The real linkage to the toolbar happens later.
2209//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2212//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2210//US tb->insertItem( mIncSearchWidget ); 2213//US tb->insertItem( mIncSearchWidget );
2211/*US 2214/*US
2212 mIncSearchWidget = new IncSearchWidget( tb ); 2215 mIncSearchWidget = new IncSearchWidget( tb );
2213 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2216 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2214 SLOT( incrementalSearch( const QString& ) ) ); 2217 SLOT( incrementalSearch( const QString& ) ) );
2215 2218
2216 mJumpButtonBar = new JumpButtonBar( this, this ); 2219 mJumpButtonBar = new JumpButtonBar( this, this );
2217 2220
2218//US topLayout->addWidget( mJumpButtonBar ); 2221//US topLayout->addWidget( mJumpButtonBar );
2219 this->layout()->add( mJumpButtonBar ); 2222 this->layout()->add( mJumpButtonBar );
2220*/ 2223*/
2221 2224
2222#endif //KAB_EMBEDDED 2225#endif //KAB_EMBEDDED
2223 2226
2224 mActionExport2phone->plug( ExportMenu ); 2227 mActionExport2phone->plug( ExportMenu );
2225 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2228 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2226 syncManager->fillSyncMenu(); 2229 syncManager->fillSyncMenu();
2227 2230
2228} 2231}
2229void KABCore::showLicence() 2232void KABCore::showLicence()
2230{ 2233{
2231 KApplication::showLicence(); 2234 KApplication::showLicence();
2232} 2235}
2233 2236
2234void KABCore::manageCategories( ) 2237void KABCore::manageCategories( )
2235{ 2238{
2236 KABCatPrefs* cp = new KABCatPrefs(); 2239 KABCatPrefs* cp = new KABCatPrefs();
2237 cp->show(); 2240 cp->show();
2238 int w =cp->sizeHint().width() ; 2241 int w =cp->sizeHint().width() ;
2239 int h = cp->sizeHint().height() ; 2242 int h = cp->sizeHint().height() ;
2240 int dw = QApplication::desktop()->width(); 2243 int dw = QApplication::desktop()->width();
2241 int dh = QApplication::desktop()->height(); 2244 int dh = QApplication::desktop()->height();
2242 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2245 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2243 if ( !cp->exec() ) { 2246 if ( !cp->exec() ) {
2244 delete cp; 2247 delete cp;
2245 return; 2248 return;
2246 } 2249 }
2247 int count = 0; 2250 int count = 0;
2248 message( i18n("Please wait, processing categories...")); 2251 message( i18n("Please wait, processing categories..."));
2249 if ( cp->addCat() ) { 2252 if ( cp->addCat() ) {
2250 KABC::AddressBook::Iterator it; 2253 KABC::AddressBook::Iterator it;
2251 QStringList catList = KABPrefs::instance()->mCustomCategories; 2254 QStringList catList = KABPrefs::instance()->mCustomCategories;
2252 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2255 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2253 QStringList catIncList = (*it).categories(); 2256 QStringList catIncList = (*it).categories();
2254 int i; 2257 int i;
2255 for( i = 0; i< catIncList.count(); ++i ) { 2258 for( i = 0; i< catIncList.count(); ++i ) {
2256 if ( !catList.contains (catIncList[i])) { 2259 if ( !catList.contains (catIncList[i])) {
2257 catList.append( catIncList[i] ); 2260 catList.append( catIncList[i] );
2258 //qDebug("add cat %s ", catIncList[i].latin1()); 2261 //qDebug("add cat %s ", catIncList[i].latin1());
2259 ++count; 2262 ++count;
2260 } 2263 }
2261 } 2264 }
2262 } 2265 }
2263 catList.sort(); 2266 catList.sort();
2264 KABPrefs::instance()->mCustomCategories = catList; 2267 KABPrefs::instance()->mCustomCategories = catList;
2265 KABPrefs::instance()->writeConfig(); 2268 KABPrefs::instance()->writeConfig();
2266 message(QString::number( count )+ i18n(" categories added to list! ")); 2269 message(QString::number( count )+ i18n(" categories added to list! "));
2267 } else { 2270 } else {
2268 QStringList catList = KABPrefs::instance()->mCustomCategories; 2271 QStringList catList = KABPrefs::instance()->mCustomCategories;
2269 QStringList catIncList; 2272 QStringList catIncList;
2270 QStringList newCatList; 2273 QStringList newCatList;
2271 KABC::AddressBook::Iterator it; 2274 KABC::AddressBook::Iterator it;
2272 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2275 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2273 QStringList catIncList = (*it).categories(); 2276 QStringList catIncList = (*it).categories();
2274 int i; 2277 int i;
2275 if ( catIncList.count() ) { 2278 if ( catIncList.count() ) {
2276 newCatList.clear(); 2279 newCatList.clear();
2277 for( i = 0; i< catIncList.count(); ++i ) { 2280 for( i = 0; i< catIncList.count(); ++i ) {
2278 if ( catList.contains (catIncList[i])) { 2281 if ( catList.contains (catIncList[i])) {
2279 newCatList.append( catIncList[i] ); 2282 newCatList.append( catIncList[i] );
2280 } 2283 }
2281 } 2284 }
2282 newCatList.sort(); 2285 newCatList.sort();
2283 (*it).setCategories( newCatList ); 2286 (*it).setCategories( newCatList );
2284 mAddressBook->insertAddressee( (*it) ); 2287 mAddressBook->insertAddressee( (*it) );
2285 } 2288 }
2286 } 2289 }
2287 setModified( true ); 2290 setModified( true );
2288 mViewManager->refreshView(); 2291 mViewManager->refreshView();
2289 mDetails->refreshView(); 2292 mDetails->refreshView();
2290 message( i18n("Removing categories done!")); 2293 message( i18n("Removing categories done!"));
2291 } 2294 }
2292 delete cp; 2295 delete cp;
2293} 2296}
2294void KABCore::removeVoice() 2297void KABCore::removeVoice()
2295{ 2298{
2296 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 ) 2299 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 )
2297 return; 2300 return;
2298 KABC::Addressee::List list; 2301 KABC::Addressee::List list;
2299 XXPortSelectDialog dlg( this, false, this ); 2302 XXPortSelectDialog dlg( this, false, this );
2300 if ( dlg.exec() ) 2303 if ( dlg.exec() )
2301 list = dlg.contacts(); 2304 list = dlg.contacts();
2302 else 2305 else
2303 return; 2306 return;
2304 KABC::Addressee::List::Iterator it; 2307 KABC::Addressee::List::Iterator it;
2305 for ( it = list.begin(); it != list.end(); ++it ) { 2308 for ( it = list.begin(); it != list.end(); ++it ) {
2306 if ( (*it).removeVoice() ) 2309 if ( (*it).removeVoice() )
2307 contactModified((*it) ); 2310 contactModified((*it) );
2308 } 2311 }
2309} 2312}
2310 2313
2311 2314
2312 2315
2313void KABCore::clipboardDataChanged() 2316void KABCore::clipboardDataChanged()
2314{ 2317{
2315 2318
2316 if ( mReadWrite ) 2319 if ( mReadWrite )
2317 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2320 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2318 2321
2319} 2322}
2320 2323
2321void KABCore::updateActionMenu() 2324void KABCore::updateActionMenu()
2322{ 2325{
2323 UndoStack *undo = UndoStack::instance(); 2326 UndoStack *undo = UndoStack::instance();
2324 RedoStack *redo = RedoStack::instance(); 2327 RedoStack *redo = RedoStack::instance();
2325 2328
2326 if ( undo->isEmpty() ) 2329 if ( undo->isEmpty() )
2327 mActionUndo->setText( i18n( "Undo" ) ); 2330 mActionUndo->setText( i18n( "Undo" ) );
2328 else 2331 else
2329 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2332 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2330 2333
2331 mActionUndo->setEnabled( !undo->isEmpty() ); 2334 mActionUndo->setEnabled( !undo->isEmpty() );
2332 2335
2333 if ( !redo->top() ) 2336 if ( !redo->top() )
2334 mActionRedo->setText( i18n( "Redo" ) ); 2337 mActionRedo->setText( i18n( "Redo" ) );
2335 else 2338 else
2336 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2339 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2337 2340
2338 mActionRedo->setEnabled( !redo->isEmpty() ); 2341 mActionRedo->setEnabled( !redo->isEmpty() );
2339} 2342}
2340 2343
2341void KABCore::configureKeyBindings() 2344void KABCore::configureKeyBindings()
2342{ 2345{
2343#ifndef KAB_EMBEDDED 2346#ifndef KAB_EMBEDDED
2344 KKeyDialog::configure( actionCollection(), true ); 2347 KKeyDialog::configure( actionCollection(), true );
2345#else //KAB_EMBEDDED 2348#else //KAB_EMBEDDED
2346 qDebug("KABCore::configureKeyBindings() not implemented"); 2349 qDebug("KABCore::configureKeyBindings() not implemented");
2347#endif //KAB_EMBEDDED 2350#endif //KAB_EMBEDDED
2348} 2351}
2349 2352
2350#ifdef KAB_EMBEDDED 2353#ifdef KAB_EMBEDDED
2351void KABCore::configureResources() 2354void KABCore::configureResources()
2352{ 2355{
2353 KRES::KCMKResources dlg( this, "" , 0 ); 2356 KRES::KCMKResources dlg( this, "" , 0 );
2354 2357
2355 if ( !dlg.exec() ) 2358 if ( !dlg.exec() )
2356 return; 2359 return;
2357 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2360 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2358} 2361}
2359#endif //KAB_EMBEDDED 2362#endif //KAB_EMBEDDED
2360 2363
2361 2364
2362/* this method will be called through the QCop interface from Ko/Pi to select addresses 2365/* this method will be called through the QCop interface from Ko/Pi to select addresses
2363 * for the attendees list of an event. 2366 * for the attendees list of an event.
2364 */ 2367 */
2365void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2368void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2366{ 2369{
2367 QStringList nameList; 2370 QStringList nameList;
2368 QStringList emailList; 2371 QStringList emailList;
2369 QStringList uidList; 2372 QStringList uidList;
2370 2373
2371 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2374 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2372 uint i=0; 2375 uint i=0;
2373 for (i=0; i < list.count(); i++) 2376 for (i=0; i < list.count(); i++)
2374 { 2377 {
2375 nameList.append(list[i].realName()); 2378 nameList.append(list[i].realName());
2376 emailList.append(list[i].preferredEmail()); 2379 emailList.append(list[i].preferredEmail());
2377 uidList.append(list[i].uid()); 2380 uidList.append(list[i].uid());
2378 } 2381 }
2379 2382
2380 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2383 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2381 2384
2382} 2385}
2383 2386
2384/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2387/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2385 * to put them into the calendar. 2388 * to put them into the calendar.
2386 */ 2389 */
2387void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2390void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2388{ 2391{
2389 // qDebug("KABCore::requestForBirthdayList"); 2392 // qDebug("KABCore::requestForBirthdayList");
2390 QStringList birthdayList; 2393 QStringList birthdayList;
2391 QStringList anniversaryList; 2394 QStringList anniversaryList;
2392 QStringList realNameList; 2395 QStringList realNameList;
2393 QStringList preferredEmailList; 2396 QStringList preferredEmailList;
2394 QStringList assembledNameList; 2397 QStringList assembledNameList;
2395 QStringList uidList; 2398 QStringList uidList;
2396 2399
2397 KABC::AddressBook::Iterator it; 2400 KABC::AddressBook::Iterator it;
2398 2401
2399 int count = 0; 2402 int count = 0;
2400 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2403 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2401 ++count; 2404 ++count;
2402 } 2405 }
2403 QProgressBar bar(count,0 ); 2406 QProgressBar bar(count,0 );
2404 int w = 300; 2407 int w = 300;
2405 if ( QApplication::desktop()->width() < 320 ) 2408 if ( QApplication::desktop()->width() < 320 )
2406 w = 220; 2409 w = 220;
2407 int h = bar.sizeHint().height() ; 2410 int h = bar.sizeHint().height() ;
2408 int dw = QApplication::desktop()->width(); 2411 int dw = QApplication::desktop()->width();
2409 int dh = QApplication::desktop()->height(); 2412 int dh = QApplication::desktop()->height();
2410 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2413 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2411 bar.show(); 2414 bar.show();
2412 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2415 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2413 qApp->processEvents(); 2416 qApp->processEvents();
2414 2417
2415 QDate bday; 2418 QDate bday;
2416 QString anni; 2419 QString anni;
2417 QString formattedbday; 2420 QString formattedbday;
2418 2421
2419 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2422 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2420 { 2423 {
2421 if ( ! bar.isVisible() ) 2424 if ( ! bar.isVisible() )
2422 return; 2425 return;
2423 bar.setProgress( count++ ); 2426 bar.setProgress( count++ );
2424 qApp->processEvents(); 2427 qApp->processEvents();
2425 bday = (*it).birthday().date(); 2428 bday = (*it).birthday().date();
2426 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2429 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2427 2430
2428 if ( bday.isValid() || !anni.isEmpty()) 2431 if ( bday.isValid() || !anni.isEmpty())
2429 { 2432 {
2430 if (bday.isValid()) 2433 if (bday.isValid())
2431 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2434 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2432 else 2435 else
2433 formattedbday = "NOTVALID"; 2436 formattedbday = "NOTVALID";
2434 if (anni.isEmpty()) 2437 if (anni.isEmpty())
2435 anni = "INVALID"; 2438 anni = "INVALID";
2436 2439
2437 birthdayList.append(formattedbday); 2440 birthdayList.append(formattedbday);
2438 anniversaryList.append(anni); //should be ISODate 2441 anniversaryList.append(anni); //should be ISODate
2439 realNameList.append((*it).realName()); 2442 realNameList.append((*it).realName());
2440 preferredEmailList.append((*it).preferredEmail()); 2443 preferredEmailList.append((*it).preferredEmail());
2441 assembledNameList.append((*it).assembledName()); 2444 assembledNameList.append((*it).assembledName());
2442 uidList.append((*it).uid()); 2445 uidList.append((*it).uid());
2443 2446
2444 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2447 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2445 } 2448 }
2446 } 2449 }
2447 2450
2448 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2451 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2449 2452
2450} 2453}
2451 2454
2452/* this method will be called through the QCop interface from other apps to show details of a contact. 2455/* this method will be called through the QCop interface from other apps to show details of a contact.
2453 */ 2456 */
2454void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2457void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2455{ 2458{
2456 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2459 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2457 2460
2458 QString foundUid = QString::null; 2461 QString foundUid = QString::null;
2459 if ( ! uid.isEmpty() ) { 2462 if ( ! uid.isEmpty() ) {
2460 Addressee adrr = mAddressBook->findByUid( uid ); 2463 Addressee adrr = mAddressBook->findByUid( uid );
2461 if ( !adrr.isEmpty() ) { 2464 if ( !adrr.isEmpty() ) {
2462 foundUid = uid; 2465 foundUid = uid;
2463 } 2466 }
2464 if ( email == "sendbacklist" ) { 2467 if ( email == "sendbacklist" ) {
2465 //qDebug("ssssssssssssssssssssssend "); 2468 //qDebug("ssssssssssssssssssssssend ");
2466 QStringList nameList; 2469 QStringList nameList;
2467 QStringList emailList; 2470 QStringList emailList;
2468 QStringList uidList; 2471 QStringList uidList;
2469 nameList.append(adrr.realName()); 2472 nameList.append(adrr.realName());
2470 emailList = adrr.emails(); 2473 emailList = adrr.emails();
2471 uidList.append( adrr.preferredEmail()); 2474 uidList.append( adrr.preferredEmail());
2472 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2475 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2473 return; 2476 return;
2474 } 2477 }
2475 2478
2476 } 2479 }
2477 2480
2478 if ( email == "sendbacklist" ) 2481 if ( email == "sendbacklist" )
2479 return; 2482 return;
2480 if (foundUid.isEmpty()) 2483 if (foundUid.isEmpty())
2481 { 2484 {
2482 //find the uid of the person first 2485 //find the uid of the person first
2483 Addressee::List namelist; 2486 Addressee::List namelist;
2484 Addressee::List emaillist; 2487 Addressee::List emaillist;
2485 2488
2486 if (!name.isEmpty()) 2489 if (!name.isEmpty())
2487 namelist = mAddressBook->findByName( name ); 2490 namelist = mAddressBook->findByName( name );
2488 2491
2489 if (!email.isEmpty()) 2492 if (!email.isEmpty())
2490 emaillist = mAddressBook->findByEmail( email ); 2493 emaillist = mAddressBook->findByEmail( email );
2491 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2494 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2492 //check if we have a match in Namelist and Emaillist 2495 //check if we have a match in Namelist and Emaillist
2493 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2496 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2494 foundUid = emaillist[0].uid(); 2497 foundUid = emaillist[0].uid();
2495 } 2498 }
2496 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2499 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2497 foundUid = namelist[0].uid(); 2500 foundUid = namelist[0].uid();
2498 else 2501 else
2499 { 2502 {
2500 for (int i = 0; i < namelist.count(); i++) 2503 for (int i = 0; i < namelist.count(); i++)
2501 { 2504 {
2502 for (int j = 0; j < emaillist.count(); j++) 2505 for (int j = 0; j < emaillist.count(); j++)
2503 { 2506 {
2504 if (namelist[i] == emaillist[j]) 2507 if (namelist[i] == emaillist[j])
2505 { 2508 {
2506 foundUid = namelist[i].uid(); 2509 foundUid = namelist[i].uid();
2507 } 2510 }
2508 } 2511 }
2509 } 2512 }
2510 } 2513 }
2511 } 2514 }
2512 else 2515 else
2513 { 2516 {
2514 foundUid = uid; 2517 foundUid = uid;
2515 } 2518 }
2516 2519
2517 if (!foundUid.isEmpty()) 2520 if (!foundUid.isEmpty())
2518 { 2521 {
2519 2522
2520 // raise Ka/Pi if it is in the background 2523 // raise Ka/Pi if it is in the background
2521#ifndef DESKTOP_VERSION 2524#ifndef DESKTOP_VERSION
2522#ifndef KORG_NODCOP 2525#ifndef KORG_NODCOP
2523 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2526 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2524#endif 2527#endif
2525#endif 2528#endif
2526 2529
2527 mMainWindow->showMaximized(); 2530 mMainWindow->showMaximized();
2528 mMainWindow-> raise(); 2531 mMainWindow-> raise();
2529 2532
2530 mViewManager->setSelected( "", false); 2533 mViewManager->setSelected( "", false);
2531 mViewManager->refreshView( "" ); 2534 mViewManager->refreshView( "" );
2532 mViewManager->setSelected( foundUid, true ); 2535 mViewManager->setSelected( foundUid, true );
2533 mViewManager->refreshView( foundUid ); 2536 mViewManager->refreshView( foundUid );
2534 2537
2535 if ( !mMultipleViewsAtOnce ) 2538 if ( !mMultipleViewsAtOnce )
2536 { 2539 {
2537 setDetailsVisible( true ); 2540 setDetailsVisible( true );
2538 mActionDetails->setChecked(true); 2541 mActionDetails->setChecked(true);
2539 } 2542 }
2540 } 2543 }
2541} 2544}
2542 2545
2543void KABCore::whatsnew() 2546void KABCore::whatsnew()
2544{ 2547{
2545 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2548 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2546} 2549}
2547void KABCore::synchowto() 2550void KABCore::synchowto()
2548{ 2551{
2549 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2552 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2550} 2553}
2551void KABCore::kdesynchowto() 2554void KABCore::kdesynchowto()
2552{ 2555{
2553 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2556 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2554} 2557}
2555void KABCore::multisynchowto() 2558void KABCore::multisynchowto()
2556{ 2559{
2557 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2560 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2558} 2561}
2559void KABCore::faq() 2562void KABCore::faq()
2560{ 2563{
2561 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2564 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2562} 2565}
2563 2566
2564#include <libkcal/syncdefines.h> 2567#include <libkcal/syncdefines.h>
2565 2568
2566KABC::Addressee KABCore::getLastSyncAddressee() 2569KABC::Addressee KABCore::getLastSyncAddressee()
2567{ 2570{
2568 Addressee lse; 2571 Addressee lse;
2569 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2572 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2570 2573
2571 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2574 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2572 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2575 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2573 if (lse.isEmpty()) { 2576 if (lse.isEmpty()) {
2574 qDebug("Creating new last-syncAddressee "); 2577 qDebug("Creating new last-syncAddressee ");
2575 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2578 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2576 QString sum = ""; 2579 QString sum = "";
2577 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2580 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2578 sum = "E: "; 2581 sum = "E: ";
2579 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2582 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2580 lse.setRevision( mLastAddressbookSync ); 2583 lse.setRevision( mLastAddressbookSync );
2581 lse.setCategories( i18n("SyncEvent") ); 2584 lse.setCategories( i18n("SyncEvent") );
2582 mAddressBook->insertAddressee( lse ); 2585 mAddressBook->insertAddressee( lse );
2583 } 2586 }
2584 return lse; 2587 return lse;
2585} 2588}
2586int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2589int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2587{ 2590{
2588 2591
2589 //void setZaurusId(int id); 2592 //void setZaurusId(int id);
2590 // int zaurusId() const; 2593 // int zaurusId() const;
2591 // void setZaurusUid(int id); 2594 // void setZaurusUid(int id);
2592 // int zaurusUid() const; 2595 // int zaurusUid() const;
2593 // void setZaurusStat(int id); 2596 // void setZaurusStat(int id);
2594 // int zaurusStat() const; 2597 // int zaurusStat() const;
2595 // 0 equal 2598 // 0 equal
2596 // 1 take local 2599 // 1 take local
2597 // 2 take remote 2600 // 2 take remote
2598 // 3 cancel 2601 // 3 cancel
2599 QDateTime lastSync = mLastAddressbookSync; 2602 QDateTime lastSync = mLastAddressbookSync;
2600 QDateTime localMod = local->revision(); 2603 QDateTime localMod = local->revision();
2601 QDateTime remoteMod = remote->revision(); 2604 QDateTime remoteMod = remote->revision();
2602 2605
2603 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2606 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2604 2607
2605 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2608 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2606 bool remCh, locCh; 2609 bool remCh, locCh;
2607 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2610 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2608 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2611 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2609 locCh = ( localMod > mLastAddressbookSync ); 2612 locCh = ( localMod > mLastAddressbookSync );
2610 if ( !remCh && ! locCh ) { 2613 if ( !remCh && ! locCh ) {
2611 //qDebug("both not changed "); 2614 //qDebug("both not changed ");
2612 lastSync = localMod.addDays(1); 2615 lastSync = localMod.addDays(1);
2613 if ( mode <= SYNC_PREF_ASK ) 2616 if ( mode <= SYNC_PREF_ASK )
2614 return 0; 2617 return 0;
2615 } else { 2618 } else {
2616 if ( locCh ) { 2619 if ( locCh ) {
2617 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2620 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2618 lastSync = localMod.addDays( -1 ); 2621 lastSync = localMod.addDays( -1 );
2619 if ( !remCh ) 2622 if ( !remCh )
2620 remoteMod =( lastSync.addDays( -1 ) ); 2623 remoteMod =( lastSync.addDays( -1 ) );
2621 } else { 2624 } else {
2622 //qDebug(" not loc changed "); 2625 //qDebug(" not loc changed ");
2623 lastSync = localMod.addDays( 1 ); 2626 lastSync = localMod.addDays( 1 );
2624 if ( remCh ) { 2627 if ( remCh ) {
2625 //qDebug("rem changed "); 2628 //qDebug("rem changed ");
2626 remoteMod =( lastSync.addDays( 1 ) ); 2629 remoteMod =( lastSync.addDays( 1 ) );
2627 } 2630 }
2628 2631
2629 } 2632 }
2630 } 2633 }
2631 full = true; 2634 full = true;
2632 if ( mode < SYNC_PREF_ASK ) 2635 if ( mode < SYNC_PREF_ASK )
2633 mode = SYNC_PREF_ASK; 2636 mode = SYNC_PREF_ASK;
2634 } else { 2637 } else {
2635 if ( localMod == remoteMod ) 2638 if ( localMod == remoteMod )
2636 return 0; 2639 return 0;
2637 2640
2638 } 2641 }
2639 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2642 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2640 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2643 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2641 //full = true; //debug only 2644 //full = true; //debug only
2642 if ( full ) { 2645 if ( full ) {
2643 bool equ = ( (*local) == (*remote) ); 2646 bool equ = ( (*local) == (*remote) );
2644 if ( equ ) { 2647 if ( equ ) {
2645 //qDebug("equal "); 2648 //qDebug("equal ");
2646 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2649 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2647 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2650 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2648 } 2651 }
2649 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2652 if ( mode < SYNC_PREF_FORCE_LOCAL )
2650 return 0; 2653 return 0;
2651 2654
2652 }//else //debug only 2655 }//else //debug only
2653 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2656 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2654 } 2657 }
2655 int result; 2658 int result;
2656 bool localIsNew; 2659 bool localIsNew;
2657 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2660 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2658 2661
2659 if ( full && mode < SYNC_PREF_NEWEST ) 2662 if ( full && mode < SYNC_PREF_NEWEST )
2660 mode = SYNC_PREF_ASK; 2663 mode = SYNC_PREF_ASK;
2661 2664
2662 switch( mode ) { 2665 switch( mode ) {
2663 case SYNC_PREF_LOCAL: 2666 case SYNC_PREF_LOCAL:
2664 if ( lastSync > remoteMod ) 2667 if ( lastSync > remoteMod )
2665 return 1; 2668 return 1;
2666 if ( lastSync > localMod ) 2669 if ( lastSync > localMod )
2667 return 2; 2670 return 2;
2668 return 1; 2671 return 1;
2669 break; 2672 break;
2670 case SYNC_PREF_REMOTE: 2673 case SYNC_PREF_REMOTE:
2671 if ( lastSync > remoteMod ) 2674 if ( lastSync > remoteMod )
2672 return 1; 2675 return 1;
2673 if ( lastSync > localMod ) 2676 if ( lastSync > localMod )
2674 return 2; 2677 return 2;
2675 return 2; 2678 return 2;
2676 break; 2679 break;
2677 case SYNC_PREF_NEWEST: 2680 case SYNC_PREF_NEWEST:
2678 if ( localMod > remoteMod ) 2681 if ( localMod > remoteMod )
2679 return 1; 2682 return 1;
2680 else 2683 else
2681 return 2; 2684 return 2;
2682 break; 2685 break;
2683 case SYNC_PREF_ASK: 2686 case SYNC_PREF_ASK:
2684 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2687 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2685 if ( lastSync > remoteMod ) 2688 if ( lastSync > remoteMod )
2686 return 1; 2689 return 1;
2687 if ( lastSync > localMod ) 2690 if ( lastSync > localMod )
2688 return 2; 2691 return 2;
2689 localIsNew = localMod >= remoteMod; 2692 localIsNew = localMod >= remoteMod;
2690 //qDebug("conflict! ************************************** "); 2693 //qDebug("conflict! ************************************** ");
2691 { 2694 {
2692 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2695 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2693 result = acd.executeD(localIsNew); 2696 result = acd.executeD(localIsNew);
2694 return result; 2697 return result;
2695 } 2698 }
2696 break; 2699 break;
2697 case SYNC_PREF_FORCE_LOCAL: 2700 case SYNC_PREF_FORCE_LOCAL:
2698 return 1; 2701 return 1;
2699 break; 2702 break;
2700 case SYNC_PREF_FORCE_REMOTE: 2703 case SYNC_PREF_FORCE_REMOTE:
2701 return 2; 2704 return 2;
2702 break; 2705 break;
2703 2706
2704 default: 2707 default:
2705 // SYNC_PREF_TAKE_BOTH not implemented 2708 // SYNC_PREF_TAKE_BOTH not implemented
2706 break; 2709 break;
2707 } 2710 }
2708 return 0; 2711 return 0;
2709} 2712}
2710 2713
2711 2714
2712bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2715bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2713{ 2716{
2714 bool syncOK = true; 2717 bool syncOK = true;
2715 int addedAddressee = 0; 2718 int addedAddressee = 0;
2716 int addedAddresseeR = 0; 2719 int addedAddresseeR = 0;
2717 int deletedAddresseeR = 0; 2720 int deletedAddresseeR = 0;
2718 int deletedAddresseeL = 0; 2721 int deletedAddresseeL = 0;
2719 int changedLocal = 0; 2722 int changedLocal = 0;
2720 int changedRemote = 0; 2723 int changedRemote = 0;
2721 2724
2722 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2725 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2723 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2726 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2724 2727
2725 //QPtrList<Addressee> el = local->rawAddressees(); 2728 //QPtrList<Addressee> el = local->rawAddressees();
2726 Addressee addresseeR; 2729 Addressee addresseeR;
2727 QString uid; 2730 QString uid;
2728 int take; 2731 int take;
2729 Addressee addresseeL; 2732 Addressee addresseeL;
2730 Addressee addresseeRSync; 2733 Addressee addresseeRSync;
2731 Addressee addresseeLSync; 2734 Addressee addresseeLSync;
2732 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2735 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2733 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2736 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2734 bool fullDateRange = false; 2737 bool fullDateRange = false;
2735 local->resetTempSyncStat(); 2738 local->resetTempSyncStat();
2736 mLastAddressbookSync = QDateTime::currentDateTime(); 2739 mLastAddressbookSync = QDateTime::currentDateTime();
2737 if ( syncManager->syncWithDesktop() ) { 2740 if ( syncManager->syncWithDesktop() ) {
2738 // remote->removeSyncInfo( QString());//remove all info 2741 // remote->removeSyncInfo( QString());//remove all info
2739 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2742 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2740 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2743 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2741 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2744 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2742 } else { 2745 } else {
2743 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2746 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2744 } 2747 }
2745 } 2748 }
2746 QDateTime modifiedCalendar = mLastAddressbookSync; 2749 QDateTime modifiedCalendar = mLastAddressbookSync;
2747 addresseeLSync = getLastSyncAddressee(); 2750 addresseeLSync = getLastSyncAddressee();
2748 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2751 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2749 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2752 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2750 if ( !addresseeR.isEmpty() ) { 2753 if ( !addresseeR.isEmpty() ) {
2751 addresseeRSync = addresseeR; 2754 addresseeRSync = addresseeR;
2752 remote->removeAddressee(addresseeR ); 2755 remote->removeAddressee(addresseeR );
2753 2756
2754 } else { 2757 } else {
2755 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2758 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2756 addresseeRSync = addresseeLSync ; 2759 addresseeRSync = addresseeLSync ;
2757 } else { 2760 } else {
2758 //qDebug("FULLDATE 1"); 2761 //qDebug("FULLDATE 1");
2759 fullDateRange = true; 2762 fullDateRange = true;
2760 Addressee newAdd; 2763 Addressee newAdd;
2761 addresseeRSync = newAdd; 2764 addresseeRSync = newAdd;
2762 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2765 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2763 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2766 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2764 addresseeRSync.setRevision( mLastAddressbookSync ); 2767 addresseeRSync.setRevision( mLastAddressbookSync );
2765 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2768 addresseeRSync.setCategories( i18n("SyncAddressee") );
2766 } 2769 }
2767 } 2770 }
2768 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2771 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2769 // qDebug("FULLDATE 2"); 2772 // qDebug("FULLDATE 2");
2770 fullDateRange = true; 2773 fullDateRange = true;
2771 } 2774 }
2772 if ( ! fullDateRange ) { 2775 if ( ! fullDateRange ) {
2773 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2776 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2774 2777
2775 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2778 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2776 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2779 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2777 fullDateRange = true; 2780 fullDateRange = true;
2778 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2781 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2779 } 2782 }
2780 } 2783 }
2781 // fullDateRange = true; // debug only! 2784 // fullDateRange = true; // debug only!
2782 if ( fullDateRange ) 2785 if ( fullDateRange )
2783 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2786 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2784 else 2787 else
2785 mLastAddressbookSync = addresseeLSync.revision(); 2788 mLastAddressbookSync = addresseeLSync.revision();
2786 // for resyncing if own file has changed 2789 // for resyncing if own file has changed
2787 // PENDING fixme later when implemented 2790 // PENDING fixme later when implemented
2788#if 0 2791#if 0
2789 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2792 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2790 mLastAddressbookSync = loadedFileVersion; 2793 mLastAddressbookSync = loadedFileVersion;
2791 qDebug("setting mLastAddressbookSync "); 2794 qDebug("setting mLastAddressbookSync ");
2792 } 2795 }
2793#endif 2796#endif
2794 2797
2795 //qDebug("*************************** "); 2798 //qDebug("*************************** ");
2796 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2799 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2797 QStringList er = remote->uidList(); 2800 QStringList er = remote->uidList();
2798 Addressee inR ;//= er.first(); 2801 Addressee inR ;//= er.first();
2799 Addressee inL; 2802 Addressee inL;
2800 2803
2801 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2804 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2802 2805
2803 int modulo = (er.count()/10)+1; 2806 int modulo = (er.count()/10)+1;
2804 int incCounter = 0; 2807 int incCounter = 0;
2805 while ( incCounter < er.count()) { 2808 while ( incCounter < er.count()) {
2806 if (syncManager->isProgressBarCanceled()) 2809 if (syncManager->isProgressBarCanceled())
2807 return false; 2810 return false;
2808 if ( incCounter % modulo == 0 ) 2811 if ( incCounter % modulo == 0 )
2809 syncManager->showProgressBar(incCounter); 2812 syncManager->showProgressBar(incCounter);
2810 2813
2811 uid = er[ incCounter ]; 2814 uid = er[ incCounter ];
2812 bool skipIncidence = false; 2815 bool skipIncidence = false;
2813 if ( uid.left(19) == QString("last-syncAddressee-") ) 2816 if ( uid.left(19) == QString("last-syncAddressee-") )
2814 skipIncidence = true; 2817 skipIncidence = true;
2815 QString idS,OidS; 2818 QString idS,OidS;
2816 qApp->processEvents(); 2819 qApp->processEvents();
2817 if ( !skipIncidence ) { 2820 if ( !skipIncidence ) {
2818 inL = local->findByUid( uid ); 2821 inL = local->findByUid( uid );
2819 inR = remote->findByUid( uid ); 2822 inR = remote->findByUid( uid );
2820 //inL.setResource( 0 ); 2823 //inL.setResource( 0 );
2821 //inR.setResource( 0 ); 2824 //inR.setResource( 0 );
2822 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2825 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2823 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2826 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2824 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2827 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2825 //qDebug("take %d %s ", take, inL.summary().latin1()); 2828 //qDebug("take %d %s ", take, inL.summary().latin1());
2826 if ( take == 3 ) 2829 if ( take == 3 )
2827 return false; 2830 return false;
2828 if ( take == 1 ) {// take local ********************** 2831 if ( take == 1 ) {// take local **********************
2829 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2832 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2830 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2833 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2831 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2834 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2832 local->insertAddressee( inL, false ); 2835 local->insertAddressee( inL, false );
2833 idS = inR.externalUID(); 2836 idS = inR.externalUID();
2834 OidS = inR.originalExternalUID(); 2837 OidS = inR.originalExternalUID();
2835 } 2838 }
2836 else 2839 else
2837 idS = inR.IDStr(); 2840 idS = inR.IDStr();
2838 remote->removeAddressee( inR ); 2841 remote->removeAddressee( inR );
2839 inR = inL; 2842 inR = inL;
2840 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2843 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2841 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2844 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2842 inR.setOriginalExternalUID( OidS ); 2845 inR.setOriginalExternalUID( OidS );
2843 inR.setExternalUID( idS ); 2846 inR.setExternalUID( idS );
2844 if ( syncManager->syncWithDesktop() ) { 2847 if ( syncManager->syncWithDesktop() ) {
2845 inR.setIDStr("changed" ); 2848 inR.setIDStr("changed" );
2846 } 2849 }
2847 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2850 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2848 } else { 2851 } else {
2849 inR.setIDStr( idS ); 2852 inR.setIDStr( idS );
2850 } 2853 }
2851 inR.setResource( 0 ); 2854 inR.setResource( 0 );
2852 remote->insertAddressee( inR , false); 2855 remote->insertAddressee( inR , false);
2853 ++changedRemote; 2856 ++changedRemote;
2854 } else { // take == 2 take remote ********************** 2857 } else { // take == 2 take remote **********************
2855 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2856 if ( inR.revision().date().year() < 2004 ) 2859 if ( inR.revision().date().year() < 2004 )
2857 inR.setRevision( modifiedCalendar ); 2860 inR.setRevision( modifiedCalendar );
2858 } 2861 }
2859 idS = inL.IDStr(); 2862 idS = inL.IDStr();
2860 local->removeAddressee( inL ); 2863 local->removeAddressee( inL );
2861 inL = inR; 2864 inL = inR;
2862 inL.setIDStr( idS ); 2865 inL.setIDStr( idS );
2863 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2866 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2864 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2867 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2865 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2868 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2866 } 2869 }
2867 inL.setResource( 0 ); 2870 inL.setResource( 0 );
2868 local->insertAddressee( inL , false ); 2871 local->insertAddressee( inL , false );
2869 ++changedLocal; 2872 ++changedLocal;
2870 } 2873 }
2871 } 2874 }
2872 } 2875 }
2873 } else { // no conflict ********** add or delete remote 2876 } else { // no conflict ********** add or delete remote
2874 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2877 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2875 QString des = addresseeLSync.note(); 2878 QString des = addresseeLSync.note();
2876 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2879 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2877 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2880 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2878 remote->insertAddressee( inR, false ); 2881 remote->insertAddressee( inR, false );
2879 ++deletedAddresseeR; 2882 ++deletedAddresseeR;
2880 } else { 2883 } else {
2881 inR.setRevision( modifiedCalendar ); 2884 inR.setRevision( modifiedCalendar );
2882 remote->insertAddressee( inR, false ); 2885 remote->insertAddressee( inR, false );
2883 inL = inR; 2886 inL = inR;
2884 inL.setIDStr( ":" ); 2887 inL.setIDStr( ":" );
2885 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2888 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2886 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2889 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2887 inL.setResource( 0 ); 2890 inL.setResource( 0 );
2888 local->insertAddressee( inL , false); 2891 local->insertAddressee( inL , false);
2889 ++addedAddressee; 2892 ++addedAddressee;
2890 } 2893 }
2891 } else { 2894 } else {
2892 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2895 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2893 inR.setRevision( modifiedCalendar ); 2896 inR.setRevision( modifiedCalendar );
2894 remote->insertAddressee( inR, false ); 2897 remote->insertAddressee( inR, false );
2895 inR.setResource( 0 ); 2898 inR.setResource( 0 );
2896 local->insertAddressee( inR, false ); 2899 local->insertAddressee( inR, false );
2897 ++addedAddressee; 2900 ++addedAddressee;
2898 } else { 2901 } else {
2899 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2902 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2900 remote->removeAddressee( inR ); 2903 remote->removeAddressee( inR );
2901 ++deletedAddresseeR; 2904 ++deletedAddresseeR;
2902 } 2905 }
2903 } 2906 }
2904 } 2907 }
2905 } 2908 }
2906 ++incCounter; 2909 ++incCounter;
2907 } 2910 }
2908 er.clear(); 2911 er.clear();
2909 QStringList el = local->uidList(); 2912 QStringList el = local->uidList();
2910 modulo = (el.count()/10)+1; 2913 modulo = (el.count()/10)+1;
2911 2914
2912 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2915 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2913 incCounter = 0; 2916 incCounter = 0;
2914 while ( incCounter < el.count()) { 2917 while ( incCounter < el.count()) {
2915 qApp->processEvents(); 2918 qApp->processEvents();
2916 if (syncManager->isProgressBarCanceled()) 2919 if (syncManager->isProgressBarCanceled())
2917 return false; 2920 return false;
2918 if ( incCounter % modulo == 0 ) 2921 if ( incCounter % modulo == 0 )
2919 syncManager->showProgressBar(incCounter); 2922 syncManager->showProgressBar(incCounter);
2920 uid = el[ incCounter ]; 2923 uid = el[ incCounter ];
2921 bool skipIncidence = false; 2924 bool skipIncidence = false;
2922 if ( uid.left(19) == QString("last-syncAddressee-") ) 2925 if ( uid.left(19) == QString("last-syncAddressee-") )
2923 skipIncidence = true; 2926 skipIncidence = true;
2924 if ( !skipIncidence ) { 2927 if ( !skipIncidence ) {
2925 inL = local->findByUid( uid ); 2928 inL = local->findByUid( uid );
2926 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2929 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2927 inR = remote->findByUid( uid ); 2930 inR = remote->findByUid( uid );
2928 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2931 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2932 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2930 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2933 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2931 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2934 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2932 local->removeAddressee( inL ); 2935 local->removeAddressee( inL );
2933 ++deletedAddresseeL; 2936 ++deletedAddresseeL;
2934 } else { 2937 } else {
2935 if ( ! syncManager->mWriteBackExistingOnly ) { 2938 if ( ! syncManager->mWriteBackExistingOnly ) {
2936 inL.removeID(mCurrentSyncDevice ); 2939 inL.removeID(mCurrentSyncDevice );
2937 ++addedAddresseeR; 2940 ++addedAddresseeR;
2938 inL.setRevision( modifiedCalendar ); 2941 inL.setRevision( modifiedCalendar );
2939 local->insertAddressee( inL, false ); 2942 local->insertAddressee( inL, false );
2940 inR = inL; 2943 inR = inL;
2941 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2944 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2942 inR.setResource( 0 ); 2945 inR.setResource( 0 );
2943 remote->insertAddressee( inR, false ); 2946 remote->insertAddressee( inR, false );
2944 } 2947 }
2945 } 2948 }
2946 } else { 2949 } else {
2947 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2950 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2948 //qDebug("data %s ", inL.revision().toString().latin1()); 2951 //qDebug("data %s ", inL.revision().toString().latin1());
2949 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2952 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2950 local->removeAddressee( inL ); 2953 local->removeAddressee( inL );
2951 ++deletedAddresseeL; 2954 ++deletedAddresseeL;
2952 } else { 2955 } else {
2953 if ( ! syncManager->mWriteBackExistingOnly ) { 2956 if ( ! syncManager->mWriteBackExistingOnly ) {
2954 ++addedAddresseeR; 2957 ++addedAddresseeR;
2955 inL.setRevision( modifiedCalendar ); 2958 inL.setRevision( modifiedCalendar );
2956 local->insertAddressee( inL, false ); 2959 local->insertAddressee( inL, false );
2957 inR = inL; 2960 inR = inL;
2958 inR.setIDStr( ":" ); 2961 inR.setIDStr( ":" );
2959 inR.setResource( 0 ); 2962 inR.setResource( 0 );
2960 remote->insertAddressee( inR, false ); 2963 remote->insertAddressee( inR, false );
2961 } 2964 }
2962 } 2965 }
2963 } 2966 }
2964 } 2967 }
2965 } 2968 }
2966 } 2969 }
2967 ++incCounter; 2970 ++incCounter;
2968 } 2971 }
2969 el.clear(); 2972 el.clear();
2970 syncManager->hideProgressBar(); 2973 syncManager->hideProgressBar();
2971 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2974 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2972 // get rid of micro seconds 2975 // get rid of micro seconds
2973 QTime t = mLastAddressbookSync.time(); 2976 QTime t = mLastAddressbookSync.time();
2974 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2977 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2975 addresseeLSync.setRevision( mLastAddressbookSync ); 2978 addresseeLSync.setRevision( mLastAddressbookSync );
2976 addresseeRSync.setRevision( mLastAddressbookSync ); 2979 addresseeRSync.setRevision( mLastAddressbookSync );
2977 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2980 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2978 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2981 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2979 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2982 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2980 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2983 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2981 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2984 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2982 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2985 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2983 addresseeRSync.setNote( "" ) ; 2986 addresseeRSync.setNote( "" ) ;
2984 addresseeLSync.setNote( "" ); 2987 addresseeLSync.setNote( "" );
2985 2988
2986 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2989 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2987 remote->insertAddressee( addresseeRSync, false ); 2990 remote->insertAddressee( addresseeRSync, false );
2988 local->insertAddressee( addresseeLSync, false ); 2991 local->insertAddressee( addresseeLSync, false );
2989 QString mes; 2992 QString mes;
2990 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2993 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2991 qDebug( mes ); 2994 qDebug( mes );
2992 mes = i18n("Local addressbook changed!\n") +mes; 2995 mes = i18n("Local addressbook changed!\n") +mes;
2993 if ( syncManager->mShowSyncSummary ) { 2996 if ( syncManager->mShowSyncSummary ) {
2994 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2997 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2995 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2998 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2996 qDebug("cancelled "); 2999 qDebug("cancelled ");
2997 return false; 3000 return false;
2998 } 3001 }
2999 } 3002 }
3000 return syncOK; 3003 return syncOK;
3001} 3004}
3002 3005
3003 3006
3004//this is a overwritten callbackmethods from the syncinterface 3007//this is a overwritten callbackmethods from the syncinterface
3005bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3008bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3006{ 3009{
3007 3010
3008 //pending prepare addresseeview for output 3011 //pending prepare addresseeview for output
3009 //pending detect, if remote file has REV field. if not switch to external sync 3012 //pending detect, if remote file has REV field. if not switch to external sync
3010 mGlobalSyncMode = SYNC_MODE_NORMAL; 3013 mGlobalSyncMode = SYNC_MODE_NORMAL;
3011 if ( manager != syncManager ) 3014 if ( manager != syncManager )
3012 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3015 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3013 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3016 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3014 3017
3015 AddressBook abLocal(filename,"syncContact"); 3018 AddressBook abLocal(filename,"syncContact");
3016 bool syncOK = false; 3019 bool syncOK = false;
3017 if ( abLocal.load() ) { 3020 if ( abLocal.load() ) {
3018 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3021 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3019 bool external = false; 3022 bool external = false;
3020 bool isXML = false; 3023 bool isXML = false;
3021 if ( filename.right(4) == ".xml") { 3024 if ( filename.right(4) == ".xml") {
3022 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3025 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3023 isXML = true; 3026 isXML = true;
3024 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3027 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3025 } else { 3028 } else {
3026 external = !manager->mIsKapiFile; 3029 external = !manager->mIsKapiFile;
3027 if ( external ) { 3030 if ( external ) {
3028 qDebug("Setting vcf mode to external "); 3031 qDebug("Setting vcf mode to external ");
3029 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3032 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3030 AddressBook::Iterator it; 3033 AddressBook::Iterator it;
3031 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3034 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3032 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3035 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3033 (*it).computeCsum( mCurrentSyncDevice ); 3036 (*it).computeCsum( mCurrentSyncDevice );
3034 } 3037 }
3035 } 3038 }
3036 } 3039 }
3037 //AddressBook::Iterator it; 3040 //AddressBook::Iterator it;
3038 //QStringList vcards; 3041 //QStringList vcards;
3039 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3042 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3040 // qDebug("Name %s ", (*it).familyName().latin1()); 3043 // qDebug("Name %s ", (*it).familyName().latin1());
3041 //} 3044 //}
3042 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3043 if ( syncOK ) { 3046 if ( syncOK ) {
3044 if ( syncManager->mWriteBackFile ) 3047 if ( syncManager->mWriteBackFile )
3045 { 3048 {
3046 if ( external ) 3049 if ( external )
3047 abLocal.removeSyncAddressees( !isXML); 3050 abLocal.removeSyncAddressees( !isXML);
3048 qDebug("Saving remote AB "); 3051 qDebug("Saving remote AB ");
3049 if ( ! abLocal.saveAB()) 3052 if ( ! abLocal.saveAB())
3050 qDebug("Error writing back AB to file "); 3053 qDebug("Error writing back AB to file ");
3051 if ( external ) { 3054 if ( external ) {
3052 // afterwrite processing 3055 // afterwrite processing
3053 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3056 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3054 } 3057 }
3055 } 3058 }
3056 } 3059 }
3057 setModified(); 3060 setModified();
3058 3061
3059 } 3062 }
3060 abLocal.removeResources(); 3063 abLocal.removeResources();
3061 if ( syncOK ) 3064 if ( syncOK )
3062 mViewManager->refreshView(); 3065 mViewManager->refreshView();
3063 return syncOK; 3066 return syncOK;
3064 3067
3065} 3068}
3066void KABCore::removeSyncInfo( QString syncProfile) 3069void KABCore::removeSyncInfo( QString syncProfile)
3067{ 3070{
3068 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3071 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3069 mAddressBook->removeSyncInfo( syncProfile ); 3072 mAddressBook->removeSyncInfo( syncProfile );
3070 setModified(); 3073 setModified();
3071} 3074}
3072 3075
3073 3076
3074//this is a overwritten callbackmethods from the syncinterface 3077//this is a overwritten callbackmethods from the syncinterface
3075bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3078bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3076{ 3079{
3077 if ( resource == "phone" ) 3080 if ( resource == "phone" )
3078 return syncPhone(); 3081 return syncPhone();
3079 disableBR( true ); 3082 disableBR( true );
3080 if ( manager != syncManager ) 3083 if ( manager != syncManager )
3081 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3084 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3082 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3085 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3083 3086
3084 AddressBook abLocal( resource,"syncContact"); 3087 AddressBook abLocal( resource,"syncContact");
3085 bool syncOK = false; 3088 bool syncOK = false;
3086 if ( abLocal.load() ) { 3089 if ( abLocal.load() ) {
3087 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3090 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3088 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3091 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3089 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3092 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3090 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3093 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3091 if ( syncOK ) { 3094 if ( syncOK ) {
3092 if ( syncManager->mWriteBackFile ) { 3095 if ( syncManager->mWriteBackFile ) {
3093 abLocal.removeSyncAddressees( false ); 3096 abLocal.removeSyncAddressees( false );
3094 abLocal.saveAB(); 3097 abLocal.saveAB();
3095 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3098 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3096 } 3099 }
3097 } else 3100 } else
3098 message( i18n("Sync cancelled or failed.") ); 3101 message( i18n("Sync cancelled or failed.") );
3099 setModified(); 3102 setModified();
3100 } 3103 }
3101 abLocal.removeResources(); 3104 abLocal.removeResources();
3102 if ( syncOK ) 3105 if ( syncOK )
3103 mViewManager->refreshView(); 3106 mViewManager->refreshView();
3104 disableBR( false ); 3107 disableBR( false );
3105 return syncOK; 3108 return syncOK;
3106 3109
3107} 3110}
3108void KABCore::message( QString m ) 3111void KABCore::message( QString m )
3109{ 3112{
3110 topLevelWidget()->setCaption( m ); 3113 topLevelWidget()->setCaption( m );
3111 mMessageTimer->start( 15000, true ); 3114 mMessageTimer->start( 15000, true );
3112} 3115}
3113bool KABCore::syncPhone() 3116bool KABCore::syncPhone()
3114{ 3117{
3115 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3118 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3116 QString fileName = getPhoneFile(); 3119 QString fileName = getPhoneFile();
3117 if ( !PhoneAccess::readFromPhone( fileName) ) { 3120 if ( !PhoneAccess::readFromPhone( fileName) ) {
3118 message(i18n("Phone access failed!")); 3121 message(i18n("Phone access failed!"));
3119 return false; 3122 return false;
3120 } 3123 }
3121 AddressBook abLocal( fileName,"syncContact"); 3124 AddressBook abLocal( fileName,"syncContact");
3122 bool syncOK = false; 3125 bool syncOK = false;
3123 { 3126 {
3124 abLocal.importFromFile( fileName ); 3127 abLocal.importFromFile( fileName );
3125 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3128 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3126 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3129 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3127 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3130 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3128 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3131 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3129 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3132 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3130 if ( syncOK ) { 3133 if ( syncOK ) {
3131 if ( syncManager->mWriteBackFile ) { 3134 if ( syncManager->mWriteBackFile ) {
3132 abLocal.removeSyncAddressees( true ); 3135 abLocal.removeSyncAddressees( true );
3133 abLocal.saveABphone( fileName ); 3136 abLocal.saveABphone( fileName );
3134 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3137 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3135 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3138 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3136 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3139 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3137 } 3140 }
3138 } 3141 }
3139 setModified(); 3142 setModified();
3140 } 3143 }
3141 abLocal.removeResources(); 3144 abLocal.removeResources();
3142 if ( syncOK ) 3145 if ( syncOK )
3143 mViewManager->refreshView(); 3146 mViewManager->refreshView();
3144 return syncOK; 3147 return syncOK;
3145} 3148}
3146void KABCore::getFile( bool success ) 3149void KABCore::getFile( bool success )
3147{ 3150{
3148 if ( ! success ) { 3151 if ( ! success ) {
3149 message( i18n("Error receiving file. Nothing changed!") ); 3152 message( i18n("Error receiving file. Nothing changed!") );
3150 return; 3153 return;
3151 } 3154 }
3152 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3155 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3153 if ( count ) 3156 if ( count )
3154 setModified( true ); 3157 setModified( true );
3155 message( i18n("Pi-Sync successful!") ); 3158 message( i18n("Pi-Sync successful!") );
3156 mViewManager->refreshView(); 3159 mViewManager->refreshView();
3157} 3160}
3158void KABCore::syncFileRequest() 3161void KABCore::syncFileRequest()
3159{ 3162{
3160 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3163 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3161 syncManager->slotSyncMenu( 999 ); 3164 syncManager->slotSyncMenu( 999 );
3162 } 3165 }
3163 mAddressBook->export2File( sentSyncFile() ); 3166 mAddressBook->export2File( sentSyncFile() );
3164} 3167}
3165QString KABCore::sentSyncFile() 3168QString KABCore::sentSyncFile()
3166{ 3169{
3167#ifdef DESKTOP_VERSION 3170#ifdef DESKTOP_VERSION
3168 return locateLocal( "tmp", "copysyncab.vcf" ); 3171 return locateLocal( "tmp", "copysyncab.vcf" );
3169#else 3172#else
3170 return QString( "/tmp/copysyncab.vcf" ); 3173 return QString( "/tmp/copysyncab.vcf" );
3171#endif 3174#endif
3172} 3175}
3173 3176
3174void KABCore::setCaptionBack() 3177void KABCore::setCaptionBack()
3175{ 3178{
3176 mMessageTimer->stop(); 3179 mMessageTimer->stop();
3177 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3180 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3178} 3181}
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 0d91c12..33bef5a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,718 +1,725 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h>
63#include <qwidgetstack.h> 64#include <qwidgetstack.h>
64 65
65#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
66#include "filtereditdialog.h" 67#include "filtereditdialog.h"
67#include "addviewdialog.h" 68#include "addviewdialog.h"
68#include "kabcore.h" 69#include "kabcore.h"
69#include "kabprefs.h" 70#include "kabprefs.h"
70#include "viewmanager.h" 71#include "viewmanager.h"
71 72
72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
74{ 75{
75 initGUI(); 76 initGUI();
76 initActions(); 77 initActions();
77 78
78 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
79 80
80 createViewFactories(); 81 createViewFactories();
81} 82}
82 83
83ViewManager::~ViewManager() 84ViewManager::~ViewManager()
84{ 85{
85 unloadViews(); 86 unloadViews();
86 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
87} 88}
88void ViewManager::scrollUP() 89void ViewManager::scrollUP()
89{ 90{
90 if ( mActiveView ) 91 if ( mActiveView )
91 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
92} 93}
93void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
94{ 95{
95 if ( mActiveView ) 96 if ( mActiveView )
96 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
97} 98}
98void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
99{ 100{
100 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
101 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
102 103
103 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
104 105
105 // Filter 106 // Filter
106 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
107 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
108 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
109 mActionSelectFilter->setComboWidth( 150 ); 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 )
112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw );
110 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
111 // been modified by global settings 115 // been modified by global settings
112 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
113 117
114 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
115 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
116 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
117 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
118 } 122 }
119 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
120 124
121 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
122} 126}
123 127
124void ViewManager::saveSettings() 128void ViewManager::saveSettings()
125{ 129{
126 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
127 131
128 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
129 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
130 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
131#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
132 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
133#else 137#else
134 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
135#endif 139#endif
136 } 140 }
137 141
138 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
139 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
140 144
141 // write the view name list 145 // write the view name list
142 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
143 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
144 148
145} 149}
146 150
147QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
148{ 152{
149 if ( mActiveView ) 153 if ( mActiveView )
150 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
151 else 155 else
152 return QStringList(); 156 return QStringList();
153} 157}
154 158
155QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
156{ 160{
157 if ( mActiveView ) 161 if ( mActiveView )
158 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
159 else 163 else
160 return QStringList(); 164 return QStringList();
161} 165}
162 166
163KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
164{ 168{
165 KABC::Addressee::List list; 169 KABC::Addressee::List list;
166 if ( mActiveView ) { 170 if ( mActiveView ) {
167 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
168 QStringList::Iterator it; 172 QStringList::Iterator it;
169 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
170 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
171 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
172 list.append( addr ); 176 list.append( addr );
173 } 177 }
174 } 178 }
175 179
176 return list; 180 return list;
177} 181}
178//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
179void ViewManager::setSelected() 183void ViewManager::setSelected()
180{ 184{
181 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
182} 186}
183 187
184void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
185{ 189{
186 if ( mActiveView ) 190 if ( mActiveView )
187 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
188} 192}
189 193
190void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
191{ 195{
192 int i, count = list.count(); 196 int i, count = list.count();
193 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
194 setSelected( list[i], true ); 198 setSelected( list[i], true );
195 199
196} 200}
197void ViewManager::unloadViews() 201void ViewManager::unloadViews()
198{ 202{
199 mViewDict.clear(); 203 mViewDict.clear();
200 mActiveView = 0; 204 mActiveView = 0;
201} 205}
202 206
203void ViewManager::setActiveView( const QString &name ) 207void ViewManager::setActiveView( const QString &name )
204{ 208{
205 KAddressBookView *view = 0; 209 KAddressBookView *view = 0;
206 210
207 // Check that this isn't the same as the current active view 211 // Check that this isn't the same as the current active view
208 if ( mActiveView && ( mActiveView->caption() == name ) ) 212 if ( mActiveView && ( mActiveView->caption() == name ) )
209 return; 213 return;
210 214
211 // At this point we know the view that should be active is not 215 // At this point we know the view that should be active is not
212 // currently active. We will try to find the new on in the list. If 216 // currently active. We will try to find the new on in the list. If
213 // we can't find it, it means it hasn't been instantiated, so we will 217 // we can't find it, it means it hasn't been instantiated, so we will
214 // create it on demand. 218 // create it on demand.
215 219
216 view = mViewDict.find( name ); 220 view = mViewDict.find( name );
217 221
218 // Check if we found the view. If we didn't, then we need to create it 222 // Check if we found the view. If we didn't, then we need to create it
219 if ( view == 0 ) { 223 if ( view == 0 ) {
220 KConfig *config = mCore->config(); 224 KConfig *config = mCore->config();
221 225
222 KConfigGroupSaver saver( config, name ); 226 KConfigGroupSaver saver( config, name );
223 227
224 QString type = config->readEntry( "Type", "Table" ); 228 QString type = config->readEntry( "Type", "Table" );
225 229
226 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
227 231
228 ViewFactory *factory = mViewFactoryDict.find( type ); 232 ViewFactory *factory = mViewFactoryDict.find( type );
229 if ( factory ) 233 if ( factory )
230 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 234 view = factory->view( mCore->addressBook(), mViewWidgetStack );
231 235
232 if ( view ) { 236 if ( view ) {
233 view->setCaption( name ); 237 view->setCaption( name );
234 mViewDict.insert( name, view ); 238 mViewDict.insert( name, view );
235//US my version needs an int as second parameter to addWidget 239//US my version needs an int as second parameter to addWidget
236 mViewWidgetStack->addWidget( view, -1 ); 240 mViewWidgetStack->addWidget( view, -1 );
237 view->readConfig( config ); 241 view->readConfig( config );
238 242
239 // The manager just relays the signals 243 // The manager just relays the signals
240 connect( view, SIGNAL( selected( const QString& ) ), 244 connect( view, SIGNAL( selected( const QString& ) ),
241 SIGNAL( selected( const QString & ) ) ); 245 SIGNAL( selected( const QString & ) ) );
242 connect( view, SIGNAL( executed( const QString& ) ), 246 connect( view, SIGNAL( executed( const QString& ) ),
243 SIGNAL( executed( const QString& ) ) ); 247 SIGNAL( executed( const QString& ) ) );
244 248
245 connect( view, SIGNAL( deleteRequest( ) ), 249 connect( view, SIGNAL( deleteRequest( ) ),
246 SIGNAL( deleteRequest( ) ) ); 250 SIGNAL( deleteRequest( ) ) );
247 251
248 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
249 connect( view, SIGNAL( dropped( QDropEvent* ) ), 253 connect( view, SIGNAL( dropped( QDropEvent* ) ),
250 SLOT( dropped( QDropEvent* ) ) ); 254 SLOT( dropped( QDropEvent* ) ) );
251 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
252 } 256 }
253 } 257 }
254 258
255 // If we found or created the view, raise it and refresh it 259 // If we found or created the view, raise it and refresh it
256 if ( view ) { 260 if ( view ) {
257 mActiveView = view; 261 mActiveView = view;
258 mViewWidgetStack->raiseWidget( view ); 262 mViewWidgetStack->raiseWidget( view );
259 // Set the proper filter in the view. By setting the combo 263 // Set the proper filter in the view. By setting the combo
260 // box, the activated slot will be called, which will push 264 // box, the activated slot will be called, which will push
261 // the filter to the view and refresh it. 265 // the filter to the view and refresh it.
262 266
263 if ( view->defaultFilterType() == KAddressBookView::None ) { 267 if ( view->defaultFilterType() == KAddressBookView::None ) {
264 268
265 mActionSelectFilter->setCurrentItem( 0 ); 269 mActionSelectFilter->setCurrentItem( 0 );
266 setActiveFilter( 0 ); 270 setActiveFilter( 0 );
267 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
268 setActiveFilter( mActionSelectFilter->currentItem() ); 272 setActiveFilter( mActionSelectFilter->currentItem() );
269 } else { 273 } else {
270 uint pos = filterPosition( view->defaultFilterName() ); 274 uint pos = filterPosition( view->defaultFilterName() );
271 mActionSelectFilter->setCurrentItem( pos ); 275 mActionSelectFilter->setCurrentItem( pos );
272 setActiveFilter( pos ); 276 setActiveFilter( pos );
273 } 277 }
274//US qDebug("ViewManager::setActiveView 6" ); 278//US qDebug("ViewManager::setActiveView 6" );
275 279
276 // Update the inc search widget to show the fields in the new active 280 // Update the inc search widget to show the fields in the new active
277 // view. 281 // view.
278 mCore->setSearchFields( mActiveView->fields() ); 282 mCore->setSearchFields( mActiveView->fields() );
279 283
280//US performance optimization. setActiveFilter calls also mActiveView->refresh() 284//US performance optimization. setActiveFilter calls also mActiveView->refresh()
281//US mActiveView->refresh(); 285//US mActiveView->refresh();
282 286
283 } 287 }
284 else 288 else
285 { 289 {
286 qDebug("ViewManager::setActiveView: unable to find view" ); 290 qDebug("ViewManager::setActiveView: unable to find view" );
287 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; 291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
288 } 292 }
289} 293}
290 294
291//US added another method with no parameter, since my moc compiler does not support default parameters. 295//US added another method with no parameter, since my moc compiler does not support default parameters.
292void ViewManager::refreshView() 296void ViewManager::refreshView()
293{ 297{
294 refreshView( QString::null ); 298 refreshView( QString::null );
295} 299}
296 300
297void ViewManager::refreshView( const QString &uid ) 301void ViewManager::refreshView( const QString &uid )
298{ 302{
299 if ( mActiveView ) 303 if ( mActiveView )
300 mActiveView->refresh( uid ); 304 mActiveView->refresh( uid );
301} 305}
302 306
303void ViewManager::setFocusAV() 307void ViewManager::setFocusAV()
304{ 308{
305 if ( mActiveView ) 309 if ( mActiveView )
306 mActiveView->setFocusAV(); 310 mActiveView->setFocusAV();
307} 311}
308void ViewManager::editView() 312void ViewManager::editView()
309{ 313{
310 if ( !mActiveView ) 314 if ( !mActiveView )
311 return; 315 return;
312 316
313 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
314 ViewConfigureWidget *wdg = 0; 318 ViewConfigureWidget *wdg = 0;
315 ViewConfigureDialog* dlg = 0; 319 ViewConfigureDialog* dlg = 0;
316 if ( factory ) { 320 if ( factory ) {
317 // Save the filters so the dialog has the latest set 321 // Save the filters so the dialog has the latest set
318 Filter::save( mCore->config(), "Filter", mFilterList ); 322 Filter::save( mCore->config(), "Filter", mFilterList );
319 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
320 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
321 } else { 325 } else {
322 qDebug("ViewManager::editView()::cannot find viewfactory "); 326 qDebug("ViewManager::editView()::cannot find viewfactory ");
323 return; 327 return;
324 } 328 }
325 if ( wdg ) { 329 if ( wdg ) {
326 dlg->setWidget( wdg ); 330 dlg->setWidget( wdg );
327 331
328#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
329 //dlg.setMaximumSize( 640, 480 ); 333 //dlg.setMaximumSize( 640, 480 );
330 //dlg->setGeometry( 40,40, 400, 300); 334 //dlg->setGeometry( 40,40, 400, 300);
331 dlg->showMaximized(); 335 dlg->showMaximized();
332#endif 336#endif
333 337
334 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
335 339
336 dlg->restoreSettings( mCore->config() ); 340 dlg->restoreSettings( mCore->config() );
337 341
338 if ( dlg->exec() ) { 342 if ( dlg->exec() ) {
339 dlg->saveSettings( mCore->config() ); 343 dlg->saveSettings( mCore->config() );
340 mActiveView->readConfig( mCore->config() ); 344 mActiveView->readConfig( mCore->config() );
341 345
342 // Set the proper filter in the view. By setting the combo 346 // Set the proper filter in the view. By setting the combo
343 // box, the activated slot will be called, which will push 347 // box, the activated slot will be called, which will push
344 // the filter to the view and refresh it. 348 // the filter to the view and refresh it.
345 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
346 mActionSelectFilter->setCurrentItem( 0 ); 350 mActionSelectFilter->setCurrentItem( 0 );
347 setActiveFilter( 0 ); 351 setActiveFilter( 0 );
348 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
349 setActiveFilter( mActionSelectFilter->currentItem() ); 353 setActiveFilter( mActionSelectFilter->currentItem() );
350 } else { 354 } else {
351 uint pos = filterPosition( mActiveView->defaultFilterName() ); 355 uint pos = filterPosition( mActiveView->defaultFilterName() );
352 mActionSelectFilter->setCurrentItem( pos ); 356 mActionSelectFilter->setCurrentItem( pos );
353 setActiveFilter( pos ); 357 setActiveFilter( pos );
354 } 358 }
355 mCore->setSearchFields( mActiveView->fields() ); 359 mCore->setSearchFields( mActiveView->fields() );
356//US performance optimization. setActiveFilter calls also mActiveView->refresh() 360//US performance optimization. setActiveFilter calls also mActiveView->refresh()
357//US mActiveView->refresh(); 361//US mActiveView->refresh();
358 362
359 363
360 //US this is a bugfix, that we get notified if we change a views configuration 364 //US this is a bugfix, that we get notified if we change a views configuration
361 emit modified(); 365 emit modified();
362 366
363 } 367 }
364 368
365 } 369 }
366 delete dlg; 370 delete dlg;
367} 371}
368 372
369void ViewManager::deleteView() 373void ViewManager::deleteView()
370{ 374{
371 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 375 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
372 .arg( mActiveView->caption() ); 376 .arg( mActiveView->caption() );
373 QString caption = i18n( "Confirm Delete" ); 377 QString caption = i18n( "Confirm Delete" );
374 378
375 379
376 if (QMessageBox::information( this, caption, 380 if (QMessageBox::information( this, caption,
377 text, 381 text,
378 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 382 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
379 { 383 {
380 mViewNameList.remove( mActiveView->caption() ); 384 mViewNameList.remove( mActiveView->caption() );
381 385
382 // remove the view from the config file 386 // remove the view from the config file
383 KConfig *config = mCore->config(); 387 KConfig *config = mCore->config();
384 config->deleteGroup( mActiveView->caption() ); 388 config->deleteGroup( mActiveView->caption() );
385 389
386 mViewDict.remove( mActiveView->caption() ); 390 mViewDict.remove( mActiveView->caption() );
387 mActiveView = 0; 391 mActiveView = 0;
388 392
389 // we are in an invalid state now, but that should be fixed after 393 // we are in an invalid state now, but that should be fixed after
390 // we emit the signal 394 // we emit the signal
391 mActionSelectView->setItems( mViewNameList ); 395 mActionSelectView->setItems( mViewNameList );
392 if ( mViewNameList.count() > 0 ) { 396 if ( mViewNameList.count() > 0 ) {
393 mActionSelectView->setCurrentItem( 0 ); 397 mActionSelectView->setCurrentItem( 0 );
394 setActiveView( mViewNameList[ 0 ] ); 398 setActiveView( mViewNameList[ 0 ] );
395 } 399 }
396 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 400 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
397 } 401 }
398} 402}
399 403
400void ViewManager::addView() 404void ViewManager::addView()
401{ 405{
402 AddViewDialog dialog( &mViewFactoryDict, this ); 406 AddViewDialog dialog( &mViewFactoryDict, this );
403 407
404 if ( dialog.exec() ) { 408 if ( dialog.exec() ) {
405 QString newName = dialog.viewName(); 409 QString newName = dialog.viewName();
406 QString type = dialog.viewType(); 410 QString type = dialog.viewType();
407 411
408 // Check for name conflicts 412 // Check for name conflicts
409 bool firstConflict = true; 413 bool firstConflict = true;
410 int numTries = 1; 414 int numTries = 1;
411 while ( mViewNameList.contains( newName ) > 0 ) { 415 while ( mViewNameList.contains( newName ) > 0 ) {
412 if ( !firstConflict ) { 416 if ( !firstConflict ) {
413 newName = newName.left( newName.length() - 4 ); 417 newName = newName.left( newName.length() - 4 );
414 firstConflict = false; 418 firstConflict = false;
415 } 419 }
416 420
417 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 421 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
418 numTries++; 422 numTries++;
419 } 423 }
420 424
421 // Add the new one to the list 425 // Add the new one to the list
422 mViewNameList.append( newName ); 426 mViewNameList.append( newName );
423 427
424 // write the view to the config file, 428 // write the view to the config file,
425 KConfig *config = mCore->config(); 429 KConfig *config = mCore->config();
426 430
427 config->deleteGroup( newName ); 431 config->deleteGroup( newName );
428 432
429 KConfigGroupSaver saver( config, newName ); 433 KConfigGroupSaver saver( config, newName );
430 434
431 config->writeEntry( "Type", type ); 435 config->writeEntry( "Type", type );
432 436
433 // try to set the active view 437 // try to set the active view
434 mActionSelectView->setItems( mViewNameList ); 438 mActionSelectView->setItems( mViewNameList );
435 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 439 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
436 setActiveView( newName ); 440 setActiveView( newName );
437 441
438 editView(); 442 editView();
439 443
440 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 444 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
441 } 445 }
442} 446}
443 447
444void ViewManager::createViewFactories() 448void ViewManager::createViewFactories()
445{ 449{
446#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
447 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 451 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
448 KTrader::OfferList::ConstIterator it; 452 KTrader::OfferList::ConstIterator it;
449 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 453 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
450 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 454 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
451 continue; 455 continue;
452 456
453 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 457 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
454 458
455 if ( !factory ) { 459 if ( !factory ) {
456 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 460 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
457 continue; 461 continue;
458 } 462 }
459 463
460 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 464 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
461 465
462 if ( !viewFactory ) { 466 if ( !viewFactory ) {
463 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 467 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
464 continue; 468 continue;
465 } 469 }
466 470
467 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 471 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
468 } 472 }
469 473
470#else //KAB_EMBEDDED 474#else //KAB_EMBEDDED
471 ViewFactory* viewFactory = new IconViewFactory(); 475 ViewFactory* viewFactory = new IconViewFactory();
472 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 476 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
473// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
474 478
475 viewFactory = new TableViewFactory(); 479 viewFactory = new TableViewFactory();
476 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 480 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
478 482
479 viewFactory = new CardViewFactory(); 483 viewFactory = new CardViewFactory();
480 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 484 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 485// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
482 486
483#endif //KAB_EMBEDDED 487#endif //KAB_EMBEDDED
484 488
485} 489}
486 490
487void ViewManager::dropped( QDropEvent *e ) 491void ViewManager::dropped( QDropEvent *e )
488{ 492{
489 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 493 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
490 494
491#ifndef KAB_EMBEDDED 495#ifndef KAB_EMBEDDED
492 496
493 QString clipText, vcards; 497 QString clipText, vcards;
494 KURL::List urls; 498 KURL::List urls;
495 499
496 if ( KURLDrag::decode( e, urls) ) { 500 if ( KURLDrag::decode( e, urls) ) {
497 KURL::List::Iterator it = urls.begin(); 501 KURL::List::Iterator it = urls.begin();
498 int c = urls.count(); 502 int c = urls.count();
499 if ( c > 1 ) { 503 if ( c > 1 ) {
500 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 504 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
501 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 505 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
502 for ( ; it != urls.end(); ++it ) 506 for ( ; it != urls.end(); ++it )
503 emit urlDropped( *it ); 507 emit urlDropped( *it );
504 } 508 }
505 } else if ( c == 1 ) 509 } else if ( c == 1 )
506 emit urlDropped( *it ); 510 emit urlDropped( *it );
507 } else if ( KVCardDrag::decode( e, vcards ) ) { 511 } else if ( KVCardDrag::decode( e, vcards ) ) {
508 KABC::Addressee addr; 512 KABC::Addressee addr;
509 KABC::VCardConverter converter; 513 KABC::VCardConverter converter;
510 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 514 QStringList list = QStringList::split( "\r\n\r\n", vcards );
511 QStringList::Iterator it; 515 QStringList::Iterator it;
512 for ( it = list.begin(); it != list.end(); ++it ) { 516 for ( it = list.begin(); it != list.end(); ++it ) {
513 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 517 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
514 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 518 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
515 if ( a.isEmpty() ) { 519 if ( a.isEmpty() ) {
516 mCore->addressBook()->insertAddressee( addr ); 520 mCore->addressBook()->insertAddressee( addr );
517 emit modified(); 521 emit modified();
518 } 522 }
519 } 523 }
520 } 524 }
521 525
522 mActiveView->refresh(); 526 mActiveView->refresh();
523 } 527 }
524#else //KAB_EMBEDDED 528#else //KAB_EMBEDDED
525qDebug("ViewManager::dropped() has to be changed!!" ); 529qDebug("ViewManager::dropped() has to be changed!!" );
526#endif //KAB_EMBEDDED 530#endif //KAB_EMBEDDED
527 531
528} 532}
529 533
530void ViewManager::startDrag() 534void ViewManager::startDrag()
531{ 535{
532 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 536 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
533 537
534#ifndef KAB_EMBEDDED 538#ifndef KAB_EMBEDDED
535 539
536 // Get the list of all the selected addressees 540 // Get the list of all the selected addressees
537 KABC::Addressee::List addrList; 541 KABC::Addressee::List addrList;
538 QStringList uidList = selectedUids(); 542 QStringList uidList = selectedUids();
539 QStringList::Iterator iter; 543 QStringList::Iterator iter;
540 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 544 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
541 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 545 addrList.append( mCore->addressBook()->findByUid( *iter ) );
542 546
543 KMultipleDrag *drag = new KMultipleDrag( this ); 547 KMultipleDrag *drag = new KMultipleDrag( this );
544 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 548 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
545 KABC::Addressee::List::Iterator it; 549 KABC::Addressee::List::Iterator it;
546 QStringList vcards; 550 QStringList vcards;
547 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 551 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
548 QString vcard = QString::null; 552 QString vcard = QString::null;
549 KABC::VCardConverter converter; 553 KABC::VCardConverter converter;
550 if ( converter.addresseeToVCard( *it, vcard ) ) 554 if ( converter.addresseeToVCard( *it, vcard ) )
551 vcards.append( vcard ); 555 vcards.append( vcard );
552 } 556 }
553 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 557 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
554 558
555 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 559 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
556 drag->dragCopy(); 560 drag->dragCopy();
557 561
558#else //KAB_EMBEDDED 562#else //KAB_EMBEDDED
559qDebug("ViewManager::startDrag() has to be changed!!" ); 563qDebug("ViewManager::startDrag() has to be changed!!" );
560#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
561 565
562} 566}
563void ViewManager::doSearch( const QString& s,KABC::Field *field ) 567void ViewManager::doSearch( const QString& s,KABC::Field *field )
564{ 568{
565 if ( mActiveView ) 569 if ( mActiveView )
566 mActiveView->doSearch( s, field ); 570 mActiveView->doSearch( s, field );
567 571
568} 572}
569void ViewManager::setActiveFilter( int index ) 573void ViewManager::setActiveFilter( int index )
570{ 574{
571 Filter currentFilter; 575 Filter currentFilter;
572 576
573 if ( ( index - 1 ) < 0 ) 577 if ( ( index - 1 ) < 0 )
574 currentFilter = Filter(); 578 currentFilter = Filter();
575 else 579 else
576 currentFilter = mFilterList[ index - 1 ]; 580 currentFilter = mFilterList[ index - 1 ];
577 581
578 // Check if we have a view. Since the filter combo is created before 582 // Check if we have a view. Since the filter combo is created before
579 // the view, this slot could be called before there is a valid view. 583 // the view, this slot could be called before there is a valid view.
580 if ( mActiveView ) { 584 if ( mActiveView ) {
581 mActiveView->setFilter( currentFilter ); 585 mActiveView->setFilter( currentFilter );
582 mActiveView->refresh(); 586 mActiveView->refresh();
583 emit selected( QString::null ); 587 emit selected( QString::null );
584 } 588 }
585} 589}
586 590
587void ViewManager::configureFilters() 591void ViewManager::configureFilters()
588{ 592{
589 FilterDialog dlg( this ); 593 FilterDialog dlg( this );
590 594
591 dlg.setFilters( mFilterList ); 595 dlg.setFilters( mFilterList );
592 596
593 if ( dlg.exec() ) 597 if ( dlg.exec() )
594 mFilterList = dlg.filters(); 598 mFilterList = dlg.filters();
595 599
596 uint pos = mActionSelectFilter->currentItem(); 600 uint pos = mActionSelectFilter->currentItem();
597 mActionSelectFilter->setItems( filterNames() ); 601 mActionSelectFilter->setItems( filterNames() );
598 mActionSelectFilter->setCurrentItem( pos ); 602 mActionSelectFilter->setCurrentItem( pos );
599 setActiveFilter( pos ); 603 setActiveFilter( pos );
600 mActionSelectFilter->setComboWidth( 150 ); 604 int cw = 150;
605 if (QApplication::desktop()->width() == 480 )
606 cw = 0;
607 mActionSelectFilter->setComboWidth( cw );
601} 608}
602 609
603QStringList ViewManager::filterNames() const 610QStringList ViewManager::filterNames() const
604{ 611{
605 QStringList names( i18n( "No Filter" ) ); 612 QStringList names( i18n( "No Filter" ) );
606 613
607 Filter::List::ConstIterator it; 614 Filter::List::ConstIterator it;
608 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 615 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
609 names.append( (*it).name() ); 616 names.append( (*it).name() );
610 617
611 return names; 618 return names;
612} 619}
613 620
614int ViewManager::filterPosition( const QString &name ) const 621int ViewManager::filterPosition( const QString &name ) const
615{ 622{
616 int pos = 0; 623 int pos = 0;
617 624
618 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
619 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
620 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
621 return pos + 1; 628 return pos + 1;
622 629
623 return 0; 630 return 0;
624} 631}
625 632
626void ViewManager::initActions() 633void ViewManager::initActions()
627{ 634{
628//US <ActionList name="view_loadedviews"/> 635//US <ActionList name="view_loadedviews"/>
629//US <Separator/> 636//US <Separator/>
630 637
631#ifdef KAB_EMBEDDED 638#ifdef KAB_EMBEDDED
632 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 639 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
633 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 640 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
634 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 641 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
635#endif //KAB_EMBEDDED 642#endif //KAB_EMBEDDED
636 643
637 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 644 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
638#if KDE_VERSION >= 309 645#if KDE_VERSION >= 309
639 mActionSelectView->setMenuAccelsEnabled( false ); 646 mActionSelectView->setMenuAccelsEnabled( false );
640#endif 647#endif
641 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 648 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
642 SLOT( setActiveView( const QString& ) ) ); 649 SLOT( setActiveView( const QString& ) ) );
643 650
644 651
645#ifdef KAB_EMBEDDED 652#ifdef KAB_EMBEDDED
646 mActionSelectView->plug(viewmenu); 653 mActionSelectView->plug(viewmenu);
647 viewmenu->insertSeparator(); 654 viewmenu->insertSeparator();
648#endif //KAB_EMBEDDED 655#endif //KAB_EMBEDDED
649 656
650 KAction *action; 657 KAction *action;
651 658
652 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 659 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
653 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 660 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
654#ifndef KAB_EMBEDDED 661#ifndef KAB_EMBEDDED
655 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 662 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
656#else //KAB_EMBEDDED 663#else //KAB_EMBEDDED
657 action->plug(viewmenu); 664 action->plug(viewmenu);
658#endif //KAB_EMBEDDED 665#endif //KAB_EMBEDDED
659 666
660 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 667 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
661 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 668 SLOT( addView() ), mCore->actionCollection(), "view_add" );
662#ifndef KAB_EMBEDDED 669#ifndef KAB_EMBEDDED
663 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 670 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
664#else //KAB_EMBEDDED 671#else //KAB_EMBEDDED
665 action->plug(viewmenu); 672 action->plug(viewmenu);
666#endif //KAB_EMBEDDED 673#endif //KAB_EMBEDDED
667 674
668 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 675 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
669 this, SLOT( deleteView() ), 676 this, SLOT( deleteView() ),
670 mCore->actionCollection(), "view_delete" ); 677 mCore->actionCollection(), "view_delete" );
671#ifndef KAB_EMBEDDED 678#ifndef KAB_EMBEDDED
672 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 679 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
673#else //KAB_EMBEDDED 680#else //KAB_EMBEDDED
674 mActionDeleteView->plug(viewmenu); 681 mActionDeleteView->plug(viewmenu);
675 viewmenu->insertSeparator(); 682 viewmenu->insertSeparator();
676#endif //KAB_EMBEDDED 683#endif //KAB_EMBEDDED
677 684
678#ifndef KAB_EMBEDDED 685#ifndef KAB_EMBEDDED
679 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 686 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
680 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 687 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
681 "view_refresh" ); 688 "view_refresh" );
682 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 689 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
683#else //KAB_EMBEDDED 690#else //KAB_EMBEDDED
684 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 691 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
685 SLOT( refreshView()), mCore->actionCollection(), 692 SLOT( refreshView()), mCore->actionCollection(),
686 "view_refresh" ); 693 "view_refresh" );
687 action->plug(viewmenu); 694 action->plug(viewmenu);
688 viewmenu->insertSeparator(); 695 viewmenu->insertSeparator();
689#endif //KAB_EMBEDDED 696#endif //KAB_EMBEDDED
690 697
691 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 698 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
692 SLOT( configureFilters() ), mCore->actionCollection(), 699 SLOT( configureFilters() ), mCore->actionCollection(),
693 "options_edit_filters" ); 700 "options_edit_filters" );
694 701
695 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 702 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
696#if KDE_VERSION >= 309 703#if KDE_VERSION >= 309
697 mActionSelectFilter->setMenuAccelsEnabled( false ); 704 mActionSelectFilter->setMenuAccelsEnabled( false );
698#endif 705#endif
699 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 706 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
700 SLOT( setActiveFilter( int ) ) ); 707 SLOT( setActiveFilter( int ) ) );
701 708
702#ifdef KAB_EMBEDDED 709#ifdef KAB_EMBEDDED
703 action->plug(settingsmenu); 710 action->plug(settingsmenu);
704 mActionSelectFilter->plug(viewmenu); 711 mActionSelectFilter->plug(viewmenu);
705#endif //KAB_EMBEDDED 712#endif //KAB_EMBEDDED
706 713
707} 714}
708 715
709void ViewManager::initGUI() 716void ViewManager::initGUI()
710{ 717{
711 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 718 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
712 mViewWidgetStack = new QWidgetStack( this ); 719 mViewWidgetStack = new QWidgetStack( this );
713 layout->addWidget( mViewWidgetStack ); 720 layout->addWidget( mViewWidgetStack );
714} 721}
715 722
716#ifndef KAB_EMBEDDED 723#ifndef KAB_EMBEDDED
717#include "viewmanager.moc" 724#include "viewmanager.moc"
718#endif //KAB_EMBEDDED 725#endif //KAB_EMBEDDED