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