summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/imagewidget.cpp25
-rw-r--r--kaddressbook/kabcore.cpp52
-rw-r--r--kaddressbook/xxportselectdialog.cpp48
-rw-r--r--kaddressbook/xxportselectdialog.h1
4 files changed, 87 insertions, 39 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index 9ee4eac..1e9743c 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -1,312 +1,311 @@
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#include <kabc/picture.h> 24#include <kabc/picture.h>
25 25
26#ifndef KAB_EMBEDDED 26#ifndef KAB_EMBEDDED
27#include <kaccelmanager.h> 27#include <kaccelmanager.h>
28#include <kio/netaccess.h> 28#include <kio/netaccess.h>
29#include <kimageio.h> 29#include <kimageio.h>
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kdialog.h> 33#include <kdialog.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kurlrequester.h> 36#include <kurlrequester.h>
37#include <kurl.h> 37#include <kurl.h>
38 38
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qgroupbox.h> 40#include <qgroupbox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h> 45#include <qapplication.h>
46 46
47#include "imagewidget.h" 47#include "imagewidget.h"
48 48
49ImageWidget::ImageWidget( QWidget *parent, const char *name ) 49ImageWidget::ImageWidget( QWidget *parent, const char *name )
50 : QWidget( parent, name ) 50 : QWidget( parent, name )
51{ 51{
52 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), 52 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(),
53 KDialog::spacingHint() ); 53 KDialog::spacingHint() );
54 54
55 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); 55 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this );
56 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 4, 2, 56 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2,
57 KDialog::spacingHint() ); 57 KDialog::spacingHint() );
58 boxLayout->setRowStretch( 2, 1 ); 58 boxLayout->setRowStretch( 2, 1 );
59 59
60 mPhotoLabel = new QLabel( photoBox ); 60 mPhotoLabel = new QLabel( photoBox );
61 int fac = 9; 61 int fac = 9;
62 if ( QApplication::desktop()->width() > 320 ) 62 if ( QApplication::desktop()->width() > 320 )
63 fac = 6; 63 fac = 6;
64 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 64 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac );
65 mPhotoLabel->setScaledContents( true ); 65 mPhotoLabel->setScaledContents( true );
66 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 66 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
67 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); 67 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 );
68 68
69 mPhotoUrl = new KURLRequester( photoBox ); 69 mPhotoUrl = new KURLRequester( photoBox );
70#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
71 mPhotoUrl->setFilter( KImageIO::pattern() ); 71 mPhotoUrl->setFilter( KImageIO::pattern() );
72#else //KAB_EMBEDDED 72#else //KAB_EMBEDDED
73//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); 73//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???");
74#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
75 75
76 76
77 boxLayout->addWidget( mPhotoUrl, 0, 1 ); 77 boxLayout->addWidget( mPhotoUrl, 0, 1 );
78 78 QHBox *hb1 = new QHBox ( photoBox );
79 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); 79 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 );
80 mUsePhotoUrl->setEnabled( false ); 80 mUsePhotoUrl->setEnabled( false );
81 boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); 81 boxLayout->addWidget( hb1, 1, 1 );
82 82
83 QPushButton * pb = new QPushButton( i18n( "Remove" ), photoBox ); 83 QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 );
84 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); 84 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) );
85 boxLayout->addWidget( pb, 2, 1 ); 85 boxLayout->addWidget( new QLabel( photoBox ), 2, 1 );
86 boxLayout->addWidget( new QLabel( photoBox ), 3, 1 );
87 86
88 topLayout->addWidget( photoBox, 0, 0 ); 87 topLayout->addWidget( photoBox, 0, 0 );
89 88
90 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); 89 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this );
91 boxLayout = new QGridLayout( logoBox->layout(), 4, 2, KDialog::spacingHint() ); 90 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() );
92 boxLayout->setRowStretch( 2, 1 ); 91 boxLayout->setRowStretch( 2, 1 );
93 92
94 mLogoLabel = new QLabel( logoBox ); 93 mLogoLabel = new QLabel( logoBox );
95 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 94 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
96 mLogoLabel->setScaledContents( true ); 95 mLogoLabel->setScaledContents( true );
97 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 96 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
98 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); 97 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 );
99 98
100 mLogoUrl = new KURLRequester( logoBox ); 99 mLogoUrl = new KURLRequester( logoBox );
101#ifndef KAB_EMBEDDED 100#ifndef KAB_EMBEDDED
102 mLogoUrl->setFilter( KImageIO::pattern() ); 101 mLogoUrl->setFilter( KImageIO::pattern() );
103#else //KAB_EMBEDDED 102#else //KAB_EMBEDDED
104//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); 103//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
105#endif //KAB_EMBEDDED 104#endif //KAB_EMBEDDED
106 boxLayout->addWidget( mLogoUrl, 0, 1 ); 105 boxLayout->addWidget( mLogoUrl, 0, 1 );
107 106
108 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); 107 QHBox *hb2 = new QHBox ( logoBox );
108 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 );
109 mUseLogoUrl->setEnabled( false ); 109 mUseLogoUrl->setEnabled( false );
110 boxLayout->addWidget( mUseLogoUrl, 1, 1 ); 110 boxLayout->addWidget( hb2, 1, 1 );
111 111
112 pb = new QPushButton( i18n( "Remove" ), logoBox ); 112 pb = new QPushButton( i18n( "Remove" ), hb2 );
113 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); 113 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) );
114 boxLayout->addWidget( pb, 2, 1 ); 114 boxLayout->addWidget( new QLabel( logoBox ), 2, 1 );
115 boxLayout->addWidget( new QLabel( logoBox ), 3, 1 );
116 topLayout->addWidget( logoBox, 1, 0 ); 115 topLayout->addWidget( logoBox, 1, 0 );
117 116
118 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), 117 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
119 SIGNAL( changed() ) ); 118 SIGNAL( changed() ) );
120 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 119 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
121 SLOT( loadPhoto() ) ); 120 SLOT( loadPhoto() ) );
122 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 121 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
123 SIGNAL( changed() ) ); 122 SIGNAL( changed() ) );
124 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 123 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
125 SLOT( updateGUI() ) ); 124 SLOT( updateGUI() ) );
126 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), 125 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
127 SIGNAL( changed() ) ); 126 SIGNAL( changed() ) );
128 127
129 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), 128 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
130 SIGNAL( changed() ) ); 129 SIGNAL( changed() ) );
131 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 130 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
132 SLOT( loadLogo() ) ); 131 SLOT( loadLogo() ) );
133 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 132 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
134 SIGNAL( changed() ) ); 133 SIGNAL( changed() ) );
135 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 134 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
136 SLOT( updateGUI() ) ); 135 SLOT( updateGUI() ) );
137 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), 136 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
138 SIGNAL( changed() ) ); 137 SIGNAL( changed() ) );
139 138
140#ifndef KAB_EMBEDDED 139#ifndef KAB_EMBEDDED
141 KAcceleratorManager::manage( this ); 140 KAcceleratorManager::manage( this );
142#endif //KAB_EMBEDDED 141#endif //KAB_EMBEDDED
143 142
144} 143}
145 144
146ImageWidget::~ImageWidget() 145ImageWidget::~ImageWidget()
147{ 146{
148} 147}
149 148
150void ImageWidget::setPhoto( const KABC::Picture &photo ) 149void ImageWidget::setPhoto( const KABC::Picture &photo )
151{ 150{
152 bool blocked = signalsBlocked(); 151 bool blocked = signalsBlocked();
153 blockSignals( true ); 152 blockSignals( true );
154 153
155 if ( photo.isIntern() ) { 154 if ( photo.isIntern() ) {
156//US 155//US
157//US mPhotoLabel->setPixmap( photo.data() ); 156//US mPhotoLabel->setPixmap( photo.data() );
158 if (photo.data().isNull() != true) 157 if (photo.data().isNull() != true)
159 { 158 {
160 QPixmap pm; 159 QPixmap pm;
161 pm.convertFromImage(photo.data()); 160 pm.convertFromImage(photo.data());
162 161
163 mPhotoLabel->setPixmap( pm ); 162 mPhotoLabel->setPixmap( pm );
164 } 163 }
165 164
166 mUsePhotoUrl->setChecked( false ); 165 mUsePhotoUrl->setChecked( false );
167 } else { 166 } else {
168 mPhotoUrl->setURL( photo.url() ); 167 mPhotoUrl->setURL( photo.url() );
169 if ( !photo.url().isEmpty() ) 168 if ( !photo.url().isEmpty() )
170 mUsePhotoUrl->setChecked( true ); 169 mUsePhotoUrl->setChecked( true );
171 loadPhoto(); 170 loadPhoto();
172 } 171 }
173 172
174 blockSignals( blocked ); 173 blockSignals( blocked );
175} 174}
176 175
177KABC::Picture ImageWidget::photo() const 176KABC::Picture ImageWidget::photo() const
178{ 177{
179 KABC::Picture photo; 178 KABC::Picture photo;
180 179
181 if ( mUsePhotoUrl->isChecked() ) 180 if ( mUsePhotoUrl->isChecked() )
182 photo.setUrl( mPhotoUrl->url() ); 181 photo.setUrl( mPhotoUrl->url() );
183 else { 182 else {
184 QPixmap *px = mPhotoLabel->pixmap(); 183 QPixmap *px = mPhotoLabel->pixmap();
185 if ( px ) { 184 if ( px ) {
186#ifndef KAB_EMBEDDED 185#ifndef KAB_EMBEDDED
187 if ( px->height() > px->width() ) 186 if ( px->height() > px->width() )
188 photo.setData( px->convertToImage().scaleHeight( 140 ) ); 187 photo.setData( px->convertToImage().scaleHeight( 140 ) );
189 else 188 else
190 photo.setData( px->convertToImage().scaleWidth( 100 ) ); 189 photo.setData( px->convertToImage().scaleWidth( 100 ) );
191#else //KAB_EMBEDDED 190#else //KAB_EMBEDDED
192//US add teh nullcheck 191//US add teh nullcheck
193 if (px->isNull() != true ) 192 if (px->isNull() != true )
194 photo.setData( px->convertToImage() ); 193 photo.setData( px->convertToImage() );
195#endif //KAB_EMBEDDED 194#endif //KAB_EMBEDDED
196 195
197 photo.setType( "PNG" ); 196 photo.setType( "PNG" );
198 } 197 }
199 } 198 }
200 199
201 return photo; 200 return photo;
202} 201}
203 202
204void ImageWidget::setLogo( const KABC::Picture &logo ) 203void ImageWidget::setLogo( const KABC::Picture &logo )
205{ 204{
206 bool blocked = signalsBlocked(); 205 bool blocked = signalsBlocked();
207 blockSignals( true ); 206 blockSignals( true );
208 207
209 if ( logo.isIntern() ) { 208 if ( logo.isIntern() ) {
210//US 209//US
211//US mLogoLabel->setPixmap( logo.data() ); 210//US mLogoLabel->setPixmap( logo.data() );
212 if (logo.data().isNull() != true) 211 if (logo.data().isNull() != true)
213 { 212 {
214 QPixmap pm; 213 QPixmap pm;
215 pm.convertFromImage(logo.data()); 214 pm.convertFromImage(logo.data());
216 mLogoLabel->setPixmap( pm ); 215 mLogoLabel->setPixmap( pm );
217 } 216 }
218 mUseLogoUrl->setChecked( false ); 217 mUseLogoUrl->setChecked( false );
219 } else { 218 } else {
220 mLogoUrl->setURL( logo.url() ); 219 mLogoUrl->setURL( logo.url() );
221 if ( !logo.url().isEmpty() ) 220 if ( !logo.url().isEmpty() )
222 mUseLogoUrl->setChecked( true ); 221 mUseLogoUrl->setChecked( true );
223 loadLogo(); 222 loadLogo();
224 } 223 }
225 224
226 blockSignals( blocked ); 225 blockSignals( blocked );
227} 226}
228 227
229KABC::Picture ImageWidget::logo() const 228KABC::Picture ImageWidget::logo() const
230{ 229{
231 KABC::Picture logo; 230 KABC::Picture logo;
232 231
233 if ( mUseLogoUrl->isChecked() ) 232 if ( mUseLogoUrl->isChecked() )
234 logo.setUrl( mLogoUrl->url() ); 233 logo.setUrl( mLogoUrl->url() );
235 else { 234 else {
236 QPixmap *px = mLogoLabel->pixmap(); 235 QPixmap *px = mLogoLabel->pixmap();
237 if ( px ) { 236 if ( px ) {
238#ifndef KAB_EMBEDDED 237#ifndef KAB_EMBEDDED
239 if ( px->height() > px->width() ) 238 if ( px->height() > px->width() )
240 logo.setData( px->convertToImage().scaleHeight( 140 ) ); 239 logo.setData( px->convertToImage().scaleHeight( 140 ) );
241 else 240 else
242 logo.setData( px->convertToImage().scaleWidth( 100 ) ); 241 logo.setData( px->convertToImage().scaleWidth( 100 ) );
243#else //KAB_EMBEDDED 242#else //KAB_EMBEDDED
244 logo.setData( px->convertToImage() ); 243 logo.setData( px->convertToImage() );
245#endif //KAB_EMBEDDED 244#endif //KAB_EMBEDDED
246 245
247 logo.setType( "PNG" ); 246 logo.setType( "PNG" );
248 247
249 } 248 }
250 } 249 }
251 return logo; 250 return logo;
252} 251}
253void ImageWidget::removePhoto() 252void ImageWidget::removePhoto()
254{ 253{
255 setPhoto(KABC::Picture() ); 254 setPhoto(KABC::Picture() );
256} 255}
257 256
258void ImageWidget::removeLogo() 257void ImageWidget::removeLogo()
259{ 258{
260 setLogo(KABC::Picture() ); 259 setLogo(KABC::Picture() );
261} 260}
262 261
263void ImageWidget::loadPhoto() 262void ImageWidget::loadPhoto()
264{ 263{
265 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); 264 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
266} 265}
267 266
268void ImageWidget::loadLogo() 267void ImageWidget::loadLogo()
269{ 268{
270 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); 269 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
271} 270}
272 271
273void ImageWidget::updateGUI() 272void ImageWidget::updateGUI()
274{ 273{
275 KURLRequester *ptr = (KURLRequester*)sender(); 274 KURLRequester *ptr = (KURLRequester*)sender();
276 275
277 276
278 if ( ptr == mPhotoUrl ) 277 if ( ptr == mPhotoUrl )
279 mUsePhotoUrl->setEnabled( true ); 278 mUsePhotoUrl->setEnabled( true );
280 else if ( ptr == mLogoUrl ) 279 else if ( ptr == mLogoUrl )
281 mUseLogoUrl->setEnabled( true ); 280 mUseLogoUrl->setEnabled( true );
282} 281}
283 282
284QPixmap ImageWidget::loadPixmap( const KURL &url ) 283QPixmap ImageWidget::loadPixmap( const KURL &url )
285{ 284{
286 QString tempFile; 285 QString tempFile;
287 QPixmap pixmap; 286 QPixmap pixmap;
288 287
289 if ( url.isEmpty() ) 288 if ( url.isEmpty() )
290 return pixmap; 289 return pixmap;
291 290
292 if ( url.isLocalFile() ) 291 if ( url.isLocalFile() )
293 pixmap = QPixmap( url.path() ); 292 pixmap = QPixmap( url.path() );
294 else 293 else
295 { 294 {
296#ifndef KAB_EMBEDDED 295#ifndef KAB_EMBEDDED
297 if ( KIO::NetAccess::download( url, tempFile ) ) { 296 if ( KIO::NetAccess::download( url, tempFile ) ) {
298 pixmap = QPixmap( tempFile ); 297 pixmap = QPixmap( tempFile );
299 KIO::NetAccess::removeTempFile( tempFile ); 298 KIO::NetAccess::removeTempFile( tempFile );
300 } 299 }
301#else //KAB_EMBEDDED 300#else //KAB_EMBEDDED
302 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); 301 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed");
303#endif //KAB_EMBEDDED 302#endif //KAB_EMBEDDED
304 303
305 } 304 }
306 305
307 return pixmap; 306 return pixmap;
308} 307}
309 308
310#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
311#include "imagewidget.moc" 310#include "imagewidget.moc"
312#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9526f23..d393660 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,612 +1,613 @@
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 } 230 }
230public: 231public:
231 QRadioButton* simple, *full, *reverse, *company; 232 QRadioButton* simple, *full, *reverse, *company;
232 QCheckBox* setCompany; 233 QCheckBox* setCompany;
233}; 234};
234 235
235 236
236 237
237class KAex2phonePrefs : public QDialog 238class KAex2phonePrefs : public QDialog
238{ 239{
239 public: 240 public:
240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 241 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
241 QDialog( parent, name, true ) 242 QDialog( parent, name, true )
242 { 243 {
243 setCaption( i18n("Export to phone options") ); 244 setCaption( i18n("Export to phone options") );
244 QVBoxLayout* lay = new QVBoxLayout( this ); 245 QVBoxLayout* lay = new QVBoxLayout( this );
245 lay->setSpacing( 3 ); 246 lay->setSpacing( 3 );
246 lay->setMargin( 3 ); 247 lay->setMargin( 3 );
247 QLabel *lab; 248 QLabel *lab;
248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 249 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
249 lab->setAlignment (AlignHCenter ); 250 lab->setAlignment (AlignHCenter );
250 QHBox* temphb; 251 QHBox* temphb;
251 temphb = new QHBox( this ); 252 temphb = new QHBox( this );
252 new QLabel( i18n("I/O device: "), temphb ); 253 new QLabel( i18n("I/O device: "), temphb );
253 mPhoneDevice = new QLineEdit( temphb); 254 mPhoneDevice = new QLineEdit( temphb);
254 lay->addWidget( temphb ); 255 lay->addWidget( temphb );
255 temphb = new QHBox( this ); 256 temphb = new QHBox( this );
256 new QLabel( i18n("Connection: "), temphb ); 257 new QLabel( i18n("Connection: "), temphb );
257 mPhoneConnection = new QLineEdit( temphb); 258 mPhoneConnection = new QLineEdit( temphb);
258 lay->addWidget( temphb ); 259 lay->addWidget( temphb );
259 temphb = new QHBox( this ); 260 temphb = new QHBox( this );
260 new QLabel( i18n("Model(opt.): "), temphb ); 261 new QLabel( i18n("Model(opt.): "), temphb );
261 mPhoneModel = new QLineEdit( temphb); 262 mPhoneModel = new QLineEdit( temphb);
262 lay->addWidget( temphb ); 263 lay->addWidget( temphb );
263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 264 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
264 // lay->addWidget( mWriteToSim ); 265 // lay->addWidget( mWriteToSim );
265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 266 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
266 lab->setAlignment (AlignHCenter); 267 lab->setAlignment (AlignHCenter);
267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 268 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
268 lay->addWidget( ok ); 269 lay->addWidget( ok );
269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 270 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
270 lay->addWidget( cancel ); 271 lay->addWidget( cancel );
271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 272 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 273 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
273 resize( 220, 240 ); 274 resize( 220, 240 );
274 275
275 } 276 }
276 277
277public: 278public:
278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 279 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
279 QCheckBox* mWriteToSim; 280 QCheckBox* mWriteToSim;
280}; 281};
281 282
282 283
283bool pasteWithNewUid = true; 284bool pasteWithNewUid = true;
284 285
285#ifdef KAB_EMBEDDED 286#ifdef KAB_EMBEDDED
286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 287KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 288 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 289 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 290 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
290#else //KAB_EMBEDDED 291#else //KAB_EMBEDDED
291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 292KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 293 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 294 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
294 mReadWrite( readWrite ), mModified( false ) 295 mReadWrite( readWrite ), mModified( false )
295#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
296{ 297{
297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 298 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
298 // syncManager->setBlockSave(false); 299 // syncManager->setBlockSave(false);
299 mMiniSplitter = 0; 300 mMiniSplitter = 0;
300 mExtensionBarSplitter = 0; 301 mExtensionBarSplitter = 0;
301 mIsPart = !parent->inherits( "KAddressBookMain" ); 302 mIsPart = !parent->inherits( "KAddressBookMain" );
302 mAddressBook = KABC::StdAddressBook::self(); 303 mAddressBook = KABC::StdAddressBook::self();
303 KABC::StdAddressBook::setAutomaticSave( false ); 304 KABC::StdAddressBook::setAutomaticSave( false );
304 305
305#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 307 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
307#endif //KAB_EMBEDDED 308#endif //KAB_EMBEDDED
308 309
309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 310 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
310 SLOT( addressBookChanged() ) ); 311 SLOT( addressBookChanged() ) );
311 312
312#if 0 313#if 0
313 // LP moved to addressbook init method 314 // LP moved to addressbook init method
314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 315 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
315 "X-Department", "KADDRESSBOOK" ); 316 "X-Department", "KADDRESSBOOK" );
316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
317 "X-Profession", "KADDRESSBOOK" ); 318 "X-Profession", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
319 "X-AssistantsName", "KADDRESSBOOK" ); 320 "X-AssistantsName", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
321 "X-ManagersName", "KADDRESSBOOK" ); 322 "X-ManagersName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 323 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
323 "X-SpousesName", "KADDRESSBOOK" ); 324 "X-SpousesName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
325 "X-Office", "KADDRESSBOOK" ); 326 "X-Office", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
327 "X-IMAddress", "KADDRESSBOOK" ); 328 "X-IMAddress", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
329 "X-Anniversary", "KADDRESSBOOK" ); 330 "X-Anniversary", "KADDRESSBOOK" );
330 331
331 //US added this field to become compatible with Opie/qtopia addressbook 332 //US added this field to become compatible with Opie/qtopia addressbook
332 // values can be "female" or "male" or "". An empty field represents undefined. 333 // values can be "female" or "male" or "". An empty field represents undefined.
333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 334 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
334 "X-Gender", "KADDRESSBOOK" ); 335 "X-Gender", "KADDRESSBOOK" );
335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
336 "X-Children", "KADDRESSBOOK" ); 337 "X-Children", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
338 "X-FreeBusyUrl", "KADDRESSBOOK" ); 339 "X-FreeBusyUrl", "KADDRESSBOOK" );
339#endif 340#endif
340 initGUI(); 341 initGUI();
341 342
342 mIncSearchWidget->setFocus(); 343 mIncSearchWidget->setFocus();
343 344
344 345
345 connect( mViewManager, SIGNAL( selected( const QString& ) ), 346 connect( mViewManager, SIGNAL( selected( const QString& ) ),
346 SLOT( setContactSelected( const QString& ) ) ); 347 SLOT( setContactSelected( const QString& ) ) );
347 connect( mViewManager, SIGNAL( executed( const QString& ) ), 348 connect( mViewManager, SIGNAL( executed( const QString& ) ),
348 SLOT( executeContact( const QString& ) ) ); 349 SLOT( executeContact( const QString& ) ) );
349 350
350 connect( mViewManager, SIGNAL( deleteRequest( ) ), 351 connect( mViewManager, SIGNAL( deleteRequest( ) ),
351 SLOT( deleteContacts( ) ) ); 352 SLOT( deleteContacts( ) ) );
352 connect( mViewManager, SIGNAL( modified() ), 353 connect( mViewManager, SIGNAL( modified() ),
353 SLOT( setModified() ) ); 354 SLOT( setModified() ) );
354 355
355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 356 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 ) ) ); 357 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
357 358
358 connect( mXXPortManager, SIGNAL( modified() ), 359 connect( mXXPortManager, SIGNAL( modified() ),
359 SLOT( setModified() ) ); 360 SLOT( setModified() ) );
360 361
361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 362 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
362 SLOT( incrementalSearch( const QString& ) ) ); 363 SLOT( incrementalSearch( const QString& ) ) );
363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 364 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
364 mJumpButtonBar, SLOT( recreateButtons() ) ); 365 mJumpButtonBar, SLOT( recreateButtons() ) );
365 366
366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 367 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
367 SLOT( sendMail( const QString& ) ) ); 368 SLOT( sendMail( const QString& ) ) );
368 369
369 370
370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 371 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&))); 372 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&))); 373 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())); 374 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
374 375
375 376
376#ifndef KAB_EMBEDDED 377#ifndef KAB_EMBEDDED
377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 378 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
378 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 379 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
379 380
380 connect( mDetails, SIGNAL( browse( const QString& ) ), 381 connect( mDetails, SIGNAL( browse( const QString& ) ),
381 SLOT( browse( const QString& ) ) ); 382 SLOT( browse( const QString& ) ) );
382 383
383 384
384 mAddressBookService = new KAddressBookService( this ); 385 mAddressBookService = new KAddressBookService( this );
385 386
386#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
387 388
388 mMessageTimer = new QTimer( this ); 389 mMessageTimer = new QTimer( this );
389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 390 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
390 mEditorDialog = 0; 391 mEditorDialog = 0;
391 createAddresseeEditorDialog( this ); 392 createAddresseeEditorDialog( this );
392 setModified( false ); 393 setModified( false );
393 mBRdisabled = false; 394 mBRdisabled = false;
394#ifndef DESKTOP_VERSION 395#ifndef DESKTOP_VERSION
395 infrared = 0; 396 infrared = 0;
396#endif 397#endif
397 //toggleBeamReceive( ); 398 //toggleBeamReceive( );
398 //mMainWindow->toolBar()->show(); 399 //mMainWindow->toolBar()->show();
399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 400 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
400 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 401 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
401} 402}
402 403
403void KABCore::updateToolBar() 404void KABCore::updateToolBar()
404{ 405{
405 static int iii = 0; 406 static int iii = 0;
406 ++iii; 407 ++iii;
407 mMainWindow->toolBar()->repaintMe(); 408 mMainWindow->toolBar()->repaintMe();
408 if ( iii < 3 ) 409 if ( iii < 3 )
409 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 410 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
410} 411}
411KABCore::~KABCore() 412KABCore::~KABCore()
412{ 413{
413 // save(); 414 // save();
414 //saveSettings(); 415 //saveSettings();
415 //KABPrefs::instance()->writeConfig(); 416 //KABPrefs::instance()->writeConfig();
416 delete AddresseeConfig::instance(); 417 delete AddresseeConfig::instance();
417 mAddressBook = 0; 418 mAddressBook = 0;
418 KABC::StdAddressBook::close(); 419 KABC::StdAddressBook::close();
419 420
420 delete syncManager; 421 delete syncManager;
421#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
422 if ( infrared ) 423 if ( infrared )
423 delete infrared; 424 delete infrared;
424#endif 425#endif
425} 426}
426void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 427void KABCore::receive( const QCString& cmsg, const QByteArray& data )
427{ 428{
428 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 429 qDebug("KA: QCOP message received: %s ", cmsg.data() );
429 if ( cmsg == "setDocument(QString)" ) { 430 if ( cmsg == "setDocument(QString)" ) {
430 QDataStream stream( data, IO_ReadOnly ); 431 QDataStream stream( data, IO_ReadOnly );
431 QString fileName; 432 QString fileName;
432 stream >> fileName; 433 stream >> fileName;
433 recieve( fileName ); 434 recieve( fileName );
434 return; 435 return;
435 } 436 }
436} 437}
437void KABCore::toggleBeamReceive( ) 438void KABCore::toggleBeamReceive( )
438{ 439{
439 if ( mBRdisabled ) 440 if ( mBRdisabled )
440 return; 441 return;
441#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
442 if ( infrared ) { 443 if ( infrared ) {
443 qDebug("AB disable BeamReceive "); 444 qDebug("AB disable BeamReceive ");
444 delete infrared; 445 delete infrared;
445 infrared = 0; 446 infrared = 0;
446 mActionBR->setChecked(false); 447 mActionBR->setChecked(false);
447 return; 448 return;
448 } 449 }
449 qDebug("AB enable BeamReceive "); 450 qDebug("AB enable BeamReceive ");
450 mActionBR->setChecked(true); 451 mActionBR->setChecked(true);
451 452
452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 453 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& ))); 454 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
454#endif 455#endif
455} 456}
456 457
457 458
458void KABCore::disableBR(bool b) 459void KABCore::disableBR(bool b)
459{ 460{
460#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
461 if ( b ) { 462 if ( b ) {
462 if ( infrared ) { 463 if ( infrared ) {
463 toggleBeamReceive( ); 464 toggleBeamReceive( );
464 } 465 }
465 mBRdisabled = true; 466 mBRdisabled = true;
466 } else { 467 } else {
467 if ( mBRdisabled ) { 468 if ( mBRdisabled ) {
468 mBRdisabled = false; 469 mBRdisabled = false;
469 //toggleBeamReceive( ); 470 //toggleBeamReceive( );
470 } 471 }
471 } 472 }
472#endif 473#endif
473 474
474} 475}
475void KABCore::recieve( QString fn ) 476void KABCore::recieve( QString fn )
476{ 477{
477 //qDebug("KABCore::recieve "); 478 //qDebug("KABCore::recieve ");
478 int count = mAddressBook->importFromFile( fn, true ); 479 int count = mAddressBook->importFromFile( fn, true );
479 if ( count ) 480 if ( count )
480 setModified( true ); 481 setModified( true );
481 mViewManager->refreshView(); 482 mViewManager->refreshView();
482 message(i18n("%1 contact(s) received!").arg( count )); 483 message(i18n("%1 contact(s) received!").arg( count ));
483 topLevelWidget()->showMaximized(); 484 topLevelWidget()->showMaximized();
484 topLevelWidget()->raise(); 485 topLevelWidget()->raise();
485} 486}
486void KABCore::restoreSettings() 487void KABCore::restoreSettings()
487{ 488{
488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 489 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
489 490
490 bool state; 491 bool state;
491 492
492 if (mMultipleViewsAtOnce) 493 if (mMultipleViewsAtOnce)
493 state = KABPrefs::instance()->mDetailsPageVisible; 494 state = KABPrefs::instance()->mDetailsPageVisible;
494 else 495 else
495 state = false; 496 state = false;
496 497
497 mActionDetails->setChecked( state ); 498 mActionDetails->setChecked( state );
498 setDetailsVisible( state ); 499 setDetailsVisible( state );
499 500
500 state = KABPrefs::instance()->mJumpButtonBarVisible; 501 state = KABPrefs::instance()->mJumpButtonBarVisible;
501 502
502 mActionJumpBar->setChecked( state ); 503 mActionJumpBar->setChecked( state );
503 setJumpButtonBarVisible( state ); 504 setJumpButtonBarVisible( state );
504/*US 505/*US
505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 506 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
506 if ( splitterSize.count() == 0 ) { 507 if ( splitterSize.count() == 0 ) {
507 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
508 splitterSize.append( width() / 2 ); 509 splitterSize.append( width() / 2 );
509 } 510 }
510 mMiniSplitter->setSizes( splitterSize ); 511 mMiniSplitter->setSizes( splitterSize );
511 if ( mExtensionBarSplitter ) { 512 if ( mExtensionBarSplitter ) {
512 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 513 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
513 if ( splitterSize.count() == 0 ) { 514 if ( splitterSize.count() == 0 ) {
514 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
515 splitterSize.append( width() / 2 ); 516 splitterSize.append( width() / 2 );
516 } 517 }
517 mExtensionBarSplitter->setSizes( splitterSize ); 518 mExtensionBarSplitter->setSizes( splitterSize );
518 519
519 } 520 }
520*/ 521*/
521 mViewManager->restoreSettings(); 522 mViewManager->restoreSettings();
522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 523 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
523 mExtensionManager->restoreSettings(); 524 mExtensionManager->restoreSettings();
524#ifdef DESKTOP_VERSION 525#ifdef DESKTOP_VERSION
525 int wid = width(); 526 int wid = width();
526 if ( wid < 10 ) 527 if ( wid < 10 )
527 wid = 400; 528 wid = 400;
528#else 529#else
529 int wid = QApplication::desktop()->width(); 530 int wid = QApplication::desktop()->width();
530 if ( wid < 640 ) 531 if ( wid < 640 )
531 wid = QApplication::desktop()->height(); 532 wid = QApplication::desktop()->height();
532#endif 533#endif
533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
534 if ( true /*splitterSize.count() == 0*/ ) { 535 if ( true /*splitterSize.count() == 0*/ ) {
535 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
536 splitterSize.append( wid / 2 ); 537 splitterSize.append( wid / 2 );
537 } 538 }
538 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
539 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
541 if ( true /*splitterSize.count() == 0*/ ) { 542 if ( true /*splitterSize.count() == 0*/ ) {
542 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
543 splitterSize.append( wid / 2 ); 544 splitterSize.append( wid / 2 );
544 } 545 }
545 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
546 547
547 } 548 }
548 549
549 550
550} 551}
551 552
552void KABCore::saveSettings() 553void KABCore::saveSettings()
553{ 554{
554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 555 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
555 if ( mExtensionBarSplitter ) 556 if ( mExtensionBarSplitter )
556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 557 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 558 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 559 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
559#ifndef KAB_EMBEDDED 560#ifndef KAB_EMBEDDED
560 561
561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 562 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 563 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
563#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
564 mExtensionManager->saveSettings(); 565 mExtensionManager->saveSettings();
565 mViewManager->saveSettings(); 566 mViewManager->saveSettings();
566 567
567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 568 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
568 KABPrefs::instance()->writeConfig(); 569 KABPrefs::instance()->writeConfig();
569 qDebug("KABCore::saveSettings() "); 570 qDebug("KABCore::saveSettings() ");
570} 571}
571 572
572KABC::AddressBook *KABCore::addressBook() const 573KABC::AddressBook *KABCore::addressBook() const
573{ 574{
574 return mAddressBook; 575 return mAddressBook;
575} 576}
576 577
577KConfig *KABCore::config() 578KConfig *KABCore::config()
578{ 579{
579#ifndef KAB_EMBEDDED 580#ifndef KAB_EMBEDDED
580 return KABPrefs::instance()->config(); 581 return KABPrefs::instance()->config();
581#else //KAB_EMBEDDED 582#else //KAB_EMBEDDED
582 return KABPrefs::instance()->getConfig(); 583 return KABPrefs::instance()->getConfig();
583#endif //KAB_EMBEDDED 584#endif //KAB_EMBEDDED
584} 585}
585 586
586KActionCollection *KABCore::actionCollection() const 587KActionCollection *KABCore::actionCollection() const
587{ 588{
588 return mGUIClient->actionCollection(); 589 return mGUIClient->actionCollection();
589} 590}
590 591
591KABC::Field *KABCore::currentSearchField() const 592KABC::Field *KABCore::currentSearchField() const
592{ 593{
593 if (mIncSearchWidget) 594 if (mIncSearchWidget)
594 return mIncSearchWidget->currentField(); 595 return mIncSearchWidget->currentField();
595 else 596 else
596 return 0; 597 return 0;
597} 598}
598 599
599QStringList KABCore::selectedUIDs() const 600QStringList KABCore::selectedUIDs() const
600{ 601{
601 return mViewManager->selectedUids(); 602 return mViewManager->selectedUids();
602} 603}
603 604
604KABC::Resource *KABCore::requestResource( QWidget *parent ) 605KABC::Resource *KABCore::requestResource( QWidget *parent )
605{ 606{
606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 607 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
607 608
608 QPtrList<KRES::Resource> kresResources; 609 QPtrList<KRES::Resource> kresResources;
609 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 610 QPtrListIterator<KABC::Resource> resIt( kabcResources );
610 KABC::Resource *resource; 611 KABC::Resource *resource;
611 while ( ( resource = resIt.current() ) != 0 ) { 612 while ( ( resource = resIt.current() ) != 0 ) {
612 ++resIt; 613 ++resIt;
@@ -992,769 +993,770 @@ void KABCore::beamDone( Ir *ir )
992} 993}
993 994
994 995
995void KABCore::browse( const QString& url ) 996void KABCore::browse( const QString& url )
996{ 997{
997#ifndef KAB_EMBEDDED 998#ifndef KAB_EMBEDDED
998 kapp->invokeBrowser( url ); 999 kapp->invokeBrowser( url );
999#else //KAB_EMBEDDED 1000#else //KAB_EMBEDDED
1000 qDebug("KABCore::browse must be fixed"); 1001 qDebug("KABCore::browse must be fixed");
1001#endif //KAB_EMBEDDED 1002#endif //KAB_EMBEDDED
1002} 1003}
1003 1004
1004void KABCore::selectAllContacts() 1005void KABCore::selectAllContacts()
1005{ 1006{
1006 mViewManager->setSelected( QString::null, true ); 1007 mViewManager->setSelected( QString::null, true );
1007} 1008}
1008 1009
1009void KABCore::deleteContacts() 1010void KABCore::deleteContacts()
1010{ 1011{
1011 QStringList uidList = mViewManager->selectedUids(); 1012 QStringList uidList = mViewManager->selectedUids();
1012 deleteContacts( uidList ); 1013 deleteContacts( uidList );
1013} 1014}
1014 1015
1015void KABCore::deleteContacts( const QStringList &uids ) 1016void KABCore::deleteContacts( const QStringList &uids )
1016{ 1017{
1017 if ( uids.count() > 0 ) { 1018 if ( uids.count() > 0 ) {
1018 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1019 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1019 UndoStack::instance()->push( command ); 1020 UndoStack::instance()->push( command );
1020 RedoStack::instance()->clear(); 1021 RedoStack::instance()->clear();
1021 1022
1022 // now if we deleted anything, refresh 1023 // now if we deleted anything, refresh
1023 setContactSelected( QString::null ); 1024 setContactSelected( QString::null );
1024 setModified( true ); 1025 setModified( true );
1025 } 1026 }
1026} 1027}
1027 1028
1028void KABCore::copyContacts() 1029void KABCore::copyContacts()
1029{ 1030{
1030 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1031 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1031 1032
1032 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1033 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1033 1034
1034 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1035 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1035 1036
1036 QClipboard *cb = QApplication::clipboard(); 1037 QClipboard *cb = QApplication::clipboard();
1037 cb->setText( clipText ); 1038 cb->setText( clipText );
1038} 1039}
1039 1040
1040void KABCore::cutContacts() 1041void KABCore::cutContacts()
1041{ 1042{
1042 QStringList uidList = mViewManager->selectedUids(); 1043 QStringList uidList = mViewManager->selectedUids();
1043 1044
1044//US if ( uidList.size() > 0 ) { 1045//US if ( uidList.size() > 0 ) {
1045 if ( uidList.count() > 0 ) { 1046 if ( uidList.count() > 0 ) {
1046 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1047 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1047 UndoStack::instance()->push( command ); 1048 UndoStack::instance()->push( command );
1048 RedoStack::instance()->clear(); 1049 RedoStack::instance()->clear();
1049 1050
1050 setModified( true ); 1051 setModified( true );
1051 } 1052 }
1052} 1053}
1053 1054
1054void KABCore::pasteContacts() 1055void KABCore::pasteContacts()
1055{ 1056{
1056 QClipboard *cb = QApplication::clipboard(); 1057 QClipboard *cb = QApplication::clipboard();
1057 1058
1058 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1059 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1059 1060
1060 pasteContacts( list ); 1061 pasteContacts( list );
1061} 1062}
1062 1063
1063void KABCore::pasteContacts( KABC::Addressee::List &list ) 1064void KABCore::pasteContacts( KABC::Addressee::List &list )
1064{ 1065{
1065 KABC::Resource *resource = requestResource( this ); 1066 KABC::Resource *resource = requestResource( this );
1066 KABC::Addressee::List::Iterator it; 1067 KABC::Addressee::List::Iterator it;
1067 for ( it = list.begin(); it != list.end(); ++it ) 1068 for ( it = list.begin(); it != list.end(); ++it )
1068 (*it).setResource( resource ); 1069 (*it).setResource( resource );
1069 1070
1070 PwPasteCommand *command = new PwPasteCommand( this, list ); 1071 PwPasteCommand *command = new PwPasteCommand( this, list );
1071 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1072 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1073 1074
1074 setModified( true ); 1075 setModified( true );
1075} 1076}
1076 1077
1077void KABCore::setWhoAmI() 1078void KABCore::setWhoAmI()
1078{ 1079{
1079 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1080 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1080 1081
1081 if ( addrList.count() > 1 ) { 1082 if ( addrList.count() > 1 ) {
1082 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1083 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1083 return; 1084 return;
1084 } 1085 }
1085 1086
1086 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1087 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1087 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1088 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1088 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1089 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1089} 1090}
1090void KABCore::editCategories() 1091void KABCore::editCategories()
1091{ 1092{
1092 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1093 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1093 dlg.exec(); 1094 dlg.exec();
1094} 1095}
1095void KABCore::setCategories() 1096void KABCore::setCategories()
1096{ 1097{
1097 1098
1098 QStringList uids; 1099 QStringList uids;
1099 XXPortSelectDialog dlgx( this, false, this ); 1100 XXPortSelectDialog dlgx( this, false, this );
1100 if ( dlgx.exec() ) 1101 if ( dlgx.exec() )
1101 uids = dlgx.uids(); 1102 uids = dlgx.uids();
1102 else 1103 else
1103 return; 1104 return;
1104 if ( uids.isEmpty() ) 1105 if ( uids.isEmpty() )
1105 return; 1106 return;
1106 // qDebug("count %d ", uids.count()); 1107 // qDebug("count %d ", uids.count());
1107 1108
1108 1109
1109 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1110 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1110 if ( !dlg.exec() ) { 1111 if ( !dlg.exec() ) {
1111 message( i18n("Setting categories cancelled") ); 1112 message( i18n("Setting categories cancelled") );
1112 return; 1113 return;
1113 } 1114 }
1114 bool merge = false; 1115 bool merge = false;
1115 QString msg = i18n( "Merge with existing categories?" ); 1116 QString msg = i18n( "Merge with existing categories?" );
1116 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1117 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1117 merge = true; 1118 merge = true;
1118 1119
1119 message( i18n("Setting categories ... please wait!") ); 1120 message( i18n("Setting categories ... please wait!") );
1120 QStringList categories = dlg.selectedCategories(); 1121 QStringList categories = dlg.selectedCategories();
1121 1122
1122 //QStringList uids = mViewManager->selectedUids(); 1123 //QStringList uids = mViewManager->selectedUids();
1123 QStringList::Iterator it; 1124 QStringList::Iterator it;
1124 for ( it = uids.begin(); it != uids.end(); ++it ) { 1125 for ( it = uids.begin(); it != uids.end(); ++it ) {
1125 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1126 KABC::Addressee addr = mAddressBook->findByUid( *it );
1126 if ( !addr.isEmpty() ) { 1127 if ( !addr.isEmpty() ) {
1127 if ( !merge ) 1128 if ( !merge )
1128 addr.setCategories( categories ); 1129 addr.setCategories( categories );
1129 else { 1130 else {
1130 QStringList addrCategories = addr.categories(); 1131 QStringList addrCategories = addr.categories();
1131 QStringList::Iterator catIt; 1132 QStringList::Iterator catIt;
1132 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1133 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1133 if ( !addrCategories.contains( *catIt ) ) 1134 if ( !addrCategories.contains( *catIt ) )
1134 addrCategories.append( *catIt ); 1135 addrCategories.append( *catIt );
1135 } 1136 }
1136 addr.setCategories( addrCategories ); 1137 addr.setCategories( addrCategories );
1137 } 1138 }
1138 mAddressBook->insertAddressee( addr ); 1139 mAddressBook->insertAddressee( addr );
1139 } 1140 }
1140 } 1141 }
1141 1142
1142 if ( uids.count() > 0 ) 1143 if ( uids.count() > 0 )
1143 setModified( true ); 1144 setModified( true );
1144 message( i18n("Setting categories completed!") ); 1145 message( i18n("Setting categories completed!") );
1145} 1146}
1146 1147
1147void KABCore::setSearchFields( const KABC::Field::List &fields ) 1148void KABCore::setSearchFields( const KABC::Field::List &fields )
1148{ 1149{
1149 mIncSearchWidget->setFields( fields ); 1150 mIncSearchWidget->setFields( fields );
1150} 1151}
1151 1152
1152void KABCore::incrementalSearch( const QString& text ) 1153void KABCore::incrementalSearch( const QString& text )
1153{ 1154{
1154 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1155 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1155} 1156}
1156 1157
1157void KABCore::setModified() 1158void KABCore::setModified()
1158{ 1159{
1159 setModified( true ); 1160 setModified( true );
1160} 1161}
1161 1162
1162void KABCore::setModifiedWOrefresh() 1163void KABCore::setModifiedWOrefresh()
1163{ 1164{
1164 // qDebug("KABCore::setModifiedWOrefresh() "); 1165 // qDebug("KABCore::setModifiedWOrefresh() ");
1165 mModified = true; 1166 mModified = true;
1166 mActionSave->setEnabled( mModified ); 1167 mActionSave->setEnabled( mModified );
1167 1168
1168 1169
1169} 1170}
1170void KABCore::setModified( bool modified ) 1171void KABCore::setModified( bool modified )
1171{ 1172{
1172 mModified = modified; 1173 mModified = modified;
1173 mActionSave->setEnabled( mModified ); 1174 mActionSave->setEnabled( mModified );
1174 1175
1175 if ( modified ) 1176 if ( modified )
1176 mJumpButtonBar->recreateButtons(); 1177 mJumpButtonBar->recreateButtons();
1177 1178
1178 mViewManager->refreshView(); 1179 mViewManager->refreshView();
1179 1180
1180} 1181}
1181 1182
1182bool KABCore::modified() const 1183bool KABCore::modified() const
1183{ 1184{
1184 return mModified; 1185 return mModified;
1185} 1186}
1186 1187
1187void KABCore::contactModified( const KABC::Addressee &addr ) 1188void KABCore::contactModified( const KABC::Addressee &addr )
1188{ 1189{
1189 addrModified( addr ); 1190 addrModified( addr );
1190} 1191}
1191 1192
1192void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1193void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1193{ 1194{
1194 1195
1195 Command *command = 0; 1196 Command *command = 0;
1196 QString uid; 1197 QString uid;
1197 1198
1198 // check if it exists already 1199 // check if it exists already
1199 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1200 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1200 if ( origAddr.isEmpty() ) 1201 if ( origAddr.isEmpty() )
1201 command = new PwNewCommand( mAddressBook, addr ); 1202 command = new PwNewCommand( mAddressBook, addr );
1202 else { 1203 else {
1203 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1204 command = new PwEditCommand( mAddressBook, origAddr, addr );
1204 uid = addr.uid(); 1205 uid = addr.uid();
1205 } 1206 }
1206 1207
1207 UndoStack::instance()->push( command ); 1208 UndoStack::instance()->push( command );
1208 RedoStack::instance()->clear(); 1209 RedoStack::instance()->clear();
1209 if ( updateDetails ) 1210 if ( updateDetails )
1210 mDetails->setAddressee( addr ); 1211 mDetails->setAddressee( addr );
1211 setModified( true ); 1212 setModified( true );
1212} 1213}
1213 1214
1214void KABCore::newContact() 1215void KABCore::newContact()
1215{ 1216{
1216 1217
1217 1218
1218 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1219 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1219 1220
1220 QPtrList<KRES::Resource> kresResources; 1221 QPtrList<KRES::Resource> kresResources;
1221 QPtrListIterator<KABC::Resource> it( kabcResources ); 1222 QPtrListIterator<KABC::Resource> it( kabcResources );
1222 KABC::Resource *resource; 1223 KABC::Resource *resource;
1223 while ( ( resource = it.current() ) != 0 ) { 1224 while ( ( resource = it.current() ) != 0 ) {
1224 ++it; 1225 ++it;
1225 if ( !resource->readOnly() ) { 1226 if ( !resource->readOnly() ) {
1226 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1227 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1227 if ( res ) 1228 if ( res )
1228 kresResources.append( res ); 1229 kresResources.append( res );
1229 } 1230 }
1230 } 1231 }
1231 1232
1232 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1233 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1233 resource = static_cast<KABC::Resource*>( res ); 1234 resource = static_cast<KABC::Resource*>( res );
1234 1235
1235 if ( resource ) { 1236 if ( resource ) {
1236 KABC::Addressee addr; 1237 KABC::Addressee addr;
1237 addr.setResource( resource ); 1238 addr.setResource( resource );
1238 mEditorDialog->setAddressee( addr ); 1239 mEditorDialog->setAddressee( addr );
1239 KApplication::execDialog ( mEditorDialog ); 1240 KApplication::execDialog ( mEditorDialog );
1240 1241
1241 } else 1242 } else
1242 return; 1243 return;
1243 1244
1244 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1245 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1245 1246
1246 1247
1247} 1248}
1248 1249
1249void KABCore::addEmail( QString aStr ) 1250void KABCore::addEmail( QString aStr )
1250{ 1251{
1251#ifndef KAB_EMBEDDED 1252#ifndef KAB_EMBEDDED
1252 QString fullName, email; 1253 QString fullName, email;
1253 1254
1254 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1255 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1255 1256
1256 // Try to lookup the addressee matching the email address 1257 // Try to lookup the addressee matching the email address
1257 bool found = false; 1258 bool found = false;
1258 QStringList emailList; 1259 QStringList emailList;
1259 KABC::AddressBook::Iterator it; 1260 KABC::AddressBook::Iterator it;
1260 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1261 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1261 emailList = (*it).emails(); 1262 emailList = (*it).emails();
1262 if ( emailList.contains( email ) > 0 ) { 1263 if ( emailList.contains( email ) > 0 ) {
1263 found = true; 1264 found = true;
1264 (*it).setNameFromString( fullName ); 1265 (*it).setNameFromString( fullName );
1265 editContact( (*it).uid() ); 1266 editContact( (*it).uid() );
1266 } 1267 }
1267 } 1268 }
1268 1269
1269 if ( !found ) { 1270 if ( !found ) {
1270 KABC::Addressee addr; 1271 KABC::Addressee addr;
1271 addr.setNameFromString( fullName ); 1272 addr.setNameFromString( fullName );
1272 addr.insertEmail( email, true ); 1273 addr.insertEmail( email, true );
1273 1274
1274 mAddressBook->insertAddressee( addr ); 1275 mAddressBook->insertAddressee( addr );
1275 mViewManager->refreshView( addr.uid() ); 1276 mViewManager->refreshView( addr.uid() );
1276 editContact( addr.uid() ); 1277 editContact( addr.uid() );
1277 } 1278 }
1278#else //KAB_EMBEDDED 1279#else //KAB_EMBEDDED
1279 qDebug("KABCore::addEmail finsih method"); 1280 qDebug("KABCore::addEmail finsih method");
1280#endif //KAB_EMBEDDED 1281#endif //KAB_EMBEDDED
1281} 1282}
1282 1283
1283void KABCore::importVCard( const KURL &url, bool showPreview ) 1284void KABCore::importVCard( const KURL &url, bool showPreview )
1284{ 1285{
1285 mXXPortManager->importVCard( url, showPreview ); 1286 mXXPortManager->importVCard( url, showPreview );
1286} 1287}
1287void KABCore::importFromOL() 1288void KABCore::importFromOL()
1288{ 1289{
1289#ifdef _WIN32_ 1290#ifdef _WIN32_
1290 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1291 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1291 idgl->exec(); 1292 idgl->exec();
1292 KABC::Addressee::List list = idgl->getAddressList(); 1293 KABC::Addressee::List list = idgl->getAddressList();
1293 if ( list.count() > 0 ) { 1294 if ( list.count() > 0 ) {
1294 KABC::Addressee::List listNew; 1295 KABC::Addressee::List listNew;
1295 KABC::Addressee::List listExisting; 1296 KABC::Addressee::List listExisting;
1296 KABC::Addressee::List::Iterator it; 1297 KABC::Addressee::List::Iterator it;
1297 KABC::AddressBook::Iterator iter; 1298 KABC::AddressBook::Iterator iter;
1298 for ( it = list.begin(); it != list.end(); ++it ) { 1299 for ( it = list.begin(); it != list.end(); ++it ) {
1299 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1300 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1300 listNew.append( (*it) ); 1301 listNew.append( (*it) );
1301 else 1302 else
1302 listExisting.append( (*it) ); 1303 listExisting.append( (*it) );
1303 } 1304 }
1304 if ( listExisting.count() > 0 ) 1305 if ( listExisting.count() > 0 )
1305 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1306 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1306 if ( listNew.count() > 0 ) { 1307 if ( listNew.count() > 0 ) {
1307 pasteWithNewUid = false; 1308 pasteWithNewUid = false;
1308 pasteContacts( listNew ); 1309 pasteContacts( listNew );
1309 pasteWithNewUid = true; 1310 pasteWithNewUid = true;
1310 } 1311 }
1311 } 1312 }
1312 delete idgl; 1313 delete idgl;
1313#endif 1314#endif
1314} 1315}
1315 1316
1316void KABCore::importVCard( const QString &vCard, bool showPreview ) 1317void KABCore::importVCard( const QString &vCard, bool showPreview )
1317{ 1318{
1318 mXXPortManager->importVCard( vCard, showPreview ); 1319 mXXPortManager->importVCard( vCard, showPreview );
1319} 1320}
1320 1321
1321//US added a second method without defaultparameter 1322//US added a second method without defaultparameter
1322void KABCore::editContact2() { 1323void KABCore::editContact2() {
1323 editContact( QString::null ); 1324 editContact( QString::null );
1324} 1325}
1325 1326
1326void KABCore::editContact( const QString &uid ) 1327void KABCore::editContact( const QString &uid )
1327{ 1328{
1328 1329
1329 if ( mExtensionManager->isQuickEditVisible() ) 1330 if ( mExtensionManager->isQuickEditVisible() )
1330 return; 1331 return;
1331 1332
1332 // First, locate the contact entry 1333 // First, locate the contact entry
1333 QString localUID = uid; 1334 QString localUID = uid;
1334 if ( localUID.isNull() ) { 1335 if ( localUID.isNull() ) {
1335 QStringList uidList = mViewManager->selectedUids(); 1336 QStringList uidList = mViewManager->selectedUids();
1336 if ( uidList.count() > 0 ) 1337 if ( uidList.count() > 0 )
1337 localUID = *( uidList.at( 0 ) ); 1338 localUID = *( uidList.at( 0 ) );
1338 } 1339 }
1339 1340
1340 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1341 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1341 if ( !addr.isEmpty() ) { 1342 if ( !addr.isEmpty() ) {
1342 mEditorDialog->setAddressee( addr ); 1343 mEditorDialog->setAddressee( addr );
1343 KApplication::execDialog ( mEditorDialog ); 1344 KApplication::execDialog ( mEditorDialog );
1344 } 1345 }
1345} 1346}
1346 1347
1347/** 1348/**
1348 Shows or edits the detail view for the given uid. If the uid is QString::null, 1349 Shows or edits the detail view for the given uid. If the uid is QString::null,
1349 the method will try to find a selected addressee in the view. 1350 the method will try to find a selected addressee in the view.
1350 */ 1351 */
1351void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1352{ 1353{
1353 if ( mMultipleViewsAtOnce ) 1354 if ( mMultipleViewsAtOnce )
1354 { 1355 {
1355 editContact( uid ); 1356 editContact( uid );
1356 } 1357 }
1357 else 1358 else
1358 { 1359 {
1359 setDetailsVisible( true ); 1360 setDetailsVisible( true );
1360 mActionDetails->setChecked(true); 1361 mActionDetails->setChecked(true);
1361 } 1362 }
1362 1363
1363} 1364}
1364 1365
1365void KABCore::save() 1366void KABCore::save()
1366{ 1367{
1367 if (syncManager->blockSave()) 1368 if (syncManager->blockSave())
1368 return; 1369 return;
1369 if ( !mModified ) 1370 if ( !mModified )
1370 return; 1371 return;
1371 1372
1372 syncManager->setBlockSave(true); 1373 syncManager->setBlockSave(true);
1373 QString text = i18n( "There was an error while attempting to save\n the " 1374 QString text = i18n( "There was an error while attempting to save\n the "
1374 "address book. Please check that some \nother application is " 1375 "address book. Please check that some \nother application is "
1375 "not using it. " ); 1376 "not using it. " );
1376 message(i18n("Saving addressbook ... ")); 1377 message(i18n("Saving ... please wait! "));
1378 qApp->processEvents();
1377#ifndef KAB_EMBEDDED 1379#ifndef KAB_EMBEDDED
1378 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1379 if ( !b || !b->save() ) { 1381 if ( !b || !b->save() ) {
1380 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1381 } 1383 }
1382#else //KAB_EMBEDDED 1384#else //KAB_EMBEDDED
1383 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1384 if ( !b || !b->save() ) { 1386 if ( !b || !b->save() ) {
1385 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1386 } 1388 }
1387#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1388 1390
1389 message(i18n("Addressbook saved!")); 1391 message(i18n("Addressbook saved!"));
1390 setModified( false ); 1392 setModified( false );
1391 syncManager->setBlockSave(false); 1393 syncManager->setBlockSave(false);
1392} 1394}
1393 1395
1394 1396
1395void KABCore::undo() 1397void KABCore::undo()
1396{ 1398{
1397 UndoStack::instance()->undo(); 1399 UndoStack::instance()->undo();
1398 1400
1399 // Refresh the view 1401 // Refresh the view
1400 mViewManager->refreshView(); 1402 mViewManager->refreshView();
1401} 1403}
1402 1404
1403void KABCore::redo() 1405void KABCore::redo()
1404{ 1406{
1405 RedoStack::instance()->redo(); 1407 RedoStack::instance()->redo();
1406 1408
1407 // Refresh the view 1409 // Refresh the view
1408 mViewManager->refreshView(); 1410 mViewManager->refreshView();
1409} 1411}
1410 1412
1411void KABCore::setJumpButtonBarVisible( bool visible ) 1413void KABCore::setJumpButtonBarVisible( bool visible )
1412{ 1414{
1413 if (mMultipleViewsAtOnce) 1415 if (mMultipleViewsAtOnce)
1414 { 1416 {
1415 if ( visible ) 1417 if ( visible )
1416 mJumpButtonBar->show(); 1418 mJumpButtonBar->show();
1417 else 1419 else
1418 mJumpButtonBar->hide(); 1420 mJumpButtonBar->hide();
1419 } 1421 }
1420 else 1422 else
1421 { 1423 {
1422 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1423 if (mViewManager->isVisible()) 1425 if (mViewManager->isVisible())
1424 { 1426 {
1425 if ( visible ) 1427 if ( visible )
1426 mJumpButtonBar->show(); 1428 mJumpButtonBar->show();
1427 else 1429 else
1428 mJumpButtonBar->hide(); 1430 mJumpButtonBar->hide();
1429 } 1431 }
1430 else 1432 else
1431 { 1433 {
1432 mJumpButtonBar->hide(); 1434 mJumpButtonBar->hide();
1433 } 1435 }
1434 } 1436 }
1435} 1437}
1436 1438
1437 1439
1438void KABCore::setDetailsToState() 1440void KABCore::setDetailsToState()
1439{ 1441{
1440 setDetailsVisible( mActionDetails->isChecked() ); 1442 setDetailsVisible( mActionDetails->isChecked() );
1441} 1443}
1442void KABCore::setDetailsToggle() 1444void KABCore::setDetailsToggle()
1443{ 1445{
1444 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1446 mActionDetails->setChecked( !mActionDetails->isChecked() );
1445 setDetailsToState(); 1447 setDetailsToState();
1446} 1448}
1447 1449
1448 1450
1449 1451
1450void KABCore::setDetailsVisible( bool visible ) 1452void KABCore::setDetailsVisible( bool visible )
1451{ 1453{
1452 if (visible && mDetails->isHidden()) 1454 if (visible && mDetails->isHidden())
1453 { 1455 {
1454 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1455 if ( addrList.count() > 0 ) 1457 if ( addrList.count() > 0 )
1456 mDetails->setAddressee( addrList[ 0 ] ); 1458 mDetails->setAddressee( addrList[ 0 ] );
1457 } 1459 }
1458 1460
1459 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1460 // the listview and the detailview. We do that by changing the splitbar size. 1462 // the listview and the detailview. We do that by changing the splitbar size.
1461 if (mMultipleViewsAtOnce) 1463 if (mMultipleViewsAtOnce)
1462 { 1464 {
1463 if ( visible ) 1465 if ( visible )
1464 mDetails->show(); 1466 mDetails->show();
1465 else 1467 else
1466 mDetails->hide(); 1468 mDetails->hide();
1467 } 1469 }
1468 else 1470 else
1469 { 1471 {
1470 if ( visible ) { 1472 if ( visible ) {
1471 mViewManager->hide(); 1473 mViewManager->hide();
1472 mDetails->show(); 1474 mDetails->show();
1473 mIncSearchWidget->setFocus(); 1475 mIncSearchWidget->setFocus();
1474 } 1476 }
1475 else { 1477 else {
1476 mViewManager->show(); 1478 mViewManager->show();
1477 mDetails->hide(); 1479 mDetails->hide();
1478 mViewManager->setFocusAV(); 1480 mViewManager->setFocusAV();
1479 } 1481 }
1480 setJumpButtonBarVisible( !visible ); 1482 setJumpButtonBarVisible( !visible );
1481 } 1483 }
1482 1484
1483} 1485}
1484 1486
1485void KABCore::extensionChanged( int id ) 1487void KABCore::extensionChanged( int id )
1486{ 1488{
1487 //change the details view only for non desktop systems 1489 //change the details view only for non desktop systems
1488#ifndef DESKTOP_VERSION 1490#ifndef DESKTOP_VERSION
1489 1491
1490 if (id == 0) 1492 if (id == 0)
1491 { 1493 {
1492 //the user disabled the extension. 1494 //the user disabled the extension.
1493 1495
1494 if (mMultipleViewsAtOnce) 1496 if (mMultipleViewsAtOnce)
1495 { // enable detailsview again 1497 { // enable detailsview again
1496 setDetailsVisible( true ); 1498 setDetailsVisible( true );
1497 mActionDetails->setChecked( true ); 1499 mActionDetails->setChecked( true );
1498 } 1500 }
1499 else 1501 else
1500 { //go back to the listview 1502 { //go back to the listview
1501 setDetailsVisible( false ); 1503 setDetailsVisible( false );
1502 mActionDetails->setChecked( false ); 1504 mActionDetails->setChecked( false );
1503 mActionDetails->setEnabled(true); 1505 mActionDetails->setEnabled(true);
1504 } 1506 }
1505 1507
1506 } 1508 }
1507 else 1509 else
1508 { 1510 {
1509 //the user enabled the extension. 1511 //the user enabled the extension.
1510 setDetailsVisible( false ); 1512 setDetailsVisible( false );
1511 mActionDetails->setChecked( false ); 1513 mActionDetails->setChecked( false );
1512 1514
1513 if (!mMultipleViewsAtOnce) 1515 if (!mMultipleViewsAtOnce)
1514 { 1516 {
1515 mActionDetails->setEnabled(false); 1517 mActionDetails->setEnabled(false);
1516 } 1518 }
1517 1519
1518 mExtensionManager->setSelectionChanged(); 1520 mExtensionManager->setSelectionChanged();
1519 1521
1520 } 1522 }
1521 1523
1522#endif// DESKTOP_VERSION 1524#endif// DESKTOP_VERSION
1523 1525
1524} 1526}
1525 1527
1526 1528
1527void KABCore::extensionModified( const KABC::Addressee::List &list ) 1529void KABCore::extensionModified( const KABC::Addressee::List &list )
1528{ 1530{
1529 1531
1530 if ( list.count() != 0 ) { 1532 if ( list.count() != 0 ) {
1531 KABC::Addressee::List::ConstIterator it; 1533 KABC::Addressee::List::ConstIterator it;
1532 for ( it = list.begin(); it != list.end(); ++it ) 1534 for ( it = list.begin(); it != list.end(); ++it )
1533 mAddressBook->insertAddressee( *it ); 1535 mAddressBook->insertAddressee( *it );
1534 if ( list.count() > 1 ) 1536 if ( list.count() > 1 )
1535 setModified(); 1537 setModified();
1536 else 1538 else
1537 setModifiedWOrefresh(); 1539 setModifiedWOrefresh();
1538 } 1540 }
1539 if ( list.count() == 0 ) 1541 if ( list.count() == 0 )
1540 mViewManager->refreshView(); 1542 mViewManager->refreshView();
1541 else 1543 else
1542 mViewManager->refreshView( list[ 0 ].uid() ); 1544 mViewManager->refreshView( list[ 0 ].uid() );
1543 1545
1544 1546
1545 1547
1546} 1548}
1547 1549
1548QString KABCore::getNameByPhone( const QString &phone ) 1550QString KABCore::getNameByPhone( const QString &phone )
1549{ 1551{
1550#ifndef KAB_EMBEDDED 1552#ifndef KAB_EMBEDDED
1551 QRegExp r( "[/*/-/ ]" ); 1553 QRegExp r( "[/*/-/ ]" );
1552 QString localPhone( phone ); 1554 QString localPhone( phone );
1553 1555
1554 bool found = false; 1556 bool found = false;
1555 QString ownerName = ""; 1557 QString ownerName = "";
1556 KABC::AddressBook::Iterator iter; 1558 KABC::AddressBook::Iterator iter;
1557 KABC::PhoneNumber::List::Iterator phoneIter; 1559 KABC::PhoneNumber::List::Iterator phoneIter;
1558 KABC::PhoneNumber::List phoneList; 1560 KABC::PhoneNumber::List phoneList;
1559 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1560 phoneList = (*iter).phoneNumbers(); 1562 phoneList = (*iter).phoneNumbers();
1561 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1562 ++phoneIter) { 1564 ++phoneIter) {
1563 // Get rid of separator chars so just the numbers are compared. 1565 // Get rid of separator chars so just the numbers are compared.
1564 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1565 ownerName = (*iter).formattedName(); 1567 ownerName = (*iter).formattedName();
1566 found = true; 1568 found = true;
1567 } 1569 }
1568 } 1570 }
1569 } 1571 }
1570 1572
1571 return ownerName; 1573 return ownerName;
1572#else //KAB_EMBEDDED 1574#else //KAB_EMBEDDED
1573 qDebug("KABCore::getNameByPhone finsih method"); 1575 qDebug("KABCore::getNameByPhone finsih method");
1574 return ""; 1576 return "";
1575#endif //KAB_EMBEDDED 1577#endif //KAB_EMBEDDED
1576 1578
1577} 1579}
1578 1580
1579void KABCore::openConfigDialog() 1581void KABCore::openConfigDialog()
1580{ 1582{
1581 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1582 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1583 ConfigureDialog->addModule(kabcfg ); 1585 ConfigureDialog->addModule(kabcfg );
1584 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1585 ConfigureDialog->addModule(kdelibcfg ); 1587 ConfigureDialog->addModule(kdelibcfg );
1586 1588
1587 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1589 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1588 this, SLOT( configurationChanged() ) ); 1590 this, SLOT( configurationChanged() ) );
1589 connect( ConfigureDialog, SIGNAL( okClicked() ), 1591 connect( ConfigureDialog, SIGNAL( okClicked() ),
1590 this, SLOT( configurationChanged() ) ); 1592 this, SLOT( configurationChanged() ) );
1591 saveSettings(); 1593 saveSettings();
1592#ifndef DESKTOP_VERSION 1594#ifndef DESKTOP_VERSION
1593 ConfigureDialog->showMaximized(); 1595 ConfigureDialog->showMaximized();
1594#endif 1596#endif
1595 if ( ConfigureDialog->exec() ) 1597 if ( ConfigureDialog->exec() )
1596 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1597 delete ConfigureDialog; 1599 delete ConfigureDialog;
1598} 1600}
1599 1601
1600void KABCore::openLDAPDialog() 1602void KABCore::openLDAPDialog()
1601{ 1603{
1602#ifndef KAB_EMBEDDED 1604#ifndef KAB_EMBEDDED
1603 if ( !mLdapSearchDialog ) { 1605 if ( !mLdapSearchDialog ) {
1604 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1605 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1606 SLOT( refreshView() ) ); 1608 SLOT( refreshView() ) );
1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1608 SLOT( setModified() ) ); 1610 SLOT( setModified() ) );
1609 } else 1611 } else
1610 mLdapSearchDialog->restoreSettings(); 1612 mLdapSearchDialog->restoreSettings();
1611 1613
1612 if ( mLdapSearchDialog->isOK() ) 1614 if ( mLdapSearchDialog->isOK() )
1613 mLdapSearchDialog->exec(); 1615 mLdapSearchDialog->exec();
1614#else //KAB_EMBEDDED 1616#else //KAB_EMBEDDED
1615 qDebug("KABCore::openLDAPDialog() finsih method"); 1617 qDebug("KABCore::openLDAPDialog() finsih method");
1616#endif //KAB_EMBEDDED 1618#endif //KAB_EMBEDDED
1617} 1619}
1618 1620
1619void KABCore::print() 1621void KABCore::print()
1620{ 1622{
1621#ifndef KAB_EMBEDDED 1623#ifndef KAB_EMBEDDED
1622 KPrinter printer; 1624 KPrinter printer;
1623 if ( !printer.setup( this ) ) 1625 if ( !printer.setup( this ) )
1624 return; 1626 return;
1625 1627
1626 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1627 mViewManager->selectedUids(), this ); 1629 mViewManager->selectedUids(), this );
1628 1630
1629 wizard.exec(); 1631 wizard.exec();
1630#else //KAB_EMBEDDED 1632#else //KAB_EMBEDDED
1631 qDebug("KABCore::print() finsih method"); 1633 qDebug("KABCore::print() finsih method");
1632#endif //KAB_EMBEDDED 1634#endif //KAB_EMBEDDED
1633 1635
1634} 1636}
1635 1637
1636 1638
1637void KABCore::addGUIClient( KXMLGUIClient *client ) 1639void KABCore::addGUIClient( KXMLGUIClient *client )
1638{ 1640{
1639 if ( mGUIClient ) 1641 if ( mGUIClient )
1640 mGUIClient->insertChildClient( client ); 1642 mGUIClient->insertChildClient( client );
1641 else 1643 else
1642 KMessageBox::error( this, "no KXMLGUICLient"); 1644 KMessageBox::error( this, "no KXMLGUICLient");
1643} 1645}
1644 1646
1645 1647
1646void KABCore::configurationChanged() 1648void KABCore::configurationChanged()
1647{ 1649{
1648 mExtensionManager->reconfigure(); 1650 mExtensionManager->reconfigure();
1649} 1651}
1650 1652
1651void KABCore::addressBookChanged() 1653void KABCore::addressBookChanged()
1652{ 1654{
1653/*US 1655/*US
1654 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1655 while ( it.current() ) { 1657 while ( it.current() ) {
1656 if ( it.current()->dirty() ) { 1658 if ( it.current()->dirty() ) {
1657 QString text = i18n( "Data has been changed externally. Unsaved " 1659 QString text = i18n( "Data has been changed externally. Unsaved "
1658 "changes will be lost." ); 1660 "changes will be lost." );
1659 KMessageBox::information( this, text ); 1661 KMessageBox::information( this, text );
1660 } 1662 }
1661 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1662 ++it; 1664 ++it;
1663 } 1665 }
1664*/ 1666*/
1665 if (mEditorDialog) 1667 if (mEditorDialog)
1666 { 1668 {
1667 if (mEditorDialog->dirty()) 1669 if (mEditorDialog->dirty())
1668 { 1670 {
1669 QString text = i18n( "Data has been changed externally. Unsaved " 1671 QString text = i18n( "Data has been changed externally. Unsaved "
1670 "changes will be lost." ); 1672 "changes will be lost." );
1671 KMessageBox::information( this, text ); 1673 KMessageBox::information( this, text );
1672 } 1674 }
1673 QString currentuid = mEditorDialog->addressee().uid(); 1675 QString currentuid = mEditorDialog->addressee().uid();
1674 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1675 } 1677 }
1676 mViewManager->refreshView(); 1678 mViewManager->refreshView();
1677 1679
1678 1680
1679} 1681}
1680 1682
1681AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1682 const char *name ) 1684 const char *name )
1683{ 1685{
1684 1686
1685 if ( mEditorDialog == 0 ) { 1687 if ( mEditorDialog == 0 ) {
1686 mEditorDialog = new AddresseeEditorDialog( this, parent, 1688 mEditorDialog = new AddresseeEditorDialog( this, parent,
1687 name ? name : "editorDialog" ); 1689 name ? name : "editorDialog" );
1688 1690
1689 1691
1690 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1691 SLOT( contactModified( const KABC::Addressee& ) ) ); 1693 SLOT( contactModified( const KABC::Addressee& ) ) );
1692 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1693 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1695 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1694 } 1696 }
1695 1697
1696 return mEditorDialog; 1698 return mEditorDialog;
1697} 1699}
1698 1700
1699void KABCore::slotEditorDestroyed( const QString &uid ) 1701void KABCore::slotEditorDestroyed( const QString &uid )
1700{ 1702{
1701 //mEditorDict.remove( uid ); 1703 //mEditorDict.remove( uid );
1702} 1704}
1703 1705
1704void KABCore::initGUI() 1706void KABCore::initGUI()
1705{ 1707{
1706#ifndef KAB_EMBEDDED 1708#ifndef KAB_EMBEDDED
1707 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1709 QHBoxLayout *topLayout = new QHBoxLayout( this );
1708 topLayout->setSpacing( KDialogBase::spacingHint() ); 1710 topLayout->setSpacing( KDialogBase::spacingHint() );
1709 1711
1710 mExtensionBarSplitter = new QSplitter( this ); 1712 mExtensionBarSplitter = new QSplitter( this );
1711 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1713 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1712 1714
1713 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1714 1716
1715 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1717 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1716 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1718 mIncSearchWidget = new IncSearchWidget( viewSpace );
1717 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1718 SLOT( incrementalSearch( const QString& ) ) ); 1720 SLOT( incrementalSearch( const QString& ) ) );
1719 1721
1720 mViewManager = new ViewManager( this, viewSpace ); 1722 mViewManager = new ViewManager( this, viewSpace );
1721 viewSpace->setStretchFactor( mViewManager, 1 ); 1723 viewSpace->setStretchFactor( mViewManager, 1 );
1722 1724
1723 mDetails = new ViewContainer( mDetailsSplitter ); 1725 mDetails = new ViewContainer( mDetailsSplitter );
1724 1726
1725 mJumpButtonBar = new JumpButtonBar( this, this ); 1727 mJumpButtonBar = new JumpButtonBar( this, this );
1726 1728
1727 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1728 1730
1729 topLayout->addWidget( mExtensionBarSplitter ); 1731 topLayout->addWidget( mExtensionBarSplitter );
1730 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1731 topLayout->addWidget( mJumpButtonBar ); 1733 topLayout->addWidget( mJumpButtonBar );
1732 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1734 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1733 1735
1734 mXXPortManager = new XXPortManager( this, this ); 1736 mXXPortManager = new XXPortManager( this, this );
1735 1737
1736#else //KAB_EMBEDDED 1738#else //KAB_EMBEDDED
1737 //US initialize viewMenu before settingup viewmanager. 1739 //US initialize viewMenu before settingup viewmanager.
1738 // Viewmanager needs this menu to plugin submenues. 1740 // Viewmanager needs this menu to plugin submenues.
1739 viewMenu = new QPopupMenu( this ); 1741 viewMenu = new QPopupMenu( this );
1740 settingsMenu = new QPopupMenu( this ); 1742 settingsMenu = new QPopupMenu( this );
1741 //filterMenu = new QPopupMenu( this ); 1743 //filterMenu = new QPopupMenu( this );
1742 ImportMenu = new QPopupMenu( this ); 1744 ImportMenu = new QPopupMenu( this );
1743 ExportMenu = new QPopupMenu( this ); 1745 ExportMenu = new QPopupMenu( this );
1744 syncMenu = new QPopupMenu( this ); 1746 syncMenu = new QPopupMenu( this );
1745 changeMenu= new QPopupMenu( this ); 1747 changeMenu= new QPopupMenu( this );
1746 beamMenu= new QPopupMenu( this ); 1748 beamMenu= new QPopupMenu( this );
1747 1749
1748//US since we have no splitter for the embedded system, setup 1750//US since we have no splitter for the embedded system, setup
1749// a layout with two frames. One left and one right. 1751// a layout with two frames. One left and one right.
1750 1752
1751 QBoxLayout *topLayout; 1753 QBoxLayout *topLayout;
1752 1754
1753 // = new QHBoxLayout( this ); 1755 // = new QHBoxLayout( this );
1754// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1756// QBoxLayout *topLayout = (QBoxLayout*)layout();
1755 1757
1756// QWidget *mainBox = new QWidget( this ); 1758// QWidget *mainBox = new QWidget( this );
1757// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1758 1760
1759#ifdef DESKTOP_VERSION 1761#ifdef DESKTOP_VERSION
1760 topLayout = new QHBoxLayout( this ); 1762 topLayout = new QHBoxLayout( this );
@@ -1982,793 +1984,799 @@ void KABCore::initActions()
1982 //US not implemented yet 1984 //US not implemented yet
1983 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1984 // this, SLOT( configureKeyBindings() ), actionCollection(), 1986 // this, SLOT( configureKeyBindings() ), actionCollection(),
1985 // "kaddressbook_configure_shortcuts" ); 1987 // "kaddressbook_configure_shortcuts" );
1986#ifdef KAB_EMBEDDED 1988#ifdef KAB_EMBEDDED
1987 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1988 mActionConfigureToolbars->setEnabled( false ); 1990 mActionConfigureToolbars->setEnabled( false );
1989#endif //KAB_EMBEDDED 1991#endif //KAB_EMBEDDED
1990 1992
1991 } else { 1993 } else {
1992 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1993 1995
1994 //US not implemented yet 1996 //US not implemented yet
1995 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1996 } 1998 }
1997 1999
1998 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1999 actionCollection(), "options_show_jump_bar" ); 2001 actionCollection(), "options_show_jump_bar" );
2000 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
2001 2003
2002 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2003 actionCollection(), "options_show_details" ); 2005 actionCollection(), "options_show_details" );
2004 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2005 2007
2006 2008
2007 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2008 SLOT( toggleBeamReceive() ), actionCollection(), 2010 SLOT( toggleBeamReceive() ), actionCollection(),
2009 "kaddressbook_beam_rec" ); 2011 "kaddressbook_beam_rec" );
2010 2012
2011 2013
2012 // misc 2014 // misc
2013 // only enable LDAP lookup if we can handle the protocol 2015 // only enable LDAP lookup if we can handle the protocol
2014#ifndef KAB_EMBEDDED 2016#ifndef KAB_EMBEDDED
2015 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2016 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2017 this, SLOT( openLDAPDialog() ), actionCollection(), 2019 this, SLOT( openLDAPDialog() ), actionCollection(),
2018 "ldap_lookup" ); 2020 "ldap_lookup" );
2019 } 2021 }
2020#else //KAB_EMBEDDED 2022#else //KAB_EMBEDDED
2021 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2023 //qDebug("KABCore::initActions() LDAP has to be implemented");
2022#endif //KAB_EMBEDDED 2024#endif //KAB_EMBEDDED
2023 2025
2024 2026
2025 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2026 SLOT( setWhoAmI() ), actionCollection(), 2028 SLOT( setWhoAmI() ), actionCollection(),
2027 "set_personal" ); 2029 "set_personal" );
2028 2030
2029 2031
2030 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
2031 SLOT( setCategories() ), actionCollection(), 2033 SLOT( setCategories() ), actionCollection(),
2032 "edit_set_categories" ); 2034 "edit_set_categories" );
2033 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
2034 SLOT( editCategories() ), actionCollection(), 2036 SLOT( editCategories() ), actionCollection(),
2035 "edit__categories" ); 2037 "edit__categories" );
2036 2038
2037 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2038 SLOT( removeVoice() ), actionCollection(), 2040 SLOT( removeVoice() ), actionCollection(),
2039 "remove_voice" ); 2041 "remove_voice" );
2040 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2041 SLOT( setFormattedName() ), actionCollection(), 2043 SLOT( setFormattedName() ), actionCollection(),
2042 "set_formatted" ); 2044 "set_formatted" );
2043 2045
2044 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2045 SLOT( manageCategories() ), actionCollection(), 2047 SLOT( manageCategories() ), actionCollection(),
2046 "remove_voice" ); 2048 "remove_voice" );
2047 2049
2048 2050
2049 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2050 SLOT( importFromOL() ), actionCollection(), 2052 SLOT( importFromOL() ), actionCollection(),
2051 "import_OL" ); 2053 "import_OL" );
2052#ifdef KAB_EMBEDDED 2054#ifdef KAB_EMBEDDED
2053 mActionLicence = new KAction( i18n( "Licence" ), 0, 2055 mActionLicence = new KAction( i18n( "Licence" ), 0,
2054 this, SLOT( showLicence() ), actionCollection(), 2056 this, SLOT( showLicence() ), actionCollection(),
2055 "licence_about_data" ); 2057 "licence_about_data" );
2056 mActionFaq = new KAction( i18n( "Faq" ), 0, 2058 mActionFaq = new KAction( i18n( "Faq" ), 0,
2057 this, SLOT( faq() ), actionCollection(), 2059 this, SLOT( faq() ), actionCollection(),
2058 "faq_about_data" ); 2060 "faq_about_data" );
2059 mActionWN = new KAction( i18n( "What's New?" ), 0, 2061 mActionWN = new KAction( i18n( "What's New?" ), 0,
2060 this, SLOT( whatsnew() ), actionCollection(), 2062 this, SLOT( whatsnew() ), actionCollection(),
2061 "wn" ); 2063 "wn" );
2062 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2063 this, SLOT( synchowto() ), actionCollection(), 2065 this, SLOT( synchowto() ), actionCollection(),
2064 "sync" ); 2066 "sync" );
2065 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2066 this, SLOT( kdesynchowto() ), actionCollection(), 2068 this, SLOT( kdesynchowto() ), actionCollection(),
2067 "kdesync" ); 2069 "kdesync" );
2068 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2069 this, SLOT( multisynchowto() ), actionCollection(), 2071 this, SLOT( multisynchowto() ), actionCollection(),
2070 "multisync" ); 2072 "multisync" );
2071 2073
2072 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2073 this, SLOT( createAboutData() ), actionCollection(), 2075 this, SLOT( createAboutData() ), actionCollection(),
2074 "kaddressbook_about_data" ); 2076 "kaddressbook_about_data" );
2075#endif //KAB_EMBEDDED 2077#endif //KAB_EMBEDDED
2076 2078
2077 clipboardDataChanged(); 2079 clipboardDataChanged();
2078 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2079 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2080} 2082}
2081 2083
2082//US we need this function, to plug all actions into the correct menues. 2084//US we need this function, to plug all actions into the correct menues.
2083// KDE uses a XML format to plug the actions, but we work her without this overhead. 2085// KDE uses a XML format to plug the actions, but we work her without this overhead.
2084void KABCore::addActionsManually() 2086void KABCore::addActionsManually()
2085{ 2087{
2086//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2087 2089
2088#ifdef KAB_EMBEDDED 2090#ifdef KAB_EMBEDDED
2089 QPopupMenu *fileMenu = new QPopupMenu( this ); 2091 QPopupMenu *fileMenu = new QPopupMenu( this );
2090 QPopupMenu *editMenu = new QPopupMenu( this ); 2092 QPopupMenu *editMenu = new QPopupMenu( this );
2091 QPopupMenu *helpMenu = new QPopupMenu( this ); 2093 QPopupMenu *helpMenu = new QPopupMenu( this );
2092 2094
2093 KToolBar* tb = mMainWindow->toolBar(); 2095 KToolBar* tb = mMainWindow->toolBar();
2094 2096
2095#ifndef DESKTOP_VERSION 2097#ifndef DESKTOP_VERSION
2096 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2097#endif 2099#endif
2098 QMenuBar* mb = mMainWindow->menuBar(); 2100 QMenuBar* mb = mMainWindow->menuBar();
2099 2101
2100 //US setup menubar. 2102 //US setup menubar.
2101 //Disable the following block if you do not want to have a menubar. 2103 //Disable the following block if you do not want to have a menubar.
2102 mb->insertItem( i18n("&File"), fileMenu ); 2104 mb->insertItem( i18n("&File"), fileMenu );
2103 mb->insertItem( i18n("&Edit"), editMenu ); 2105 mb->insertItem( i18n("&Edit"), editMenu );
2104 mb->insertItem( i18n("&View"), viewMenu ); 2106 mb->insertItem( i18n("&View"), viewMenu );
2105 mb->insertItem( i18n("&Settings"), settingsMenu ); 2107 mb->insertItem( i18n("&Settings"), settingsMenu );
2106 mb->insertItem( i18n("Synchronize"), syncMenu ); 2108 mb->insertItem( i18n("Synchronize"), syncMenu );
2107 //mb->insertItem( i18n("&Change"), changeMenu ); 2109 //mb->insertItem( i18n("&Change"), changeMenu );
2108 mb->insertItem( i18n("&Help"), helpMenu ); 2110 mb->insertItem( i18n("&Help"), helpMenu );
2109 mIncSearchWidget = new IncSearchWidget( tb ); 2111 mIncSearchWidget = new IncSearchWidget( tb );
2110 // tb->insertWidget(-1, 0, mIncSearchWidget); 2112 // tb->insertWidget(-1, 0, mIncSearchWidget);
2111#ifndef DESKTOP_VERSION 2113#ifndef DESKTOP_VERSION
2112 } else { 2114 } else {
2113 //US setup toolbar 2115 //US setup toolbar
2114 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2115 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2117 QPopupMenu *popupBarTB = new QPopupMenu( this );
2116 menuBarTB->insertItem( "ME", popupBarTB); 2118 menuBarTB->insertItem( "ME", popupBarTB);
2117 tb->insertWidget(-1, 0, menuBarTB); 2119 tb->insertWidget(-1, 0, menuBarTB);
2118 mIncSearchWidget = new IncSearchWidget( tb ); 2120 mIncSearchWidget = new IncSearchWidget( tb );
2119 2121
2120 tb->enableMoving(false); 2122 tb->enableMoving(false);
2121 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2123 popupBarTB->insertItem( i18n("&File"), fileMenu );
2122 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2124 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2123 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2125 popupBarTB->insertItem( i18n("&View"), viewMenu );
2124 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2125 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2126 mViewManager->getFilterAction()->plug ( popupBarTB); 2128 mViewManager->getFilterAction()->plug ( popupBarTB);
2127 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2128 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2130 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2129 if (QApplication::desktop()->width() > 320 ) { 2131 if (QApplication::desktop()->width() > 320 ) {
2130 // mViewManager->getFilterAction()->plug ( tb); 2132 // mViewManager->getFilterAction()->plug ( tb);
2131 } 2133 }
2132 } 2134 }
2133#endif 2135#endif
2134 // mActionQuit->plug ( mMainWindow->toolBar()); 2136 // mActionQuit->plug ( mMainWindow->toolBar());
2135 2137
2136 2138
2137 2139
2138 //US Now connect the actions with the menue entries. 2140 //US Now connect the actions with the menue entries.
2139#ifdef DESKTOP_VERSION 2141#ifdef DESKTOP_VERSION
2140 mActionPrint->plug( fileMenu ); 2142 mActionPrint->plug( fileMenu );
2141 mActionPrintDetails->plug( fileMenu ); 2143 mActionPrintDetails->plug( fileMenu );
2142 fileMenu->insertSeparator(); 2144 fileMenu->insertSeparator();
2143#endif 2145#endif
2144 mActionMail->plug( fileMenu ); 2146 mActionMail->plug( fileMenu );
2145 fileMenu->insertSeparator(); 2147 fileMenu->insertSeparator();
2146 2148
2147 mActionNewContact->plug( fileMenu ); 2149 mActionNewContact->plug( fileMenu );
2148 mActionNewContact->plug( tb ); 2150 mActionNewContact->plug( tb );
2149 2151
2150 mActionEditAddressee->plug( fileMenu ); 2152 mActionEditAddressee->plug( fileMenu );
2151 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2152 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2153 mActionEditAddressee->plug( tb ); 2155 mActionEditAddressee->plug( tb );
2154 2156
2155 fileMenu->insertSeparator(); 2157 fileMenu->insertSeparator();
2156 mActionSave->plug( fileMenu ); 2158 mActionSave->plug( fileMenu );
2157 fileMenu->insertItem( "&Import", ImportMenu ); 2159 fileMenu->insertItem( "&Import", ImportMenu );
2158 fileMenu->insertItem( "&Export", ExportMenu ); 2160 fileMenu->insertItem( "&Export", ExportMenu );
2159 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2161 fileMenu->insertItem( i18n("&Change"), changeMenu );
2160#ifndef DESKTOP_VERSION 2162#ifndef DESKTOP_VERSION
2161 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2162#endif 2164#endif
2163#if 0 2165#if 0
2164 // PENDING fix MailVCard 2166 // PENDING fix MailVCard
2165 fileMenu->insertSeparator(); 2167 fileMenu->insertSeparator();
2166 mActionMailVCard->plug( fileMenu ); 2168 mActionMailVCard->plug( fileMenu );
2167#endif 2169#endif
2168#ifndef DESKTOP_VERSION 2170#ifndef DESKTOP_VERSION
2169 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2171 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2170 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2171 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2172#endif 2174#endif
2173 fileMenu->insertSeparator(); 2175 fileMenu->insertSeparator();
2174 mActionQuit->plug( fileMenu ); 2176 mActionQuit->plug( fileMenu );
2175#ifdef _WIN32_ 2177#ifdef _WIN32_
2176 mActionImportOL->plug( ImportMenu ); 2178 mActionImportOL->plug( ImportMenu );
2177#endif 2179#endif
2178 // edit menu 2180 // edit menu
2179 mActionUndo->plug( editMenu ); 2181 mActionUndo->plug( editMenu );
2180 mActionRedo->plug( editMenu ); 2182 mActionRedo->plug( editMenu );
2181 editMenu->insertSeparator(); 2183 editMenu->insertSeparator();
2182 mActionCut->plug( editMenu ); 2184 mActionCut->plug( editMenu );
2183 mActionCopy->plug( editMenu ); 2185 mActionCopy->plug( editMenu );
2184 mActionPaste->plug( editMenu ); 2186 mActionPaste->plug( editMenu );
2185 mActionDelete->plug( editMenu ); 2187 mActionDelete->plug( editMenu );
2186 editMenu->insertSeparator(); 2188 editMenu->insertSeparator();
2187 mActionSelectAll->plug( editMenu ); 2189 mActionSelectAll->plug( editMenu );
2188 2190
2189 mActionSetFormattedName->plug( changeMenu ); 2191 mActionSetFormattedName->plug( changeMenu );
2190 mActionRemoveVoice->plug( changeMenu ); 2192 mActionRemoveVoice->plug( changeMenu );
2191 // settings menu 2193 // settings menu
2192//US special menuentry to configure the addressbook resources. On KDE 2194//US special menuentry to configure the addressbook resources. On KDE
2193// you do that through the control center !!! 2195// you do that through the control center !!!
2194 mActionConfigResources->plug( settingsMenu ); 2196 mActionConfigResources->plug( settingsMenu );
2195 settingsMenu->insertSeparator(); 2197 settingsMenu->insertSeparator();
2196 2198
2197 mActionConfigKAddressbook->plug( settingsMenu ); 2199 mActionConfigKAddressbook->plug( settingsMenu );
2198 2200
2199 if ( mIsPart ) { 2201 if ( mIsPart ) {
2200 //US not implemented yet 2202 //US not implemented yet
2201 //mActionConfigShortcuts->plug( settingsMenu ); 2203 //mActionConfigShortcuts->plug( settingsMenu );
2202 //mActionConfigureToolbars->plug( settingsMenu ); 2204 //mActionConfigureToolbars->plug( settingsMenu );
2203 2205
2204 } else { 2206 } else {
2205 //US not implemented yet 2207 //US not implemented yet
2206 //mActionKeyBindings->plug( settingsMenu ); 2208 //mActionKeyBindings->plug( settingsMenu );
2207 } 2209 }
2208 2210
2209 settingsMenu->insertSeparator(); 2211 settingsMenu->insertSeparator();
2210 2212
2211 mActionJumpBar->plug( settingsMenu ); 2213 mActionJumpBar->plug( settingsMenu );
2212 mActionDetails->plug( settingsMenu ); 2214 mActionDetails->plug( settingsMenu );
2213 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2214 mActionDetails->plug( tb ); 2216 mActionDetails->plug( tb );
2215 settingsMenu->insertSeparator(); 2217 settingsMenu->insertSeparator();
2216#ifndef DESKTOP_VERSION 2218#ifndef DESKTOP_VERSION
2217 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2218#endif 2220#endif
2219 settingsMenu->insertSeparator(); 2221 settingsMenu->insertSeparator();
2220 2222
2221 mActionWhoAmI->plug( settingsMenu ); 2223 mActionWhoAmI->plug( settingsMenu );
2222 mActionEditCategories->plug( settingsMenu ); 2224 mActionEditCategories->plug( settingsMenu );
2223 mActionEditCategories->plug( changeMenu ); 2225 mActionEditCategories->plug( changeMenu );
2224 mActionCategories->plug( changeMenu ); 2226 mActionCategories->plug( changeMenu );
2225 mActionManageCategories->plug( changeMenu ); 2227 mActionManageCategories->plug( changeMenu );
2226 2228
2227 mActionCategories->plug( settingsMenu ); 2229 mActionCategories->plug( settingsMenu );
2228 mActionManageCategories->plug( settingsMenu ); 2230 mActionManageCategories->plug( settingsMenu );
2229 2231
2230 2232
2231 mActionWN->plug( helpMenu ); 2233 mActionWN->plug( helpMenu );
2232 mActionSyncHowto->plug( helpMenu ); 2234 mActionSyncHowto->plug( helpMenu );
2233 mActionKdeSyncHowto->plug( helpMenu ); 2235 mActionKdeSyncHowto->plug( helpMenu );
2234 mActionMultiSyncHowto->plug( helpMenu ); 2236 mActionMultiSyncHowto->plug( helpMenu );
2235 mActionFaq->plug( helpMenu ); 2237 mActionFaq->plug( helpMenu );
2236 mActionLicence->plug( helpMenu ); 2238 mActionLicence->plug( helpMenu );
2237 mActionAboutKAddressbook->plug( helpMenu ); 2239 mActionAboutKAddressbook->plug( helpMenu );
2238 2240
2239 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2240 2242
2241 mActionSave->plug( tb ); 2243 mActionSave->plug( tb );
2242 mViewManager->getFilterAction()->plug ( tb); 2244 mViewManager->getFilterAction()->plug ( tb);
2243 //LR hide filteraction on started in 480x640 2245 //LR hide filteraction on started in 480x640
2244 if (QApplication::desktop()->width() == 480 ) { 2246 if (QApplication::desktop()->width() == 480 ) {
2245 mViewManager->getFilterAction()->setComboWidth( 0 ); 2247 mViewManager->getFilterAction()->setComboWidth( 0 );
2246 } 2248 }
2247 mActionUndo->plug( tb ); 2249 mActionUndo->plug( tb );
2248 mActionDelete->plug( tb ); 2250 mActionDelete->plug( tb );
2249 mActionRedo->plug( tb ); 2251 mActionRedo->plug( tb );
2250 } else { 2252 } else {
2251 mActionSave->plug( tb ); 2253 mActionSave->plug( tb );
2252 tb->enableMoving(false); 2254 tb->enableMoving(false);
2253 } 2255 }
2254 //mActionQuit->plug ( tb ); 2256 //mActionQuit->plug ( tb );
2255 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2256 2258
2257 //US link the searchwidget first to this. 2259 //US link the searchwidget first to this.
2258 // The real linkage to the toolbar happens later. 2260 // The real linkage to the toolbar happens later.
2259//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2260//US tb->insertItem( mIncSearchWidget ); 2262//US tb->insertItem( mIncSearchWidget );
2261/*US 2263/*US
2262 mIncSearchWidget = new IncSearchWidget( tb ); 2264 mIncSearchWidget = new IncSearchWidget( tb );
2263 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2264 SLOT( incrementalSearch( const QString& ) ) ); 2266 SLOT( incrementalSearch( const QString& ) ) );
2265 2267
2266 mJumpButtonBar = new JumpButtonBar( this, this ); 2268 mJumpButtonBar = new JumpButtonBar( this, this );
2267 2269
2268//US topLayout->addWidget( mJumpButtonBar ); 2270//US topLayout->addWidget( mJumpButtonBar );
2269 this->layout()->add( mJumpButtonBar ); 2271 this->layout()->add( mJumpButtonBar );
2270*/ 2272*/
2271 2273
2272#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2273 2275
2274 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2275 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2276 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2277 2279
2278} 2280}
2279void KABCore::showLicence() 2281void KABCore::showLicence()
2280{ 2282{
2281 KApplication::showLicence(); 2283 KApplication::showLicence();
2282} 2284}
2283 2285
2284void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2285{ 2287{
2286 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2287 cp->show(); 2289 cp->show();
2288 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2289 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2290 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2291 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2292 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2293 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2294 delete cp; 2296 delete cp;
2295 return; 2297 return;
2296 } 2298 }
2297 int count = 0; 2299 int count = 0;
2298 message( i18n("Please wait, processing categories...")); 2300 message( i18n("Please wait, processing categories..."));
2299 if ( cp->addCat() ) { 2301 if ( cp->addCat() ) {
2300 KABC::AddressBook::Iterator it; 2302 KABC::AddressBook::Iterator it;
2301 QStringList catList = KABPrefs::instance()->mCustomCategories; 2303 QStringList catList = KABPrefs::instance()->mCustomCategories;
2302 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2304 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2303 QStringList catIncList = (*it).categories(); 2305 QStringList catIncList = (*it).categories();
2304 int i; 2306 int i;
2305 for( i = 0; i< catIncList.count(); ++i ) { 2307 for( i = 0; i< catIncList.count(); ++i ) {
2306 if ( !catList.contains (catIncList[i])) { 2308 if ( !catList.contains (catIncList[i])) {
2307 catList.append( catIncList[i] ); 2309 catList.append( catIncList[i] );
2308 //qDebug("add cat %s ", catIncList[i].latin1()); 2310 //qDebug("add cat %s ", catIncList[i].latin1());
2309 ++count; 2311 ++count;
2310 } 2312 }
2311 } 2313 }
2312 } 2314 }
2313 catList.sort(); 2315 catList.sort();
2314 KABPrefs::instance()->mCustomCategories = catList; 2316 KABPrefs::instance()->mCustomCategories = catList;
2315 KABPrefs::instance()->writeConfig(); 2317 KABPrefs::instance()->writeConfig();
2316 message(QString::number( count )+ i18n(" categories added to list! ")); 2318 message(QString::number( count )+ i18n(" categories added to list! "));
2317 } else { 2319 } else {
2318 QStringList catList = KABPrefs::instance()->mCustomCategories; 2320 QStringList catList = KABPrefs::instance()->mCustomCategories;
2319 QStringList catIncList; 2321 QStringList catIncList;
2320 QStringList newCatList; 2322 QStringList newCatList;
2321 KABC::AddressBook::Iterator it; 2323 KABC::AddressBook::Iterator it;
2322 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2324 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2323 QStringList catIncList = (*it).categories(); 2325 QStringList catIncList = (*it).categories();
2324 int i; 2326 int i;
2325 if ( catIncList.count() ) { 2327 if ( catIncList.count() ) {
2326 newCatList.clear(); 2328 newCatList.clear();
2327 for( i = 0; i< catIncList.count(); ++i ) { 2329 for( i = 0; i< catIncList.count(); ++i ) {
2328 if ( catList.contains (catIncList[i])) { 2330 if ( catList.contains (catIncList[i])) {
2329 newCatList.append( catIncList[i] ); 2331 newCatList.append( catIncList[i] );
2330 } 2332 }
2331 } 2333 }
2332 newCatList.sort(); 2334 newCatList.sort();
2333 (*it).setCategories( newCatList ); 2335 (*it).setCategories( newCatList );
2334 mAddressBook->insertAddressee( (*it) ); 2336 mAddressBook->insertAddressee( (*it) );
2335 } 2337 }
2336 } 2338 }
2337 setModified( true ); 2339 setModified( true );
2338 mViewManager->refreshView(); 2340 mViewManager->refreshView();
2339 message( i18n("Removing categories done!")); 2341 message( i18n("Removing categories done!"));
2340 } 2342 }
2341 delete cp; 2343 delete cp;
2342} 2344}
2343void KABCore::removeVoice() 2345void KABCore::removeVoice()
2344{ 2346{
2345 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 ) 2347 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 )
2346 return; 2348 return;
2347 KABC::Addressee::List list; 2349 KABC::Addressee::List list;
2348 XXPortSelectDialog dlg( this, false, this ); 2350 XXPortSelectDialog dlg( this, false, this );
2349 if ( dlg.exec() ) 2351 if ( dlg.exec() )
2350 list = dlg.contacts(); 2352 list = dlg.contacts();
2351 else 2353 else
2352 return; 2354 return;
2353 KABC::Addressee::List::Iterator it; 2355 KABC::Addressee::List::Iterator it;
2354 for ( it = list.begin(); it != list.end(); ++it ) { 2356 for ( it = list.begin(); it != list.end(); ++it ) {
2355 if ( (*it).removeVoice() ) 2357 if ( (*it).removeVoice() )
2356 addrModified((*it), false ); 2358 addrModified((*it), false );
2357 } 2359 }
2358} 2360}
2359 2361
2360void KABCore::setFormattedName() 2362void KABCore::setFormattedName()
2361{ 2363{
2362 KABFormatPrefs setpref; 2364 KABFormatPrefs setpref;
2363 if ( !setpref.exec() ) { 2365 if ( !setpref.exec() ) {
2364 return; 2366 return;
2365 } 2367 }
2366 KABC::Addressee::List list;
2367 XXPortSelectDialog dlg( this, false, this ); 2368 XXPortSelectDialog dlg( this, false, this );
2368 if ( dlg.exec() ) 2369 if ( !dlg.exec() )
2369 list = dlg.contacts();
2370 else
2371 return; 2370 return;
2372 KABC::Addressee::List::Iterator it; 2371 mAddressBook->setUntagged();
2373 for ( it = list.begin(); it != list.end(); ++it ) { 2372 dlg.tagSelected();
2374 QString fName; 2373 int count = 0;
2375 if ( setpref.simple->isChecked() ) 2374 KABC::AddressBook::Iterator it;
2376 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2375 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2377 else if ( setpref.full->isChecked() ) 2376 if ( (*it).tagged() ) {
2378 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2377 message(i18n("Changing contact #%1").arg( ++count ) );
2379 else if ( setpref.reverse->isChecked() ) 2378 qApp->processEvents();
2380 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2379 QString fName;
2381 else 2380 if ( setpref.simple->isChecked() )
2382 fName = (*it).organization(); 2381 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2383 if ( setpref.setCompany->isChecked() ) 2382 else if ( setpref.full->isChecked() )
2384 if ( fName.isEmpty() || fName =="," ) 2383 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2384 else if ( setpref.reverse->isChecked() )
2385 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2386 else
2385 fName = (*it).organization(); 2387 fName = (*it).organization();
2386 (*it).setFormattedName( fName ); 2388 if ( setpref.setCompany->isChecked() )
2387 addrModified((*it),false ); 2389 if ( fName.isEmpty() || fName =="," )
2390 fName = (*it).organization();
2391 (*it).setFormattedName( fName );
2392 }
2388 } 2393 }
2394 message(i18n("Refreshing view...") );
2395 mViewManager->refreshView( "" );
2389 Addressee add; 2396 Addressee add;
2390 mDetails->setAddressee( add ); 2397 mDetails->setAddressee( add );
2398 message(i18n("Setting formatted name completed!") );
2391} 2399}
2392 2400
2393void KABCore::clipboardDataChanged() 2401void KABCore::clipboardDataChanged()
2394{ 2402{
2395 2403
2396 if ( mReadWrite ) 2404 if ( mReadWrite )
2397 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2405 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2398 2406
2399} 2407}
2400 2408
2401void KABCore::updateActionMenu() 2409void KABCore::updateActionMenu()
2402{ 2410{
2403 UndoStack *undo = UndoStack::instance(); 2411 UndoStack *undo = UndoStack::instance();
2404 RedoStack *redo = RedoStack::instance(); 2412 RedoStack *redo = RedoStack::instance();
2405 2413
2406 if ( undo->isEmpty() ) 2414 if ( undo->isEmpty() )
2407 mActionUndo->setText( i18n( "Undo" ) ); 2415 mActionUndo->setText( i18n( "Undo" ) );
2408 else 2416 else
2409 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2417 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2410 2418
2411 mActionUndo->setEnabled( !undo->isEmpty() ); 2419 mActionUndo->setEnabled( !undo->isEmpty() );
2412 2420
2413 if ( !redo->top() ) 2421 if ( !redo->top() )
2414 mActionRedo->setText( i18n( "Redo" ) ); 2422 mActionRedo->setText( i18n( "Redo" ) );
2415 else 2423 else
2416 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2424 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2417 2425
2418 mActionRedo->setEnabled( !redo->isEmpty() ); 2426 mActionRedo->setEnabled( !redo->isEmpty() );
2419} 2427}
2420 2428
2421void KABCore::configureKeyBindings() 2429void KABCore::configureKeyBindings()
2422{ 2430{
2423#ifndef KAB_EMBEDDED 2431#ifndef KAB_EMBEDDED
2424 KKeyDialog::configure( actionCollection(), true ); 2432 KKeyDialog::configure( actionCollection(), true );
2425#else //KAB_EMBEDDED 2433#else //KAB_EMBEDDED
2426 qDebug("KABCore::configureKeyBindings() not implemented"); 2434 qDebug("KABCore::configureKeyBindings() not implemented");
2427#endif //KAB_EMBEDDED 2435#endif //KAB_EMBEDDED
2428} 2436}
2429 2437
2430#ifdef KAB_EMBEDDED 2438#ifdef KAB_EMBEDDED
2431void KABCore::configureResources() 2439void KABCore::configureResources()
2432{ 2440{
2433 KRES::KCMKResources dlg( this, "" , 0 ); 2441 KRES::KCMKResources dlg( this, "" , 0 );
2434 2442
2435 if ( !dlg.exec() ) 2443 if ( !dlg.exec() )
2436 return; 2444 return;
2437 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2445 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2438} 2446}
2439#endif //KAB_EMBEDDED 2447#endif //KAB_EMBEDDED
2440 2448
2441 2449
2442/* this method will be called through the QCop interface from Ko/Pi to select addresses 2450/* this method will be called through the QCop interface from Ko/Pi to select addresses
2443 * for the attendees list of an event. 2451 * for the attendees list of an event.
2444 */ 2452 */
2445void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2453void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2446{ 2454{
2447 QStringList nameList; 2455 QStringList nameList;
2448 QStringList emailList; 2456 QStringList emailList;
2449 QStringList uidList; 2457 QStringList uidList;
2450 2458
2451 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2459 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2452 uint i=0; 2460 uint i=0;
2453 for (i=0; i < list.count(); i++) 2461 for (i=0; i < list.count(); i++)
2454 { 2462 {
2455 nameList.append(list[i].realName()); 2463 nameList.append(list[i].realName());
2456 emailList.append(list[i].preferredEmail()); 2464 emailList.append(list[i].preferredEmail());
2457 uidList.append(list[i].uid()); 2465 uidList.append(list[i].uid());
2458 } 2466 }
2459 2467
2460 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2468 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2461 2469
2462} 2470}
2463 2471
2464/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2472/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2465 * to put them into the calendar. 2473 * to put them into the calendar.
2466 */ 2474 */
2467void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2475void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2468{ 2476{
2469 // qDebug("KABCore::requestForBirthdayList"); 2477 // qDebug("KABCore::requestForBirthdayList");
2470 QStringList birthdayList; 2478 QStringList birthdayList;
2471 QStringList anniversaryList; 2479 QStringList anniversaryList;
2472 QStringList realNameList; 2480 QStringList realNameList;
2473 QStringList preferredEmailList; 2481 QStringList preferredEmailList;
2474 QStringList assembledNameList; 2482 QStringList assembledNameList;
2475 QStringList uidList; 2483 QStringList uidList;
2476 2484
2477 KABC::AddressBook::Iterator it; 2485 KABC::AddressBook::Iterator it;
2478 2486
2479 int count = 0; 2487 int count = 0;
2480 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2488 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2481 ++count; 2489 ++count;
2482 } 2490 }
2483 QProgressBar bar(count,0 ); 2491 QProgressBar bar(count,0 );
2484 int w = 300; 2492 int w = 300;
2485 if ( QApplication::desktop()->width() < 320 ) 2493 if ( QApplication::desktop()->width() < 320 )
2486 w = 220; 2494 w = 220;
2487 int h = bar.sizeHint().height() ; 2495 int h = bar.sizeHint().height() ;
2488 int dw = QApplication::desktop()->width(); 2496 int dw = QApplication::desktop()->width();
2489 int dh = QApplication::desktop()->height(); 2497 int dh = QApplication::desktop()->height();
2490 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2498 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2491 bar.show(); 2499 bar.show();
2492 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2500 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2493 qApp->processEvents(); 2501 qApp->processEvents();
2494 2502
2495 QDate bday; 2503 QDate bday;
2496 QString anni; 2504 QString anni;
2497 QString formattedbday; 2505 QString formattedbday;
2498 2506
2499 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2507 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2500 { 2508 {
2501 if ( ! bar.isVisible() ) 2509 if ( ! bar.isVisible() )
2502 return; 2510 return;
2503 bar.setProgress( count++ ); 2511 bar.setProgress( count++ );
2504 qApp->processEvents(); 2512 qApp->processEvents();
2505 bday = (*it).birthday().date(); 2513 bday = (*it).birthday().date();
2506 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2514 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2507 2515
2508 if ( bday.isValid() || !anni.isEmpty()) 2516 if ( bday.isValid() || !anni.isEmpty())
2509 { 2517 {
2510 if (bday.isValid()) 2518 if (bday.isValid())
2511 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2519 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2512 else 2520 else
2513 formattedbday = "NOTVALID"; 2521 formattedbday = "NOTVALID";
2514 if (anni.isEmpty()) 2522 if (anni.isEmpty())
2515 anni = "INVALID"; 2523 anni = "INVALID";
2516 2524
2517 birthdayList.append(formattedbday); 2525 birthdayList.append(formattedbday);
2518 anniversaryList.append(anni); //should be ISODate 2526 anniversaryList.append(anni); //should be ISODate
2519 realNameList.append((*it).realName()); 2527 realNameList.append((*it).realName());
2520 preferredEmailList.append((*it).preferredEmail()); 2528 preferredEmailList.append((*it).preferredEmail());
2521 assembledNameList.append((*it).assembledName()); 2529 assembledNameList.append((*it).assembledName());
2522 uidList.append((*it).uid()); 2530 uidList.append((*it).uid());
2523 2531
2524 //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() ); 2532 //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() );
2525 } 2533 }
2526 } 2534 }
2527 2535
2528 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2536 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2529 2537
2530} 2538}
2531 2539
2532/* this method will be called through the QCop interface from other apps to show details of a contact. 2540/* this method will be called through the QCop interface from other apps to show details of a contact.
2533 */ 2541 */
2534void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2542void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2535{ 2543{
2536 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2544 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2537 2545
2538 QString foundUid = QString::null; 2546 QString foundUid = QString::null;
2539 if ( ! uid.isEmpty() ) { 2547 if ( ! uid.isEmpty() ) {
2540 Addressee adrr = mAddressBook->findByUid( uid ); 2548 Addressee adrr = mAddressBook->findByUid( uid );
2541 if ( !adrr.isEmpty() ) { 2549 if ( !adrr.isEmpty() ) {
2542 foundUid = uid; 2550 foundUid = uid;
2543 } 2551 }
2544 if ( email == "sendbacklist" ) { 2552 if ( email == "sendbacklist" ) {
2545 //qDebug("ssssssssssssssssssssssend "); 2553 //qDebug("ssssssssssssssssssssssend ");
2546 QStringList nameList; 2554 QStringList nameList;
2547 QStringList emailList; 2555 QStringList emailList;
2548 QStringList uidList; 2556 QStringList uidList;
2549 nameList.append(adrr.realName()); 2557 nameList.append(adrr.realName());
2550 emailList = adrr.emails(); 2558 emailList = adrr.emails();
2551 uidList.append( adrr.preferredEmail()); 2559 uidList.append( adrr.preferredEmail());
2552 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2560 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2553 return; 2561 return;
2554 } 2562 }
2555 2563
2556 } 2564 }
2557 2565
2558 if ( email == "sendbacklist" ) 2566 if ( email == "sendbacklist" )
2559 return; 2567 return;
2560 if (foundUid.isEmpty()) 2568 if (foundUid.isEmpty())
2561 { 2569 {
2562 //find the uid of the person first 2570 //find the uid of the person first
2563 Addressee::List namelist; 2571 Addressee::List namelist;
2564 Addressee::List emaillist; 2572 Addressee::List emaillist;
2565 2573
2566 if (!name.isEmpty()) 2574 if (!name.isEmpty())
2567 namelist = mAddressBook->findByName( name ); 2575 namelist = mAddressBook->findByName( name );
2568 2576
2569 if (!email.isEmpty()) 2577 if (!email.isEmpty())
2570 emaillist = mAddressBook->findByEmail( email ); 2578 emaillist = mAddressBook->findByEmail( email );
2571 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2579 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2572 //check if we have a match in Namelist and Emaillist 2580 //check if we have a match in Namelist and Emaillist
2573 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2581 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2574 foundUid = emaillist[0].uid(); 2582 foundUid = emaillist[0].uid();
2575 } 2583 }
2576 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2584 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2577 foundUid = namelist[0].uid(); 2585 foundUid = namelist[0].uid();
2578 else 2586 else
2579 { 2587 {
2580 for (int i = 0; i < namelist.count(); i++) 2588 for (int i = 0; i < namelist.count(); i++)
2581 { 2589 {
2582 for (int j = 0; j < emaillist.count(); j++) 2590 for (int j = 0; j < emaillist.count(); j++)
2583 { 2591 {
2584 if (namelist[i] == emaillist[j]) 2592 if (namelist[i] == emaillist[j])
2585 { 2593 {
2586 foundUid = namelist[i].uid(); 2594 foundUid = namelist[i].uid();
2587 } 2595 }
2588 } 2596 }
2589 } 2597 }
2590 } 2598 }
2591 } 2599 }
2592 else 2600 else
2593 { 2601 {
2594 foundUid = uid; 2602 foundUid = uid;
2595 } 2603 }
2596 2604
2597 if (!foundUid.isEmpty()) 2605 if (!foundUid.isEmpty())
2598 { 2606 {
2599 2607
2600 // raise Ka/Pi if it is in the background 2608 // raise Ka/Pi if it is in the background
2601#ifndef DESKTOP_VERSION 2609#ifndef DESKTOP_VERSION
2602#ifndef KORG_NODCOP 2610#ifndef KORG_NODCOP
2603 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2611 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2604#endif 2612#endif
2605#endif 2613#endif
2606 2614
2607 mMainWindow->showMaximized(); 2615 mMainWindow->showMaximized();
2608 mMainWindow-> raise(); 2616 mMainWindow-> raise();
2609 2617
2610 mViewManager->setSelected( "", false); 2618 mViewManager->setSelected( "", false);
2611 mViewManager->refreshView( "" ); 2619 mViewManager->refreshView( "" );
2612 mViewManager->setSelected( foundUid, true ); 2620 mViewManager->setSelected( foundUid, true );
2613 mViewManager->refreshView( foundUid ); 2621 mViewManager->refreshView( foundUid );
2614 2622
2615 if ( !mMultipleViewsAtOnce ) 2623 if ( !mMultipleViewsAtOnce )
2616 { 2624 {
2617 setDetailsVisible( true ); 2625 setDetailsVisible( true );
2618 mActionDetails->setChecked(true); 2626 mActionDetails->setChecked(true);
2619 } 2627 }
2620 } 2628 }
2621} 2629}
2622 2630
2623void KABCore::whatsnew() 2631void KABCore::whatsnew()
2624{ 2632{
2625 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2633 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2626} 2634}
2627void KABCore::synchowto() 2635void KABCore::synchowto()
2628{ 2636{
2629 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2630} 2638}
2631void KABCore::kdesynchowto() 2639void KABCore::kdesynchowto()
2632{ 2640{
2633 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2641 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2634} 2642}
2635void KABCore::multisynchowto() 2643void KABCore::multisynchowto()
2636{ 2644{
2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2645 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2638} 2646}
2639void KABCore::faq() 2647void KABCore::faq()
2640{ 2648{
2641 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2649 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2642} 2650}
2643 2651
2644#include <libkcal/syncdefines.h> 2652#include <libkcal/syncdefines.h>
2645 2653
2646KABC::Addressee KABCore::getLastSyncAddressee() 2654KABC::Addressee KABCore::getLastSyncAddressee()
2647{ 2655{
2648 Addressee lse; 2656 Addressee lse;
2649 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2657 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2650 2658
2651 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2659 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2652 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2660 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2653 if (lse.isEmpty()) { 2661 if (lse.isEmpty()) {
2654 qDebug("Creating new last-syncAddressee "); 2662 qDebug("Creating new last-syncAddressee ");
2655 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2663 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2656 QString sum = ""; 2664 QString sum = "";
2657 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2665 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2658 sum = "E: "; 2666 sum = "E: ";
2659 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2667 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2660 lse.setRevision( mLastAddressbookSync ); 2668 lse.setRevision( mLastAddressbookSync );
2661 lse.setCategories( i18n("SyncEvent") ); 2669 lse.setCategories( i18n("SyncEvent") );
2662 mAddressBook->insertAddressee( lse ); 2670 mAddressBook->insertAddressee( lse );
2663 } 2671 }
2664 return lse; 2672 return lse;
2665} 2673}
2666int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2674int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2667{ 2675{
2668 2676
2669 //void setZaurusId(int id); 2677 //void setZaurusId(int id);
2670 // int zaurusId() const; 2678 // int zaurusId() const;
2671 // void setZaurusUid(int id); 2679 // void setZaurusUid(int id);
2672 // int zaurusUid() const; 2680 // int zaurusUid() const;
2673 // void setZaurusStat(int id); 2681 // void setZaurusStat(int id);
2674 // int zaurusStat() const; 2682 // int zaurusStat() const;
2675 // 0 equal 2683 // 0 equal
2676 // 1 take local 2684 // 1 take local
2677 // 2 take remote 2685 // 2 take remote
2678 // 3 cancel 2686 // 3 cancel
2679 QDateTime lastSync = mLastAddressbookSync; 2687 QDateTime lastSync = mLastAddressbookSync;
2680 QDateTime localMod = local->revision(); 2688 QDateTime localMod = local->revision();
2681 QDateTime remoteMod = remote->revision(); 2689 QDateTime remoteMod = remote->revision();
2682 2690
2683 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2691 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2684 2692
2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2693 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2686 bool remCh, locCh; 2694 bool remCh, locCh;
2687 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2695 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2688 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2696 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2689 locCh = ( localMod > mLastAddressbookSync ); 2697 locCh = ( localMod > mLastAddressbookSync );
2690 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2698 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2691 if ( !remCh && ! locCh ) { 2699 if ( !remCh && ! locCh ) {
2692 //qDebug("both not changed "); 2700 //qDebug("both not changed ");
2693 lastSync = localMod.addDays(1); 2701 lastSync = localMod.addDays(1);
2694 if ( mode <= SYNC_PREF_ASK ) 2702 if ( mode <= SYNC_PREF_ASK )
2695 return 0; 2703 return 0;
2696 } else { 2704 } else {
2697 if ( locCh ) { 2705 if ( locCh ) {
2698 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2706 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2699 lastSync = localMod.addDays( -1 ); 2707 lastSync = localMod.addDays( -1 );
2700 if ( !remCh ) 2708 if ( !remCh )
2701 remoteMod =( lastSync.addDays( -1 ) ); 2709 remoteMod =( lastSync.addDays( -1 ) );
2702 } else { 2710 } else {
2703 //qDebug(" not loc changed "); 2711 //qDebug(" not loc changed ");
2704 lastSync = localMod.addDays( 1 ); 2712 lastSync = localMod.addDays( 1 );
2705 if ( remCh ) { 2713 if ( remCh ) {
2706 //qDebug("rem changed "); 2714 //qDebug("rem changed ");
2707 remoteMod =( lastSync.addDays( 1 ) ); 2715 remoteMod =( lastSync.addDays( 1 ) );
2708 } 2716 }
2709 2717
2710 } 2718 }
2711 } 2719 }
2712 full = true; 2720 full = true;
2713 if ( mode < SYNC_PREF_ASK ) 2721 if ( mode < SYNC_PREF_ASK )
2714 mode = SYNC_PREF_ASK; 2722 mode = SYNC_PREF_ASK;
2715 } else { 2723 } else {
2716 if ( localMod == remoteMod ) 2724 if ( localMod == remoteMod )
2717 return 0; 2725 return 0;
2718 2726
2719 } 2727 }
2720 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2728 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2721 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2729 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2722 //full = true; //debug only 2730 //full = true; //debug only
2723 if ( full ) { 2731 if ( full ) {
2724 bool equ = ( (*local) == (*remote) ); 2732 bool equ = ( (*local) == (*remote) );
2725 if ( equ ) { 2733 if ( equ ) {
2726 //qDebug("equal "); 2734 //qDebug("equal ");
2727 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2735 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2728 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2736 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2729 } 2737 }
2730 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2738 if ( mode < SYNC_PREF_FORCE_LOCAL )
2731 return 0; 2739 return 0;
2732 2740
2733 }//else //debug only 2741 }//else //debug only
2734 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2742 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2735 } 2743 }
2736 int result; 2744 int result;
2737 bool localIsNew; 2745 bool localIsNew;
2738 //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() ); 2746 //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() );
2739 2747
2740 if ( full && mode < SYNC_PREF_NEWEST ) 2748 if ( full && mode < SYNC_PREF_NEWEST )
2741 mode = SYNC_PREF_ASK; 2749 mode = SYNC_PREF_ASK;
2742 2750
2743 switch( mode ) { 2751 switch( mode ) {
2744 case SYNC_PREF_LOCAL: 2752 case SYNC_PREF_LOCAL:
2745 if ( lastSync > remoteMod ) 2753 if ( lastSync > remoteMod )
2746 return 1; 2754 return 1;
2747 if ( lastSync > localMod ) 2755 if ( lastSync > localMod )
2748 return 2; 2756 return 2;
2749 return 1; 2757 return 1;
2750 break; 2758 break;
2751 case SYNC_PREF_REMOTE: 2759 case SYNC_PREF_REMOTE:
2752 if ( lastSync > remoteMod ) 2760 if ( lastSync > remoteMod )
2753 return 1; 2761 return 1;
2754 if ( lastSync > localMod ) 2762 if ( lastSync > localMod )
2755 return 2; 2763 return 2;
2756 return 2; 2764 return 2;
2757 break; 2765 break;
2758 case SYNC_PREF_NEWEST: 2766 case SYNC_PREF_NEWEST:
2759 if ( localMod > remoteMod ) 2767 if ( localMod > remoteMod )
2760 return 1; 2768 return 1;
2761 else 2769 else
2762 return 2; 2770 return 2;
2763 break; 2771 break;
2764 case SYNC_PREF_ASK: 2772 case SYNC_PREF_ASK:
2765 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2773 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2766 if ( lastSync > remoteMod ) 2774 if ( lastSync > remoteMod )
2767 return 1; 2775 return 1;
2768 if ( lastSync > localMod ) { 2776 if ( lastSync > localMod ) {
2769 return 2; 2777 return 2;
2770 } 2778 }
2771 localIsNew = localMod >= remoteMod; 2779 localIsNew = localMod >= remoteMod;
2772 //qDebug("conflict! ************************************** "); 2780 //qDebug("conflict! ************************************** ");
2773 { 2781 {
2774 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2782 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
@@ -2825,452 +2833,452 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2825 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2833 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2826 } else { 2834 } else {
2827 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2835 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2828 } 2836 }
2829 } 2837 }
2830 QDateTime modifiedCalendar = mLastAddressbookSync; 2838 QDateTime modifiedCalendar = mLastAddressbookSync;
2831 addresseeLSync = getLastSyncAddressee(); 2839 addresseeLSync = getLastSyncAddressee();
2832 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2840 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2833 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2841 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2834 if ( !addresseeR.isEmpty() ) { 2842 if ( !addresseeR.isEmpty() ) {
2835 addresseeRSync = addresseeR; 2843 addresseeRSync = addresseeR;
2836 remote->removeAddressee(addresseeR ); 2844 remote->removeAddressee(addresseeR );
2837 2845
2838 } else { 2846 } else {
2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2847 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2840 addresseeRSync = addresseeLSync ; 2848 addresseeRSync = addresseeLSync ;
2841 } else { 2849 } else {
2842 //qDebug("FULLDATE 1"); 2850 //qDebug("FULLDATE 1");
2843 fullDateRange = true; 2851 fullDateRange = true;
2844 Addressee newAdd; 2852 Addressee newAdd;
2845 addresseeRSync = newAdd; 2853 addresseeRSync = newAdd;
2846 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2854 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2847 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2855 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2848 addresseeRSync.setRevision( mLastAddressbookSync ); 2856 addresseeRSync.setRevision( mLastAddressbookSync );
2849 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2857 addresseeRSync.setCategories( i18n("SyncAddressee") );
2850 } 2858 }
2851 } 2859 }
2852 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2860 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2853 // qDebug("FULLDATE 2"); 2861 // qDebug("FULLDATE 2");
2854 fullDateRange = true; 2862 fullDateRange = true;
2855 } 2863 }
2856 if ( ! fullDateRange ) { 2864 if ( ! fullDateRange ) {
2857 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2865 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2858 2866
2859 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2867 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2860 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2868 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2861 fullDateRange = true; 2869 fullDateRange = true;
2862 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2870 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2863 } 2871 }
2864 } 2872 }
2865 // fullDateRange = true; // debug only! 2873 // fullDateRange = true; // debug only!
2866 if ( fullDateRange ) 2874 if ( fullDateRange )
2867 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2875 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2868 else 2876 else
2869 mLastAddressbookSync = addresseeLSync.revision(); 2877 mLastAddressbookSync = addresseeLSync.revision();
2870 // for resyncing if own file has changed 2878 // for resyncing if own file has changed
2871 // PENDING fixme later when implemented 2879 // PENDING fixme later when implemented
2872#if 0 2880#if 0
2873 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2881 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2874 mLastAddressbookSync = loadedFileVersion; 2882 mLastAddressbookSync = loadedFileVersion;
2875 qDebug("setting mLastAddressbookSync "); 2883 qDebug("setting mLastAddressbookSync ");
2876 } 2884 }
2877#endif 2885#endif
2878 2886
2879 2887
2880 // ********** setting filters **************** 2888 // ********** setting filters ****************
2881 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2889 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2882 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2890 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2883 2891
2884 //qDebug("*************************** "); 2892 //qDebug("*************************** ");
2885 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2893 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2886 QStringList er = remote->uidList(); 2894 QStringList er = remote->uidList();
2887 Addressee inR ;//= er.first(); 2895 Addressee inR ;//= er.first();
2888 Addressee inL; 2896 Addressee inL;
2889 2897
2890 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2898 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2891 2899
2892 int modulo = (er.count()/10)+1; 2900 int modulo = (er.count()/10)+1;
2893 int incCounter = 0; 2901 int incCounter = 0;
2894 while ( incCounter < er.count()) { 2902 while ( incCounter < er.count()) {
2895 if (syncManager->isProgressBarCanceled()) 2903 if (syncManager->isProgressBarCanceled())
2896 return false; 2904 return false;
2897 if ( incCounter % modulo == 0 ) 2905 if ( incCounter % modulo == 0 )
2898 syncManager->showProgressBar(incCounter); 2906 syncManager->showProgressBar(incCounter);
2899 2907
2900 uid = er[ incCounter ]; 2908 uid = er[ incCounter ];
2901 bool skipIncidence = false; 2909 bool skipIncidence = false;
2902 if ( uid.left(19) == QString("last-syncAddressee-") ) 2910 if ( uid.left(19) == QString("last-syncAddressee-") )
2903 skipIncidence = true; 2911 skipIncidence = true;
2904 QString idS,OidS; 2912 QString idS,OidS;
2905 qApp->processEvents(); 2913 qApp->processEvents();
2906 if ( !skipIncidence ) { 2914 if ( !skipIncidence ) {
2907 inL = local->findByUid( uid ); 2915 inL = local->findByUid( uid );
2908 inR = remote->findByUid( uid ); 2916 inR = remote->findByUid( uid );
2909 //inL.setResource( 0 ); 2917 //inL.setResource( 0 );
2910 //inR.setResource( 0 ); 2918 //inR.setResource( 0 );
2911 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2919 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2912 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2920 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2913 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2921 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2914 //qDebug("take %d %s ", take, inL.summary().latin1()); 2922 //qDebug("take %d %s ", take, inL.summary().latin1());
2915 if ( take == 3 ) 2923 if ( take == 3 )
2916 return false; 2924 return false;
2917 if ( take == 1 ) {// take local ********************** 2925 if ( take == 1 ) {// take local **********************
2918 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2926 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2919 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2927 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2920 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2928 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2921 local->insertAddressee( inL, false ); 2929 local->insertAddressee( inL, false );
2922 idS = inR.externalUID(); 2930 idS = inR.externalUID();
2923 OidS = inR.originalExternalUID(); 2931 OidS = inR.originalExternalUID();
2924 } 2932 }
2925 else 2933 else
2926 idS = inR.IDStr(); 2934 idS = inR.IDStr();
2927 remote->removeAddressee( inR ); 2935 remote->removeAddressee( inR );
2928 inR = inL; 2936 inR = inL;
2929 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2937 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2930 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2938 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2931 inR.setOriginalExternalUID( OidS ); 2939 inR.setOriginalExternalUID( OidS );
2932 inR.setExternalUID( idS ); 2940 inR.setExternalUID( idS );
2933 if ( syncManager->syncWithDesktop() ) { 2941 if ( syncManager->syncWithDesktop() ) {
2934 inR.setIDStr("changed" ); 2942 inR.setIDStr("changed" );
2935 } 2943 }
2936 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2944 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2937 } else { 2945 } else {
2938 inR.setIDStr( idS ); 2946 inR.setIDStr( idS );
2939 } 2947 }
2940 inR.setResource( 0 ); 2948 inR.setResource( 0 );
2941 remote->insertAddressee( inR , false); 2949 remote->insertAddressee( inR , false);
2942 ++changedRemote; 2950 ++changedRemote;
2943 } else { // take == 2 take remote ********************** 2951 } else { // take == 2 take remote **********************
2944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2945 if ( inR.revision().date().year() < 2004 ) 2953 if ( inR.revision().date().year() < 2004 )
2946 inR.setRevision( modifiedCalendar ); 2954 inR.setRevision( modifiedCalendar );
2947 } 2955 }
2948 idS = inL.IDStr(); 2956 idS = inL.IDStr();
2949 local->removeAddressee( inL ); 2957 local->removeAddressee( inL );
2950 inL = inR; 2958 inL = inR;
2951 inL.setIDStr( idS ); 2959 inL.setIDStr( idS );
2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2961 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2962 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2955 } 2963 }
2956 inL.setResource( 0 ); 2964 inL.setResource( 0 );
2957 local->insertAddressee( inL , false ); 2965 local->insertAddressee( inL , false );
2958 ++changedLocal; 2966 ++changedLocal;
2959 } 2967 }
2960 } 2968 }
2961 } 2969 }
2962 } else { // no conflict ********** add or delete remote 2970 } else { // no conflict ********** add or delete remote
2963 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2971 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2972 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2965 QString des = addresseeLSync.note(); 2973 QString des = addresseeLSync.note();
2966 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2974 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2967 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2975 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2968 remote->insertAddressee( inR, false ); 2976 remote->insertAddressee( inR, false );
2969 ++deletedAddresseeR; 2977 ++deletedAddresseeR;
2970 } else { 2978 } else {
2971 inR.setRevision( modifiedCalendar ); 2979 inR.setRevision( modifiedCalendar );
2972 remote->insertAddressee( inR, false ); 2980 remote->insertAddressee( inR, false );
2973 inL = inR; 2981 inL = inR;
2974 inL.setIDStr( ":" ); 2982 inL.setIDStr( ":" );
2975 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2983 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2976 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2984 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2977 inL.setResource( 0 ); 2985 inL.setResource( 0 );
2978 local->insertAddressee( inL , false); 2986 local->insertAddressee( inL , false);
2979 ++addedAddressee; 2987 ++addedAddressee;
2980 } 2988 }
2981 } else { 2989 } else {
2982 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2990 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2983 inR.setRevision( modifiedCalendar ); 2991 inR.setRevision( modifiedCalendar );
2984 remote->insertAddressee( inR, false ); 2992 remote->insertAddressee( inR, false );
2985 inR.setResource( 0 ); 2993 inR.setResource( 0 );
2986 local->insertAddressee( inR, false ); 2994 local->insertAddressee( inR, false );
2987 ++addedAddressee; 2995 ++addedAddressee;
2988 } else { 2996 } else {
2989 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2997 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2990 remote->removeAddressee( inR ); 2998 remote->removeAddressee( inR );
2991 ++deletedAddresseeR; 2999 ++deletedAddresseeR;
2992 } 3000 }
2993 } 3001 }
2994 } else { 3002 } else {
2995 ++filteredIN; 3003 ++filteredIN;
2996 } 3004 }
2997 } 3005 }
2998 } 3006 }
2999 ++incCounter; 3007 ++incCounter;
3000 } 3008 }
3001 er.clear(); 3009 er.clear();
3002 QStringList el = local->uidList(); 3010 QStringList el = local->uidList();
3003 modulo = (el.count()/10)+1; 3011 modulo = (el.count()/10)+1;
3004 3012
3005 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3013 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3006 incCounter = 0; 3014 incCounter = 0;
3007 while ( incCounter < el.count()) { 3015 while ( incCounter < el.count()) {
3008 qApp->processEvents(); 3016 qApp->processEvents();
3009 if (syncManager->isProgressBarCanceled()) 3017 if (syncManager->isProgressBarCanceled())
3010 return false; 3018 return false;
3011 if ( incCounter % modulo == 0 ) 3019 if ( incCounter % modulo == 0 )
3012 syncManager->showProgressBar(incCounter); 3020 syncManager->showProgressBar(incCounter);
3013 uid = el[ incCounter ]; 3021 uid = el[ incCounter ];
3014 bool skipIncidence = false; 3022 bool skipIncidence = false;
3015 if ( uid.left(19) == QString("last-syncAddressee-") ) 3023 if ( uid.left(19) == QString("last-syncAddressee-") )
3016 skipIncidence = true; 3024 skipIncidence = true;
3017 if ( !skipIncidence ) { 3025 if ( !skipIncidence ) {
3018 inL = local->findByUid( uid ); 3026 inL = local->findByUid( uid );
3019 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3027 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3020 inR = remote->findByUid( uid ); 3028 inR = remote->findByUid( uid );
3021 if ( inR.isEmpty() ){ 3029 if ( inR.isEmpty() ){
3022 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3030 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3023 // no conflict ********** add or delete local 3031 // no conflict ********** add or delete local
3024 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3032 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3025 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3033 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3026 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3034 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3027 local->removeAddressee( inL ); 3035 local->removeAddressee( inL );
3028 ++deletedAddresseeL; 3036 ++deletedAddresseeL;
3029 } else { 3037 } else {
3030 if ( ! syncManager->mWriteBackExistingOnly ) { 3038 if ( ! syncManager->mWriteBackExistingOnly ) {
3031 inL.removeID(mCurrentSyncDevice ); 3039 inL.removeID(mCurrentSyncDevice );
3032 ++addedAddresseeR; 3040 ++addedAddresseeR;
3033 inL.setRevision( modifiedCalendar ); 3041 inL.setRevision( modifiedCalendar );
3034 local->insertAddressee( inL, false ); 3042 local->insertAddressee( inL, false );
3035 inR = inL; 3043 inR = inL;
3036 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3044 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3037 inR.setResource( 0 ); 3045 inR.setResource( 0 );
3038 remote->insertAddressee( inR, false ); 3046 remote->insertAddressee( inR, false );
3039 } 3047 }
3040 } 3048 }
3041 } else { 3049 } else {
3042 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3050 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3043 //qDebug("data %s ", inL.revision().toString().latin1()); 3051 //qDebug("data %s ", inL.revision().toString().latin1());
3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3052 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3045 local->removeAddressee( inL ); 3053 local->removeAddressee( inL );
3046 ++deletedAddresseeL; 3054 ++deletedAddresseeL;
3047 } else { 3055 } else {
3048 if ( ! syncManager->mWriteBackExistingOnly ) { 3056 if ( ! syncManager->mWriteBackExistingOnly ) {
3049 ++addedAddresseeR; 3057 ++addedAddresseeR;
3050 inL.setRevision( modifiedCalendar ); 3058 inL.setRevision( modifiedCalendar );
3051 local->insertAddressee( inL, false ); 3059 local->insertAddressee( inL, false );
3052 inR = inL; 3060 inR = inL;
3053 inR.setIDStr( ":" ); 3061 inR.setIDStr( ":" );
3054 inR.setResource( 0 ); 3062 inR.setResource( 0 );
3055 remote->insertAddressee( inR, false ); 3063 remote->insertAddressee( inR, false );
3056 } 3064 }
3057 } 3065 }
3058 } 3066 }
3059 } else { 3067 } else {
3060 ++filteredOUT; 3068 ++filteredOUT;
3061 } 3069 }
3062 } 3070 }
3063 } 3071 }
3064 } 3072 }
3065 ++incCounter; 3073 ++incCounter;
3066 } 3074 }
3067 el.clear(); 3075 el.clear();
3068 syncManager->hideProgressBar(); 3076 syncManager->hideProgressBar();
3069 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3077 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3070 // get rid of micro seconds 3078 // get rid of micro seconds
3071 QTime t = mLastAddressbookSync.time(); 3079 QTime t = mLastAddressbookSync.time();
3072 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3080 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3073 addresseeLSync.setRevision( mLastAddressbookSync ); 3081 addresseeLSync.setRevision( mLastAddressbookSync );
3074 addresseeRSync.setRevision( mLastAddressbookSync ); 3082 addresseeRSync.setRevision( mLastAddressbookSync );
3075 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3083 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3076 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3084 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3077 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3085 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3078 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3086 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3079 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3087 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3080 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3088 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3081 addresseeRSync.setNote( "" ) ; 3089 addresseeRSync.setNote( "" ) ;
3082 addresseeLSync.setNote( "" ); 3090 addresseeLSync.setNote( "" );
3083 3091
3084 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3085 remote->insertAddressee( addresseeRSync, false ); 3093 remote->insertAddressee( addresseeRSync, false );
3086 local->insertAddressee( addresseeLSync, false ); 3094 local->insertAddressee( addresseeLSync, false );
3087 QString mes; 3095 QString mes;
3088 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3096 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3089 qDebug( mes ); 3097 qDebug( mes );
3090 mes = i18n("Local addressbook changed!\n") +mes; 3098 mes = i18n("Local addressbook changed!\n") +mes;
3091 if ( syncManager->mShowSyncSummary ) { 3099 if ( syncManager->mShowSyncSummary ) {
3092 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3100 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3093 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3101 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3094 qDebug("cancelled "); 3102 qDebug("cancelled ");
3095 return false; 3103 return false;
3096 } 3104 }
3097 } 3105 }
3098 return syncOK; 3106 return syncOK;
3099} 3107}
3100 3108
3101 3109
3102//this is a overwritten callbackmethods from the syncinterface 3110//this is a overwritten callbackmethods from the syncinterface
3103bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3111bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3104{ 3112{
3105 3113
3106 //pending prepare addresseeview for output 3114 //pending prepare addresseeview for output
3107 //pending detect, if remote file has REV field. if not switch to external sync 3115 //pending detect, if remote file has REV field. if not switch to external sync
3108 mGlobalSyncMode = SYNC_MODE_NORMAL; 3116 mGlobalSyncMode = SYNC_MODE_NORMAL;
3109 if ( manager != syncManager ) 3117 if ( manager != syncManager )
3110 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3118 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3111 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3119 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3112 3120
3113 AddressBook abLocal(filename,"syncContact"); 3121 AddressBook abLocal(filename,"syncContact");
3114 bool syncOK = false; 3122 bool syncOK = false;
3115 if ( abLocal.load() ) { 3123 if ( abLocal.load() ) {
3116 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3124 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3117 bool external = false; 3125 bool external = false;
3118 bool isXML = false; 3126 bool isXML = false;
3119 if ( filename.right(4) == ".xml") { 3127 if ( filename.right(4) == ".xml") {
3120 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3128 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3121 isXML = true; 3129 isXML = true;
3122 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3130 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3123 } else { 3131 } else {
3124 external = !manager->mIsKapiFile; 3132 external = !manager->mIsKapiFile;
3125 if ( external ) { 3133 if ( external ) {
3126 qDebug("Setting vcf mode to external "); 3134 qDebug("Setting vcf mode to external ");
3127 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3135 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3128 AddressBook::Iterator it; 3136 AddressBook::Iterator it;
3129 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3137 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3130 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3138 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3131 (*it).computeCsum( mCurrentSyncDevice ); 3139 (*it).computeCsum( mCurrentSyncDevice );
3132 } 3140 }
3133 } 3141 }
3134 } 3142 }
3135 //AddressBook::Iterator it; 3143 //AddressBook::Iterator it;
3136 //QStringList vcards; 3144 //QStringList vcards;
3137 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3145 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3138 // qDebug("Name %s ", (*it).familyName().latin1()); 3146 // qDebug("Name %s ", (*it).familyName().latin1());
3139 //} 3147 //}
3140 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3148 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3141 if ( syncOK ) { 3149 if ( syncOK ) {
3142 if ( syncManager->mWriteBackFile ) 3150 if ( syncManager->mWriteBackFile )
3143 { 3151 {
3144 if ( external ) 3152 if ( external )
3145 abLocal.removeSyncAddressees( !isXML); 3153 abLocal.removeSyncAddressees( !isXML);
3146 qDebug("Saving remote AB "); 3154 qDebug("Saving remote AB ");
3147 if ( ! abLocal.saveAB()) 3155 if ( ! abLocal.saveAB())
3148 qDebug("Error writing back AB to file "); 3156 qDebug("Error writing back AB to file ");
3149 if ( external ) { 3157 if ( external ) {
3150 // afterwrite processing 3158 // afterwrite processing
3151 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3159 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3152 } 3160 }
3153 } 3161 }
3154 } 3162 }
3155 setModified(); 3163 setModified();
3156 3164
3157 } 3165 }
3158 abLocal.removeResources(); 3166 abLocal.removeResources();
3159 if ( syncOK ) 3167 if ( syncOK )
3160 mViewManager->refreshView(); 3168 mViewManager->refreshView();
3161 return syncOK; 3169 return syncOK;
3162 3170
3163} 3171}
3164void KABCore::removeSyncInfo( QString syncProfile) 3172void KABCore::removeSyncInfo( QString syncProfile)
3165{ 3173{
3166 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3174 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3167 mAddressBook->removeSyncInfo( syncProfile ); 3175 mAddressBook->removeSyncInfo( syncProfile );
3168 setModified(); 3176 setModified();
3169} 3177}
3170 3178
3171 3179
3172//this is a overwritten callbackmethods from the syncinterface 3180//this is a overwritten callbackmethods from the syncinterface
3173bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3181bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3174{ 3182{
3175 if ( resource == "phone" ) 3183 if ( resource == "phone" )
3176 return syncPhone(); 3184 return syncPhone();
3177 disableBR( true ); 3185 disableBR( true );
3178 if ( manager != syncManager ) 3186 if ( manager != syncManager )
3179 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3187 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3180 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3188 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3181 3189
3182 AddressBook abLocal( resource,"syncContact"); 3190 AddressBook abLocal( resource,"syncContact");
3183 bool syncOK = false; 3191 bool syncOK = false;
3184 if ( abLocal.load() ) { 3192 if ( abLocal.load() ) {
3185 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3193 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3186 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3194 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3187 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3195 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3196 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3189 if ( syncOK ) { 3197 if ( syncOK ) {
3190 if ( syncManager->mWriteBackFile ) { 3198 if ( syncManager->mWriteBackFile ) {
3191 abLocal.removeSyncAddressees( false ); 3199 abLocal.removeSyncAddressees( false );
3192 abLocal.saveAB(); 3200 abLocal.saveAB();
3193 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3201 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3194 } 3202 }
3195 } else 3203 } else
3196 message( i18n("Sync cancelled or failed.") ); 3204 message( i18n("Sync cancelled or failed.") );
3197 setModified(); 3205 setModified();
3198 } 3206 }
3199 abLocal.removeResources(); 3207 abLocal.removeResources();
3200 if ( syncOK ) 3208 if ( syncOK )
3201 mViewManager->refreshView(); 3209 mViewManager->refreshView();
3202 disableBR( false ); 3210 disableBR( false );
3203 return syncOK; 3211 return syncOK;
3204 3212
3205} 3213}
3206void KABCore::message( QString m ) 3214void KABCore::message( QString m )
3207{ 3215{
3208 topLevelWidget()->setCaption( m ); 3216 topLevelWidget()->setCaption( m );
3209 mMessageTimer->start( 15000, true ); 3217 mMessageTimer->start( 20000, true );
3210} 3218}
3211bool KABCore::syncPhone() 3219bool KABCore::syncPhone()
3212{ 3220{
3213 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3221 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3214 QString fileName = getPhoneFile(); 3222 QString fileName = getPhoneFile();
3215 if ( !PhoneAccess::readFromPhone( fileName) ) { 3223 if ( !PhoneAccess::readFromPhone( fileName) ) {
3216 message(i18n("Phone access failed!")); 3224 message(i18n("Phone access failed!"));
3217 return false; 3225 return false;
3218 } 3226 }
3219 AddressBook abLocal( fileName,"syncContact"); 3227 AddressBook abLocal( fileName,"syncContact");
3220 bool syncOK = false; 3228 bool syncOK = false;
3221 { 3229 {
3222 abLocal.importFromFile( fileName ); 3230 abLocal.importFromFile( fileName );
3223 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3231 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3224 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3232 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3225 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3233 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3226 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3234 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3227 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3235 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3228 if ( syncOK ) { 3236 if ( syncOK ) {
3229 if ( syncManager->mWriteBackFile ) { 3237 if ( syncManager->mWriteBackFile ) {
3230 abLocal.removeSyncAddressees( true ); 3238 abLocal.removeSyncAddressees( true );
3231 abLocal.saveABphone( fileName ); 3239 abLocal.saveABphone( fileName );
3232 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3240 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3233 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3241 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3234 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3242 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3235 } 3243 }
3236 } 3244 }
3237 setModified(); 3245 setModified();
3238 } 3246 }
3239 abLocal.removeResources(); 3247 abLocal.removeResources();
3240 if ( syncOK ) 3248 if ( syncOK )
3241 mViewManager->refreshView(); 3249 mViewManager->refreshView();
3242 return syncOK; 3250 return syncOK;
3243} 3251}
3244void KABCore::getFile( bool success ) 3252void KABCore::getFile( bool success )
3245{ 3253{
3246 if ( ! success ) { 3254 if ( ! success ) {
3247 message( i18n("Error receiving file. Nothing changed!") ); 3255 message( i18n("Error receiving file. Nothing changed!") );
3248 return; 3256 return;
3249 } 3257 }
3250 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3258 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3251 if ( count ) 3259 if ( count )
3252 setModified( true ); 3260 setModified( true );
3253 message( i18n("Pi-Sync successful!") ); 3261 message( i18n("Pi-Sync successful!") );
3254 mViewManager->refreshView(); 3262 mViewManager->refreshView();
3255} 3263}
3256void KABCore::syncFileRequest() 3264void KABCore::syncFileRequest()
3257{ 3265{
3258 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3266 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3259 syncManager->slotSyncMenu( 999 ); 3267 syncManager->slotSyncMenu( 999 );
3260 } 3268 }
3261 mAddressBook->export2File( sentSyncFile() ); 3269 mAddressBook->export2File( sentSyncFile() );
3262} 3270}
3263QString KABCore::sentSyncFile() 3271QString KABCore::sentSyncFile()
3264{ 3272{
3265#ifdef DESKTOP_VERSION 3273#ifdef DESKTOP_VERSION
3266 return locateLocal( "tmp", "copysyncab.vcf" ); 3274 return locateLocal( "tmp", "copysyncab.vcf" );
3267#else 3275#else
3268 return QString( "/tmp/copysyncab.vcf" ); 3276 return QString( "/tmp/copysyncab.vcf" );
3269#endif 3277#endif
3270} 3278}
3271 3279
3272void KABCore::setCaptionBack() 3280void KABCore::setCaptionBack()
3273{ 3281{
3274 mMessageTimer->stop(); 3282 mMessageTimer->stop();
3275 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3283 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3276} 3284}
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index 6282453..e7bc8c0 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -1,294 +1,334 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qbuttongroup.h> 39#include <qbuttongroup.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qheader.h> 41#include <qheader.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qlistview.h> 44#include <qlistview.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qradiobutton.h> 46#include <qradiobutton.h>
47#include <qstringlist.h> 47#include <qstringlist.h>
48#include <qwhatsthis.h> 48#include <qwhatsthis.h>
49 49
50#include "kabcore.h" 50#include "kabcore.h"
51#include "kabprefs.h" 51#include "kabprefs.h"
52 52
53#include "xxportselectdialog.h" 53#include "xxportselectdialog.h"
54 54
55XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 55XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
56 QWidget* parent, const char* name ) 56 QWidget* parent, const char* name )
57 : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel, 57 : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel,
58 Ok, parent, name, true, true ), mCore( core ), 58 Ok, parent, name, true, true ), mCore( core ),
59 mUseSorting( sort ) 59 mUseSorting( sort )
60{ 60{
61 initGUI(); 61 initGUI();
62 62
63 connect( mFiltersCombo, SIGNAL( activated( int ) ), 63 connect( mFiltersCombo, SIGNAL( activated( int ) ),
64 SLOT( filterChanged( int ) ) ); 64 SLOT( filterChanged( int ) ) );
65 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 65 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ),
66 SLOT( categoryClicked( QListViewItem* ) ) ); 66 SLOT( categoryClicked( QListViewItem* ) ) );
67 67
68 // setup filters 68 // setup filters
69#ifndef KAB_EMBEDDED 69#ifndef KAB_EMBEDDED
70 mFilters = Filter::restore( kapp->config(), "Filter" ); 70 mFilters = Filter::restore( kapp->config(), "Filter" );
71 Filter::List::iterator filterIt; 71 Filter::List::iterator filterIt;
72#else //KAB_EMBEDDED 72#else //KAB_EMBEDDED
73 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 73 mFilters = Filter::restore( KGlobal::config(), "Filter" );
74 Filter::List::Iterator filterIt; 74 Filter::List::Iterator filterIt;
75#endif //KAB_EMBEDDED 75#endif //KAB_EMBEDDED
76 QStringList filters; 76 QStringList filters;
77 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 77 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
78 filters.append( (*filterIt).name() ); 78 filters.append( (*filterIt).name() );
79 79
80 mFiltersCombo->insertStringList( filters ); 80 mFiltersCombo->insertStringList( filters );
81 mUseFilters->setEnabled( filters.count() > 0 ); 81 mUseFilters->setEnabled( filters.count() > 0 );
82 82
83 // setup categories 83 // setup categories
84 QStringList categories = KABPrefs::instance()->mCustomCategories; 84 QStringList categories = KABPrefs::instance()->mCustomCategories;
85 QStringList::Iterator it; 85 QStringList::Iterator it;
86 for ( it = categories.begin(); it != categories.end(); ++it ) 86 for ( it = categories.begin(); it != categories.end(); ++it )
87 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 87 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox );
88 mUseCategories->setEnabled( categories.count() > 0 ); 88 mUseCategories->setEnabled( categories.count() > 0 );
89 89
90 int count = mCore->selectedUIDs().count(); 90 int count = mCore->selectedUIDs().count();
91 mUseSelection->setEnabled( count != 0 ); 91 mUseSelection->setEnabled( count != 0 );
92 mUseSelection->setChecked( count > 1 ); 92 mUseSelection->setChecked( count > 1 );
93 93
94 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 94 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
95 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 95 mSortTypeCombo->insertItem( i18n( "Descending" ) );
96 96
97 mFields = mCore->addressBook()->fields( KABC::Field::All ); 97 mFields = mCore->addressBook()->fields( KABC::Field::All );
98 KABC::Field::List::Iterator fieldIt; 98 KABC::Field::List::Iterator fieldIt;
99 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 99 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
100 mFieldCombo->insertItem( (*fieldIt)->label() ); 100 mFieldCombo->insertItem( (*fieldIt)->label() );
101} 101}
102 102
103QStringList XXPortSelectDialog::uids() 103QStringList XXPortSelectDialog::uids()
104{ 104{
105 QStringList uidlist; 105 QStringList uidlist;
106 KABC::AddresseeList list = contacts(); 106 KABC::AddresseeList list = contacts();
107 KABC::Addressee::List::Iterator it; 107 KABC::Addressee::List::Iterator it;
108 for ( it = list.begin(); it != list.end(); ++it ) 108 for ( it = list.begin(); it != list.end(); ++it )
109 uidlist.append((*it).uid()); 109 uidlist.append((*it).uid());
110 return uidlist; 110 return uidlist;
111} 111}
112void XXPortSelectDialog::tagSelected()
113{
114 if ( mUseSelection->isChecked() ) {
115
116 QStringList selection = mCore->selectedUIDs();
117 KABC::AddressBook::Iterator it;
118 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
119 if ( selection.findIndex((*it).uid()) >= 0 )
120 (*it).setTagged( true );
121 }
122 } else if ( mUseFilters->isChecked() ) {
123 // find contacts that can pass selected filter
124 Filter::List::Iterator filterIt;
125 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
126 if ( (*filterIt).name() == mFiltersCombo->currentText() )
127 break;
128 KABC::AddressBook::Iterator it;
129 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
130 if ( (*filterIt).filterAddressee( *it ) )
131 (*it).setTagged( true );
132 }
133 } else if ( mUseCategories->isChecked() ) {
134 QStringList categorieList = categories();
135 KABC::AddressBook::Iterator it;
136 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
137 QStringList tmp( (*it).categories() );
138 QStringList::Iterator tmpIt;
139 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
140 if ( categorieList.contains( *tmpIt ) ) {
141 (*it).setTagged( true );
142 break;
143 }
144 }
145 } else {
146 // create a string list of all entries:
147 KABC::AddressBook::Iterator it;
148 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
149 (*it).setTagged( true );
150 }
151}
112KABC::AddresseeList XXPortSelectDialog::contacts() 152KABC::AddresseeList XXPortSelectDialog::contacts()
113{ 153{
114 QStringList selection = mCore->selectedUIDs();
115 154
116 KABC::AddresseeList list; 155 KABC::AddresseeList list;
117 if ( mUseSelection->isChecked() ) { 156 if ( mUseSelection->isChecked() ) {
118 QStringList::Iterator it; 157 QStringList::Iterator it;
158 QStringList selection = mCore->selectedUIDs();
119 for ( it = selection.begin(); it != selection.end(); ++it ) { 159 for ( it = selection.begin(); it != selection.end(); ++it ) {
120 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 160 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
121 if ( !addr.isEmpty() ) 161 if ( !addr.isEmpty() )
122 list.append( addr ); 162 list.append( addr );
123 } 163 }
124 } else if ( mUseFilters->isChecked() ) { 164 } else if ( mUseFilters->isChecked() ) {
125 // find contacts that can pass selected filter 165 // find contacts that can pass selected filter
126 Filter::List::Iterator filterIt; 166 Filter::List::Iterator filterIt;
127 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 167 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
128 if ( (*filterIt).name() == mFiltersCombo->currentText() ) 168 if ( (*filterIt).name() == mFiltersCombo->currentText() )
129 break; 169 break;
130 170
131 KABC::AddressBook::Iterator it; 171 KABC::AddressBook::Iterator it;
132 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 172 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
133 if ( (*filterIt).filterAddressee( *it ) ) 173 if ( (*filterIt).filterAddressee( *it ) )
134 list.append( *it ); 174 list.append( *it );
135 } 175 }
136 } else if ( mUseCategories->isChecked() ) { 176 } else if ( mUseCategories->isChecked() ) {
137 QStringList categorieList = categories(); 177 QStringList categorieList = categories();
138 KABC::AddressBook::Iterator it; 178 KABC::AddressBook::Iterator it;
139 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 179 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
140 QStringList tmp( (*it).categories() ); 180 QStringList tmp( (*it).categories() );
141 QStringList::Iterator tmpIt; 181 QStringList::Iterator tmpIt;
142 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) 182 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
143 if ( categorieList.contains( *tmpIt ) ) { 183 if ( categorieList.contains( *tmpIt ) ) {
144 list.append( *it ); 184 list.append( *it );
145 break; 185 break;
146 } 186 }
147 } 187 }
148 } else { 188 } else {
149 // create a string list of all entries: 189 // create a string list of all entries:
150 KABC::AddressBook::Iterator it; 190 KABC::AddressBook::Iterator it;
151 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 191 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
152 list.append( *it ); 192 list.append( *it );
153 } 193 }
154 194
155 if ( mUseSorting ) { 195 if ( mUseSorting ) {
156 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); 196 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 );
157 uint pos = mFieldCombo->currentItem(); 197 uint pos = mFieldCombo->currentItem();
158 if ( pos < mFields.count() ) 198 if ( pos < mFields.count() )
159 list.sortByField( mFields[ pos ] ); 199 list.sortByField( mFields[ pos ] );
160 } 200 }
161 201
162 return list; 202 return list;
163} 203}
164 204
165QStringList XXPortSelectDialog::categories() const 205QStringList XXPortSelectDialog::categories() const
166{ 206{
167 QStringList list; 207 QStringList list;
168 208
169 QListViewItemIterator it( mCategoriesView ); 209 QListViewItemIterator it( mCategoriesView );
170 for ( ; it.current(); ++it ) { 210 for ( ; it.current(); ++it ) {
171 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 211 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current());
172 if ( qcli->isOn() ) 212 if ( qcli->isOn() )
173 list.append( it.current()->text( 0 ) ); 213 list.append( it.current()->text( 0 ) );
174 } 214 }
175 215
176 return list; 216 return list;
177} 217}
178 218
179void XXPortSelectDialog::filterChanged( int ) 219void XXPortSelectDialog::filterChanged( int )
180{ 220{
181 mUseFilters->setChecked( true ); 221 mUseFilters->setChecked( true );
182} 222}
183 223
184void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 224void XXPortSelectDialog::categoryClicked( QListViewItem *i )
185{ 225{
186 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 226 QCheckListItem *qcli = static_cast<QCheckListItem*>( i );
187 if ( qcli->isOn() ) 227 if ( qcli->isOn() )
188 mUseCategories->setChecked( true ); 228 mUseCategories->setChecked( true );
189} 229}
190 230
191void XXPortSelectDialog::slotHelp() 231void XXPortSelectDialog::slotHelp()
192{ 232{
193#ifndef KAB_EMBEDDED 233#ifndef KAB_EMBEDDED
194 kapp->invokeHelp( "import-and-export" ); 234 kapp->invokeHelp( "import-and-export" );
195#else //KAB_EMBEDDED 235#else //KAB_EMBEDDED
196 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 236 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
197#endif //KAB_EMBEDDED 237#endif //KAB_EMBEDDED
198 238
199} 239}
200 240
201void XXPortSelectDialog::initGUI() 241void XXPortSelectDialog::initGUI()
202{ 242{
203 QFrame *page = plainPage(); 243 QFrame *page = plainPage();
204 244
205 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), 245 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(),
206 KDialog::spacingHint() ); 246 KDialog::spacingHint() );
207 247
208 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page ); 248 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page );
209 topLayout->addWidget( label ); 249 topLayout->addWidget( label );
210 250
211 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); 251 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page );
212 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 252 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
213 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 253 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
214 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 254 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
215 255
216 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 256 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() );
217 groupLayout->setAlignment( Qt::AlignTop ); 257 groupLayout->setAlignment( Qt::AlignTop );
218 258
219 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); 259 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
220 mUseWholeBook->setChecked( true ); 260 mUseWholeBook->setChecked( true );
221 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) ); 261 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) );
222 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 262 groupLayout->addWidget( mUseWholeBook, 0, 0 );
223 263
224 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); 264 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
225 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" 265 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n"
226 "This option is disabled if no contacts are selected." ) ); 266 "This option is disabled if no contacts are selected." ) );
227 groupLayout->addWidget( mUseSelection, 1, 0 ); 267 groupLayout->addWidget( mUseSelection, 1, 0 );
228 268
229 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); 269 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
230 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" 270 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n"
231 "This option is disabled if you haven't defined any filters" ) ); 271 "This option is disabled if you haven't defined any filters" ) );
232 groupLayout->addWidget( mUseFilters, 2, 0 ); 272 groupLayout->addWidget( mUseFilters, 2, 0 );
233 273
234 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); 274 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
235 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" 275 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n"
236 "This option is disabled if you have no categories." ) ); 276 "This option is disabled if you have no categories." ) );
237 groupLayout->addWidget( mUseCategories, 3, 0 ); 277 groupLayout->addWidget( mUseCategories, 3, 0 );
238 278
239 mFiltersCombo = new QComboBox( false, mButtonGroup ); 279 mFiltersCombo = new QComboBox( false, mButtonGroup );
240 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); 280 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) );
241 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 281 groupLayout->addWidget( mFiltersCombo, 2, 1 );
242 282
243 mCategoriesView = new QListView( mButtonGroup ); 283 mCategoriesView = new QListView( mButtonGroup );
244 mCategoriesView->addColumn( "" ); 284 mCategoriesView->addColumn( "" );
245 mCategoriesView->header()->hide(); 285 mCategoriesView->header()->hide();
246 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); 286 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) );
247 groupLayout->addWidget( mCategoriesView, 3, 1 ); 287 groupLayout->addWidget( mCategoriesView, 3, 1 );
248 288
249 // if (QApplication::desktop()->height() == 480 ) 289 if (QApplication::desktop()->height() == 480 )
250 // mCategoriesView->setMaximumHeight( 240 ); 290 mCategoriesView->setMaximumHeight( 240 );
251 topLayout->addWidget( mButtonGroup ); 291 topLayout->addWidget( mButtonGroup );
252 292
253 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 293 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page );
254 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 294 sortingGroup->setColumnLayout( 0, Qt::Vertical );
255 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 295 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2,
256 KDialog::spacingHint() ); 296 KDialog::spacingHint() );
257 sortLayout->setAlignment( Qt::AlignTop ); 297 sortLayout->setAlignment( Qt::AlignTop );
258 298
259 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 299 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
260 sortLayout->addWidget( label, 0, 0 ); 300 sortLayout->addWidget( label, 0, 0 );
261 301
262#ifndef KAB_EMBEDDED 302#ifndef KAB_EMBEDDED
263 mFieldCombo = new KComboBox( false, sortingGroup ); 303 mFieldCombo = new KComboBox( false, sortingGroup );
264#else //KAB_EMBEDDED 304#else //KAB_EMBEDDED
265 //US Combobox is not editable anyway 305 //US Combobox is not editable anyway
266 mFieldCombo = new KComboBox( sortingGroup ); 306 mFieldCombo = new KComboBox( sortingGroup );
267#endif //KAB_EMBEDDED 307#endif //KAB_EMBEDDED
268 sortLayout->addWidget( mFieldCombo, 0, 1 ); 308 sortLayout->addWidget( mFieldCombo, 0, 1 );
269 309
270 label = new QLabel( i18n( "Order:" ), sortingGroup ); 310 label = new QLabel( i18n( "Order:" ), sortingGroup );
271 sortLayout->addWidget( label, 1, 0 ); 311 sortLayout->addWidget( label, 1, 0 );
272 312
273#ifndef KAB_EMBEDDED 313#ifndef KAB_EMBEDDED
274 mSortTypeCombo = new KComboBox( false, sortingGroup ); 314 mSortTypeCombo = new KComboBox( false, sortingGroup );
275#else //KAB_EMBEDDED 315#else //KAB_EMBEDDED
276 //US Combobox is not editable anyway 316 //US Combobox is not editable anyway
277 mSortTypeCombo = new KComboBox( sortingGroup ); 317 mSortTypeCombo = new KComboBox( sortingGroup );
278#endif //KAB_EMBEDDED 318#endif //KAB_EMBEDDED
279 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 319 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
280 320
281 topLayout->addWidget( sortingGroup ); 321 topLayout->addWidget( sortingGroup );
282 322
283 if ( !mUseSorting ) 323 if ( !mUseSorting )
284 sortingGroup->hide(); 324 sortingGroup->hide();
285#ifndef DESKTOP_VERSION 325#ifndef DESKTOP_VERSION
286 hideButtons(); 326 hideButtons();
287#endif 327#endif
288} 328}
289 329
290#ifndef KAB_EMBEDDED 330#ifndef KAB_EMBEDDED
291#include "xxportselectdialog.moc" 331#include "xxportselectdialog.moc"
292#endif //KAB_EMBEDDED 332#endif //KAB_EMBEDDED
293 333
294 334
diff --git a/kaddressbook/xxportselectdialog.h b/kaddressbook/xxportselectdialog.h
index 3bb696f..28b1fef 100644
--- a/kaddressbook/xxportselectdialog.h
+++ b/kaddressbook/xxportselectdialog.h
@@ -1,82 +1,83 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef XXPORTSELECTDIALOG_H 24#ifndef XXPORTSELECTDIALOG_H
25#define XXPORTSELECTDIALOG_H 25#define XXPORTSELECTDIALOG_H
26 26
27#include <kabc/addresseelist.h> 27#include <kabc/addresseelist.h>
28#include <kabc/field.h> 28#include <kabc/field.h>
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30 30
31#include "filter.h" 31#include "filter.h"
32 32
33class QButtonGroup; 33class QButtonGroup;
34class QComboBox; 34class QComboBox;
35class QListView; 35class QListView;
36class QListViewItem; 36class QListViewItem;
37class QRadioButton; 37class QRadioButton;
38 38
39class KABCore; 39class KABCore;
40class KComboBox; 40class KComboBox;
41 41
42class XXPortSelectDialog : public KDialogBase 42class XXPortSelectDialog : public KDialogBase
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, 47 XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent,
48 const char* name = 0 ); 48 const char* name = 0 );
49 49
50 KABC::AddresseeList contacts(); 50 KABC::AddresseeList contacts();
51 void tagSelected();
51 QStringList uids(); 52 QStringList uids();
52 53
53 private slots: 54 private slots:
54 void filterChanged( int ); 55 void filterChanged( int );
55 void categoryClicked( QListViewItem * i ); 56 void categoryClicked( QListViewItem * i );
56 57
57 protected slots: 58 protected slots:
58 void slotHelp(); 59 void slotHelp();
59 60
60 private: 61 private:
61 void initGUI(); 62 void initGUI();
62 QStringList categories() const; 63 QStringList categories() const;
63 64
64 QButtonGroup* mButtonGroup; 65 QButtonGroup* mButtonGroup;
65 QRadioButton* mUseCategories; 66 QRadioButton* mUseCategories;
66 QRadioButton* mUseFilters; 67 QRadioButton* mUseFilters;
67 QRadioButton* mUseWholeBook; 68 QRadioButton* mUseWholeBook;
68 QRadioButton* mUseSelection; 69 QRadioButton* mUseSelection;
69 QComboBox* mFiltersCombo; 70 QComboBox* mFiltersCombo;
70 QListView* mCategoriesView; 71 QListView* mCategoriesView;
71 72
72 KComboBox *mFieldCombo; 73 KComboBox *mFieldCombo;
73 KComboBox *mSortTypeCombo; 74 KComboBox *mSortTypeCombo;
74 75
75 KABCore *mCore; 76 KABCore *mCore;
76 KABC::AddresseeList mAddresseeList; 77 KABC::AddresseeList mAddresseeList;
77 Filter::List mFilters; 78 Filter::List mFilters;
78 KABC::Field::List mFields; 79 KABC::Field::List mFields;
79 bool mUseSorting; 80 bool mUseSorting;
80}; 81};
81 82
82#endif 83#endif