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