summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-27 21:34:55 (UTC)
committer zautrix <zautrix>2004-10-27 21:34:55 (UTC)
commit9c88346fc757fd1dc54b3fca151a2a610159d8cf (patch) (unidiff)
tree4a5de97ba71ce66eea914d55923d88aff3515c93
parent7f3cc07fab5f5f6ddd402c458341f1df3a144e2c (diff)
downloadkdepimpi-9c88346fc757fd1dc54b3fca151a2a610159d8cf.zip
kdepimpi-9c88346fc757fd1dc54b3fca151a2a610159d8cf.tar.gz
kdepimpi-9c88346fc757fd1dc54b3fca151a2a610159d8cf.tar.bz2
several fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp87
-rw-r--r--kaddressbook/kabprefs.cpp5
-rw-r--r--kaddressbook/kabprefs.h1
-rw-r--r--kaddressbook/kaddressbookview.h1
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp7
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h2
-rw-r--r--kaddressbook/viewmanager.cpp6
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp5
-rw-r--r--kaddressbook/views/kaddressbookcardview.h1
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp6
-rw-r--r--kaddressbook/views/kaddressbookiconview.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
-rw-r--r--kaddressbook/views/kaddressbooktableview.h1
-rw-r--r--kmicromail/editaccounts.cpp8
14 files changed, 84 insertions, 53 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index b0cb986..4964a6c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2937 +1,2938 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207 207
208bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
209 209
210#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
215#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
219 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
220#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
221{ 221{
222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
223 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
224 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
225 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 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&))); 295 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&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 310
311 mMessageTimer = new QTimer( this ); 311 mMessageTimer = new QTimer( this );
312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
313 mEditorDialog = 0; 313 mEditorDialog = 0;
314 createAddresseeEditorDialog( this ); 314 createAddresseeEditorDialog( this );
315 setModified( false ); 315 setModified( false );
316 mBRdisabled = false; 316 mBRdisabled = false;
317#ifndef DESKTOP_VERSION 317#ifndef DESKTOP_VERSION
318 infrared = 0; 318 infrared = 0;
319#endif 319#endif
320 //toggleBeamReceive( ); 320 //toggleBeamReceive( );
321} 321}
322 322
323KABCore::~KABCore() 323KABCore::~KABCore()
324{ 324{
325 // save(); 325 // save();
326 //saveSettings(); 326 //saveSettings();
327 //KABPrefs::instance()->writeConfig(); 327 //KABPrefs::instance()->writeConfig();
328 delete AddresseeConfig::instance(); 328 delete AddresseeConfig::instance();
329 mAddressBook = 0; 329 mAddressBook = 0;
330 KABC::StdAddressBook::close(); 330 KABC::StdAddressBook::close();
331 331
332 delete syncManager; 332 delete syncManager;
333#ifndef DESKTOP_VERSION 333#ifndef DESKTOP_VERSION
334 if ( infrared ) 334 if ( infrared )
335 delete infrared; 335 delete infrared;
336#endif 336#endif
337} 337}
338void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 338void KABCore::receive( const QCString& cmsg, const QByteArray& data )
339{ 339{
340 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 340 qDebug("KA: QCOP message received: %s ", cmsg.data() );
341 if ( cmsg == "setDocument(QString)" ) { 341 if ( cmsg == "setDocument(QString)" ) {
342 QDataStream stream( data, IO_ReadOnly ); 342 QDataStream stream( data, IO_ReadOnly );
343 QString fileName; 343 QString fileName;
344 stream >> fileName; 344 stream >> fileName;
345 recieve( fileName ); 345 recieve( fileName );
346 return; 346 return;
347 } 347 }
348} 348}
349void KABCore::toggleBeamReceive( ) 349void KABCore::toggleBeamReceive( )
350{ 350{
351 if ( mBRdisabled ) 351 if ( mBRdisabled )
352 return; 352 return;
353#ifndef DESKTOP_VERSION 353#ifndef DESKTOP_VERSION
354 if ( infrared ) { 354 if ( infrared ) {
355 qDebug("AB disable BeamReceive "); 355 qDebug("AB disable BeamReceive ");
356 delete infrared; 356 delete infrared;
357 infrared = 0; 357 infrared = 0;
358 mActionBR->setChecked(false); 358 mActionBR->setChecked(false);
359 return; 359 return;
360 } 360 }
361 qDebug("AB enable BeamReceive "); 361 qDebug("AB enable BeamReceive ");
362 mActionBR->setChecked(true); 362 mActionBR->setChecked(true);
363 363
364 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 364 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
365 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 365 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
366#endif 366#endif
367} 367}
368 368
369 369
370void KABCore::disableBR(bool b) 370void KABCore::disableBR(bool b)
371{ 371{
372#ifndef DESKTOP_VERSION 372#ifndef DESKTOP_VERSION
373 if ( b ) { 373 if ( b ) {
374 if ( infrared ) { 374 if ( infrared ) {
375 toggleBeamReceive( ); 375 toggleBeamReceive( );
376 } 376 }
377 mBRdisabled = true; 377 mBRdisabled = true;
378 } else { 378 } else {
379 if ( mBRdisabled ) { 379 if ( mBRdisabled ) {
380 mBRdisabled = false; 380 mBRdisabled = false;
381 //toggleBeamReceive( ); 381 //toggleBeamReceive( );
382 } 382 }
383 } 383 }
384#endif 384#endif
385 385
386} 386}
387void KABCore::recieve( QString fn ) 387void KABCore::recieve( QString fn )
388{ 388{
389 //qDebug("KABCore::recieve "); 389 //qDebug("KABCore::recieve ");
390 int count = mAddressBook->importFromFile( fn, true ); 390 int count = mAddressBook->importFromFile( fn, true );
391 if ( count ) 391 if ( count )
392 setModified( true ); 392 setModified( true );
393 mViewManager->refreshView(); 393 mViewManager->refreshView();
394 message(i18n("%1 contact(s) received!").arg( count )); 394 message(i18n("%1 contact(s) received!").arg( count ));
395 topLevelWidget()->showMaximized(); 395 topLevelWidget()->showMaximized();
396 topLevelWidget()->raise(); 396 topLevelWidget()->raise();
397} 397}
398void KABCore::restoreSettings() 398void KABCore::restoreSettings()
399{ 399{
400 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 400 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
401 401
402 bool state; 402 bool state;
403 403
404 if (mMultipleViewsAtOnce) 404 if (mMultipleViewsAtOnce)
405 state = KABPrefs::instance()->mDetailsPageVisible; 405 state = KABPrefs::instance()->mDetailsPageVisible;
406 else 406 else
407 state = false; 407 state = false;
408 408
409 mActionDetails->setChecked( state ); 409 mActionDetails->setChecked( state );
410 setDetailsVisible( state ); 410 setDetailsVisible( state );
411 411
412 state = KABPrefs::instance()->mJumpButtonBarVisible; 412 state = KABPrefs::instance()->mJumpButtonBarVisible;
413 413
414 mActionJumpBar->setChecked( state ); 414 mActionJumpBar->setChecked( state );
415 setJumpButtonBarVisible( state ); 415 setJumpButtonBarVisible( state );
416/*US 416/*US
417 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 417 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
418 if ( splitterSize.count() == 0 ) { 418 if ( splitterSize.count() == 0 ) {
419 splitterSize.append( width() / 2 ); 419 splitterSize.append( width() / 2 );
420 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
421 } 421 }
422 mMiniSplitter->setSizes( splitterSize ); 422 mMiniSplitter->setSizes( splitterSize );
423 if ( mExtensionBarSplitter ) { 423 if ( mExtensionBarSplitter ) {
424 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 424 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
425 if ( splitterSize.count() == 0 ) { 425 if ( splitterSize.count() == 0 ) {
426 splitterSize.append( width() / 2 ); 426 splitterSize.append( width() / 2 );
427 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
428 } 428 }
429 mExtensionBarSplitter->setSizes( splitterSize ); 429 mExtensionBarSplitter->setSizes( splitterSize );
430 430
431 } 431 }
432*/ 432*/
433 mViewManager->restoreSettings(); 433 mViewManager->restoreSettings();
434 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 434 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
435 mExtensionManager->restoreSettings(); 435 mExtensionManager->restoreSettings();
436#ifdef DESKTOP_VERSION 436#ifdef DESKTOP_VERSION
437 int wid = width(); 437 int wid = width();
438 if ( wid < 10 ) 438 if ( wid < 10 )
439 wid = 400; 439 wid = 400;
440#else 440#else
441 int wid = QApplication::desktop()->width(); 441 int wid = QApplication::desktop()->width();
442 if ( wid < 640 ) 442 if ( wid < 640 )
443 wid = QApplication::desktop()->height(); 443 wid = QApplication::desktop()->height();
444#endif 444#endif
445 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 445 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
446 if ( true /*splitterSize.count() == 0*/ ) { 446 if ( true /*splitterSize.count() == 0*/ ) {
447 splitterSize.append( wid / 2 ); 447 splitterSize.append( wid / 2 );
448 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
449 } 449 }
450 mMiniSplitter->setSizes( splitterSize ); 450 mMiniSplitter->setSizes( splitterSize );
451 if ( mExtensionBarSplitter ) { 451 if ( mExtensionBarSplitter ) {
452 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 452 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
453 if ( true /*splitterSize.count() == 0*/ ) { 453 if ( true /*splitterSize.count() == 0*/ ) {
454 splitterSize.append( wid / 2 ); 454 splitterSize.append( wid / 2 );
455 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
456 } 456 }
457 mExtensionBarSplitter->setSizes( splitterSize ); 457 mExtensionBarSplitter->setSizes( splitterSize );
458 458
459 } 459 }
460 460
461 461
462} 462}
463 463
464void KABCore::saveSettings() 464void KABCore::saveSettings()
465{ 465{
466 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 466 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
467 if ( mExtensionBarSplitter ) 467 if ( mExtensionBarSplitter )
468 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 468 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
469 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 469 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
470 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 470 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
471#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
472 472
473 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 473 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
474 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 474 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
475#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
476 mExtensionManager->saveSettings(); 476 mExtensionManager->saveSettings();
477 mViewManager->saveSettings(); 477 mViewManager->saveSettings();
478 478
479 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 479 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
480} 480}
481 481
482KABC::AddressBook *KABCore::addressBook() const 482KABC::AddressBook *KABCore::addressBook() const
483{ 483{
484 return mAddressBook; 484 return mAddressBook;
485} 485}
486 486
487KConfig *KABCore::config() 487KConfig *KABCore::config()
488{ 488{
489#ifndef KAB_EMBEDDED 489#ifndef KAB_EMBEDDED
490 return KABPrefs::instance()->config(); 490 return KABPrefs::instance()->config();
491#else //KAB_EMBEDDED 491#else //KAB_EMBEDDED
492 return KABPrefs::instance()->getConfig(); 492 return KABPrefs::instance()->getConfig();
493#endif //KAB_EMBEDDED 493#endif //KAB_EMBEDDED
494} 494}
495 495
496KActionCollection *KABCore::actionCollection() const 496KActionCollection *KABCore::actionCollection() const
497{ 497{
498 return mGUIClient->actionCollection(); 498 return mGUIClient->actionCollection();
499} 499}
500 500
501KABC::Field *KABCore::currentSearchField() const 501KABC::Field *KABCore::currentSearchField() const
502{ 502{
503 if (mIncSearchWidget) 503 if (mIncSearchWidget)
504 return mIncSearchWidget->currentField(); 504 return mIncSearchWidget->currentField();
505 else 505 else
506 return 0; 506 return 0;
507} 507}
508 508
509QStringList KABCore::selectedUIDs() const 509QStringList KABCore::selectedUIDs() const
510{ 510{
511 return mViewManager->selectedUids(); 511 return mViewManager->selectedUids();
512} 512}
513 513
514KABC::Resource *KABCore::requestResource( QWidget *parent ) 514KABC::Resource *KABCore::requestResource( QWidget *parent )
515{ 515{
516 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 516 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
517 517
518 QPtrList<KRES::Resource> kresResources; 518 QPtrList<KRES::Resource> kresResources;
519 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 519 QPtrListIterator<KABC::Resource> resIt( kabcResources );
520 KABC::Resource *resource; 520 KABC::Resource *resource;
521 while ( ( resource = resIt.current() ) != 0 ) { 521 while ( ( resource = resIt.current() ) != 0 ) {
522 ++resIt; 522 ++resIt;
523 if ( !resource->readOnly() ) { 523 if ( !resource->readOnly() ) {
524 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 524 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
525 if ( res ) 525 if ( res )
526 kresResources.append( res ); 526 kresResources.append( res );
527 } 527 }
528 } 528 }
529 529
530 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 530 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
531 return static_cast<KABC::Resource*>( res ); 531 return static_cast<KABC::Resource*>( res );
532} 532}
533 533
534#ifndef KAB_EMBEDDED 534#ifndef KAB_EMBEDDED
535KAboutData *KABCore::createAboutData() 535KAboutData *KABCore::createAboutData()
536#else //KAB_EMBEDDED 536#else //KAB_EMBEDDED
537void KABCore::createAboutData() 537void KABCore::createAboutData()
538#endif //KAB_EMBEDDED 538#endif //KAB_EMBEDDED
539{ 539{
540#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
541 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 541 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
542 "3.1", I18N_NOOP( "The KDE Address Book" ), 542 "3.1", I18N_NOOP( "The KDE Address Book" ),
543 KAboutData::License_GPL_V2, 543 KAboutData::License_GPL_V2,
544 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 544 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
545 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 545 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
546 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 546 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
547 about->addAuthor( "Cornelius Schumacher", 547 about->addAuthor( "Cornelius Schumacher",
548 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 548 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
549 "schumacher@kde.org" ); 549 "schumacher@kde.org" );
550 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 550 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
551 "mpilone@slac.com" ); 551 "mpilone@slac.com" );
552 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 552 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
553 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 553 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
554 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 554 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
555 "michel@klaralvdalens-datakonsult.se" ); 555 "michel@klaralvdalens-datakonsult.se" );
556 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 556 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
557 "hansen@kde.org" ); 557 "hansen@kde.org" );
558 558
559 return about; 559 return about;
560#endif //KAB_EMBEDDED 560#endif //KAB_EMBEDDED
561 561
562 QString version; 562 QString version;
563#include <../version> 563#include <../version>
564 QMessageBox::about( this, "About KAddressbook/Pi", 564 QMessageBox::about( this, "About KAddressbook/Pi",
565 "KAddressbook/Platform-independent\n" 565 "KAddressbook/Platform-independent\n"
566 "(KA/Pi) " +version + " - " + 566 "(KA/Pi) " +version + " - " +
567#ifdef DESKTOP_VERSION 567#ifdef DESKTOP_VERSION
568 "Desktop Edition\n" 568 "Desktop Edition\n"
569#else 569#else
570 "PDA-Edition\n" 570 "PDA-Edition\n"
571 "for: Zaurus 5500 / 7x0 / 8x0\n" 571 "for: Zaurus 5500 / 7x0 / 8x0\n"
572#endif 572#endif
573 573
574 "(c) 2004 Ulf Schenk\n" 574 "(c) 2004 Ulf Schenk\n"
575 "(c) 2004 Lutz Rogowski\n" 575 "(c) 2004 Lutz Rogowski\n"
576 "(c) 1997-2003, The KDE PIM Team\n" 576 "(c) 1997-2003, The KDE PIM Team\n"
577 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 577 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
578 "Don Sanders Original author\n" 578 "Don Sanders Original author\n"
579 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 579 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
580 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 580 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
581 "Greg Stern DCOP interface\n" 581 "Greg Stern DCOP interface\n"
582 "Mark Westcot Contact pinning\n" 582 "Mark Westcot Contact pinning\n"
583 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 583 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
584 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 584 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
585#ifdef _WIN32_ 585#ifdef _WIN32_
586 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 586 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
587#endif 587#endif
588 ); 588 );
589} 589}
590 590
591void KABCore::setContactSelected( const QString &uid ) 591void KABCore::setContactSelected( const QString &uid )
592{ 592{
593 KABC::Addressee addr = mAddressBook->findByUid( uid ); 593 KABC::Addressee addr = mAddressBook->findByUid( uid );
594 if ( !mDetails->isHidden() ) 594 if ( !mDetails->isHidden() )
595 mDetails->setAddressee( addr ); 595 mDetails->setAddressee( addr );
596 596
597 if ( !addr.isEmpty() ) { 597 if ( !addr.isEmpty() ) {
598 emit contactSelected( addr.formattedName() ); 598 emit contactSelected( addr.formattedName() );
599 KABC::Picture pic = addr.photo(); 599 KABC::Picture pic = addr.photo();
600 if ( pic.isIntern() ) { 600 if ( pic.isIntern() ) {
601//US emit contactSelected( pic.data() ); 601//US emit contactSelected( pic.data() );
602//US instead use: 602//US instead use:
603 QPixmap px; 603 QPixmap px;
604 if (pic.data().isNull() != true) 604 if (pic.data().isNull() != true)
605 { 605 {
606 px.convertFromImage(pic.data()); 606 px.convertFromImage(pic.data());
607 } 607 }
608 608
609 emit contactSelected( px ); 609 emit contactSelected( px );
610 } 610 }
611 } 611 }
612 612
613 613
614 mExtensionManager->setSelectionChanged(); 614 mExtensionManager->setSelectionChanged();
615 615
616 // update the actions 616 // update the actions
617 bool selected = !uid.isEmpty(); 617 bool selected = !uid.isEmpty();
618 618
619 if ( mReadWrite ) { 619 if ( mReadWrite ) {
620 mActionCut->setEnabled( selected ); 620 mActionCut->setEnabled( selected );
621 mActionPaste->setEnabled( selected ); 621 mActionPaste->setEnabled( selected );
622 } 622 }
623 623
624 mActionCopy->setEnabled( selected ); 624 mActionCopy->setEnabled( selected );
625 mActionDelete->setEnabled( selected ); 625 mActionDelete->setEnabled( selected );
626 mActionEditAddressee->setEnabled( selected ); 626 mActionEditAddressee->setEnabled( selected );
627 mActionMail->setEnabled( selected ); 627 mActionMail->setEnabled( selected );
628 mActionMailVCard->setEnabled( selected ); 628 mActionMailVCard->setEnabled( selected );
629 //if (mActionBeam) 629 //if (mActionBeam)
630 //mActionBeam->setEnabled( selected ); 630 //mActionBeam->setEnabled( selected );
631 631
632 if (mActionBeamVCard) 632 if (mActionBeamVCard)
633 mActionBeamVCard->setEnabled( selected ); 633 mActionBeamVCard->setEnabled( selected );
634 634
635 mActionExport2phone->setEnabled( selected ); 635 mActionExport2phone->setEnabled( selected );
636 mActionWhoAmI->setEnabled( selected ); 636 mActionWhoAmI->setEnabled( selected );
637 mActionCategories->setEnabled( selected ); 637 mActionCategories->setEnabled( selected );
638} 638}
639 639
640void KABCore::sendMail() 640void KABCore::sendMail()
641{ 641{
642 sendMail( mViewManager->selectedEmails().join( ", " ) ); 642 sendMail( mViewManager->selectedEmails().join( ", " ) );
643} 643}
644 644
645void KABCore::sendMail( const QString& emaillist ) 645void KABCore::sendMail( const QString& emaillist )
646{ 646{
647 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 647 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
648 if (emaillist.contains(",") > 0) 648 if (emaillist.contains(",") > 0)
649 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 649 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
650 else 650 else
651 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 651 ExternalAppHandler::instance()->mailToOneContact( emaillist );
652} 652}
653 653
654 654
655 655
656void KABCore::mailVCard() 656void KABCore::mailVCard()
657{ 657{
658 QStringList uids = mViewManager->selectedUids(); 658 QStringList uids = mViewManager->selectedUids();
659 if ( !uids.isEmpty() ) 659 if ( !uids.isEmpty() )
660 mailVCard( uids ); 660 mailVCard( uids );
661} 661}
662 662
663void KABCore::mailVCard( const QStringList& uids ) 663void KABCore::mailVCard( const QStringList& uids )
664{ 664{
665 QStringList urls; 665 QStringList urls;
666 666
667// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 667// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
668 668
669 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 669 QString dirName = "/tmp/" + KApplication::randomString( 8 );
670 670
671 671
672 672
673 QDir().mkdir( dirName, true ); 673 QDir().mkdir( dirName, true );
674 674
675 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 675 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
676 KABC::Addressee a = mAddressBook->findByUid( *it ); 676 KABC::Addressee a = mAddressBook->findByUid( *it );
677 677
678 if ( a.isEmpty() ) 678 if ( a.isEmpty() )
679 continue; 679 continue;
680 680
681 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 681 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
682 682
683 QString fileName = dirName + "/" + name; 683 QString fileName = dirName + "/" + name;
684 684
685 QFile outFile(fileName); 685 QFile outFile(fileName);
686 686
687 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 687 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
688 KABC::VCardConverter converter; 688 KABC::VCardConverter converter;
689 QString vcard; 689 QString vcard;
690 690
691 converter.addresseeToVCard( a, vcard ); 691 converter.addresseeToVCard( a, vcard );
692 692
693 QTextStream t( &outFile ); // use a text stream 693 QTextStream t( &outFile ); // use a text stream
694 t.setEncoding( QTextStream::UnicodeUTF8 ); 694 t.setEncoding( QTextStream::UnicodeUTF8 );
695 t << vcard; 695 t << vcard;
696 696
697 outFile.close(); 697 outFile.close();
698 698
699 urls.append( fileName ); 699 urls.append( fileName );
700 } 700 }
701 } 701 }
702 702
703 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 703 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
704 704
705 705
706/*US 706/*US
707 kapp->invokeMailer( QString::null, QString::null, QString::null, 707 kapp->invokeMailer( QString::null, QString::null, QString::null,
708 QString::null, // subject 708 QString::null, // subject
709 QString::null, // body 709 QString::null, // body
710 QString::null, 710 QString::null,
711 urls ); // attachments 711 urls ); // attachments
712*/ 712*/
713 713
714} 714}
715 715
716/** 716/**
717 Beams the "WhoAmI contact. 717 Beams the "WhoAmI contact.
718*/ 718*/
719void KABCore::beamMySelf() 719void KABCore::beamMySelf()
720{ 720{
721 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 721 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
722 if (!a.isEmpty()) 722 if (!a.isEmpty())
723 { 723 {
724 QStringList uids; 724 QStringList uids;
725 uids << a.uid(); 725 uids << a.uid();
726 726
727 beamVCard(uids); 727 beamVCard(uids);
728 } else { 728 } else {
729 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 729 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
730 730
731 731
732 } 732 }
733} 733}
734 734
735void KABCore::export2phone() 735void KABCore::export2phone()
736{ 736{
737 737
738 KAex2phonePrefs ex2phone; 738 KAex2phonePrefs ex2phone;
739 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 739 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
740 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 740 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
741 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 741 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
742 742
743 if ( !ex2phone.exec() ) { 743 if ( !ex2phone.exec() ) {
744 return; 744 return;
745 } 745 }
746 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 746 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
747 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
748 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
749 749
750 750
751 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 751 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
752 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 752 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
753 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 753 KPimGlobalPrefs::instance()->mEx2PhoneModel );
754 754
755 QStringList uids = mViewManager->selectedUids(); 755 QStringList uids = mViewManager->selectedUids();
756 if ( uids.isEmpty() ) 756 if ( uids.isEmpty() )
757 return; 757 return;
758 758
759 QString fileName = getPhoneFile(); 759 QString fileName = getPhoneFile();
760 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 760 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
761 return; 761 return;
762 762
763 message(i18n("Exporting to phone...")); 763 message(i18n("Exporting to phone..."));
764 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 764 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
765 765
766} 766}
767QString KABCore::getPhoneFile() 767QString KABCore::getPhoneFile()
768{ 768{
769#ifdef DESKTOP_VERSION 769#ifdef DESKTOP_VERSION
770 return locateLocal("tmp", "phonefile.vcf"); 770 return locateLocal("tmp", "phonefile.vcf");
771#else 771#else
772 return "/tmp/phonefile.vcf"; 772 return "/tmp/phonefile.vcf";
773#endif 773#endif
774 774
775} 775}
776void KABCore::writeToPhone( ) 776void KABCore::writeToPhone( )
777{ 777{
778 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 778 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
779 message(i18n("Export to phone finished!")); 779 message(i18n("Export to phone finished!"));
780 else 780 else
781 qDebug(i18n("Error exporting to phone")); 781 qDebug(i18n("Error exporting to phone"));
782} 782}
783void KABCore::beamVCard() 783void KABCore::beamVCard()
784{ 784{
785 QStringList uids = mViewManager->selectedUids(); 785 QStringList uids = mViewManager->selectedUids();
786 if ( !uids.isEmpty() ) 786 if ( !uids.isEmpty() )
787 beamVCard( uids ); 787 beamVCard( uids );
788} 788}
789 789
790 790
791void KABCore::beamVCard(const QStringList& uids) 791void KABCore::beamVCard(const QStringList& uids)
792{ 792{
793 793
794 // LR: we should use the /tmp dir on the Zaurus, 794 // LR: we should use the /tmp dir on the Zaurus,
795 // because: /tmp = RAM, (HOME)/kdepim = flash memory 795 // because: /tmp = RAM, (HOME)/kdepim = flash memory
796 796
797#ifdef DESKTOP_VERSION 797#ifdef DESKTOP_VERSION
798 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 798 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
799#else 799#else
800 QString fileName = "/tmp/kapibeamfile.vcf"; 800 QString fileName = "/tmp/kapibeamfile.vcf";
801#endif 801#endif
802 802
803 KABC::VCardConverter converter; 803 KABC::VCardConverter converter;
804 QString description; 804 QString description;
805 QString datastream; 805 QString datastream;
806 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 806 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
807 KABC::Addressee a = mAddressBook->findByUid( *it ); 807 KABC::Addressee a = mAddressBook->findByUid( *it );
808 808
809 if ( a.isEmpty() ) 809 if ( a.isEmpty() )
810 continue; 810 continue;
811 811
812 if (description.isEmpty()) 812 if (description.isEmpty())
813 description = a.formattedName(); 813 description = a.formattedName();
814 814
815 QString vcard; 815 QString vcard;
816 converter.addresseeToVCard( a, vcard ); 816 converter.addresseeToVCard( a, vcard );
817 int start = 0; 817 int start = 0;
818 int next; 818 int next;
819 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 819 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
820 int semi = vcard.find(";", next); 820 int semi = vcard.find(";", next);
821 int dopp = vcard.find(":", next); 821 int dopp = vcard.find(":", next);
822 int sep; 822 int sep;
823 if ( semi < dopp && semi >= 0 ) 823 if ( semi < dopp && semi >= 0 )
824 sep = semi ; 824 sep = semi ;
825 else 825 else
826 sep = dopp; 826 sep = dopp;
827 datastream +=vcard.mid( start, next - start); 827 datastream +=vcard.mid( start, next - start);
828 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 828 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
829 start = sep; 829 start = sep;
830 } 830 }
831 datastream += vcard.mid( start,vcard.length() ); 831 datastream += vcard.mid( start,vcard.length() );
832 } 832 }
833#ifndef DESKTOP_VERSION 833#ifndef DESKTOP_VERSION
834 QFile outFile(fileName); 834 QFile outFile(fileName);
835 if ( outFile.open(IO_WriteOnly) ) { 835 if ( outFile.open(IO_WriteOnly) ) {
836 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 836 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
837 QTextStream t( &outFile ); // use a text stream 837 QTextStream t( &outFile ); // use a text stream
838 //t.setEncoding( QTextStream::UnicodeUTF8 ); 838 //t.setEncoding( QTextStream::UnicodeUTF8 );
839 t.setEncoding( QTextStream::Latin1 ); 839 t.setEncoding( QTextStream::Latin1 );
840 t <<datastream.latin1(); 840 t <<datastream.latin1();
841 outFile.close(); 841 outFile.close();
842 Ir *ir = new Ir( this ); 842 Ir *ir = new Ir( this );
843 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 843 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
844 ir->send( fileName, description, "text/x-vCard" ); 844 ir->send( fileName, description, "text/x-vCard" );
845 } else { 845 } else {
846 qDebug("Error open temp beam file "); 846 qDebug("Error open temp beam file ");
847 return; 847 return;
848 } 848 }
849#endif 849#endif
850 850
851} 851}
852 852
853void KABCore::beamDone( Ir *ir ) 853void KABCore::beamDone( Ir *ir )
854{ 854{
855#ifndef DESKTOP_VERSION 855#ifndef DESKTOP_VERSION
856 delete ir; 856 delete ir;
857#endif 857#endif
858 topLevelWidget()->raise(); 858 topLevelWidget()->raise();
859 message( i18n("Beaming finished!") ); 859 message( i18n("Beaming finished!") );
860} 860}
861 861
862 862
863void KABCore::browse( const QString& url ) 863void KABCore::browse( const QString& url )
864{ 864{
865#ifndef KAB_EMBEDDED 865#ifndef KAB_EMBEDDED
866 kapp->invokeBrowser( url ); 866 kapp->invokeBrowser( url );
867#else //KAB_EMBEDDED 867#else //KAB_EMBEDDED
868 qDebug("KABCore::browse must be fixed"); 868 qDebug("KABCore::browse must be fixed");
869#endif //KAB_EMBEDDED 869#endif //KAB_EMBEDDED
870} 870}
871 871
872void KABCore::selectAllContacts() 872void KABCore::selectAllContacts()
873{ 873{
874 mViewManager->setSelected( QString::null, true ); 874 mViewManager->setSelected( QString::null, true );
875} 875}
876 876
877void KABCore::deleteContacts() 877void KABCore::deleteContacts()
878{ 878{
879 QStringList uidList = mViewManager->selectedUids(); 879 QStringList uidList = mViewManager->selectedUids();
880 deleteContacts( uidList ); 880 deleteContacts( uidList );
881} 881}
882 882
883void KABCore::deleteContacts( const QStringList &uids ) 883void KABCore::deleteContacts( const QStringList &uids )
884{ 884{
885 if ( uids.count() > 0 ) { 885 if ( uids.count() > 0 ) {
886 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 886 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
887 UndoStack::instance()->push( command ); 887 UndoStack::instance()->push( command );
888 RedoStack::instance()->clear(); 888 RedoStack::instance()->clear();
889 889
890 // now if we deleted anything, refresh 890 // now if we deleted anything, refresh
891 setContactSelected( QString::null ); 891 setContactSelected( QString::null );
892 setModified( true ); 892 setModified( true );
893 } 893 }
894} 894}
895 895
896void KABCore::copyContacts() 896void KABCore::copyContacts()
897{ 897{
898 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 898 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
899 899
900 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 900 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
901 901
902 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 902 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
903 903
904 QClipboard *cb = QApplication::clipboard(); 904 QClipboard *cb = QApplication::clipboard();
905 cb->setText( clipText ); 905 cb->setText( clipText );
906} 906}
907 907
908void KABCore::cutContacts() 908void KABCore::cutContacts()
909{ 909{
910 QStringList uidList = mViewManager->selectedUids(); 910 QStringList uidList = mViewManager->selectedUids();
911 911
912//US if ( uidList.size() > 0 ) { 912//US if ( uidList.size() > 0 ) {
913 if ( uidList.count() > 0 ) { 913 if ( uidList.count() > 0 ) {
914 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 914 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
915 UndoStack::instance()->push( command ); 915 UndoStack::instance()->push( command );
916 RedoStack::instance()->clear(); 916 RedoStack::instance()->clear();
917 917
918 setModified( true ); 918 setModified( true );
919 } 919 }
920} 920}
921 921
922void KABCore::pasteContacts() 922void KABCore::pasteContacts()
923{ 923{
924 QClipboard *cb = QApplication::clipboard(); 924 QClipboard *cb = QApplication::clipboard();
925 925
926 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 926 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
927 927
928 pasteContacts( list ); 928 pasteContacts( list );
929} 929}
930 930
931void KABCore::pasteContacts( KABC::Addressee::List &list ) 931void KABCore::pasteContacts( KABC::Addressee::List &list )
932{ 932{
933 KABC::Resource *resource = requestResource( this ); 933 KABC::Resource *resource = requestResource( this );
934 KABC::Addressee::List::Iterator it; 934 KABC::Addressee::List::Iterator it;
935 for ( it = list.begin(); it != list.end(); ++it ) 935 for ( it = list.begin(); it != list.end(); ++it )
936 (*it).setResource( resource ); 936 (*it).setResource( resource );
937 937
938 PwPasteCommand *command = new PwPasteCommand( this, list ); 938 PwPasteCommand *command = new PwPasteCommand( this, list );
939 UndoStack::instance()->push( command ); 939 UndoStack::instance()->push( command );
940 RedoStack::instance()->clear(); 940 RedoStack::instance()->clear();
941 941
942 setModified( true ); 942 setModified( true );
943} 943}
944 944
945void KABCore::setWhoAmI() 945void KABCore::setWhoAmI()
946{ 946{
947 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 947 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
948 948
949 if ( addrList.count() > 1 ) { 949 if ( addrList.count() > 1 ) {
950 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 950 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
951 return; 951 return;
952 } 952 }
953 953
954 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 954 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
955 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 955 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
956 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 956 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
957} 957}
958 958
959void KABCore::setCategories() 959void KABCore::setCategories()
960{ 960{
961 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 961 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
962 if ( !dlg.exec() ) 962 if ( !dlg.exec() )
963 return; 963 return;
964 964
965 bool merge = false; 965 bool merge = false;
966 QString msg = i18n( "Merge with existing categories?" ); 966 QString msg = i18n( "Merge with existing categories?" );
967 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 967 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
968 merge = true; 968 merge = true;
969 969
970 QStringList categories = dlg.selectedCategories(); 970 QStringList categories = dlg.selectedCategories();
971 971
972 QStringList uids = mViewManager->selectedUids(); 972 QStringList uids = mViewManager->selectedUids();
973 QStringList::Iterator it; 973 QStringList::Iterator it;
974 for ( it = uids.begin(); it != uids.end(); ++it ) { 974 for ( it = uids.begin(); it != uids.end(); ++it ) {
975 KABC::Addressee addr = mAddressBook->findByUid( *it ); 975 KABC::Addressee addr = mAddressBook->findByUid( *it );
976 if ( !addr.isEmpty() ) { 976 if ( !addr.isEmpty() ) {
977 if ( !merge ) 977 if ( !merge )
978 addr.setCategories( categories ); 978 addr.setCategories( categories );
979 else { 979 else {
980 QStringList addrCategories = addr.categories(); 980 QStringList addrCategories = addr.categories();
981 QStringList::Iterator catIt; 981 QStringList::Iterator catIt;
982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
983 if ( !addrCategories.contains( *catIt ) ) 983 if ( !addrCategories.contains( *catIt ) )
984 addrCategories.append( *catIt ); 984 addrCategories.append( *catIt );
985 } 985 }
986 addr.setCategories( addrCategories ); 986 addr.setCategories( addrCategories );
987 } 987 }
988 988
989 mAddressBook->insertAddressee( addr ); 989 mAddressBook->insertAddressee( addr );
990 } 990 }
991 } 991 }
992 992
993 if ( uids.count() > 0 ) 993 if ( uids.count() > 0 )
994 setModified( true ); 994 setModified( true );
995} 995}
996 996
997void KABCore::setSearchFields( const KABC::Field::List &fields ) 997void KABCore::setSearchFields( const KABC::Field::List &fields )
998{ 998{
999 mIncSearchWidget->setFields( fields ); 999 mIncSearchWidget->setFields( fields );
1000} 1000}
1001 1001
1002void KABCore::incrementalSearch( const QString& text ) 1002void KABCore::incrementalSearch( const QString& text )
1003{ 1003{
1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1005} 1005}
1006 1006
1007void KABCore::setModified() 1007void KABCore::setModified()
1008{ 1008{
1009 setModified( true ); 1009 setModified( true );
1010} 1010}
1011 1011
1012void KABCore::setModifiedWOrefresh() 1012void KABCore::setModifiedWOrefresh()
1013{ 1013{
1014 // qDebug("KABCore::setModifiedWOrefresh() "); 1014 // qDebug("KABCore::setModifiedWOrefresh() ");
1015 mModified = true; 1015 mModified = true;
1016 mActionSave->setEnabled( mModified ); 1016 mActionSave->setEnabled( mModified );
1017#ifdef DESKTOP_VERSION 1017#ifdef DESKTOP_VERSION
1018 mDetails->refreshView(); 1018 mDetails->refreshView();
1019#endif 1019#endif
1020 1020
1021} 1021}
1022void KABCore::setModified( bool modified ) 1022void KABCore::setModified( bool modified )
1023{ 1023{
1024 mModified = modified; 1024 mModified = modified;
1025 mActionSave->setEnabled( mModified ); 1025 mActionSave->setEnabled( mModified );
1026 1026
1027 if ( modified ) 1027 if ( modified )
1028 mJumpButtonBar->recreateButtons(); 1028 mJumpButtonBar->recreateButtons();
1029 1029
1030 mViewManager->refreshView(); 1030 mViewManager->refreshView();
1031 mDetails->refreshView(); 1031 mDetails->refreshView();
1032 1032
1033} 1033}
1034 1034
1035bool KABCore::modified() const 1035bool KABCore::modified() const
1036{ 1036{
1037 return mModified; 1037 return mModified;
1038} 1038}
1039 1039
1040void KABCore::contactModified( const KABC::Addressee &addr ) 1040void KABCore::contactModified( const KABC::Addressee &addr )
1041{ 1041{
1042 1042
1043 Command *command = 0; 1043 Command *command = 0;
1044 QString uid; 1044 QString uid;
1045 1045
1046 // check if it exists already 1046 // check if it exists already
1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1048 if ( origAddr.isEmpty() ) 1048 if ( origAddr.isEmpty() )
1049 command = new PwNewCommand( mAddressBook, addr ); 1049 command = new PwNewCommand( mAddressBook, addr );
1050 else { 1050 else {
1051 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1051 command = new PwEditCommand( mAddressBook, origAddr, addr );
1052 uid = addr.uid(); 1052 uid = addr.uid();
1053 } 1053 }
1054 1054
1055 UndoStack::instance()->push( command ); 1055 UndoStack::instance()->push( command );
1056 RedoStack::instance()->clear(); 1056 RedoStack::instance()->clear();
1057 1057
1058 setModified( true ); 1058 setModified( true );
1059} 1059}
1060 1060
1061void KABCore::newContact() 1061void KABCore::newContact()
1062{ 1062{
1063 1063
1064 1064
1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1066 1066
1067 QPtrList<KRES::Resource> kresResources; 1067 QPtrList<KRES::Resource> kresResources;
1068 QPtrListIterator<KABC::Resource> it( kabcResources ); 1068 QPtrListIterator<KABC::Resource> it( kabcResources );
1069 KABC::Resource *resource; 1069 KABC::Resource *resource;
1070 while ( ( resource = it.current() ) != 0 ) { 1070 while ( ( resource = it.current() ) != 0 ) {
1071 ++it; 1071 ++it;
1072 if ( !resource->readOnly() ) { 1072 if ( !resource->readOnly() ) {
1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1074 if ( res ) 1074 if ( res )
1075 kresResources.append( res ); 1075 kresResources.append( res );
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1080 resource = static_cast<KABC::Resource*>( res ); 1080 resource = static_cast<KABC::Resource*>( res );
1081 1081
1082 if ( resource ) { 1082 if ( resource ) {
1083 KABC::Addressee addr; 1083 KABC::Addressee addr;
1084 addr.setResource( resource ); 1084 addr.setResource( resource );
1085 mEditorDialog->setAddressee( addr ); 1085 mEditorDialog->setAddressee( addr );
1086 KApplication::execDialog ( mEditorDialog ); 1086 KApplication::execDialog ( mEditorDialog );
1087 1087
1088 } else 1088 } else
1089 return; 1089 return;
1090 1090
1091 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1091 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1092 1092
1093 1093
1094} 1094}
1095 1095
1096void KABCore::addEmail( QString aStr ) 1096void KABCore::addEmail( QString aStr )
1097{ 1097{
1098#ifndef KAB_EMBEDDED 1098#ifndef KAB_EMBEDDED
1099 QString fullName, email; 1099 QString fullName, email;
1100 1100
1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1102 1102
1103 // Try to lookup the addressee matching the email address 1103 // Try to lookup the addressee matching the email address
1104 bool found = false; 1104 bool found = false;
1105 QStringList emailList; 1105 QStringList emailList;
1106 KABC::AddressBook::Iterator it; 1106 KABC::AddressBook::Iterator it;
1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1108 emailList = (*it).emails(); 1108 emailList = (*it).emails();
1109 if ( emailList.contains( email ) > 0 ) { 1109 if ( emailList.contains( email ) > 0 ) {
1110 found = true; 1110 found = true;
1111 (*it).setNameFromString( fullName ); 1111 (*it).setNameFromString( fullName );
1112 editContact( (*it).uid() ); 1112 editContact( (*it).uid() );
1113 } 1113 }
1114 } 1114 }
1115 1115
1116 if ( !found ) { 1116 if ( !found ) {
1117 KABC::Addressee addr; 1117 KABC::Addressee addr;
1118 addr.setNameFromString( fullName ); 1118 addr.setNameFromString( fullName );
1119 addr.insertEmail( email, true ); 1119 addr.insertEmail( email, true );
1120 1120
1121 mAddressBook->insertAddressee( addr ); 1121 mAddressBook->insertAddressee( addr );
1122 mViewManager->refreshView( addr.uid() ); 1122 mViewManager->refreshView( addr.uid() );
1123 editContact( addr.uid() ); 1123 editContact( addr.uid() );
1124 } 1124 }
1125#else //KAB_EMBEDDED 1125#else //KAB_EMBEDDED
1126 qDebug("KABCore::addEmail finsih method"); 1126 qDebug("KABCore::addEmail finsih method");
1127#endif //KAB_EMBEDDED 1127#endif //KAB_EMBEDDED
1128} 1128}
1129 1129
1130void KABCore::importVCard( const KURL &url, bool showPreview ) 1130void KABCore::importVCard( const KURL &url, bool showPreview )
1131{ 1131{
1132 mXXPortManager->importVCard( url, showPreview ); 1132 mXXPortManager->importVCard( url, showPreview );
1133} 1133}
1134void KABCore::importFromOL() 1134void KABCore::importFromOL()
1135{ 1135{
1136#ifdef _WIN32_ 1136#ifdef _WIN32_
1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1138 idgl->exec(); 1138 idgl->exec();
1139 KABC::Addressee::List list = idgl->getAddressList(); 1139 KABC::Addressee::List list = idgl->getAddressList();
1140 if ( list.count() > 0 ) { 1140 if ( list.count() > 0 ) {
1141 KABC::Addressee::List listNew; 1141 KABC::Addressee::List listNew;
1142 KABC::Addressee::List listExisting; 1142 KABC::Addressee::List listExisting;
1143 KABC::Addressee::List::Iterator it; 1143 KABC::Addressee::List::Iterator it;
1144 KABC::AddressBook::Iterator iter; 1144 KABC::AddressBook::Iterator iter;
1145 for ( it = list.begin(); it != list.end(); ++it ) { 1145 for ( it = list.begin(); it != list.end(); ++it ) {
1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1147 listNew.append( (*it) ); 1147 listNew.append( (*it) );
1148 else 1148 else
1149 listExisting.append( (*it) ); 1149 listExisting.append( (*it) );
1150 } 1150 }
1151 if ( listExisting.count() > 0 ) 1151 if ( listExisting.count() > 0 )
1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1153 if ( listNew.count() > 0 ) { 1153 if ( listNew.count() > 0 ) {
1154 pasteWithNewUid = false; 1154 pasteWithNewUid = false;
1155 pasteContacts( listNew ); 1155 pasteContacts( listNew );
1156 pasteWithNewUid = true; 1156 pasteWithNewUid = true;
1157 } 1157 }
1158 } 1158 }
1159 delete idgl; 1159 delete idgl;
1160#endif 1160#endif
1161} 1161}
1162 1162
1163void KABCore::importVCard( const QString &vCard, bool showPreview ) 1163void KABCore::importVCard( const QString &vCard, bool showPreview )
1164{ 1164{
1165 mXXPortManager->importVCard( vCard, showPreview ); 1165 mXXPortManager->importVCard( vCard, showPreview );
1166} 1166}
1167 1167
1168//US added a second method without defaultparameter 1168//US added a second method without defaultparameter
1169void KABCore::editContact2() { 1169void KABCore::editContact2() {
1170 editContact( QString::null ); 1170 editContact( QString::null );
1171} 1171}
1172 1172
1173void KABCore::editContact( const QString &uid ) 1173void KABCore::editContact( const QString &uid )
1174{ 1174{
1175 1175
1176 if ( mExtensionManager->isQuickEditVisible() ) 1176 if ( mExtensionManager->isQuickEditVisible() )
1177 return; 1177 return;
1178 1178
1179 // First, locate the contact entry 1179 // First, locate the contact entry
1180 QString localUID = uid; 1180 QString localUID = uid;
1181 if ( localUID.isNull() ) { 1181 if ( localUID.isNull() ) {
1182 QStringList uidList = mViewManager->selectedUids(); 1182 QStringList uidList = mViewManager->selectedUids();
1183 if ( uidList.count() > 0 ) 1183 if ( uidList.count() > 0 )
1184 localUID = *( uidList.at( 0 ) ); 1184 localUID = *( uidList.at( 0 ) );
1185 } 1185 }
1186 1186
1187 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1187 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1188 if ( !addr.isEmpty() ) { 1188 if ( !addr.isEmpty() ) {
1189 mEditorDialog->setAddressee( addr ); 1189 mEditorDialog->setAddressee( addr );
1190 KApplication::execDialog ( mEditorDialog ); 1190 KApplication::execDialog ( mEditorDialog );
1191 } 1191 }
1192} 1192}
1193 1193
1194/** 1194/**
1195 Shows or edits the detail view for the given uid. If the uid is QString::null, 1195 Shows or edits the detail view for the given uid. If the uid is QString::null,
1196 the method will try to find a selected addressee in the view. 1196 the method will try to find a selected addressee in the view.
1197 */ 1197 */
1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1199{ 1199{
1200 if ( mMultipleViewsAtOnce ) 1200 if ( mMultipleViewsAtOnce )
1201 { 1201 {
1202 editContact( uid ); 1202 editContact( uid );
1203 } 1203 }
1204 else 1204 else
1205 { 1205 {
1206 setDetailsVisible( true ); 1206 setDetailsVisible( true );
1207 mActionDetails->setChecked(true); 1207 mActionDetails->setChecked(true);
1208 } 1208 }
1209 1209
1210} 1210}
1211 1211
1212void KABCore::save() 1212void KABCore::save()
1213{ 1213{
1214 if (syncManager->blockSave()) 1214 if (syncManager->blockSave())
1215 return; 1215 return;
1216 if ( !mModified ) 1216 if ( !mModified )
1217 return; 1217 return;
1218 1218
1219 syncManager->setBlockSave(true); 1219 syncManager->setBlockSave(true);
1220 QString text = i18n( "There was an error while attempting to save\n the " 1220 QString text = i18n( "There was an error while attempting to save\n the "
1221 "address book. Please check that some \nother application is " 1221 "address book. Please check that some \nother application is "
1222 "not using it. " ); 1222 "not using it. " );
1223 message(i18n("Saving addressbook ... ")); 1223 message(i18n("Saving addressbook ... "));
1224#ifndef KAB_EMBEDDED 1224#ifndef KAB_EMBEDDED
1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1226 if ( !b || !b->save() ) { 1226 if ( !b || !b->save() ) {
1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1228 } 1228 }
1229#else //KAB_EMBEDDED 1229#else //KAB_EMBEDDED
1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1231 if ( !b || !b->save() ) { 1231 if ( !b || !b->save() ) {
1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1233 } 1233 }
1234#endif //KAB_EMBEDDED 1234#endif //KAB_EMBEDDED
1235 1235
1236 message(i18n("Addressbook saved!")); 1236 message(i18n("Addressbook saved!"));
1237 setModified( false ); 1237 setModified( false );
1238 syncManager->setBlockSave(false); 1238 syncManager->setBlockSave(false);
1239} 1239}
1240 1240
1241 1241
1242void KABCore::undo() 1242void KABCore::undo()
1243{ 1243{
1244 UndoStack::instance()->undo(); 1244 UndoStack::instance()->undo();
1245 1245
1246 // Refresh the view 1246 // Refresh the view
1247 mViewManager->refreshView(); 1247 mViewManager->refreshView();
1248} 1248}
1249 1249
1250void KABCore::redo() 1250void KABCore::redo()
1251{ 1251{
1252 RedoStack::instance()->redo(); 1252 RedoStack::instance()->redo();
1253 1253
1254 // Refresh the view 1254 // Refresh the view
1255 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1256} 1256}
1257 1257
1258void KABCore::setJumpButtonBarVisible( bool visible ) 1258void KABCore::setJumpButtonBarVisible( bool visible )
1259{ 1259{
1260 if (mMultipleViewsAtOnce) 1260 if (mMultipleViewsAtOnce)
1261 { 1261 {
1262 if ( visible ) 1262 if ( visible )
1263 mJumpButtonBar->show(); 1263 mJumpButtonBar->show();
1264 else 1264 else
1265 mJumpButtonBar->hide(); 1265 mJumpButtonBar->hide();
1266 } 1266 }
1267 else 1267 else
1268 { 1268 {
1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1270 if (mViewManager->isVisible()) 1270 if (mViewManager->isVisible())
1271 { 1271 {
1272 if ( visible ) 1272 if ( visible )
1273 mJumpButtonBar->show(); 1273 mJumpButtonBar->show();
1274 else 1274 else
1275 mJumpButtonBar->hide(); 1275 mJumpButtonBar->hide();
1276 } 1276 }
1277 else 1277 else
1278 { 1278 {
1279 mJumpButtonBar->hide(); 1279 mJumpButtonBar->hide();
1280 } 1280 }
1281 } 1281 }
1282} 1282}
1283 1283
1284 1284
1285void KABCore::setDetailsToState() 1285void KABCore::setDetailsToState()
1286{ 1286{
1287 setDetailsVisible( mActionDetails->isChecked() ); 1287 setDetailsVisible( mActionDetails->isChecked() );
1288} 1288}
1289 1289
1290 1290
1291 1291
1292void KABCore::setDetailsVisible( bool visible ) 1292void KABCore::setDetailsVisible( bool visible )
1293{ 1293{
1294 if (visible && mDetails->isHidden()) 1294 if (visible && mDetails->isHidden())
1295 { 1295 {
1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1297 if ( addrList.count() > 0 ) 1297 if ( addrList.count() > 0 )
1298 mDetails->setAddressee( addrList[ 0 ] ); 1298 mDetails->setAddressee( addrList[ 0 ] );
1299 } 1299 }
1300 1300
1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1302 // the listview and the detailview. We do that by changing the splitbar size. 1302 // the listview and the detailview. We do that by changing the splitbar size.
1303 if (mMultipleViewsAtOnce) 1303 if (mMultipleViewsAtOnce)
1304 { 1304 {
1305 if ( visible ) 1305 if ( visible )
1306 mDetails->show(); 1306 mDetails->show();
1307 else 1307 else
1308 mDetails->hide(); 1308 mDetails->hide();
1309 } 1309 }
1310 else 1310 else
1311 { 1311 {
1312 if ( visible ) { 1312 if ( visible ) {
1313 mViewManager->hide(); 1313 mViewManager->hide();
1314 mDetails->show(); 1314 mDetails->show();
1315 mIncSearchWidget->setFocus(); 1315 mIncSearchWidget->setFocus();
1316 } 1316 }
1317 else { 1317 else {
1318 mViewManager->show(); 1318 mViewManager->show();
1319 mDetails->hide(); 1319 mDetails->hide();
1320 mViewManager->setFocusAV(); 1320 mViewManager->setFocusAV();
1321 } 1321 }
1322 setJumpButtonBarVisible( !visible ); 1322 setJumpButtonBarVisible( !visible );
1323 } 1323 }
1324 1324
1325} 1325}
1326 1326
1327void KABCore::extensionChanged( int id ) 1327void KABCore::extensionChanged( int id )
1328{ 1328{
1329 //change the details view only for non desktop systems 1329 //change the details view only for non desktop systems
1330#ifndef DESKTOP_VERSION 1330#ifndef DESKTOP_VERSION
1331 1331
1332 if (id == 0) 1332 if (id == 0)
1333 { 1333 {
1334 //the user disabled the extension. 1334 //the user disabled the extension.
1335 1335
1336 if (mMultipleViewsAtOnce) 1336 if (mMultipleViewsAtOnce)
1337 { // enable detailsview again 1337 { // enable detailsview again
1338 setDetailsVisible( true ); 1338 setDetailsVisible( true );
1339 mActionDetails->setChecked( true ); 1339 mActionDetails->setChecked( true );
1340 } 1340 }
1341 else 1341 else
1342 { //go back to the listview 1342 { //go back to the listview
1343 setDetailsVisible( false ); 1343 setDetailsVisible( false );
1344 mActionDetails->setChecked( false ); 1344 mActionDetails->setChecked( false );
1345 mActionDetails->setEnabled(true); 1345 mActionDetails->setEnabled(true);
1346 } 1346 }
1347 1347
1348 } 1348 }
1349 else 1349 else
1350 { 1350 {
1351 //the user enabled the extension. 1351 //the user enabled the extension.
1352 setDetailsVisible( false ); 1352 setDetailsVisible( false );
1353 mActionDetails->setChecked( false ); 1353 mActionDetails->setChecked( false );
1354 1354
1355 if (!mMultipleViewsAtOnce) 1355 if (!mMultipleViewsAtOnce)
1356 { 1356 {
1357 mActionDetails->setEnabled(false); 1357 mActionDetails->setEnabled(false);
1358 } 1358 }
1359 1359
1360 mExtensionManager->setSelectionChanged(); 1360 mExtensionManager->setSelectionChanged();
1361 1361
1362 } 1362 }
1363 1363
1364#endif// DESKTOP_VERSION 1364#endif// DESKTOP_VERSION
1365 1365
1366} 1366}
1367 1367
1368 1368
1369void KABCore::extensionModified( const KABC::Addressee::List &list ) 1369void KABCore::extensionModified( const KABC::Addressee::List &list )
1370{ 1370{
1371 1371
1372 if ( list.count() != 0 ) { 1372 if ( list.count() != 0 ) {
1373 KABC::Addressee::List::ConstIterator it; 1373 KABC::Addressee::List::ConstIterator it;
1374 for ( it = list.begin(); it != list.end(); ++it ) 1374 for ( it = list.begin(); it != list.end(); ++it )
1375 mAddressBook->insertAddressee( *it ); 1375 mAddressBook->insertAddressee( *it );
1376 if ( list.count() > 1 ) 1376 if ( list.count() > 1 )
1377 setModified(); 1377 setModified();
1378 else 1378 else
1379 setModifiedWOrefresh(); 1379 setModifiedWOrefresh();
1380 } 1380 }
1381 if ( list.count() == 0 ) 1381 if ( list.count() == 0 )
1382 mViewManager->refreshView(); 1382 mViewManager->refreshView();
1383 else 1383 else
1384 mViewManager->refreshView( list[ 0 ].uid() ); 1384 mViewManager->refreshView( list[ 0 ].uid() );
1385 1385
1386 1386
1387 1387
1388} 1388}
1389 1389
1390QString KABCore::getNameByPhone( const QString &phone ) 1390QString KABCore::getNameByPhone( const QString &phone )
1391{ 1391{
1392#ifndef KAB_EMBEDDED 1392#ifndef KAB_EMBEDDED
1393 QRegExp r( "[/*/-/ ]" ); 1393 QRegExp r( "[/*/-/ ]" );
1394 QString localPhone( phone ); 1394 QString localPhone( phone );
1395 1395
1396 bool found = false; 1396 bool found = false;
1397 QString ownerName = ""; 1397 QString ownerName = "";
1398 KABC::AddressBook::Iterator iter; 1398 KABC::AddressBook::Iterator iter;
1399 KABC::PhoneNumber::List::Iterator phoneIter; 1399 KABC::PhoneNumber::List::Iterator phoneIter;
1400 KABC::PhoneNumber::List phoneList; 1400 KABC::PhoneNumber::List phoneList;
1401 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1401 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1402 phoneList = (*iter).phoneNumbers(); 1402 phoneList = (*iter).phoneNumbers();
1403 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1403 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1404 ++phoneIter) { 1404 ++phoneIter) {
1405 // Get rid of separator chars so just the numbers are compared. 1405 // Get rid of separator chars so just the numbers are compared.
1406 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1406 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1407 ownerName = (*iter).formattedName(); 1407 ownerName = (*iter).formattedName();
1408 found = true; 1408 found = true;
1409 } 1409 }
1410 } 1410 }
1411 } 1411 }
1412 1412
1413 return ownerName; 1413 return ownerName;
1414#else //KAB_EMBEDDED 1414#else //KAB_EMBEDDED
1415 qDebug("KABCore::getNameByPhone finsih method"); 1415 qDebug("KABCore::getNameByPhone finsih method");
1416 return ""; 1416 return "";
1417#endif //KAB_EMBEDDED 1417#endif //KAB_EMBEDDED
1418 1418
1419} 1419}
1420 1420
1421void KABCore::openConfigDialog() 1421void KABCore::openConfigDialog()
1422{ 1422{
1423 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1423 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1424 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1424 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1425 ConfigureDialog->addModule(kabcfg ); 1425 ConfigureDialog->addModule(kabcfg );
1426 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1426 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1427 ConfigureDialog->addModule(kdelibcfg ); 1427 ConfigureDialog->addModule(kdelibcfg );
1428 1428
1429 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1429 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1430 this, SLOT( configurationChanged() ) ); 1430 this, SLOT( configurationChanged() ) );
1431 connect( ConfigureDialog, SIGNAL( okClicked() ), 1431 connect( ConfigureDialog, SIGNAL( okClicked() ),
1432 this, SLOT( configurationChanged() ) ); 1432 this, SLOT( configurationChanged() ) );
1433 saveSettings(); 1433 saveSettings();
1434#ifndef DESKTOP_VERSION 1434#ifndef DESKTOP_VERSION
1435 ConfigureDialog->showMaximized(); 1435 ConfigureDialog->showMaximized();
1436#endif 1436#endif
1437 if ( ConfigureDialog->exec() ) 1437 if ( ConfigureDialog->exec() )
1438 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1438 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1439 delete ConfigureDialog; 1439 delete ConfigureDialog;
1440} 1440}
1441 1441
1442void KABCore::openLDAPDialog() 1442void KABCore::openLDAPDialog()
1443{ 1443{
1444#ifndef KAB_EMBEDDED 1444#ifndef KAB_EMBEDDED
1445 if ( !mLdapSearchDialog ) { 1445 if ( !mLdapSearchDialog ) {
1446 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1446 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1448 SLOT( refreshView() ) ); 1448 SLOT( refreshView() ) );
1449 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1449 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1450 SLOT( setModified() ) ); 1450 SLOT( setModified() ) );
1451 } else 1451 } else
1452 mLdapSearchDialog->restoreSettings(); 1452 mLdapSearchDialog->restoreSettings();
1453 1453
1454 if ( mLdapSearchDialog->isOK() ) 1454 if ( mLdapSearchDialog->isOK() )
1455 mLdapSearchDialog->exec(); 1455 mLdapSearchDialog->exec();
1456#else //KAB_EMBEDDED 1456#else //KAB_EMBEDDED
1457 qDebug("KABCore::openLDAPDialog() finsih method"); 1457 qDebug("KABCore::openLDAPDialog() finsih method");
1458#endif //KAB_EMBEDDED 1458#endif //KAB_EMBEDDED
1459} 1459}
1460 1460
1461void KABCore::print() 1461void KABCore::print()
1462{ 1462{
1463#ifndef KAB_EMBEDDED 1463#ifndef KAB_EMBEDDED
1464 KPrinter printer; 1464 KPrinter printer;
1465 if ( !printer.setup( this ) ) 1465 if ( !printer.setup( this ) )
1466 return; 1466 return;
1467 1467
1468 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1468 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1469 mViewManager->selectedUids(), this ); 1469 mViewManager->selectedUids(), this );
1470 1470
1471 wizard.exec(); 1471 wizard.exec();
1472#else //KAB_EMBEDDED 1472#else //KAB_EMBEDDED
1473 qDebug("KABCore::print() finsih method"); 1473 qDebug("KABCore::print() finsih method");
1474#endif //KAB_EMBEDDED 1474#endif //KAB_EMBEDDED
1475 1475
1476} 1476}
1477 1477
1478 1478
1479void KABCore::addGUIClient( KXMLGUIClient *client ) 1479void KABCore::addGUIClient( KXMLGUIClient *client )
1480{ 1480{
1481 if ( mGUIClient ) 1481 if ( mGUIClient )
1482 mGUIClient->insertChildClient( client ); 1482 mGUIClient->insertChildClient( client );
1483 else 1483 else
1484 KMessageBox::error( this, "no KXMLGUICLient"); 1484 KMessageBox::error( this, "no KXMLGUICLient");
1485} 1485}
1486 1486
1487 1487
1488void KABCore::configurationChanged() 1488void KABCore::configurationChanged()
1489{ 1489{
1490 mExtensionManager->reconfigure(); 1490 mExtensionManager->reconfigure();
1491} 1491}
1492 1492
1493void KABCore::addressBookChanged() 1493void KABCore::addressBookChanged()
1494{ 1494{
1495/*US 1495/*US
1496 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1496 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1497 while ( it.current() ) { 1497 while ( it.current() ) {
1498 if ( it.current()->dirty() ) { 1498 if ( it.current()->dirty() ) {
1499 QString text = i18n( "Data has been changed externally. Unsaved " 1499 QString text = i18n( "Data has been changed externally. Unsaved "
1500 "changes will be lost." ); 1500 "changes will be lost." );
1501 KMessageBox::information( this, text ); 1501 KMessageBox::information( this, text );
1502 } 1502 }
1503 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1503 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1504 ++it; 1504 ++it;
1505 } 1505 }
1506*/ 1506*/
1507 if (mEditorDialog) 1507 if (mEditorDialog)
1508 { 1508 {
1509 if (mEditorDialog->dirty()) 1509 if (mEditorDialog->dirty())
1510 { 1510 {
1511 QString text = i18n( "Data has been changed externally. Unsaved " 1511 QString text = i18n( "Data has been changed externally. Unsaved "
1512 "changes will be lost." ); 1512 "changes will be lost." );
1513 KMessageBox::information( this, text ); 1513 KMessageBox::information( this, text );
1514 } 1514 }
1515 QString currentuid = mEditorDialog->addressee().uid(); 1515 QString currentuid = mEditorDialog->addressee().uid();
1516 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1516 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1517 } 1517 }
1518 mViewManager->refreshView(); 1518 mViewManager->refreshView();
1519// mDetails->refreshView(); 1519// mDetails->refreshView();
1520 1520
1521 1521
1522} 1522}
1523 1523
1524AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1524AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1525 const char *name ) 1525 const char *name )
1526{ 1526{
1527 1527
1528 if ( mEditorDialog == 0 ) { 1528 if ( mEditorDialog == 0 ) {
1529 mEditorDialog = new AddresseeEditorDialog( this, parent, 1529 mEditorDialog = new AddresseeEditorDialog( this, parent,
1530 name ? name : "editorDialog" ); 1530 name ? name : "editorDialog" );
1531 1531
1532 1532
1533 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1533 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1534 SLOT( contactModified( const KABC::Addressee& ) ) ); 1534 SLOT( contactModified( const KABC::Addressee& ) ) );
1535 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1535 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1536 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1536 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1537 } 1537 }
1538 1538
1539 return mEditorDialog; 1539 return mEditorDialog;
1540} 1540}
1541 1541
1542void KABCore::slotEditorDestroyed( const QString &uid ) 1542void KABCore::slotEditorDestroyed( const QString &uid )
1543{ 1543{
1544 //mEditorDict.remove( uid ); 1544 //mEditorDict.remove( uid );
1545} 1545}
1546 1546
1547void KABCore::initGUI() 1547void KABCore::initGUI()
1548{ 1548{
1549#ifndef KAB_EMBEDDED 1549#ifndef KAB_EMBEDDED
1550 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1550 QHBoxLayout *topLayout = new QHBoxLayout( this );
1551 topLayout->setSpacing( KDialogBase::spacingHint() ); 1551 topLayout->setSpacing( KDialogBase::spacingHint() );
1552 1552
1553 mExtensionBarSplitter = new QSplitter( this ); 1553 mExtensionBarSplitter = new QSplitter( this );
1554 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1554 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1555 1555
1556 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1556 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1557 1557
1558 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1558 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1559 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1559 mIncSearchWidget = new IncSearchWidget( viewSpace );
1560 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1560 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1561 SLOT( incrementalSearch( const QString& ) ) ); 1561 SLOT( incrementalSearch( const QString& ) ) );
1562 1562
1563 mViewManager = new ViewManager( this, viewSpace ); 1563 mViewManager = new ViewManager( this, viewSpace );
1564 viewSpace->setStretchFactor( mViewManager, 1 ); 1564 viewSpace->setStretchFactor( mViewManager, 1 );
1565 1565
1566 mDetails = new ViewContainer( mDetailsSplitter ); 1566 mDetails = new ViewContainer( mDetailsSplitter );
1567 1567
1568 mJumpButtonBar = new JumpButtonBar( this, this ); 1568 mJumpButtonBar = new JumpButtonBar( this, this );
1569 1569
1570 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1570 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1571 1571
1572 topLayout->addWidget( mExtensionBarSplitter ); 1572 topLayout->addWidget( mExtensionBarSplitter );
1573 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1573 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1574 topLayout->addWidget( mJumpButtonBar ); 1574 topLayout->addWidget( mJumpButtonBar );
1575 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1575 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1576 1576
1577 mXXPortManager = new XXPortManager( this, this ); 1577 mXXPortManager = new XXPortManager( this, this );
1578 1578
1579#else //KAB_EMBEDDED 1579#else //KAB_EMBEDDED
1580 //US initialize viewMenu before settingup viewmanager. 1580 //US initialize viewMenu before settingup viewmanager.
1581 // Viewmanager needs this menu to plugin submenues. 1581 // Viewmanager needs this menu to plugin submenues.
1582 viewMenu = new QPopupMenu( this ); 1582 viewMenu = new QPopupMenu( this );
1583 settingsMenu = new QPopupMenu( this ); 1583 settingsMenu = new QPopupMenu( this );
1584 //filterMenu = new QPopupMenu( this ); 1584 //filterMenu = new QPopupMenu( this );
1585 ImportMenu = new QPopupMenu( this ); 1585 ImportMenu = new QPopupMenu( this );
1586 ExportMenu = new QPopupMenu( this ); 1586 ExportMenu = new QPopupMenu( this );
1587 syncMenu = new QPopupMenu( this ); 1587 syncMenu = new QPopupMenu( this );
1588 changeMenu= new QPopupMenu( this ); 1588 changeMenu= new QPopupMenu( this );
1589 1589
1590//US since we have no splitter for the embedded system, setup 1590//US since we have no splitter for the embedded system, setup
1591// a layout with two frames. One left and one right. 1591// a layout with two frames. One left and one right.
1592 1592
1593 QBoxLayout *topLayout; 1593 QBoxLayout *topLayout;
1594 1594
1595 // = new QHBoxLayout( this ); 1595 // = new QHBoxLayout( this );
1596// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1596// QBoxLayout *topLayout = (QBoxLayout*)layout();
1597 1597
1598// QWidget *mainBox = new QWidget( this ); 1598// QWidget *mainBox = new QWidget( this );
1599// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1599// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1600 1600
1601#ifdef DESKTOP_VERSION 1601#ifdef DESKTOP_VERSION
1602 topLayout = new QHBoxLayout( this ); 1602 topLayout = new QHBoxLayout( this );
1603 1603
1604 1604
1605 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1605 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1606 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1606 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1607 1607
1608 topLayout->addWidget(mMiniSplitter ); 1608 topLayout->addWidget(mMiniSplitter );
1609 1609
1610 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1610 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1611 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1611 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1612 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1612 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1613 mDetails = new ViewContainer( mMiniSplitter ); 1613 mDetails = new ViewContainer( mMiniSplitter );
1614 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1614 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1615#else 1615#else
1616 if ( QApplication::desktop()->width() > 480 ) { 1616 if ( QApplication::desktop()->width() > 480 ) {
1617 topLayout = new QHBoxLayout( this ); 1617 topLayout = new QHBoxLayout( this );
1618 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1618 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1619 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1619 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1620 } else { 1620 } else {
1621 1621
1622 topLayout = new QHBoxLayout( this ); 1622 topLayout = new QHBoxLayout( this );
1623 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1623 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1624 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1624 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1625 } 1625 }
1626 1626
1627 topLayout->addWidget(mMiniSplitter ); 1627 topLayout->addWidget(mMiniSplitter );
1628 mViewManager = new ViewManager( this, mMiniSplitter ); 1628 mViewManager = new ViewManager( this, mMiniSplitter );
1629 mDetails = new ViewContainer( mMiniSplitter ); 1629 mDetails = new ViewContainer( mMiniSplitter );
1630 1630
1631 1631
1632 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1632 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1633#endif 1633#endif
1634 //eh->hide(); 1634 //eh->hide();
1635 // topLayout->addWidget(mExtensionManager ); 1635 // topLayout->addWidget(mExtensionManager );
1636 1636
1637 1637
1638/*US 1638/*US
1639#ifndef KAB_NOSPLITTER 1639#ifndef KAB_NOSPLITTER
1640 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1640 QHBoxLayout *topLayout = new QHBoxLayout( this );
1641//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1641//US topLayout->setSpacing( KDialogBase::spacingHint() );
1642 topLayout->setSpacing( 10 ); 1642 topLayout->setSpacing( 10 );
1643 1643
1644 mDetailsSplitter = new QSplitter( this ); 1644 mDetailsSplitter = new QSplitter( this );
1645 1645
1646 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1646 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1647 1647
1648 mViewManager = new ViewManager( this, viewSpace ); 1648 mViewManager = new ViewManager( this, viewSpace );
1649 viewSpace->setStretchFactor( mViewManager, 1 ); 1649 viewSpace->setStretchFactor( mViewManager, 1 );
1650 1650
1651 mDetails = new ViewContainer( mDetailsSplitter ); 1651 mDetails = new ViewContainer( mDetailsSplitter );
1652 1652
1653 topLayout->addWidget( mDetailsSplitter ); 1653 topLayout->addWidget( mDetailsSplitter );
1654 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1654 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1655#else //KAB_NOSPLITTER 1655#else //KAB_NOSPLITTER
1656 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1656 QHBoxLayout *topLayout = new QHBoxLayout( this );
1657//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1657//US topLayout->setSpacing( KDialogBase::spacingHint() );
1658 topLayout->setSpacing( 10 ); 1658 topLayout->setSpacing( 10 );
1659 1659
1660// mDetailsSplitter = new QSplitter( this ); 1660// mDetailsSplitter = new QSplitter( this );
1661 1661
1662 QVBox *viewSpace = new QVBox( this ); 1662 QVBox *viewSpace = new QVBox( this );
1663 1663
1664 mViewManager = new ViewManager( this, viewSpace ); 1664 mViewManager = new ViewManager( this, viewSpace );
1665 viewSpace->setStretchFactor( mViewManager, 1 ); 1665 viewSpace->setStretchFactor( mViewManager, 1 );
1666 1666
1667 mDetails = new ViewContainer( this ); 1667 mDetails = new ViewContainer( this );
1668 1668
1669 topLayout->addWidget( viewSpace ); 1669 topLayout->addWidget( viewSpace );
1670// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1670// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1671 topLayout->addWidget( mDetails ); 1671 topLayout->addWidget( mDetails );
1672#endif //KAB_NOSPLITTER 1672#endif //KAB_NOSPLITTER
1673*/ 1673*/
1674 1674
1675 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1675 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1676 syncManager->setBlockSave(false); 1676 syncManager->setBlockSave(false);
1677 1677
1678 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1678 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1679 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1679 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1680 syncManager->setDefaultFileName( sentSyncFile()); 1680 syncManager->setDefaultFileName( sentSyncFile());
1681 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1681 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1682 1682
1683#endif //KAB_EMBEDDED 1683#endif //KAB_EMBEDDED
1684 initActions(); 1684 initActions();
1685 1685
1686#ifdef KAB_EMBEDDED 1686#ifdef KAB_EMBEDDED
1687 addActionsManually(); 1687 addActionsManually();
1688 //US make sure the export and import menues are initialized before creating the xxPortManager. 1688 //US make sure the export and import menues are initialized before creating the xxPortManager.
1689 mXXPortManager = new XXPortManager( this, this ); 1689 mXXPortManager = new XXPortManager( this, this );
1690 1690
1691 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1691 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1692 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1692 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1693 // mActionQuit->plug ( mMainWindow->toolBar()); 1693 // mActionQuit->plug ( mMainWindow->toolBar());
1694 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1694 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1695 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1695 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1696 // mIncSearchWidget->hide(); 1696 // mIncSearchWidget->hide();
1697 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1697 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1698 SLOT( incrementalSearch( const QString& ) ) ); 1698 SLOT( incrementalSearch( const QString& ) ) );
1699 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1699 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1700 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1700 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1701 1701
1702 mJumpButtonBar = new JumpButtonBar( this, this ); 1702 mJumpButtonBar = new JumpButtonBar( this, this );
1703 1703
1704 topLayout->addWidget( mJumpButtonBar ); 1704 topLayout->addWidget( mJumpButtonBar );
1705//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1705//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1706 1706
1707// mMainWindow->getIconToolBar()->raise(); 1707// mMainWindow->getIconToolBar()->raise();
1708 1708
1709#endif //KAB_EMBEDDED 1709#endif //KAB_EMBEDDED
1710 1710
1711} 1711}
1712void KABCore::initActions() 1712void KABCore::initActions()
1713{ 1713{
1714//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1714//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1715 1715
1716#ifndef KAB_EMBEDDED 1716#ifndef KAB_EMBEDDED
1717 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1717 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1718 SLOT( clipboardDataChanged() ) ); 1718 SLOT( clipboardDataChanged() ) );
1719#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1720 1720
1721 // file menu 1721 // file menu
1722 if ( mIsPart ) { 1722 if ( mIsPart ) {
1723 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1723 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1724 SLOT( sendMail() ), actionCollection(), 1724 SLOT( sendMail() ), actionCollection(),
1725 "kaddressbook_mail" ); 1725 "kaddressbook_mail" );
1726 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1726 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1727 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1727 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1728 1728
1729 } else { 1729 } else {
1730 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1730 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1731 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1731 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1732 } 1732 }
1733 1733
1734 1734
1735 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1735 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1736 SLOT( save() ), actionCollection(), "file_sync" ); 1736 SLOT( save() ), actionCollection(), "file_sync" );
1737 1737
1738 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1738 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1739 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1739 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1740 1740
1741 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1741 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1742 this, SLOT( mailVCard() ), 1742 this, SLOT( mailVCard() ),
1743 actionCollection(), "file_mail_vcard"); 1743 actionCollection(), "file_mail_vcard");
1744 1744
1745 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1745 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1746 SLOT( export2phone() ), actionCollection(), 1746 SLOT( export2phone() ), actionCollection(),
1747 "kaddressbook_ex2phone" ); 1747 "kaddressbook_ex2phone" );
1748 1748
1749 mActionBeamVCard = 0; 1749 mActionBeamVCard = 0;
1750 mActionBeam = 0; 1750 mActionBeam = 0;
1751 1751
1752#ifndef DESKTOP_VERSION 1752#ifndef DESKTOP_VERSION
1753 if ( Ir::supported() ) { 1753 if ( Ir::supported() ) {
1754 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1754 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1755 SLOT( beamVCard() ), actionCollection(), 1755 SLOT( beamVCard() ), actionCollection(),
1756 "kaddressbook_beam_vcard" ); 1756 "kaddressbook_beam_vcard" );
1757 1757
1758 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1758 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1759 SLOT( beamMySelf() ), actionCollection(), 1759 SLOT( beamMySelf() ), actionCollection(),
1760 "kaddressbook_beam_myself" ); 1760 "kaddressbook_beam_myself" );
1761 } 1761 }
1762#endif 1762#endif
1763 1763
1764 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1764 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1765 this, SLOT( editContact2() ), 1765 this, SLOT( editContact2() ),
1766 actionCollection(), "file_properties" ); 1766 actionCollection(), "file_properties" );
1767 1767
1768#ifdef KAB_EMBEDDED 1768#ifdef KAB_EMBEDDED
1769 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1769 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1770 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1770 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1771 mMainWindow, SLOT( exit() ), 1771 mMainWindow, SLOT( exit() ),
1772 actionCollection(), "quit" ); 1772 actionCollection(), "quit" );
1773#endif //KAB_EMBEDDED 1773#endif //KAB_EMBEDDED
1774 1774
1775 // edit menu 1775 // edit menu
1776 if ( mIsPart ) { 1776 if ( mIsPart ) {
1777 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1777 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1778 SLOT( copyContacts() ), actionCollection(), 1778 SLOT( copyContacts() ), actionCollection(),
1779 "kaddressbook_copy" ); 1779 "kaddressbook_copy" );
1780 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1780 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1781 SLOT( cutContacts() ), actionCollection(), 1781 SLOT( cutContacts() ), actionCollection(),
1782 "kaddressbook_cut" ); 1782 "kaddressbook_cut" );
1783 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1783 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1784 SLOT( pasteContacts() ), actionCollection(), 1784 SLOT( pasteContacts() ), actionCollection(),
1785 "kaddressbook_paste" ); 1785 "kaddressbook_paste" );
1786 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1786 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1787 SLOT( selectAllContacts() ), actionCollection(), 1787 SLOT( selectAllContacts() ), actionCollection(),
1788 "kaddressbook_select_all" ); 1788 "kaddressbook_select_all" );
1789 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1789 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1790 SLOT( undo() ), actionCollection(), 1790 SLOT( undo() ), actionCollection(),
1791 "kaddressbook_undo" ); 1791 "kaddressbook_undo" );
1792 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1792 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1793 this, SLOT( redo() ), actionCollection(), 1793 this, SLOT( redo() ), actionCollection(),
1794 "kaddressbook_redo" ); 1794 "kaddressbook_redo" );
1795 } else { 1795 } else {
1796 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1796 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1797 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1797 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1798 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1798 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1799 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1799 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1800 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1800 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1801 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1801 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1802 } 1802 }
1803 1803
1804 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1804 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1805 Key_Delete, this, SLOT( deleteContacts() ), 1805 Key_Delete, this, SLOT( deleteContacts() ),
1806 actionCollection(), "edit_delete" ); 1806 actionCollection(), "edit_delete" );
1807 1807
1808 mActionUndo->setEnabled( false ); 1808 mActionUndo->setEnabled( false );
1809 mActionRedo->setEnabled( false ); 1809 mActionRedo->setEnabled( false );
1810 1810
1811 // settings menu 1811 // settings menu
1812#ifdef KAB_EMBEDDED 1812#ifdef KAB_EMBEDDED
1813//US special menuentry to configure the addressbook resources. On KDE 1813//US special menuentry to configure the addressbook resources. On KDE
1814// you do that through the control center !!! 1814// you do that through the control center !!!
1815 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1815 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1816 SLOT( configureResources() ), actionCollection(), 1816 SLOT( configureResources() ), actionCollection(),
1817 "kaddressbook_configure_resources" ); 1817 "kaddressbook_configure_resources" );
1818#endif //KAB_EMBEDDED 1818#endif //KAB_EMBEDDED
1819 1819
1820 if ( mIsPart ) { 1820 if ( mIsPart ) {
1821 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1821 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1822 SLOT( openConfigDialog() ), actionCollection(), 1822 SLOT( openConfigDialog() ), actionCollection(),
1823 "kaddressbook_configure" ); 1823 "kaddressbook_configure" );
1824 1824
1825 //US not implemented yet 1825 //US not implemented yet
1826 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1826 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1827 // this, SLOT( configureKeyBindings() ), actionCollection(), 1827 // this, SLOT( configureKeyBindings() ), actionCollection(),
1828 // "kaddressbook_configure_shortcuts" ); 1828 // "kaddressbook_configure_shortcuts" );
1829#ifdef KAB_EMBEDDED 1829#ifdef KAB_EMBEDDED
1830 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1830 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1831 mActionConfigureToolbars->setEnabled( false ); 1831 mActionConfigureToolbars->setEnabled( false );
1832#endif //KAB_EMBEDDED 1832#endif //KAB_EMBEDDED
1833 1833
1834 } else { 1834 } else {
1835 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1835 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1836 1836
1837 //US not implemented yet 1837 //US not implemented yet
1838 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1838 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1839 } 1839 }
1840 1840
1841 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1841 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1842 actionCollection(), "options_show_jump_bar" ); 1842 actionCollection(), "options_show_jump_bar" );
1843 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1843 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1844 1844
1845 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1845 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1846 actionCollection(), "options_show_details" ); 1846 actionCollection(), "options_show_details" );
1847 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1847 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1848 1848
1849 1849
1850 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1850 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1851 SLOT( toggleBeamReceive() ), actionCollection(), 1851 SLOT( toggleBeamReceive() ), actionCollection(),
1852 "kaddressbook_beam_rec" ); 1852 "kaddressbook_beam_rec" );
1853 1853
1854 1854
1855 // misc 1855 // misc
1856 // only enable LDAP lookup if we can handle the protocol 1856 // only enable LDAP lookup if we can handle the protocol
1857#ifndef KAB_EMBEDDED 1857#ifndef KAB_EMBEDDED
1858 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1858 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1859 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1859 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1860 this, SLOT( openLDAPDialog() ), actionCollection(), 1860 this, SLOT( openLDAPDialog() ), actionCollection(),
1861 "ldap_lookup" ); 1861 "ldap_lookup" );
1862 } 1862 }
1863#else //KAB_EMBEDDED 1863#else //KAB_EMBEDDED
1864 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1864 //qDebug("KABCore::initActions() LDAP has to be implemented");
1865#endif //KAB_EMBEDDED 1865#endif //KAB_EMBEDDED
1866 1866
1867 1867
1868 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1868 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1869 SLOT( setWhoAmI() ), actionCollection(), 1869 SLOT( setWhoAmI() ), actionCollection(),
1870 "set_personal" ); 1870 "set_personal" );
1871 1871
1872 1872
1873 1873
1874 1874
1875 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1875 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1876 SLOT( setCategories() ), actionCollection(), 1876 SLOT( setCategories() ), actionCollection(),
1877 "edit_set_categories" ); 1877 "edit_set_categories" );
1878 1878
1879 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1879 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1880 SLOT( removeVoice() ), actionCollection(), 1880 SLOT( removeVoice() ), actionCollection(),
1881 "remove_voice" ); 1881 "remove_voice" );
1882 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1882 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1883 SLOT( importFromOL() ), actionCollection(), 1883 SLOT( importFromOL() ), actionCollection(),
1884 "import_OL" ); 1884 "import_OL" );
1885#ifdef KAB_EMBEDDED 1885#ifdef KAB_EMBEDDED
1886 mActionLicence = new KAction( i18n( "Licence" ), 0, 1886 mActionLicence = new KAction( i18n( "Licence" ), 0,
1887 this, SLOT( showLicence() ), actionCollection(), 1887 this, SLOT( showLicence() ), actionCollection(),
1888 "licence_about_data" ); 1888 "licence_about_data" );
1889 mActionFaq = new KAction( i18n( "Faq" ), 0, 1889 mActionFaq = new KAction( i18n( "Faq" ), 0,
1890 this, SLOT( faq() ), actionCollection(), 1890 this, SLOT( faq() ), actionCollection(),
1891 "faq_about_data" ); 1891 "faq_about_data" );
1892 mActionWN = new KAction( i18n( "What's New?" ), 0, 1892 mActionWN = new KAction( i18n( "What's New?" ), 0,
1893 this, SLOT( whatsnew() ), actionCollection(), 1893 this, SLOT( whatsnew() ), actionCollection(),
1894 "wn" ); 1894 "wn" );
1895 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1895 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1896 this, SLOT( synchowto() ), actionCollection(), 1896 this, SLOT( synchowto() ), actionCollection(),
1897 "sync" ); 1897 "sync" );
1898 1898
1899 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1899 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1900 this, SLOT( createAboutData() ), actionCollection(), 1900 this, SLOT( createAboutData() ), actionCollection(),
1901 "kaddressbook_about_data" ); 1901 "kaddressbook_about_data" );
1902#endif //KAB_EMBEDDED 1902#endif //KAB_EMBEDDED
1903 1903
1904 clipboardDataChanged(); 1904 clipboardDataChanged();
1905 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1905 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1906 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1906 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1907} 1907}
1908 1908
1909//US we need this function, to plug all actions into the correct menues. 1909//US we need this function, to plug all actions into the correct menues.
1910// KDE uses a XML format to plug the actions, but we work her without this overhead. 1910// KDE uses a XML format to plug the actions, but we work her without this overhead.
1911void KABCore::addActionsManually() 1911void KABCore::addActionsManually()
1912{ 1912{
1913//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1913//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1914 1914
1915#ifdef KAB_EMBEDDED 1915#ifdef KAB_EMBEDDED
1916 QPopupMenu *fileMenu = new QPopupMenu( this ); 1916 QPopupMenu *fileMenu = new QPopupMenu( this );
1917 QPopupMenu *editMenu = new QPopupMenu( this ); 1917 QPopupMenu *editMenu = new QPopupMenu( this );
1918 QPopupMenu *helpMenu = new QPopupMenu( this ); 1918 QPopupMenu *helpMenu = new QPopupMenu( this );
1919 1919
1920 KToolBar* tb = mMainWindow->toolBar(); 1920 KToolBar* tb = mMainWindow->toolBar();
1921 1921
1922#ifdef DESKTOP_VERSION
1923 QMenuBar* mb = mMainWindow->menuBar();
1924
1925 //US setup menubar.
1926 //Disable the following block if you do not want to have a menubar.
1927 mb->insertItem( "&File", fileMenu );
1928 mb->insertItem( "&Edit", editMenu );
1929 mb->insertItem( "&View", viewMenu );
1930 mb->insertItem( "&Settings", settingsMenu );
1931 mb->insertItem( i18n("Synchronize"), syncMenu );
1932 mb->insertItem( "&Change selected", changeMenu );
1933 mb->insertItem( "&Help", helpMenu );
1934 mIncSearchWidget = new IncSearchWidget( tb );
1935 // tb->insertWidget(-1, 0, mIncSearchWidget);
1936
1937#else
1938 //US setup toolbar
1939 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1940 QPopupMenu *popupBarTB = new QPopupMenu( this );
1941 menuBarTB->insertItem( "ME", popupBarTB);
1942 tb->insertWidget(-1, 0, menuBarTB);
1943 mIncSearchWidget = new IncSearchWidget( tb );
1944 1922
1945 tb->enableMoving(false); 1923 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
1946 popupBarTB->insertItem( "&File", fileMenu ); 1924 QMenuBar* mb = mMainWindow->menuBar();
1947 popupBarTB->insertItem( "&Edit", editMenu ); 1925
1948 popupBarTB->insertItem( "&View", viewMenu ); 1926 //US setup menubar.
1949 popupBarTB->insertItem( "&Settings", settingsMenu ); 1927 //Disable the following block if you do not want to have a menubar.
1950 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1928 mb->insertItem( "&File", fileMenu );
1951 mViewManager->getFilterAction()->plug ( popupBarTB); 1929 mb->insertItem( "&Edit", editMenu );
1952 popupBarTB->insertItem( "&Change selected", changeMenu ); 1930 mb->insertItem( "&View", viewMenu );
1953 popupBarTB->insertItem( "&Help", helpMenu ); 1931 mb->insertItem( "&Settings", settingsMenu );
1954 if (QApplication::desktop()->width() > 320 ) { 1932 mb->insertItem( i18n("Synchronize"), syncMenu );
1955 // mViewManager->getFilterAction()->plug ( tb); 1933 mb->insertItem( "&Change selected", changeMenu );
1934 mb->insertItem( "&Help", helpMenu );
1935 mIncSearchWidget = new IncSearchWidget( tb );
1936 // tb->insertWidget(-1, 0, mIncSearchWidget);
1937
1938 } else {
1939 //US setup toolbar
1940 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1941 QPopupMenu *popupBarTB = new QPopupMenu( this );
1942 menuBarTB->insertItem( "ME", popupBarTB);
1943 tb->insertWidget(-1, 0, menuBarTB);
1944 mIncSearchWidget = new IncSearchWidget( tb );
1945
1946 tb->enableMoving(false);
1947 popupBarTB->insertItem( "&File", fileMenu );
1948 popupBarTB->insertItem( "&Edit", editMenu );
1949 popupBarTB->insertItem( "&View", viewMenu );
1950 popupBarTB->insertItem( "&Settings", settingsMenu );
1951 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1952 mViewManager->getFilterAction()->plug ( popupBarTB);
1953 popupBarTB->insertItem( "&Change selected", changeMenu );
1954 popupBarTB->insertItem( "&Help", helpMenu );
1955 if (QApplication::desktop()->width() > 320 ) {
1956 // mViewManager->getFilterAction()->plug ( tb);
1957 }
1956 } 1958 }
1957#endif
1958 // mActionQuit->plug ( mMainWindow->toolBar()); 1959 // mActionQuit->plug ( mMainWindow->toolBar());
1959 1960
1960 1961
1961 1962
1962 //US Now connect the actions with the menue entries. 1963 //US Now connect the actions with the menue entries.
1963 mActionPrint->plug( fileMenu ); 1964 mActionPrint->plug( fileMenu );
1964 mActionMail->plug( fileMenu ); 1965 mActionMail->plug( fileMenu );
1965 fileMenu->insertSeparator(); 1966 fileMenu->insertSeparator();
1966 1967
1967 mActionNewContact->plug( fileMenu ); 1968 mActionNewContact->plug( fileMenu );
1968 mActionNewContact->plug( tb ); 1969 mActionNewContact->plug( tb );
1969 1970
1970 mActionEditAddressee->plug( fileMenu ); 1971 mActionEditAddressee->plug( fileMenu );
1971 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1972 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1972 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1973 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1973 mActionEditAddressee->plug( tb ); 1974 mActionEditAddressee->plug( tb );
1974 1975
1975 fileMenu->insertSeparator(); 1976 fileMenu->insertSeparator();
1976 mActionSave->plug( fileMenu ); 1977 mActionSave->plug( fileMenu );
1977 fileMenu->insertItem( "&Import", ImportMenu ); 1978 fileMenu->insertItem( "&Import", ImportMenu );
1978 fileMenu->insertItem( "&Export", ExportMenu ); 1979 fileMenu->insertItem( "&Export", ExportMenu );
1979 fileMenu->insertSeparator(); 1980 fileMenu->insertSeparator();
1980 mActionMailVCard->plug( fileMenu ); 1981 mActionMailVCard->plug( fileMenu );
1981#ifndef DESKTOP_VERSION 1982#ifndef DESKTOP_VERSION
1982 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1983 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1983 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1984 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1984#endif 1985#endif
1985 fileMenu->insertSeparator(); 1986 fileMenu->insertSeparator();
1986 mActionQuit->plug( fileMenu ); 1987 mActionQuit->plug( fileMenu );
1987#ifdef _WIN32_ 1988#ifdef _WIN32_
1988 mActionImportOL->plug( ImportMenu ); 1989 mActionImportOL->plug( ImportMenu );
1989#endif 1990#endif
1990 // edit menu 1991 // edit menu
1991 mActionUndo->plug( editMenu ); 1992 mActionUndo->plug( editMenu );
1992 mActionRedo->plug( editMenu ); 1993 mActionRedo->plug( editMenu );
1993 editMenu->insertSeparator(); 1994 editMenu->insertSeparator();
1994 mActionCut->plug( editMenu ); 1995 mActionCut->plug( editMenu );
1995 mActionCopy->plug( editMenu ); 1996 mActionCopy->plug( editMenu );
1996 mActionPaste->plug( editMenu ); 1997 mActionPaste->plug( editMenu );
1997 mActionDelete->plug( editMenu ); 1998 mActionDelete->plug( editMenu );
1998 editMenu->insertSeparator(); 1999 editMenu->insertSeparator();
1999 mActionSelectAll->plug( editMenu ); 2000 mActionSelectAll->plug( editMenu );
2000 2001
2001 mActionRemoveVoice->plug( changeMenu ); 2002 mActionRemoveVoice->plug( changeMenu );
2002 // settings menu 2003 // settings menu
2003//US special menuentry to configure the addressbook resources. On KDE 2004//US special menuentry to configure the addressbook resources. On KDE
2004// you do that through the control center !!! 2005// you do that through the control center !!!
2005 mActionConfigResources->plug( settingsMenu ); 2006 mActionConfigResources->plug( settingsMenu );
2006 settingsMenu->insertSeparator(); 2007 settingsMenu->insertSeparator();
2007 2008
2008 mActionConfigKAddressbook->plug( settingsMenu ); 2009 mActionConfigKAddressbook->plug( settingsMenu );
2009 2010
2010 if ( mIsPart ) { 2011 if ( mIsPart ) {
2011 //US not implemented yet 2012 //US not implemented yet
2012 //mActionConfigShortcuts->plug( settingsMenu ); 2013 //mActionConfigShortcuts->plug( settingsMenu );
2013 //mActionConfigureToolbars->plug( settingsMenu ); 2014 //mActionConfigureToolbars->plug( settingsMenu );
2014 2015
2015 } else { 2016 } else {
2016 //US not implemented yet 2017 //US not implemented yet
2017 //mActionKeyBindings->plug( settingsMenu ); 2018 //mActionKeyBindings->plug( settingsMenu );
2018 } 2019 }
2019 2020
2020 settingsMenu->insertSeparator(); 2021 settingsMenu->insertSeparator();
2021 2022
2022 mActionJumpBar->plug( settingsMenu ); 2023 mActionJumpBar->plug( settingsMenu );
2023 mActionDetails->plug( settingsMenu ); 2024 mActionDetails->plug( settingsMenu );
2024 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2025 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2025 mActionDetails->plug( tb ); 2026 mActionDetails->plug( tb );
2026 settingsMenu->insertSeparator(); 2027 settingsMenu->insertSeparator();
2027 mActionBR->plug(settingsMenu ); 2028 mActionBR->plug(settingsMenu );
2028 settingsMenu->insertSeparator(); 2029 settingsMenu->insertSeparator();
2029 2030
2030 mActionWhoAmI->plug( settingsMenu ); 2031 mActionWhoAmI->plug( settingsMenu );
2031 mActionCategories->plug( settingsMenu ); 2032 mActionCategories->plug( settingsMenu );
2032 2033
2033 2034
2034 mActionWN->plug( helpMenu ); 2035 mActionWN->plug( helpMenu );
2035 mActionSyncHowto->plug( helpMenu ); 2036 mActionSyncHowto->plug( helpMenu );
2036 mActionLicence->plug( helpMenu ); 2037 mActionLicence->plug( helpMenu );
2037 mActionFaq->plug( helpMenu ); 2038 mActionFaq->plug( helpMenu );
2038 mActionAboutKAddressbook->plug( helpMenu ); 2039 mActionAboutKAddressbook->plug( helpMenu );
2039 2040
2040 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2041 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2041 2042
2042 mActionSave->plug( tb ); 2043 mActionSave->plug( tb );
2043 mViewManager->getFilterAction()->plug ( tb); 2044 mViewManager->getFilterAction()->plug ( tb);
2044 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2045 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2045 mActionUndo->plug( tb ); 2046 mActionUndo->plug( tb );
2046 mActionDelete->plug( tb ); 2047 mActionDelete->plug( tb );
2047 mActionRedo->plug( tb ); 2048 mActionRedo->plug( tb );
2048 } 2049 }
2049 } else { 2050 } else {
2050 if (KABPrefs::instance()->mMultipleViewsAtOnce ) 2051 mActionSave->plug( tb );
2051 mActionSave->plug( tb ); 2052 tb->enableMoving(false);
2052 } 2053 }
2053 //mActionQuit->plug ( tb ); 2054 //mActionQuit->plug ( tb );
2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2055 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2055 2056
2056 //US link the searchwidget first to this. 2057 //US link the searchwidget first to this.
2057 // The real linkage to the toolbar happens later. 2058 // The real linkage to the toolbar happens later.
2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2059//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2059//US tb->insertItem( mIncSearchWidget ); 2060//US tb->insertItem( mIncSearchWidget );
2060/*US 2061/*US
2061 mIncSearchWidget = new IncSearchWidget( tb ); 2062 mIncSearchWidget = new IncSearchWidget( tb );
2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2063 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2063 SLOT( incrementalSearch( const QString& ) ) ); 2064 SLOT( incrementalSearch( const QString& ) ) );
2064 2065
2065 mJumpButtonBar = new JumpButtonBar( this, this ); 2066 mJumpButtonBar = new JumpButtonBar( this, this );
2066 2067
2067//US topLayout->addWidget( mJumpButtonBar ); 2068//US topLayout->addWidget( mJumpButtonBar );
2068 this->layout()->add( mJumpButtonBar ); 2069 this->layout()->add( mJumpButtonBar );
2069*/ 2070*/
2070 2071
2071#endif //KAB_EMBEDDED 2072#endif //KAB_EMBEDDED
2072 2073
2073 mActionExport2phone->plug( ExportMenu ); 2074 mActionExport2phone->plug( ExportMenu );
2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2075 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2075 syncManager->fillSyncMenu(); 2076 syncManager->fillSyncMenu();
2076 2077
2077} 2078}
2078void KABCore::showLicence() 2079void KABCore::showLicence()
2079{ 2080{
2080 KApplication::showLicence(); 2081 KApplication::showLicence();
2081} 2082}
2082void KABCore::removeVoice() 2083void KABCore::removeVoice()
2083{ 2084{
2084 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 ) 2085 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 )
2085 return; 2086 return;
2086 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2087 KABC::Addressee::List list = mViewManager->selectedAddressees();
2087 KABC::Addressee::List::Iterator it; 2088 KABC::Addressee::List::Iterator it;
2088 for ( it = list.begin(); it != list.end(); ++it ) { 2089 for ( it = list.begin(); it != list.end(); ++it ) {
2089 2090
2090 if ( (*it).removeVoice() ) 2091 if ( (*it).removeVoice() )
2091 contactModified((*it) ); 2092 contactModified((*it) );
2092 } 2093 }
2093} 2094}
2094 2095
2095 2096
2096 2097
2097void KABCore::clipboardDataChanged() 2098void KABCore::clipboardDataChanged()
2098{ 2099{
2099 2100
2100 if ( mReadWrite ) 2101 if ( mReadWrite )
2101 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2102 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2102 2103
2103} 2104}
2104 2105
2105void KABCore::updateActionMenu() 2106void KABCore::updateActionMenu()
2106{ 2107{
2107 UndoStack *undo = UndoStack::instance(); 2108 UndoStack *undo = UndoStack::instance();
2108 RedoStack *redo = RedoStack::instance(); 2109 RedoStack *redo = RedoStack::instance();
2109 2110
2110 if ( undo->isEmpty() ) 2111 if ( undo->isEmpty() )
2111 mActionUndo->setText( i18n( "Undo" ) ); 2112 mActionUndo->setText( i18n( "Undo" ) );
2112 else 2113 else
2113 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2114 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2114 2115
2115 mActionUndo->setEnabled( !undo->isEmpty() ); 2116 mActionUndo->setEnabled( !undo->isEmpty() );
2116 2117
2117 if ( !redo->top() ) 2118 if ( !redo->top() )
2118 mActionRedo->setText( i18n( "Redo" ) ); 2119 mActionRedo->setText( i18n( "Redo" ) );
2119 else 2120 else
2120 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2121 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2121 2122
2122 mActionRedo->setEnabled( !redo->isEmpty() ); 2123 mActionRedo->setEnabled( !redo->isEmpty() );
2123} 2124}
2124 2125
2125void KABCore::configureKeyBindings() 2126void KABCore::configureKeyBindings()
2126{ 2127{
2127#ifndef KAB_EMBEDDED 2128#ifndef KAB_EMBEDDED
2128 KKeyDialog::configure( actionCollection(), true ); 2129 KKeyDialog::configure( actionCollection(), true );
2129#else //KAB_EMBEDDED 2130#else //KAB_EMBEDDED
2130 qDebug("KABCore::configureKeyBindings() not implemented"); 2131 qDebug("KABCore::configureKeyBindings() not implemented");
2131#endif //KAB_EMBEDDED 2132#endif //KAB_EMBEDDED
2132} 2133}
2133 2134
2134#ifdef KAB_EMBEDDED 2135#ifdef KAB_EMBEDDED
2135void KABCore::configureResources() 2136void KABCore::configureResources()
2136{ 2137{
2137 KRES::KCMKResources dlg( this, "" , 0 ); 2138 KRES::KCMKResources dlg( this, "" , 0 );
2138 2139
2139 if ( !dlg.exec() ) 2140 if ( !dlg.exec() )
2140 return; 2141 return;
2141 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2142 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2142} 2143}
2143#endif //KAB_EMBEDDED 2144#endif //KAB_EMBEDDED
2144 2145
2145 2146
2146/* this method will be called through the QCop interface from Ko/Pi to select addresses 2147/* this method will be called through the QCop interface from Ko/Pi to select addresses
2147 * for the attendees list of an event. 2148 * for the attendees list of an event.
2148 */ 2149 */
2149void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2150void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2150{ 2151{
2151 QStringList nameList; 2152 QStringList nameList;
2152 QStringList emailList; 2153 QStringList emailList;
2153 QStringList uidList; 2154 QStringList uidList;
2154 2155
2155 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2156 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2156 uint i=0; 2157 uint i=0;
2157 for (i=0; i < list.count(); i++) 2158 for (i=0; i < list.count(); i++)
2158 { 2159 {
2159 nameList.append(list[i].realName()); 2160 nameList.append(list[i].realName());
2160 emailList.append(list[i].preferredEmail()); 2161 emailList.append(list[i].preferredEmail());
2161 uidList.append(list[i].uid()); 2162 uidList.append(list[i].uid());
2162 } 2163 }
2163 2164
2164 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2165 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2165 2166
2166} 2167}
2167 2168
2168/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2169/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2169 * to put them into the calendar. 2170 * to put them into the calendar.
2170 */ 2171 */
2171void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2172void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2172{ 2173{
2173 // qDebug("KABCore::requestForBirthdayList"); 2174 // qDebug("KABCore::requestForBirthdayList");
2174 QStringList birthdayList; 2175 QStringList birthdayList;
2175 QStringList anniversaryList; 2176 QStringList anniversaryList;
2176 QStringList realNameList; 2177 QStringList realNameList;
2177 QStringList preferredEmailList; 2178 QStringList preferredEmailList;
2178 QStringList assembledNameList; 2179 QStringList assembledNameList;
2179 QStringList uidList; 2180 QStringList uidList;
2180 2181
2181 KABC::AddressBook::Iterator it; 2182 KABC::AddressBook::Iterator it;
2182 2183
2183 int count = 0; 2184 int count = 0;
2184 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2185 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2185 ++count; 2186 ++count;
2186 } 2187 }
2187 QProgressBar bar(count,0 ); 2188 QProgressBar bar(count,0 );
2188 int w = 300; 2189 int w = 300;
2189 if ( QApplication::desktop()->width() < 320 ) 2190 if ( QApplication::desktop()->width() < 320 )
2190 w = 220; 2191 w = 220;
2191 int h = bar.sizeHint().height() ; 2192 int h = bar.sizeHint().height() ;
2192 int dw = QApplication::desktop()->width(); 2193 int dw = QApplication::desktop()->width();
2193 int dh = QApplication::desktop()->height(); 2194 int dh = QApplication::desktop()->height();
2194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2195 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2195 bar.show(); 2196 bar.show();
2196 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2197 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2197 qApp->processEvents(); 2198 qApp->processEvents();
2198 2199
2199 QDate bday; 2200 QDate bday;
2200 QString anni; 2201 QString anni;
2201 QString formattedbday; 2202 QString formattedbday;
2202 2203
2203 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2204 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2204 { 2205 {
2205 if ( ! bar.isVisible() ) 2206 if ( ! bar.isVisible() )
2206 return; 2207 return;
2207 bar.setProgress( count++ ); 2208 bar.setProgress( count++ );
2208 qApp->processEvents(); 2209 qApp->processEvents();
2209 bday = (*it).birthday().date(); 2210 bday = (*it).birthday().date();
2210 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2211 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2211 2212
2212 if ( bday.isValid() || !anni.isEmpty()) 2213 if ( bday.isValid() || !anni.isEmpty())
2213 { 2214 {
2214 if (bday.isValid()) 2215 if (bday.isValid())
2215 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2216 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2216 else 2217 else
2217 formattedbday = "NOTVALID"; 2218 formattedbday = "NOTVALID";
2218 if (anni.isEmpty()) 2219 if (anni.isEmpty())
2219 anni = "INVALID"; 2220 anni = "INVALID";
2220 2221
2221 birthdayList.append(formattedbday); 2222 birthdayList.append(formattedbday);
2222 anniversaryList.append(anni); //should be ISODate 2223 anniversaryList.append(anni); //should be ISODate
2223 realNameList.append((*it).realName()); 2224 realNameList.append((*it).realName());
2224 preferredEmailList.append((*it).preferredEmail()); 2225 preferredEmailList.append((*it).preferredEmail());
2225 assembledNameList.append((*it).assembledName()); 2226 assembledNameList.append((*it).assembledName());
2226 uidList.append((*it).uid()); 2227 uidList.append((*it).uid());
2227 2228
2228 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() ); 2229 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() );
2229 } 2230 }
2230 } 2231 }
2231 2232
2232 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2233 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2233 2234
2234} 2235}
2235 2236
2236/* this method will be called through the QCop interface from other apps to show details of a contact. 2237/* this method will be called through the QCop interface from other apps to show details of a contact.
2237 */ 2238 */
2238void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2239void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2239{ 2240{
2240 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2241 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2241 2242
2242 QString foundUid = QString::null; 2243 QString foundUid = QString::null;
2243 if ( ! uid.isEmpty() ) { 2244 if ( ! uid.isEmpty() ) {
2244 Addressee adrr = mAddressBook->findByUid( uid ); 2245 Addressee adrr = mAddressBook->findByUid( uid );
2245 if ( !adrr.isEmpty() ) { 2246 if ( !adrr.isEmpty() ) {
2246 foundUid = uid; 2247 foundUid = uid;
2247 } 2248 }
2248 if ( email == "sendbacklist" ) { 2249 if ( email == "sendbacklist" ) {
2249 //qDebug("ssssssssssssssssssssssend "); 2250 //qDebug("ssssssssssssssssssssssend ");
2250 QStringList nameList; 2251 QStringList nameList;
2251 QStringList emailList; 2252 QStringList emailList;
2252 QStringList uidList; 2253 QStringList uidList;
2253 nameList.append(adrr.realName()); 2254 nameList.append(adrr.realName());
2254 emailList = adrr.emails(); 2255 emailList = adrr.emails();
2255 uidList.append( adrr.preferredEmail()); 2256 uidList.append( adrr.preferredEmail());
2256 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2257 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2257 return; 2258 return;
2258 } 2259 }
2259 2260
2260 } 2261 }
2261 2262
2262 if ( email == "sendbacklist" ) 2263 if ( email == "sendbacklist" )
2263 return; 2264 return;
2264 if (foundUid.isEmpty()) 2265 if (foundUid.isEmpty())
2265 { 2266 {
2266 //find the uid of the person first 2267 //find the uid of the person first
2267 Addressee::List namelist; 2268 Addressee::List namelist;
2268 Addressee::List emaillist; 2269 Addressee::List emaillist;
2269 2270
2270 if (!name.isEmpty()) 2271 if (!name.isEmpty())
2271 namelist = mAddressBook->findByName( name ); 2272 namelist = mAddressBook->findByName( name );
2272 2273
2273 if (!email.isEmpty()) 2274 if (!email.isEmpty())
2274 emaillist = mAddressBook->findByEmail( email ); 2275 emaillist = mAddressBook->findByEmail( email );
2275 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2276 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2276 //check if we have a match in Namelist and Emaillist 2277 //check if we have a match in Namelist and Emaillist
2277 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2278 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2278 foundUid = emaillist[0].uid(); 2279 foundUid = emaillist[0].uid();
2279 } 2280 }
2280 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2281 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2281 foundUid = namelist[0].uid(); 2282 foundUid = namelist[0].uid();
2282 else 2283 else
2283 { 2284 {
2284 for (int i = 0; i < namelist.count(); i++) 2285 for (int i = 0; i < namelist.count(); i++)
2285 { 2286 {
2286 for (int j = 0; j < emaillist.count(); j++) 2287 for (int j = 0; j < emaillist.count(); j++)
2287 { 2288 {
2288 if (namelist[i] == emaillist[j]) 2289 if (namelist[i] == emaillist[j])
2289 { 2290 {
2290 foundUid = namelist[i].uid(); 2291 foundUid = namelist[i].uid();
2291 } 2292 }
2292 } 2293 }
2293 } 2294 }
2294 } 2295 }
2295 } 2296 }
2296 else 2297 else
2297 { 2298 {
2298 foundUid = uid; 2299 foundUid = uid;
2299 } 2300 }
2300 2301
2301 if (!foundUid.isEmpty()) 2302 if (!foundUid.isEmpty())
2302 { 2303 {
2303 2304
2304 // raise Ka/Pi if it is in the background 2305 // raise Ka/Pi if it is in the background
2305#ifndef DESKTOP_VERSION 2306#ifndef DESKTOP_VERSION
2306#ifndef KORG_NODCOP 2307#ifndef KORG_NODCOP
2307 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2308 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2308#endif 2309#endif
2309#endif 2310#endif
2310 2311
2311 mMainWindow->showMaximized(); 2312 mMainWindow->showMaximized();
2312 mMainWindow-> raise(); 2313 mMainWindow-> raise();
2313 2314
2314 mViewManager->setSelected( "", false); 2315 mViewManager->setSelected( "", false);
2315 mViewManager->refreshView( "" ); 2316 mViewManager->refreshView( "" );
2316 mViewManager->setSelected( foundUid, true ); 2317 mViewManager->setSelected( foundUid, true );
2317 mViewManager->refreshView( foundUid ); 2318 mViewManager->refreshView( foundUid );
2318 2319
2319 if ( !mMultipleViewsAtOnce ) 2320 if ( !mMultipleViewsAtOnce )
2320 { 2321 {
2321 setDetailsVisible( true ); 2322 setDetailsVisible( true );
2322 mActionDetails->setChecked(true); 2323 mActionDetails->setChecked(true);
2323 } 2324 }
2324 } 2325 }
2325} 2326}
2326 2327
2327void KABCore::whatsnew() 2328void KABCore::whatsnew()
2328{ 2329{
2329 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2330 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2330} 2331}
2331void KABCore::synchowto() 2332void KABCore::synchowto()
2332{ 2333{
2333 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2334 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2334} 2335}
2335 2336
2336void KABCore::faq() 2337void KABCore::faq()
2337{ 2338{
2338 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2339 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2339} 2340}
2340 2341
2341#include <libkcal/syncdefines.h> 2342#include <libkcal/syncdefines.h>
2342 2343
2343KABC::Addressee KABCore::getLastSyncAddressee() 2344KABC::Addressee KABCore::getLastSyncAddressee()
2344{ 2345{
2345 Addressee lse; 2346 Addressee lse;
2346 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2347 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2347 2348
2348 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2349 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2349 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2350 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2350 if (lse.isEmpty()) { 2351 if (lse.isEmpty()) {
2351 qDebug("Creating new last-syncAddressee "); 2352 qDebug("Creating new last-syncAddressee ");
2352 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2353 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2353 QString sum = ""; 2354 QString sum = "";
2354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2355 sum = "E: "; 2356 sum = "E: ";
2356 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2357 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2357 lse.setRevision( mLastAddressbookSync ); 2358 lse.setRevision( mLastAddressbookSync );
2358 lse.setCategories( i18n("SyncEvent") ); 2359 lse.setCategories( i18n("SyncEvent") );
2359 mAddressBook->insertAddressee( lse ); 2360 mAddressBook->insertAddressee( lse );
2360 } 2361 }
2361 return lse; 2362 return lse;
2362} 2363}
2363int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2364int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2364{ 2365{
2365 2366
2366 //void setZaurusId(int id); 2367 //void setZaurusId(int id);
2367 // int zaurusId() const; 2368 // int zaurusId() const;
2368 // void setZaurusUid(int id); 2369 // void setZaurusUid(int id);
2369 // int zaurusUid() const; 2370 // int zaurusUid() const;
2370 // void setZaurusStat(int id); 2371 // void setZaurusStat(int id);
2371 // int zaurusStat() const; 2372 // int zaurusStat() const;
2372 // 0 equal 2373 // 0 equal
2373 // 1 take local 2374 // 1 take local
2374 // 2 take remote 2375 // 2 take remote
2375 // 3 cancel 2376 // 3 cancel
2376 QDateTime lastSync = mLastAddressbookSync; 2377 QDateTime lastSync = mLastAddressbookSync;
2377 QDateTime localMod = local->revision(); 2378 QDateTime localMod = local->revision();
2378 QDateTime remoteMod = remote->revision(); 2379 QDateTime remoteMod = remote->revision();
2379 2380
2380 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2381 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2381 2382
2382 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2383 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2383 bool remCh, locCh; 2384 bool remCh, locCh;
2384 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2385 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2385 2386
2386 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2387 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2387 locCh = ( localMod > mLastAddressbookSync ); 2388 locCh = ( localMod > mLastAddressbookSync );
2388 if ( !remCh && ! locCh ) { 2389 if ( !remCh && ! locCh ) {
2389 //qDebug("both not changed "); 2390 //qDebug("both not changed ");
2390 lastSync = localMod.addDays(1); 2391 lastSync = localMod.addDays(1);
2391 if ( mode <= SYNC_PREF_ASK ) 2392 if ( mode <= SYNC_PREF_ASK )
2392 return 0; 2393 return 0;
2393 } else { 2394 } else {
2394 if ( locCh ) { 2395 if ( locCh ) {
2395 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2396 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2396 lastSync = localMod.addDays( -1 ); 2397 lastSync = localMod.addDays( -1 );
2397 if ( !remCh ) 2398 if ( !remCh )
2398 remoteMod =( lastSync.addDays( -1 ) ); 2399 remoteMod =( lastSync.addDays( -1 ) );
2399 } else { 2400 } else {
2400 //qDebug(" not loc changed "); 2401 //qDebug(" not loc changed ");
2401 lastSync = localMod.addDays( 1 ); 2402 lastSync = localMod.addDays( 1 );
2402 if ( remCh ) 2403 if ( remCh )
2403 remoteMod =( lastSync.addDays( 1 ) ); 2404 remoteMod =( lastSync.addDays( 1 ) );
2404 2405
2405 } 2406 }
2406 } 2407 }
2407 full = true; 2408 full = true;
2408 if ( mode < SYNC_PREF_ASK ) 2409 if ( mode < SYNC_PREF_ASK )
2409 mode = SYNC_PREF_ASK; 2410 mode = SYNC_PREF_ASK;
2410 } else { 2411 } else {
2411 if ( localMod == remoteMod ) 2412 if ( localMod == remoteMod )
2412 return 0; 2413 return 0;
2413 2414
2414 } 2415 }
2415 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2416 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2416 2417
2417 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2418 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2418 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2419 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2419 //full = true; //debug only 2420 //full = true; //debug only
2420 if ( full ) { 2421 if ( full ) {
2421 bool equ = ( (*local) == (*remote) ); 2422 bool equ = ( (*local) == (*remote) );
2422 if ( equ ) { 2423 if ( equ ) {
2423 //qDebug("equal "); 2424 //qDebug("equal ");
2424 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2425 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2425 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2426 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2426 } 2427 }
2427 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2428 if ( mode < SYNC_PREF_FORCE_LOCAL )
2428 return 0; 2429 return 0;
2429 2430
2430 }//else //debug only 2431 }//else //debug only
2431 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2432 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2432 } 2433 }
2433 int result; 2434 int result;
2434 bool localIsNew; 2435 bool localIsNew;
2435 //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() ); 2436 //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() );
2436 2437
2437 if ( full && mode < SYNC_PREF_NEWEST ) 2438 if ( full && mode < SYNC_PREF_NEWEST )
2438 mode = SYNC_PREF_ASK; 2439 mode = SYNC_PREF_ASK;
2439 2440
2440 switch( mode ) { 2441 switch( mode ) {
2441 case SYNC_PREF_LOCAL: 2442 case SYNC_PREF_LOCAL:
2442 if ( lastSync > remoteMod ) 2443 if ( lastSync > remoteMod )
2443 return 1; 2444 return 1;
2444 if ( lastSync > localMod ) 2445 if ( lastSync > localMod )
2445 return 2; 2446 return 2;
2446 return 1; 2447 return 1;
2447 break; 2448 break;
2448 case SYNC_PREF_REMOTE: 2449 case SYNC_PREF_REMOTE:
2449 if ( lastSync > remoteMod ) 2450 if ( lastSync > remoteMod )
2450 return 1; 2451 return 1;
2451 if ( lastSync > localMod ) 2452 if ( lastSync > localMod )
2452 return 2; 2453 return 2;
2453 return 2; 2454 return 2;
2454 break; 2455 break;
2455 case SYNC_PREF_NEWEST: 2456 case SYNC_PREF_NEWEST:
2456 if ( localMod > remoteMod ) 2457 if ( localMod > remoteMod )
2457 return 1; 2458 return 1;
2458 else 2459 else
2459 return 2; 2460 return 2;
2460 break; 2461 break;
2461 case SYNC_PREF_ASK: 2462 case SYNC_PREF_ASK:
2462 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2463 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2463 if ( lastSync > remoteMod ) 2464 if ( lastSync > remoteMod )
2464 return 1; 2465 return 1;
2465 if ( lastSync > localMod ) 2466 if ( lastSync > localMod )
2466 return 2; 2467 return 2;
2467 localIsNew = localMod >= remoteMod; 2468 localIsNew = localMod >= remoteMod;
2468 //qDebug("conflict! ************************************** "); 2469 //qDebug("conflict! ************************************** ");
2469 { 2470 {
2470 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2471 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2471 result = acd.executeD(localIsNew); 2472 result = acd.executeD(localIsNew);
2472 return result; 2473 return result;
2473 } 2474 }
2474 break; 2475 break;
2475 case SYNC_PREF_FORCE_LOCAL: 2476 case SYNC_PREF_FORCE_LOCAL:
2476 return 1; 2477 return 1;
2477 break; 2478 break;
2478 case SYNC_PREF_FORCE_REMOTE: 2479 case SYNC_PREF_FORCE_REMOTE:
2479 return 2; 2480 return 2;
2480 break; 2481 break;
2481 2482
2482 default: 2483 default:
2483 // SYNC_PREF_TAKE_BOTH not implemented 2484 // SYNC_PREF_TAKE_BOTH not implemented
2484 break; 2485 break;
2485 } 2486 }
2486 return 0; 2487 return 0;
2487} 2488}
2488 2489
2489 2490
2490bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2491bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2491{ 2492{
2492 bool syncOK = true; 2493 bool syncOK = true;
2493 int addedAddressee = 0; 2494 int addedAddressee = 0;
2494 int addedAddresseeR = 0; 2495 int addedAddresseeR = 0;
2495 int deletedAddresseeR = 0; 2496 int deletedAddresseeR = 0;
2496 int deletedAddresseeL = 0; 2497 int deletedAddresseeL = 0;
2497 int changedLocal = 0; 2498 int changedLocal = 0;
2498 int changedRemote = 0; 2499 int changedRemote = 0;
2499 2500
2500 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2501 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2501 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2502 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2502 2503
2503 //QPtrList<Addressee> el = local->rawAddressees(); 2504 //QPtrList<Addressee> el = local->rawAddressees();
2504 Addressee addresseeR; 2505 Addressee addresseeR;
2505 QString uid; 2506 QString uid;
2506 int take; 2507 int take;
2507 Addressee addresseeL; 2508 Addressee addresseeL;
2508 Addressee addresseeRSync; 2509 Addressee addresseeRSync;
2509 Addressee addresseeLSync; 2510 Addressee addresseeLSync;
2510 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2511 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2511 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2512 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2512 bool fullDateRange = false; 2513 bool fullDateRange = false;
2513 local->resetTempSyncStat(); 2514 local->resetTempSyncStat();
2514 mLastAddressbookSync = QDateTime::currentDateTime(); 2515 mLastAddressbookSync = QDateTime::currentDateTime();
2515 if ( syncManager->syncWithDesktop() ) { 2516 if ( syncManager->syncWithDesktop() ) {
2516 // remote->removeSyncInfo( QString());//remove all info 2517 // remote->removeSyncInfo( QString());//remove all info
2517 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2518 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2518 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2519 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2519 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2520 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2520 } else { 2521 } else {
2521 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2522 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2522 } 2523 }
2523 } 2524 }
2524 QDateTime modifiedCalendar = mLastAddressbookSync; 2525 QDateTime modifiedCalendar = mLastAddressbookSync;
2525 addresseeLSync = getLastSyncAddressee(); 2526 addresseeLSync = getLastSyncAddressee();
2526 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2527 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2527 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2528 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2528 if ( !addresseeR.isEmpty() ) { 2529 if ( !addresseeR.isEmpty() ) {
2529 addresseeRSync = addresseeR; 2530 addresseeRSync = addresseeR;
2530 remote->removeAddressee(addresseeR ); 2531 remote->removeAddressee(addresseeR );
2531 2532
2532 } else { 2533 } else {
2533 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2534 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2534 addresseeRSync = addresseeLSync ; 2535 addresseeRSync = addresseeLSync ;
2535 } else { 2536 } else {
2536 qDebug("FULLDATE 1"); 2537 qDebug("FULLDATE 1");
2537 fullDateRange = true; 2538 fullDateRange = true;
2538 Addressee newAdd; 2539 Addressee newAdd;
2539 addresseeRSync = newAdd; 2540 addresseeRSync = newAdd;
2540 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2541 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2541 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2542 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2542 addresseeRSync.setRevision( mLastAddressbookSync ); 2543 addresseeRSync.setRevision( mLastAddressbookSync );
2543 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2544 addresseeRSync.setCategories( i18n("SyncAddressee") );
2544 } 2545 }
2545 } 2546 }
2546 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2547 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2547 qDebug("FULLDATE 2"); 2548 qDebug("FULLDATE 2");
2548 fullDateRange = true; 2549 fullDateRange = true;
2549 } 2550 }
2550 if ( ! fullDateRange ) { 2551 if ( ! fullDateRange ) {
2551 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2552 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2552 2553
2553 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2554 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2554 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2555 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2555 fullDateRange = true; 2556 fullDateRange = true;
2556 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2557 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2557 } 2558 }
2558 } 2559 }
2559 // fullDateRange = true; // debug only! 2560 // fullDateRange = true; // debug only!
2560 if ( fullDateRange ) 2561 if ( fullDateRange )
2561 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2562 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2562 else 2563 else
2563 mLastAddressbookSync = addresseeLSync.revision(); 2564 mLastAddressbookSync = addresseeLSync.revision();
2564 // for resyncing if own file has changed 2565 // for resyncing if own file has changed
2565 // PENDING fixme later when implemented 2566 // PENDING fixme later when implemented
2566#if 0 2567#if 0
2567 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2568 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2568 mLastAddressbookSync = loadedFileVersion; 2569 mLastAddressbookSync = loadedFileVersion;
2569 qDebug("setting mLastAddressbookSync "); 2570 qDebug("setting mLastAddressbookSync ");
2570 } 2571 }
2571#endif 2572#endif
2572 2573
2573 //qDebug("*************************** "); 2574 //qDebug("*************************** ");
2574 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2575 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2575 QStringList er = remote->uidList(); 2576 QStringList er = remote->uidList();
2576 Addressee inR ;//= er.first(); 2577 Addressee inR ;//= er.first();
2577 Addressee inL; 2578 Addressee inL;
2578 2579
2579 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2580 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2580 2581
2581 int modulo = (er.count()/10)+1; 2582 int modulo = (er.count()/10)+1;
2582 int incCounter = 0; 2583 int incCounter = 0;
2583 while ( incCounter < er.count()) { 2584 while ( incCounter < er.count()) {
2584 if (syncManager->isProgressBarCanceled()) 2585 if (syncManager->isProgressBarCanceled())
2585 return false; 2586 return false;
2586 if ( incCounter % modulo == 0 ) 2587 if ( incCounter % modulo == 0 )
2587 syncManager->showProgressBar(incCounter); 2588 syncManager->showProgressBar(incCounter);
2588 2589
2589 uid = er[ incCounter ]; 2590 uid = er[ incCounter ];
2590 bool skipIncidence = false; 2591 bool skipIncidence = false;
2591 if ( uid.left(19) == QString("last-syncAddressee-") ) 2592 if ( uid.left(19) == QString("last-syncAddressee-") )
2592 skipIncidence = true; 2593 skipIncidence = true;
2593 QString idS,OidS; 2594 QString idS,OidS;
2594 qApp->processEvents(); 2595 qApp->processEvents();
2595 if ( !skipIncidence ) { 2596 if ( !skipIncidence ) {
2596 inL = local->findByUid( uid ); 2597 inL = local->findByUid( uid );
2597 inR = remote->findByUid( uid ); 2598 inR = remote->findByUid( uid );
2598 //inL.setResource( 0 ); 2599 //inL.setResource( 0 );
2599 //inR.setResource( 0 ); 2600 //inR.setResource( 0 );
2600 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2601 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2601 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2602 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2602 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2603 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2603 //qDebug("take %d %s ", take, inL.summary().latin1()); 2604 //qDebug("take %d %s ", take, inL.summary().latin1());
2604 if ( take == 3 ) 2605 if ( take == 3 )
2605 return false; 2606 return false;
2606 if ( take == 1 ) {// take local 2607 if ( take == 1 ) {// take local
2607 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2608 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2608 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2609 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2609 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2610 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2610 local->insertAddressee( inL, false ); 2611 local->insertAddressee( inL, false );
2611 idS = inR.externalUID(); 2612 idS = inR.externalUID();
2612 OidS = inR.originalExternalUID(); 2613 OidS = inR.originalExternalUID();
2613 } 2614 }
2614 else 2615 else
2615 idS = inR.IDStr(); 2616 idS = inR.IDStr();
2616 remote->removeAddressee( inR ); 2617 remote->removeAddressee( inR );
2617 inR = inL; 2618 inR = inL;
2618 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2619 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2619 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2620 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2620 inR.setOriginalExternalUID( OidS ); 2621 inR.setOriginalExternalUID( OidS );
2621 inR.setExternalUID( idS ); 2622 inR.setExternalUID( idS );
2622 if ( syncManager->syncWithDesktop() ) 2623 if ( syncManager->syncWithDesktop() )
2623 inR.setIDStr("changed" ); 2624 inR.setIDStr("changed" );
2624 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2625 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2625 } else { 2626 } else {
2626 inR.setIDStr( idS ); 2627 inR.setIDStr( idS );
2627 } 2628 }
2628 inR.setResource( 0 ); 2629 inR.setResource( 0 );
2629 remote->insertAddressee( inR , false); 2630 remote->insertAddressee( inR , false);
2630 ++changedRemote; 2631 ++changedRemote;
2631 } else { // take == 2 take remote 2632 } else { // take == 2 take remote
2632 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2633 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2633 if ( inR.revision().date().year() < 2004 ) 2634 if ( inR.revision().date().year() < 2004 )
2634 inR.setRevision( modifiedCalendar ); 2635 inR.setRevision( modifiedCalendar );
2635 } 2636 }
2636 idS = inL.IDStr(); 2637 idS = inL.IDStr();
2637 local->removeAddressee( inL ); 2638 local->removeAddressee( inL );
2638 inL = inR; 2639 inL = inR;
2639 inL.setIDStr( idS ); 2640 inL.setIDStr( idS );
2640 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2641 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2642 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2642 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2643 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2643 } 2644 }
2644 inL.setResource( 0 ); 2645 inL.setResource( 0 );
2645 local->insertAddressee( inL , false ); 2646 local->insertAddressee( inL , false );
2646 ++changedLocal; 2647 ++changedLocal;
2647 } 2648 }
2648 } 2649 }
2649 } 2650 }
2650 } else { // no conflict 2651 } else { // no conflict
2651 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2652 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2652 QString des = addresseeLSync.note(); 2653 QString des = addresseeLSync.note();
2653 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2654 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2654 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2655 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2655 remote->insertAddressee( inR, false ); 2656 remote->insertAddressee( inR, false );
2656 ++deletedAddresseeR; 2657 ++deletedAddresseeR;
2657 } else { 2658 } else {
2658 inR.setRevision( modifiedCalendar ); 2659 inR.setRevision( modifiedCalendar );
2659 remote->insertAddressee( inR, false ); 2660 remote->insertAddressee( inR, false );
2660 inL = inR; 2661 inL = inR;
2661 inL.setResource( 0 ); 2662 inL.setResource( 0 );
2662 local->insertAddressee( inL , false); 2663 local->insertAddressee( inL , false);
2663 ++addedAddressee; 2664 ++addedAddressee;
2664 } 2665 }
2665 } else { 2666 } else {
2666 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2667 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2667 inR.setRevision( modifiedCalendar ); 2668 inR.setRevision( modifiedCalendar );
2668 remote->insertAddressee( inR, false ); 2669 remote->insertAddressee( inR, false );
2669 inR.setResource( 0 ); 2670 inR.setResource( 0 );
2670 local->insertAddressee( inR, false ); 2671 local->insertAddressee( inR, false );
2671 ++addedAddressee; 2672 ++addedAddressee;
2672 } else { 2673 } else {
2673 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2674 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2674 remote->removeAddressee( inR ); 2675 remote->removeAddressee( inR );
2675 ++deletedAddresseeR; 2676 ++deletedAddresseeR;
2676 } 2677 }
2677 } 2678 }
2678 } 2679 }
2679 } 2680 }
2680 ++incCounter; 2681 ++incCounter;
2681 } 2682 }
2682 er.clear(); 2683 er.clear();
2683 QStringList el = local->uidList(); 2684 QStringList el = local->uidList();
2684 modulo = (el.count()/10)+1; 2685 modulo = (el.count()/10)+1;
2685 2686
2686 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2687 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2687 incCounter = 0; 2688 incCounter = 0;
2688 while ( incCounter < el.count()) { 2689 while ( incCounter < el.count()) {
2689 qApp->processEvents(); 2690 qApp->processEvents();
2690 if (syncManager->isProgressBarCanceled()) 2691 if (syncManager->isProgressBarCanceled())
2691 return false; 2692 return false;
2692 if ( incCounter % modulo == 0 ) 2693 if ( incCounter % modulo == 0 )
2693 syncManager->showProgressBar(incCounter); 2694 syncManager->showProgressBar(incCounter);
2694 uid = el[ incCounter ]; 2695 uid = el[ incCounter ];
2695 bool skipIncidence = false; 2696 bool skipIncidence = false;
2696 if ( uid.left(19) == QString("last-syncAddressee-") ) 2697 if ( uid.left(19) == QString("last-syncAddressee-") )
2697 skipIncidence = true; 2698 skipIncidence = true;
2698 if ( !skipIncidence ) { 2699 if ( !skipIncidence ) {
2699 inL = local->findByUid( uid ); 2700 inL = local->findByUid( uid );
2700 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2701 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2701 inR = remote->findByUid( uid ); 2702 inR = remote->findByUid( uid );
2702 if ( inR.isEmpty() ) { 2703 if ( inR.isEmpty() ) {
2703 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2704 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2704 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2705 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2705 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2706 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2706 local->removeAddressee( inL ); 2707 local->removeAddressee( inL );
2707 ++deletedAddresseeL; 2708 ++deletedAddresseeL;
2708 } else { 2709 } else {
2709 if ( ! syncManager->mWriteBackExistingOnly ) { 2710 if ( ! syncManager->mWriteBackExistingOnly ) {
2710 inL.removeID(mCurrentSyncDevice ); 2711 inL.removeID(mCurrentSyncDevice );
2711 ++addedAddresseeR; 2712 ++addedAddresseeR;
2712 inL.setRevision( modifiedCalendar ); 2713 inL.setRevision( modifiedCalendar );
2713 local->insertAddressee( inL, false ); 2714 local->insertAddressee( inL, false );
2714 inR = inL; 2715 inR = inL;
2715 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2716 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2716 inR.setResource( 0 ); 2717 inR.setResource( 0 );
2717 remote->insertAddressee( inR, false ); 2718 remote->insertAddressee( inR, false );
2718 } 2719 }
2719 } 2720 }
2720 } else { 2721 } else {
2721 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2722 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2722 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2723 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2723 local->removeAddressee( inL ); 2724 local->removeAddressee( inL );
2724 ++deletedAddresseeL; 2725 ++deletedAddresseeL;
2725 } else { 2726 } else {
2726 if ( ! syncManager->mWriteBackExistingOnly ) { 2727 if ( ! syncManager->mWriteBackExistingOnly ) {
2727 ++addedAddresseeR; 2728 ++addedAddresseeR;
2728 inL.setRevision( modifiedCalendar ); 2729 inL.setRevision( modifiedCalendar );
2729 local->insertAddressee( inL, false ); 2730 local->insertAddressee( inL, false );
2730 inR = inL; 2731 inR = inL;
2731 inR.setResource( 0 ); 2732 inR.setResource( 0 );
2732 remote->insertAddressee( inR, false ); 2733 remote->insertAddressee( inR, false );
2733 } 2734 }
2734 } 2735 }
2735 } 2736 }
2736 } 2737 }
2737 } 2738 }
2738 } 2739 }
2739 ++incCounter; 2740 ++incCounter;
2740 } 2741 }
2741 el.clear(); 2742 el.clear();
2742 syncManager->hideProgressBar(); 2743 syncManager->hideProgressBar();
2743 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2744 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2744 // get rid of micro seconds 2745 // get rid of micro seconds
2745 QTime t = mLastAddressbookSync.time(); 2746 QTime t = mLastAddressbookSync.time();
2746 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2747 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2747 addresseeLSync.setRevision( mLastAddressbookSync ); 2748 addresseeLSync.setRevision( mLastAddressbookSync );
2748 addresseeRSync.setRevision( mLastAddressbookSync ); 2749 addresseeRSync.setRevision( mLastAddressbookSync );
2749 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2750 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2750 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2751 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2751 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2752 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2752 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2753 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2753 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2754 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2754 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2755 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2755 addresseeRSync.setNote( "" ) ; 2756 addresseeRSync.setNote( "" ) ;
2756 addresseeLSync.setNote( "" ); 2757 addresseeLSync.setNote( "" );
2757 2758
2758 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2759 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2759 remote->insertAddressee( addresseeRSync, false ); 2760 remote->insertAddressee( addresseeRSync, false );
2760 local->insertAddressee( addresseeLSync, false ); 2761 local->insertAddressee( addresseeLSync, false );
2761 QString mes; 2762 QString mes;
2762 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2763 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2763 if ( syncManager->mShowSyncSummary ) { 2764 if ( syncManager->mShowSyncSummary ) {
2764 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2765 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2765 } 2766 }
2766 qDebug( mes ); 2767 qDebug( mes );
2767 return syncOK; 2768 return syncOK;
2768} 2769}
2769 2770
2770 2771
2771//this is a overwritten callbackmethods from the syncinterface 2772//this is a overwritten callbackmethods from the syncinterface
2772bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2773bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2773{ 2774{
2774 2775
2775 //pending prepare addresseeview for output 2776 //pending prepare addresseeview for output
2776 //pending detect, if remote file has REV field. if not switch to external sync 2777 //pending detect, if remote file has REV field. if not switch to external sync
2777 mGlobalSyncMode = SYNC_MODE_NORMAL; 2778 mGlobalSyncMode = SYNC_MODE_NORMAL;
2778 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2779 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2779 2780
2780 AddressBook abLocal(filename,"syncContact"); 2781 AddressBook abLocal(filename,"syncContact");
2781 bool syncOK = false; 2782 bool syncOK = false;
2782 if ( abLocal.load() ) { 2783 if ( abLocal.load() ) {
2783 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2784 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2784 bool external = false; 2785 bool external = false;
2785 bool isXML = false; 2786 bool isXML = false;
2786 if ( filename.right(4) == ".xml") { 2787 if ( filename.right(4) == ".xml") {
2787 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2788 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2788 isXML = true; 2789 isXML = true;
2789 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2790 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2790 } else { 2791 } else {
2791 external = !manager->mIsKapiFile; 2792 external = !manager->mIsKapiFile;
2792 if ( external ) { 2793 if ( external ) {
2793 qDebug("Setting vcf mode to external "); 2794 qDebug("Setting vcf mode to external ");
2794 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2795 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2795 AddressBook::Iterator it; 2796 AddressBook::Iterator it;
2796 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2797 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2797 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2798 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2798 (*it).computeCsum( mCurrentSyncDevice ); 2799 (*it).computeCsum( mCurrentSyncDevice );
2799 } 2800 }
2800 } 2801 }
2801 } 2802 }
2802 //AddressBook::Iterator it; 2803 //AddressBook::Iterator it;
2803 //QStringList vcards; 2804 //QStringList vcards;
2804 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2805 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2805 // qDebug("Name %s ", (*it).familyName().latin1()); 2806 // qDebug("Name %s ", (*it).familyName().latin1());
2806 //} 2807 //}
2807 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2808 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2808 if ( syncOK ) { 2809 if ( syncOK ) {
2809 if ( syncManager->mWriteBackFile ) 2810 if ( syncManager->mWriteBackFile )
2810 { 2811 {
2811 if ( external ) 2812 if ( external )
2812 abLocal.removeSyncAddressees( !isXML); 2813 abLocal.removeSyncAddressees( !isXML);
2813 qDebug("Saving remote AB "); 2814 qDebug("Saving remote AB ");
2814 if ( ! abLocal.saveAB()) 2815 if ( ! abLocal.saveAB())
2815 qDebug("Error writing back AB to file "); 2816 qDebug("Error writing back AB to file ");
2816 if ( external ) { 2817 if ( external ) {
2817 // afterwrite processing 2818 // afterwrite processing
2818 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 2819 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2819 } 2820 }
2820 } 2821 }
2821 } 2822 }
2822 setModified(); 2823 setModified();
2823 2824
2824 } 2825 }
2825 if ( syncOK ) 2826 if ( syncOK )
2826 mViewManager->refreshView(); 2827 mViewManager->refreshView();
2827 return syncOK; 2828 return syncOK;
2828 2829
2829} 2830}
2830void KABCore::removeSyncInfo( QString syncProfile) 2831void KABCore::removeSyncInfo( QString syncProfile)
2831{ 2832{
2832 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2833 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2833 mAddressBook->removeSyncInfo( syncProfile ); 2834 mAddressBook->removeSyncInfo( syncProfile );
2834 setModified(); 2835 setModified();
2835} 2836}
2836 2837
2837 2838
2838//this is a overwritten callbackmethods from the syncinterface 2839//this is a overwritten callbackmethods from the syncinterface
2839bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2840bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2840{ 2841{
2841 if ( resource == "phone" ) 2842 if ( resource == "phone" )
2842 return syncPhone(); 2843 return syncPhone();
2843 disableBR( true ); 2844 disableBR( true );
2844 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2845 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2845 2846
2846 AddressBook abLocal( resource,"syncContact"); 2847 AddressBook abLocal( resource,"syncContact");
2847 bool syncOK = false; 2848 bool syncOK = false;
2848 if ( abLocal.load() ) { 2849 if ( abLocal.load() ) {
2849 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2850 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2850 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2851 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2851 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2852 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2852 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2853 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2853 if ( syncOK ) { 2854 if ( syncOK ) {
2854 if ( syncManager->mWriteBackFile ) { 2855 if ( syncManager->mWriteBackFile ) {
2855 abLocal.removeSyncAddressees( false ); 2856 abLocal.removeSyncAddressees( false );
2856 abLocal.saveAB(); 2857 abLocal.saveAB();
2857 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2858 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2858 } 2859 }
2859 } 2860 }
2860 setModified(); 2861 setModified();
2861 } 2862 }
2862 if ( syncOK ) 2863 if ( syncOK )
2863 mViewManager->refreshView(); 2864 mViewManager->refreshView();
2864 disableBR( false ); 2865 disableBR( false );
2865 return syncOK; 2866 return syncOK;
2866 2867
2867} 2868}
2868void KABCore::message( QString m ) 2869void KABCore::message( QString m )
2869{ 2870{
2870 topLevelWidget()->setCaption( m ); 2871 topLevelWidget()->setCaption( m );
2871 mMessageTimer->start( 15000, true ); 2872 mMessageTimer->start( 15000, true );
2872} 2873}
2873bool KABCore::syncPhone() 2874bool KABCore::syncPhone()
2874{ 2875{
2875 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2876 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2876 QString fileName = getPhoneFile(); 2877 QString fileName = getPhoneFile();
2877 if ( !PhoneAccess::readFromPhone( fileName) ) { 2878 if ( !PhoneAccess::readFromPhone( fileName) ) {
2878 message(i18n("Phone access failed!")); 2879 message(i18n("Phone access failed!"));
2879 return false; 2880 return false;
2880 } 2881 }
2881 AddressBook abLocal( fileName,"syncContact"); 2882 AddressBook abLocal( fileName,"syncContact");
2882 bool syncOK = false; 2883 bool syncOK = false;
2883 { 2884 {
2884 abLocal.importFromFile( fileName ); 2885 abLocal.importFromFile( fileName );
2885 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2886 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2886 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2887 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2887 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2888 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2888 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2889 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2889 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2890 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2890 if ( syncOK ) { 2891 if ( syncOK ) {
2891 if ( syncManager->mWriteBackFile ) { 2892 if ( syncManager->mWriteBackFile ) {
2892 abLocal.removeSyncAddressees( true ); 2893 abLocal.removeSyncAddressees( true );
2893 abLocal.saveABphone( fileName ); 2894 abLocal.saveABphone( fileName );
2894 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2895 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2895 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2896 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2896 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2897 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2897 } 2898 }
2898 } 2899 }
2899 setModified(); 2900 setModified();
2900 } 2901 }
2901 if ( syncOK ) 2902 if ( syncOK )
2902 mViewManager->refreshView(); 2903 mViewManager->refreshView();
2903 return syncOK; 2904 return syncOK;
2904} 2905}
2905void KABCore::getFile( bool success ) 2906void KABCore::getFile( bool success )
2906{ 2907{
2907 if ( ! success ) { 2908 if ( ! success ) {
2908 message( i18n("Error receiving file. Nothing changed!") ); 2909 message( i18n("Error receiving file. Nothing changed!") );
2909 return; 2910 return;
2910 } 2911 }
2911 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2912 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2912 if ( count ) 2913 if ( count )
2913 setModified( true ); 2914 setModified( true );
2914 message( i18n("Pi-Sync successful!") ); 2915 message( i18n("Pi-Sync successful!") );
2915 mViewManager->refreshView(); 2916 mViewManager->refreshView();
2916} 2917}
2917void KABCore::syncFileRequest() 2918void KABCore::syncFileRequest()
2918{ 2919{
2919 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 2920 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
2920 syncManager->slotSyncMenu( 999 ); 2921 syncManager->slotSyncMenu( 999 );
2921 } 2922 }
2922 mAddressBook->export2File( sentSyncFile() ); 2923 mAddressBook->export2File( sentSyncFile() );
2923} 2924}
2924QString KABCore::sentSyncFile() 2925QString KABCore::sentSyncFile()
2925{ 2926{
2926#ifdef DESKTOP_VERSION 2927#ifdef DESKTOP_VERSION
2927 return locateLocal( "tmp", "copysyncab.vcf" ); 2928 return locateLocal( "tmp", "copysyncab.vcf" );
2928#else 2929#else
2929 return QString( "/tmp/copysyncab.vcf" ); 2930 return QString( "/tmp/copysyncab.vcf" );
2930#endif 2931#endif
2931} 2932}
2932 2933
2933void KABCore::setCaptionBack() 2934void KABCore::setCaptionBack()
2934{ 2935{
2935 mMessageTimer->stop(); 2936 mMessageTimer->stop();
2936 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2937 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2937} 2938}
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 3cbcc9a..db123da 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,150 +1,155 @@
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <libkdepim/kpimglobalprefs.h> 32#include <libkdepim/kpimglobalprefs.h>
33 33
34#include <kconfig.h> 34#include <kconfig.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37//US#include <kdebug.h> // defines kdDebug() 37//US#include <kdebug.h> // defines kdDebug()
38 38
39#include "kabprefs.h" 39#include "kabprefs.h"
40 40
41#ifdef DESKTOP_VERSION 41#ifdef DESKTOP_VERSION
42#include <qapplication.h> 42#include <qapplication.h>
43#endif 43#endif
44 44
45KABPrefs *KABPrefs::sInstance = 0; 45KABPrefs *KABPrefs::sInstance = 0;
46static KStaticDeleter<KABPrefs> staticDeleterAB; 46static KStaticDeleter<KABPrefs> staticDeleterAB;
47 47
48KABPrefs::KABPrefs() 48KABPrefs::KABPrefs()
49 : KPimPrefs("kaddressbookrc") 49 : KPimPrefs("kaddressbookrc")
50{ 50{
51 mDetailsFont = QFont("helvetica",12); 51 mDetailsFont = QFont("helvetica",12);
52 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
54 54
55 KPrefs::setCurrentGroup( "General" ); 55 KPrefs::setCurrentGroup( "General" );
56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
58 58
59#ifdef KAB_EMBEDDED 59#ifdef KAB_EMBEDDED
60 addItemBool("AskForQuit",&mAskForQuit,true); 60 addItemBool("AskForQuit",&mAskForQuit,true);
61 addItemBool("ToolBarHor",&mToolBarHor, true ); 61 addItemBool("ToolBarHor",&mToolBarHor, true );
62 addItemBool("ToolBarUp",&mToolBarUp, false ); 62 addItemBool("ToolBarUp",&mToolBarUp, false );
63 addItemBool("SearchWithReturn",&mSearchWithReturn, true ); 63 addItemBool("SearchWithReturn",&mSearchWithReturn, true );
64 addItemFont("DetailsFont",&mDetailsFont); 64 addItemFont("DetailsFont",&mDetailsFont);
65 65
66 66
67#endif //KAB_EMBEDDED 67#endif //KAB_EMBEDDED
68 68
69 KPrefs::setCurrentGroup( "MainWindow" ); 69 KPrefs::setCurrentGroup( "MainWindow" );
70 bool m_visible = false;
71#ifdef DESKTOP_VERSION
72 m_visible = true;
73#endif
74 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
70 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 75 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
71 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 76 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
72 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 77 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
73 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 78 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
74 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 79 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
75 80
76 81
77 KPrefs::setCurrentGroup( "Extensions_General" ); 82 KPrefs::setCurrentGroup( "Extensions_General" );
78 QStringList defaultExtensions; 83 QStringList defaultExtensions;
79 defaultExtensions << "merge"; 84 defaultExtensions << "merge";
80 defaultExtensions << "distribution_list_editor"; 85 defaultExtensions << "distribution_list_editor";
81 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 86 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
82 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 87 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
83 88
84 KPrefs::setCurrentGroup( "Views" ); 89 KPrefs::setCurrentGroup( "Views" );
85 QString defaultView = i18n( "Default Table View" ); 90 QString defaultView = i18n( "Default Table View" );
86 addItemString( "CurrentView", &mCurrentView, defaultView ); 91 addItemString( "CurrentView", &mCurrentView, defaultView );
87 addItemStringList( "ViewNames", &mViewNames, defaultView ); 92 addItemStringList( "ViewNames", &mViewNames, defaultView );
88 93
89 KPrefs::setCurrentGroup( "Filters" ); 94 KPrefs::setCurrentGroup( "Filters" );
90 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 95 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
91 96
92} 97}
93 98
94KABPrefs::~KABPrefs() 99KABPrefs::~KABPrefs()
95{ 100{
96 //qDebug("KABPrefs::~KABPrefs() "); 101 //qDebug("KABPrefs::~KABPrefs() ");
97 if (sInstance == this) 102 if (sInstance == this)
98 sInstance = staticDeleterAB.setObject(0); 103 sInstance = staticDeleterAB.setObject(0);
99} 104}
100 105
101KABPrefs *KABPrefs::instance() 106KABPrefs *KABPrefs::instance()
102{ 107{
103 if ( !sInstance ) { 108 if ( !sInstance ) {
104#ifdef KAB_EMBEDDED 109#ifdef KAB_EMBEDDED
105 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 110 sInstance = staticDeleterAB.setObject( new KABPrefs() );
106#else //KAB_EMBEDDED 111#else //KAB_EMBEDDED
107 //US the following line has changed ???. Why 112 //US the following line has changed ???. Why
108 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 113 staticDeleterAB.setObject( sInstance, new KABPrefs() );
109#endif //KAB_EMBEDDED 114#endif //KAB_EMBEDDED
110 sInstance->readConfig(); 115 sInstance->readConfig();
111 } 116 }
112 117
113 return sInstance; 118 return sInstance;
114} 119}
115 120
116void KABPrefs::setCategoryDefaults() 121void KABPrefs::setCategoryDefaults()
117{ 122{
118 mCustomCategories.clear(); 123 mCustomCategories.clear();
119 124
120 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 125 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
121 << i18n( "Customer" ) << i18n( "Friend" ); 126 << i18n( "Customer" ) << i18n( "Friend" );
122} 127}
123 128
124 // US introduce a nonconst way to return the config object. 129 // US introduce a nonconst way to return the config object.
125KConfig* KABPrefs::getConfig() 130KConfig* KABPrefs::getConfig()
126{ 131{
127 return config(); 132 return config();
128} 133}
129void KABPrefs::usrReadConfig() 134void KABPrefs::usrReadConfig()
130{ 135{
131 KPimPrefs::usrReadConfig(); 136 KPimPrefs::usrReadConfig();
132} 137}
133 138
134 139
135/*US 140/*US
136void KABPrefs::usrSetDefaults() 141void KABPrefs::usrSetDefaults()
137{ 142{
138 KPimPrefs::usrSetDefaults(); 143 KPimPrefs::usrSetDefaults();
139} 144}
140 145
141void KABPrefs::usrReadConfig() 146void KABPrefs::usrReadConfig()
142{ 147{
143 KPimPrefs::usrReadConfig(); 148 KPimPrefs::usrReadConfig();
144} 149}
145 150
146void KABPrefs::usrWriteConfig() 151void KABPrefs::usrWriteConfig()
147{ 152{
148 KPimPrefs::usrWriteConfig(); 153 KPimPrefs::usrWriteConfig();
149} 154}
150*/ 155*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index cc8413e..1e3b48f 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,95 +1,96 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qdict.h> 28#include <qdict.h>
29 29
30#include <libkdepim/kpimprefs.h> 30#include <libkdepim/kpimprefs.h>
31 31
32class KConfig; 32class KConfig;
33 33
34class KABPrefs : public KPimPrefs 34class KABPrefs : public KPimPrefs
35{ 35{
36 public: 36 public:
37 virtual ~KABPrefs(); 37 virtual ~KABPrefs();
38 38
39 static KABPrefs *instance(); 39 static KABPrefs *instance();
40 40
41 // General 41 // General
42 bool mHonorSingleClick; 42 bool mHonorSingleClick;
43 bool mAutomaticNameParsing; 43 bool mAutomaticNameParsing;
44 int mCurrentIncSearchField; 44 int mCurrentIncSearchField;
45 45
46#ifdef KAB_EMBEDDED 46#ifdef KAB_EMBEDDED
47 // US introduce a nonconst way to return the config object. 47 // US introduce a nonconst way to return the config object.
48 KConfig* getConfig(); 48 KConfig* getConfig();
49 49
50 bool mToolBarHor; 50 bool mToolBarHor;
51 bool mToolBarUp; 51 bool mToolBarUp;
52 bool mAskForQuit; 52 bool mAskForQuit;
53 53
54 54
55 /** Set preferences to default values */ 55 /** Set preferences to default values */
56// void usrSetDefaults(); 56// void usrSetDefaults();
57 57
58 /** Read preferences from config file */ 58 /** Read preferences from config file */
59// void usrReadConfig(); 59// void usrReadConfig();
60 60
61 /** Write preferences to config file */ 61 /** Write preferences to config file */
62// void usrWriteConfig(); 62// void usrWriteConfig();
63#endif //KAB_EMBEDDED 63#endif //KAB_EMBEDDED
64 void usrReadConfig(); 64 void usrReadConfig();
65 65
66 66
67 // GUI 67 // GUI
68 bool mFullMenuBarVisible;
68 bool mJumpButtonBarVisible; 69 bool mJumpButtonBarVisible;
69 bool mDetailsPageVisible; 70 bool mDetailsPageVisible;
70 bool mMultipleViewsAtOnce; 71 bool mMultipleViewsAtOnce;
71 bool mSearchWithReturn; 72 bool mSearchWithReturn;
72 QValueList<int> mExtensionsSplitter; 73 QValueList<int> mExtensionsSplitter;
73 QValueList<int> mDetailsSplitter; 74 QValueList<int> mDetailsSplitter;
74 75
75 // Extensions stuff 76 // Extensions stuff
76 int mCurrentExtension; 77 int mCurrentExtension;
77 QStringList mActiveExtensions; 78 QStringList mActiveExtensions;
78 79
79 // Views stuff 80 // Views stuff
80 QString mCurrentView; 81 QString mCurrentView;
81 QStringList mViewNames; 82 QStringList mViewNames;
82 83
83 // Filter 84 // Filter
84 int mCurrentFilter; 85 int mCurrentFilter;
85 86
86 void setCategoryDefaults(); 87 void setCategoryDefaults();
87 QFont mDetailsFont; 88 QFont mDetailsFont;
88 89
89 private: 90 private:
90 KABPrefs(); 91 KABPrefs();
91 92
92 static KABPrefs *sInstance; 93 static KABPrefs *sInstance;
93}; 94};
94 95
95#endif 96#endif
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index c134e96..2e91cbc 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -1,298 +1,299 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKVIEW_H 24#ifndef KADDRESSBOOKVIEW_H
25#define KADDRESSBOOKVIEW_H 25#define KADDRESSBOOKVIEW_H
26 26
27#ifndef KAB_EMBEDDED 27#ifndef KAB_EMBEDDED
28#include <klibloader.h> 28#include <klibloader.h>
29#endif //KAB_EMBEDDED 29#endif //KAB_EMBEDDED
30 30
31class KConfig; 31class KConfig;
32class QDropEvent; 32class QDropEvent;
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <kabc/field.h> 35#include <kabc/field.h>
36#include <qwidget.h> 36#include <qwidget.h>
37 37
38#include "viewconfigurewidget.h" 38#include "viewconfigurewidget.h"
39#include "filter.h" 39#include "filter.h"
40 40
41namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
42 42
43/** 43/**
44 Base class for all views in kaddressbook. This class implements 44 Base class for all views in kaddressbook. This class implements
45 all the common methods needed to provide a view to the user. 45 all the common methods needed to provide a view to the user.
46 46
47 To implement a specific view (table, card, etc), just inherit from 47 To implement a specific view (table, card, etc), just inherit from
48 this class and implement all the pure virtuals. 48 this class and implement all the pure virtuals.
49 49
50 @author Mike Pilone <mpilone@slac.com> 50 @author Mike Pilone <mpilone@slac.com>
51 */ 51 */
52class KAddressBookView : public QWidget 52class KAddressBookView : public QWidget
53{ 53{
54 Q_OBJECT 54 Q_OBJECT
55 55
56 public: 56 public:
57 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; 57 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
58 58
59 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); 59 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name );
60 virtual ~KAddressBookView(); 60 virtual ~KAddressBookView();
61 61
62 /** 62 /**
63 Must be overloaded in subclasses. Should return a list of 63 Must be overloaded in subclasses. Should return a list of
64 all the uids of selected contacts. 64 all the uids of selected contacts.
65 */ 65 */
66 virtual QStringList selectedUids() = 0; 66 virtual QStringList selectedUids() = 0;
67 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; 67 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0;
68 virtual void scrollUP() = 0; 68 virtual void scrollUP() = 0;
69 virtual void scrollDOWN() = 0; 69 virtual void scrollDOWN() = 0;
70 virtual void setFocusAV() = 0;
70 71
71 /** 72 /**
72 Called whenever this view should read the config. This can be used 73 Called whenever this view should read the config. This can be used
73 as a sign that the config has changed, therefore the view should 74 as a sign that the config has changed, therefore the view should
74 assume the worst and rebuild itself if necessary. For example, 75 assume the worst and rebuild itself if necessary. For example,
75 in a table view this method may be called when the user adds or 76 in a table view this method may be called when the user adds or
76 removes columns from the view. 77 removes columns from the view.
77 78
78 If overloaded in the subclass, do not forget to call super class's 79 If overloaded in the subclass, do not forget to call super class's
79 method. 80 method.
80 81
81 @param config The KConfig object to read from. The group will already 82 @param config The KConfig object to read from. The group will already
82 be set, so do not change the group. 83 be set, so do not change the group.
83 */ 84 */
84 virtual void readConfig( KConfig *config ); 85 virtual void readConfig( KConfig *config );
85 86
86 /** 87 /**
87 Called whenever this view should write the config. The view should not 88 Called whenever this view should write the config. The view should not
88 write out information handled by the application, such as which fields 89 write out information handled by the application, such as which fields
89 are visible. The view should only write out information specific 90 are visible. The view should only write out information specific
90 to itself (i.e.: All information in the ViewConfigWidget) 91 to itself (i.e.: All information in the ViewConfigWidget)
91 92
92 If overloaded in the subclass, do not forget to call the super class's 93 If overloaded in the subclass, do not forget to call the super class's
93 method. 94 method.
94 95
95 @param config The KConfig object to read from. The group will already 96 @param config The KConfig object to read from. The group will already
96 be set, so do not change the group. 97 be set, so do not change the group.
97 */ 98 */
98 virtual void writeConfig( KConfig *config ); 99 virtual void writeConfig( KConfig *config );
99 100
100 /** 101 /**
101 Returns a QString with all the selected email addresses concatenated 102 Returns a QString with all the selected email addresses concatenated
102 together with a ',' seperator. 103 together with a ',' seperator.
103 */ 104 */
104 virtual QString selectedEmails(); 105 virtual QString selectedEmails();
105 106
106 /** 107 /**
107 Return the type of the view: Icon, Table, etc. Please make sure that 108 Return the type of the view: Icon, Table, etc. Please make sure that
108 this is the same value that ViewWrapper::type() will return for your 109 this is the same value that ViewWrapper::type() will return for your
109 view. 110 view.
110 */ 111 */
111 virtual QString type() const = 0; 112 virtual QString type() const = 0;
112 113
113 /** 114 /**
114 Returns a list of the fields that should be displayed. The list 115 Returns a list of the fields that should be displayed. The list
115 is composed of the fields proper names (ie: Home Address), so 116 is composed of the fields proper names (ie: Home Address), so
116 the view may need to translate them in order to get the 117 the view may need to translate them in order to get the
117 value from the addressee. 118 value from the addressee.
118 119
119 This list is generated from the config file, so it is advisable to call 120 This list is generated from the config file, so it is advisable to call
120 this method whenever a readConfig() is called in order to get the newest 121 this method whenever a readConfig() is called in order to get the newest
121 list of fields. 122 list of fields.
122 */ 123 */
123 KABC::Field::List fields() const; 124 KABC::Field::List fields() const;
124 125
125 /** 126 /**
126 Sets the active filter. This filter will be used for filtering 127 Sets the active filter. This filter will be used for filtering
127 the list of addressees to display. The view will <b>not</b> 128 the list of addressees to display. The view will <b>not</b>
128 automatically refresh itself, so in most cases you will want to call 129 automatically refresh itself, so in most cases you will want to call
129 KAddressBookView::refresh() after this method. 130 KAddressBookView::refresh() after this method.
130 */ 131 */
131 void setFilter( const Filter& ); 132 void setFilter( const Filter& );
132 133
133 /** 134 /**
134 @return The default filter type selection. If the selection 135 @return The default filter type selection. If the selection
135 is SpecificFilter, the name of the filter can be retrieved with 136 is SpecificFilter, the name of the filter can be retrieved with
136 defaultFilterName() 137 defaultFilterName()
137 */ 138 */
138 DefaultFilterType defaultFilterType() const; 139 DefaultFilterType defaultFilterType() const;
139 140
140 /** 141 /**
141 @return The name of the default filter. This string is 142 @return The name of the default filter. This string is
142 only valid if defaultFilterType() is returning SpecificFilter. 143 only valid if defaultFilterType() is returning SpecificFilter.
143 */ 144 */
144 const QString &defaultFilterName() const; 145 const QString &defaultFilterName() const;
145 146
146 /** 147 /**
147 @return The address book. 148 @return The address book.
148 */ 149 */
149 KABC::AddressBook *addressBook() const; 150 KABC::AddressBook *addressBook() const;
150 151
151 public slots: 152 public slots:
152 /** 153 /**
153 Must be overloaded in subclasses to refresh the view. 154 Must be overloaded in subclasses to refresh the view.
154 Refreshing includes updating the view to ensure that only items 155 Refreshing includes updating the view to ensure that only items
155 in the document are visible. If <i>uid</i> is valid, only the 156 in the document are visible. If <i>uid</i> is valid, only the
156 addressee with uid needs to be refreshed. This is an optimization 157 addressee with uid needs to be refreshed. This is an optimization
157 only. 158 only.
158 */ 159 */
159 virtual void refresh( QString uid = QString::null ) = 0; 160 virtual void refresh( QString uid = QString::null ) = 0;
160 161
161 /** 162 /**
162 This method must be overloaded in subclasses. Select (highlight) 163 This method must be overloaded in subclasses. Select (highlight)
163 the addressee matching <i>uid</i>. If uid 164 the addressee matching <i>uid</i>. If uid
164 is equal to QString::null, then all addressees should be selected. 165 is equal to QString::null, then all addressees should be selected.
165 */ 166 */
166#ifndef KAB_EMBEDDED 167#ifndef KAB_EMBEDDED
167//MOC_SKIP_BEGIN 168//MOC_SKIP_BEGIN
168 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; 169 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
169//MOC_SKIP_END 170//MOC_SKIP_END
170#else //KAB_EMBEDDED 171#else //KAB_EMBEDDED
171 //US my moc can not handle the default parameters. Is this a problem ??? 172 //US my moc can not handle the default parameters. Is this a problem ???
172 virtual void setSelected( QString uid, bool selected) = 0; 173 virtual void setSelected( QString uid, bool selected) = 0;
173#endif //KAB_EMBEDDED 174#endif //KAB_EMBEDDED
174 175
175 signals: 176 signals:
176 /** 177 /**
177 This signal should be emitted by a subclass whenever an addressee 178 This signal should be emitted by a subclass whenever an addressee
178 is modified. 179 is modified.
179 */ 180 */
180 void modified(); 181 void modified();
181 182
182 /** 183 /**
183 This signal should be emitted by a subclass whenever an addressee 184 This signal should be emitted by a subclass whenever an addressee
184 is selected. Selected means that the addressee was given the focus. 185 is selected. Selected means that the addressee was given the focus.
185 Some widgets may call this 'highlighted'. The view is responsible for 186 Some widgets may call this 'highlighted'. The view is responsible for
186 emitting this signal multiple times if multiple items are selected, 187 emitting this signal multiple times if multiple items are selected,
187 with the last item selected being the last emit. 188 with the last item selected being the last emit.
188 189
189 @param uid The uid of the selected addressee. 190 @param uid The uid of the selected addressee.
190 191
191 @see KListView 192 @see KListView
192 */ 193 */
193 void selected( const QString &uid ); 194 void selected( const QString &uid );
194 void deleteRequest(); 195 void deleteRequest();
195 /** 196 /**
196 This signal should be emitted by a subclass whenever an addressee 197 This signal should be emitted by a subclass whenever an addressee
197 is executed. This is defined by the KDE system wide config, but it 198 is executed. This is defined by the KDE system wide config, but it
198 either means single or doubleclicked. 199 either means single or doubleclicked.
199 200
200 @param ui The uid of the selected addressee 201 @param ui The uid of the selected addressee
201 202
202 @see KListView 203 @see KListView
203 */ 204 */
204 void executed( const QString &uid ); 205 void executed( const QString &uid );
205 206
206 /** 207 /**
207 This signal is emitted whenever a user attempts to start a drag 208 This signal is emitted whenever a user attempts to start a drag
208 in the view. The slot connected to this signal would usually want 209 in the view. The slot connected to this signal would usually want
209 to create a QDragObject. 210 to create a QDragObject.
210 */ 211 */
211 void startDrag(); 212 void startDrag();
212 213
213 /** 214 /**
214 This signal is emitted whenever the user drops something on the 215 This signal is emitted whenever the user drops something on the
215 view. The individual view should handle checking if the item is 216 view. The individual view should handle checking if the item is
216 droppable (ie: if it is a vcard). 217 droppable (ie: if it is a vcard).
217 */ 218 */
218 void dropped( QDropEvent* ); 219 void dropped( QDropEvent* );
219 220
220 protected: 221 protected:
221 /** 222 /**
222 Returns a list of the addressees that should be displayed. This method 223 Returns a list of the addressees that should be displayed. This method
223 should always be used by the subclass to get a list of addressees. This 224 should always be used by the subclass to get a list of addressees. This
224 method internally takes many factors into account, including the current 225 method internally takes many factors into account, including the current
225 filter. 226 filter.
226 */ 227 */
227 KABC::Addressee::List addressees(); 228 KABC::Addressee::List addressees();
228 229
229 /** 230 /**
230 This method returns the widget that should be used as the parent for 231 This method returns the widget that should be used as the parent for
231 all view components. By using this widget as the parent and not 232 all view components. By using this widget as the parent and not
232 'this', the view subclass has the option of placing other widgets 233 'this', the view subclass has the option of placing other widgets
233 around the view (ie: search fields, etc). Do not delete this widget! 234 around the view (ie: search fields, etc). Do not delete this widget!
234 */ 235 */
235 QWidget *viewWidget(); 236 QWidget *viewWidget();
236 237
237 private: 238 private:
238 void initGUI(); 239 void initGUI();
239 240
240 DefaultFilterType mDefaultFilterType; 241 DefaultFilterType mDefaultFilterType;
241 Filter mFilter; 242 Filter mFilter;
242 QString mDefaultFilterName; 243 QString mDefaultFilterName;
243 KABC::AddressBook *mAddressBook; 244 KABC::AddressBook *mAddressBook;
244 KABC::Field::List mFieldList; 245 KABC::Field::List mFieldList;
245 246
246 QWidget *mViewWidget; 247 QWidget *mViewWidget;
247}; 248};
248 249
249#ifndef KAB_EMBEDDED 250#ifndef KAB_EMBEDDED
250//MOC_SKIP_BEGIN 251//MOC_SKIP_BEGIN
251class ViewFactory : public KLibFactory 252class ViewFactory : public KLibFactory
252//MOC_SKIP_END 253//MOC_SKIP_END
253#else //KAB_EMBEDDED 254#else //KAB_EMBEDDED
254class ViewFactory 255class ViewFactory
255#endif //KAB_EMBEDDED 256#endif //KAB_EMBEDDED
256{ 257{
257 258
258 public: 259 public:
259 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, 260 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
260 const char *name = 0 ) = 0; 261 const char *name = 0 ) = 0;
261 262
262 /** 263 /**
263 @return The type of the view. This is normally a small one word 264 @return The type of the view. This is normally a small one word
264 string (ie: Table, Icon, Tree, etc). 265 string (ie: Table, Icon, Tree, etc).
265 */ 266 */
266 virtual QString type() const = 0; 267 virtual QString type() const = 0;
267 268
268 /** 269 /**
269 @return The description of the view. This should be a 3 to 270 @return The description of the view. This should be a 3 to
270 4 line string (don't actually use return characters in the string) 271 4 line string (don't actually use return characters in the string)
271 describing the features offered by the view. 272 describing the features offered by the view.
272 */ 273 */
273 virtual QString description() const = 0; 274 virtual QString description() const = 0;
274 275
275 /** 276 /**
276 Creates a config dialog for the view type. The default 277 Creates a config dialog for the view type. The default
277 implementation will return a ViewConfigDialog. This default 278 implementation will return a ViewConfigDialog. This default
278 dialog will allow the user to set the visible fields only. If 279 dialog will allow the user to set the visible fields only. If
279 you need more config options (as most views will), this method 280 you need more config options (as most views will), this method
280 can be overloaded to return your sublcass of ViewConfigDialog. 281 can be overloaded to return your sublcass of ViewConfigDialog.
281 If this method is over loaded the base classes method should 282 If this method is over loaded the base classes method should
282 <B>not</B> be called. 283 <B>not</B> be called.
283 */ 284 */
284 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, 285 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
285 QWidget *parent, 286 QWidget *parent,
286 const char *name = 0 ); 287 const char *name = 0 );
287 288
288 protected: 289 protected:
289 virtual QObject* createObject( QObject*, const char*, const char*, 290 virtual QObject* createObject( QObject*, const char*, const char*,
290 const QStringList & ) 291 const QStringList & )
291 { 292 {
292 return 0; 293 return 0;
293 } 294 }
294 295
295}; 296};
296 297
297 298
298#endif 299#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 936d052..8bf9bb0 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,398 +1,401 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qvbox.h> 34#include <qvbox.h>
35 35
36#include <kconfig.h> 36#include <kconfig.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klistview.h> 39#include <klistview.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kglobal.h> 41#include <kglobal.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <ktrader.h> 46#include <ktrader.h>
47#else // KAB_EMBEDDED 47#else // KAB_EMBEDDED
48#include <mergewidget.h> 48#include <mergewidget.h>
49#include <distributionlistwidget.h> 49#include <distributionlistwidget.h>
50#endif // KAB_EMBEDDED 50#endif // KAB_EMBEDDED
51 51
52#include "addresseewidget.h" 52#include "addresseewidget.h"
53#include "extensionconfigdialog.h" 53#include "extensionconfigdialog.h"
54#include "extensionwidget.h" 54#include "extensionwidget.h"
55#include "kabprefs.h" 55#include "kabprefs.h"
56 56
57#include "kabconfigwidget.h" 57#include "kabconfigwidget.h"
58 58
59class ExtensionItem : public QCheckListItem 59class ExtensionItem : public QCheckListItem
60{ 60{
61 public: 61 public:
62 62
63#ifndef KAB_EMBEDDED 63#ifndef KAB_EMBEDDED
64 ExtensionItem( QListView *parent, const QString &text ); 64 ExtensionItem( QListView *parent, const QString &text );
65 void setService( const KService::Ptr &ptr ); 65 void setService( const KService::Ptr &ptr );
66#else //KAB_EMBEDDED 66#else //KAB_EMBEDDED
67 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 67 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
68 void setFactory( ExtensionFactory* fac ); 68 void setFactory( ExtensionFactory* fac );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 bool configWidgetAvailable() const; 71 bool configWidgetAvailable() const;
72 ExtensionFactory *factory() const; 72 ExtensionFactory *factory() const;
73 73
74 virtual QString text( int column ) const; 74 virtual QString text( int column ) const;
75 75
76 private: 76 private:
77#ifndef KAB_EMBEDDED 77#ifndef KAB_EMBEDDED
78 KService::Ptr mPtr; 78 KService::Ptr mPtr;
79#else //KAB_EMBEDDED 79#else //KAB_EMBEDDED
80 ExtensionFactory* mFactory; 80 ExtensionFactory* mFactory;
81 QString mName; 81 QString mName;
82 QString mComment; 82 QString mComment;
83 83
84#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
85 85
86}; 86};
87 87
88KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) 88KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name )
89 : KPrefsWidget( prefs, parent, name ) 89 : KPrefsWidget( prefs, parent, name )
90{ 90{
91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
92 KDialog::spacingHint() ); 92 KDialog::spacingHint() );
93 93
94 QTabWidget *tabWidget = new QTabWidget( this ); 94 QTabWidget *tabWidget = new QTabWidget( this );
95 topLayout->addWidget( tabWidget ); 95 topLayout->addWidget( tabWidget );
96 96
97 // General page 97 // General page
98 QWidget *generalPage = new QWidget( this ); 98 QWidget *generalPage = new QWidget( this );
99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
100 KDialog::spacingHintSmall() ); 100 KDialog::spacingHintSmall() );
101 101
102 102
103 QWidget *hBox = new QWidget( generalPage, "qhbox" ); 103 QWidget *hBox = new QWidget( generalPage, "qhbox" );
104 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); 104 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox);
105 KPrefsWidFont *detailsFont = 105 KPrefsWidFont *detailsFont =
106 addWidFont(i18n("phone:123"),i18n("Details view font"), 106 addWidFont(i18n("phone:123"),i18n("Details view font"),
107 &(KABPrefs::instance()->mDetailsFont),hBox); 107 &(KABPrefs::instance()->mDetailsFont),hBox);
108 hboxLayout->addWidget(detailsFont->label()); 108 hboxLayout->addWidget(detailsFont->label());
109 hboxLayout->addWidget(detailsFont->preview()); 109 hboxLayout->addWidget(detailsFont->preview());
110 hboxLayout->addWidget(detailsFont->button()); 110 hboxLayout->addWidget(detailsFont->button());
111 hboxLayout->setMargin(KDialog::marginHintSmall() ); 111 hboxLayout->setMargin(KDialog::marginHintSmall() );
112 hboxLayout->setSpacing(KDialog::spacingHintSmall()); 112 hboxLayout->setSpacing(KDialog::spacingHintSmall());
113 //hBox->setBackgroundColor( black); 113 //hBox->setBackgroundColor( black);
114 layout->addWidget( hBox ); 114 layout->addWidget( hBox );
115 115
116 //general groupbox 116 //general groupbox
117 QWidget *vBox = new QWidget( generalPage, "qvbox" ); 117 QWidget *vBox = new QWidget( generalPage, "qvbox" );
118 QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); 118 QVBoxLayout *boxLayout = new QVBoxLayout( vBox );
119 boxLayout->setAlignment( Qt::AlignTop ); 119 boxLayout->setAlignment( Qt::AlignTop );
120 boxLayout->setMargin(KDialog::marginHintSmall() ); 120 boxLayout->setMargin(KDialog::marginHintSmall() );
121 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 121 boxLayout->setSpacing( KDialog::spacingHintSmall() );
122 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" );
123 boxLayout->addWidget( mMenuBarBox );
122 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); 124 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
123 boxLayout->addWidget( mSearchReturnBox ); 125 boxLayout->addWidget( mSearchReturnBox );
124 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); 126 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" );
125 boxLayout->addWidget( mViewsSingleClickBox ); 127 boxLayout->addWidget( mViewsSingleClickBox );
126 128
127 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); 129 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" );
128 boxLayout->addWidget( mNameParsing ); 130 boxLayout->addWidget( mNameParsing );
129 131
130 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); 132 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
131 boxLayout->addWidget( mMultipleViewsAtOnce ); 133 boxLayout->addWidget( mMultipleViewsAtOnce );
132 134
133 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); 135 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" );
134 boxLayout->addWidget( mAskForQuit ); 136 boxLayout->addWidget( mAskForQuit );
135 137
136 layout->addWidget( vBox ); 138 layout->addWidget( vBox );
137 139
138 tabWidget->addTab( generalPage, i18n( "General" ) ); 140 tabWidget->addTab( generalPage, i18n( "General" ) );
139 141
140 // Extension page 142 // Extension page
141 QWidget *extensionPage = new QWidget( this ); 143 QWidget *extensionPage = new QWidget( this );
142 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), 144 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(),
143 KDialog::spacingHintSmall() ); 145 KDialog::spacingHintSmall() );
144 146
145 //extensions groupbox 147 //extensions groupbox
146 148
147 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); 149 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
148 boxLayout = new QVBoxLayout( groupBox->layout() ); 150 boxLayout = new QVBoxLayout( groupBox->layout() );
149 boxLayout->setAlignment( Qt::AlignTop ); 151 boxLayout->setAlignment( Qt::AlignTop );
150 boxLayout->setMargin(KDialog::marginHintSmall()); 152 boxLayout->setMargin(KDialog::marginHintSmall());
151 boxLayout->setSpacing(KDialog::spacingHintSmall()); 153 boxLayout->setSpacing(KDialog::spacingHintSmall());
152 groupBox->layout()->setMargin(1) ; 154 groupBox->layout()->setMargin(1) ;
153 groupBox->layout()->setSpacing(0); 155 groupBox->layout()->setSpacing(0);
154 mExtensionView = new KListView( groupBox ); 156 mExtensionView = new KListView( groupBox );
155 mExtensionView->setAllColumnsShowFocus( true ); 157 mExtensionView->setAllColumnsShowFocus( true );
156 mExtensionView->addColumn( i18n( "Name" ) ); 158 mExtensionView->addColumn( i18n( "Name" ) );
157 mExtensionView->addColumn( i18n( "Description" ) ); 159 mExtensionView->addColumn( i18n( "Description" ) );
158 mExtensionView->setMaximumHeight(80); 160 mExtensionView->setMaximumHeight(80);
159 161
160 boxLayout->addWidget( mExtensionView ); 162 boxLayout->addWidget( mExtensionView );
161 163
162 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 164 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
163 mConfigureButton->setEnabled( false ); 165 mConfigureButton->setEnabled( false );
164 boxLayout->addWidget( mConfigureButton ); 166 boxLayout->addWidget( mConfigureButton );
165 167
166 extensionLayout->addWidget( groupBox ); 168 extensionLayout->addWidget( groupBox );
167 169
170 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
168 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 171 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
169 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 172 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
170 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 173 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
171 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 174 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
172 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 175 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
173 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 176 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
174 SLOT( selectionChanged( QListViewItem* ) ) ); 177 SLOT( selectionChanged( QListViewItem* ) ) );
175 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 178 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
176 SLOT( itemClicked( QListViewItem* ) ) ); 179 SLOT( itemClicked( QListViewItem* ) ) );
177 connect( mConfigureButton, SIGNAL( clicked() ), 180 connect( mConfigureButton, SIGNAL( clicked() ),
178 SLOT( configureExtension() ) ); 181 SLOT( configureExtension() ) );
179 182
180 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 183 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
181 184
182 // Addressee page 185 // Addressee page
183 mAddresseeWidget = new AddresseeWidget( this ); 186 mAddresseeWidget = new AddresseeWidget( this );
184 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 187 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
185 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 188 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
186 189
187} 190}
188 191
189void KABConfigWidget::usrReadConfig() 192void KABConfigWidget::usrReadConfig()
190{ 193{
191 KABPrefs* prefs = KABPrefs::instance(); 194 KABPrefs* prefs = KABPrefs::instance();
192 195
193 bool blocked = signalsBlocked(); 196 bool blocked = signalsBlocked();
194 blockSignals( true ); 197 blockSignals( true );
195 198 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible);
196 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 199 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
197 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 200 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
198 mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); 201 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
199 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 202 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
200 mAskForQuit->setChecked( prefs->mAskForQuit ); 203 mAskForQuit->setChecked( prefs->mAskForQuit );
201 204
202 mAddresseeWidget->restoreSettings(); 205 mAddresseeWidget->restoreSettings();
203 206
204 restoreExtensionSettings(); 207 restoreExtensionSettings();
205 208
206 blockSignals( blocked ); 209 blockSignals( blocked );
207 210
208} 211}
209 212
210void KABConfigWidget::usrWriteConfig() 213void KABConfigWidget::usrWriteConfig()
211{ 214{
212 KABPrefs* prefs = KABPrefs::instance(); 215 KABPrefs* prefs = KABPrefs::instance();
213 216 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked();
214 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 217 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
215 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 218 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
216 prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); 219 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
217 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 220 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
218 prefs->mAskForQuit = mAskForQuit->isChecked(); 221 prefs->mAskForQuit = mAskForQuit->isChecked();
219 222
220 mAddresseeWidget->saveSettings(); 223 mAddresseeWidget->saveSettings();
221 224
222 saveExtensionSettings(); 225 saveExtensionSettings();
223 226
224} 227}
225 228
226void KABConfigWidget::restoreExtensionSettings() 229void KABConfigWidget::restoreExtensionSettings()
227{ 230{
228 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 231 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
229 232
230 mExtensionView->clear(); 233 mExtensionView->clear();
231 234
232#ifndef KAB_EMBEDDED 235#ifndef KAB_EMBEDDED
233 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 236 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
234 KTrader::OfferList::ConstIterator it; 237 KTrader::OfferList::ConstIterator it;
235 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 238 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
236 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 239 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
237 continue; 240 continue;
238 241
239 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 242 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
240 item->setService( *it ); 243 item->setService( *it );
241 if ( activeExtensions.contains( item->factory()->identifier() ) ) 244 if ( activeExtensions.contains( item->factory()->identifier() ) )
242 item->setOn( true ); 245 item->setOn( true );
243 } 246 }
244#else //KAB_EMBEDDED 247#else //KAB_EMBEDDED
245 ExtensionFactory *extensionFactory = new MergeFactory(); 248 ExtensionFactory *extensionFactory = new MergeFactory();
246 249
247 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 250 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
248 251
249 item->setFactory( extensionFactory ); 252 item->setFactory( extensionFactory );
250 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 253 if ( activeExtensions.contains( extensionFactory->identifier() ) )
251 item->setOn( true ); 254 item->setOn( true );
252 255
253 256
254 257
255 extensionFactory = new DistributionListFactory(); 258 extensionFactory = new DistributionListFactory();
256 259
257 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 260 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
258 261
259 item->setFactory( extensionFactory ); 262 item->setFactory( extensionFactory );
260 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 263 if ( activeExtensions.contains( extensionFactory->identifier() ) )
261 item->setOn( true ); 264 item->setOn( true );
262 265
263 266
264#endif //KAB_EMBEDDED 267#endif //KAB_EMBEDDED
265 268
266} 269}
267 270
268void KABConfigWidget::saveExtensionSettings() 271void KABConfigWidget::saveExtensionSettings()
269{ 272{
270 QStringList activeExtensions; 273 QStringList activeExtensions;
271 274
272 QPtrList<QListViewItem> list; 275 QPtrList<QListViewItem> list;
273 QListViewItemIterator it( mExtensionView ); 276 QListViewItemIterator it( mExtensionView );
274 while ( it.current() ) { 277 while ( it.current() ) {
275 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 278 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
276 if ( item ) { 279 if ( item ) {
277 if ( item->isOn() ) 280 if ( item->isOn() )
278 activeExtensions.append( item->factory()->identifier() ); 281 activeExtensions.append( item->factory()->identifier() );
279 } 282 }
280 ++it; 283 ++it;
281 } 284 }
282 285
283 KABPrefs::instance()->mActiveExtensions = activeExtensions; 286 KABPrefs::instance()->mActiveExtensions = activeExtensions;
284} 287}
285 288
286void KABConfigWidget::configureExtension() 289void KABConfigWidget::configureExtension()
287{ 290{
288 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 291 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
289 if ( !item ) 292 if ( !item )
290 return; 293 return;
291 294
292#ifndef KAB_EMBEDDED 295#ifndef KAB_EMBEDDED
293 KConfig config( "kaddressbookrc" ); 296 KConfig config( "kaddressbookrc" );
294#else //KAB_EMBEDDED 297#else //KAB_EMBEDDED
295 KConfig config( locateLocal("config", "kaddressbookrc") ); 298 KConfig config( locateLocal("config", "kaddressbookrc") );
296#endif //KAB_EMBEDDED 299#endif //KAB_EMBEDDED
297 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 300 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
298 301
299 ExtensionConfigDialog dlg( item->factory(), &config, this ); 302 ExtensionConfigDialog dlg( item->factory(), &config, this );
300 dlg.exec(); 303 dlg.exec();
301 304
302 config.sync(); 305 config.sync();
303} 306}
304 307
305void KABConfigWidget::selectionChanged( QListViewItem *i ) 308void KABConfigWidget::selectionChanged( QListViewItem *i )
306{ 309{
307 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 310 ExtensionItem *item = static_cast<ExtensionItem*>( i );
308 if ( !item ) 311 if ( !item )
309 return; 312 return;
310 313
311 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 314 mConfigureButton->setEnabled( item->configWidgetAvailable() );
312} 315}
313 316
314void KABConfigWidget::itemClicked( QListViewItem *item ) 317void KABConfigWidget::itemClicked( QListViewItem *item )
315{ 318{
316 if ( item != 0 ) 319 if ( item != 0 )
317 modified(); 320 modified();
318} 321}
319 322
320#ifndef KAB_EMBEDDED 323#ifndef KAB_EMBEDDED
321ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 324ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
322 : QCheckListItem( parent, text, CheckBox ) 325 : QCheckListItem( parent, text, CheckBox )
323{ 326{
324} 327}
325 328
326void ExtensionItem::setService( const KService::Ptr &ptr ) 329void ExtensionItem::setService( const KService::Ptr &ptr )
327{ 330{
328 mPtr = ptr; 331 mPtr = ptr;
329} 332}
330#else //KAB_EMBEDDED 333#else //KAB_EMBEDDED
331ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 334ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment )
332 : QCheckListItem( parent, text, CheckBox ) 335 : QCheckListItem( parent, text, CheckBox )
333{ 336{
334 mName = name; 337 mName = name;
335 mComment = comment; 338 mComment = comment;
336} 339}
337 340
338 341
339void ExtensionItem::setFactory( ExtensionFactory* fac ) 342void ExtensionItem::setFactory( ExtensionFactory* fac )
340{ 343{
341 mFactory = fac; 344 mFactory = fac;
342} 345}
343#endif //KAB_EMBEDDED 346#endif //KAB_EMBEDDED
344 347
345bool ExtensionItem::configWidgetAvailable() const 348bool ExtensionItem::configWidgetAvailable() const
346{ 349{
347#ifndef KAB_EMBEDDED 350#ifndef KAB_EMBEDDED
348 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 351 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
349 if ( !factory ) 352 if ( !factory )
350 return false; 353 return false;
351 354
352 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 355 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
353 if ( !extensionFactory ) 356 if ( !extensionFactory )
354 return false; 357 return false;
355 358
356 return extensionFactory->configureWidgetAvailable(); 359 return extensionFactory->configureWidgetAvailable();
357#else //KAB_EMBEDDED 360#else //KAB_EMBEDDED
358 return mFactory->configureWidgetAvailable(); 361 return mFactory->configureWidgetAvailable();
359#endif //KAB_EMBEDDED 362#endif //KAB_EMBEDDED
360 363
361} 364}
362 365
363ExtensionFactory *ExtensionItem::factory() const 366ExtensionFactory *ExtensionItem::factory() const
364{ 367{
365#ifndef KAB_EMBEDDED 368#ifndef KAB_EMBEDDED
366 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 369 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
367 if ( !factory ) 370 if ( !factory )
368 return 0; 371 return 0;
369 372
370 return static_cast<ExtensionFactory*>( factory ); 373 return static_cast<ExtensionFactory*>( factory );
371#else //KAB_EMBEDDED 374#else //KAB_EMBEDDED
372 return mFactory; 375 return mFactory;
373#endif //KAB_EMBEDDED 376#endif //KAB_EMBEDDED
374} 377}
375 378
376QString ExtensionItem::text( int column ) const 379QString ExtensionItem::text( int column ) const
377{ 380{
378#ifndef KAB_EMBEDDED 381#ifndef KAB_EMBEDDED
379 if ( column == 0 ) 382 if ( column == 0 )
380 return mPtr->name(); 383 return mPtr->name();
381 else if ( column == 1 ) 384 else if ( column == 1 )
382 return mPtr->comment(); 385 return mPtr->comment();
383 else 386 else
384 return QString::null; 387 return QString::null;
385#else //KAB_EMBEDDED 388#else //KAB_EMBEDDED
386 if ( column == 0 ) 389 if ( column == 0 )
387 return mName; 390 return mName;
388 else if ( column == 1 ) 391 else if ( column == 1 )
389 return mComment; 392 return mComment;
390 else 393 else
391 return QString::null; 394 return QString::null;
392#endif //KAB_EMBEDDED 395#endif //KAB_EMBEDDED
393} 396}
394 397
395#ifndef KAB_EMBEDDED 398#ifndef KAB_EMBEDDED
396#include "kabconfigwidget.moc" 399#include "kabconfigwidget.moc"
397#endif //KAB_EMBEDDED 400#endif //KAB_EMBEDDED
398 401
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 1e71fd1..08d71b4 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,75 +1,75 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <kprefswidget.h> 27#include <kprefswidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public KPrefsWidget 39class KABConfigWidget : public KPrefsWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); 44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 );
45 45
46 protected: 46 protected:
47 /** Implement this to read custom configuration widgets. */ 47 /** Implement this to read custom configuration widgets. */
48 virtual void usrReadConfig(); 48 virtual void usrReadConfig();
49 /** Implement this to write custom configuration widgets. */ 49 /** Implement this to write custom configuration widgets. */
50 virtual void usrWriteConfig(); 50 virtual void usrWriteConfig();
51 51
52 52
53 53
54 private slots: 54 private slots:
55 void configureExtension(); 55 void configureExtension();
56 void selectionChanged( QListViewItem* ); 56 void selectionChanged( QListViewItem* );
57 void itemClicked( QListViewItem* ); 57 void itemClicked( QListViewItem* );
58 58
59 private: 59 private:
60 void restoreExtensionSettings(); 60 void restoreExtensionSettings();
61 void saveExtensionSettings(); 61 void saveExtensionSettings();
62 62
63 KListView *mExtensionView; 63 KListView *mExtensionView;
64 QCheckBox *mSearchReturnBox; 64 QCheckBox *mSearchReturnBox;
65 QCheckBox *mNameParsing; 65 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 66 QCheckBox *mViewsSingleClickBox;
67 QCheckBox *mMultipleViewsAtOnce; 67 QCheckBox *mMultipleViewsAtOnce;
68 QCheckBox *mAskForQuit; 68 QCheckBox *mAskForQuit;
69 69 QCheckBox *mMenuBarBox;
70 QPushButton *mConfigureButton; 70 QPushButton *mConfigureButton;
71 71
72 AddresseeWidget *mAddresseeWidget; 72 AddresseeWidget *mAddresseeWidget;
73}; 73};
74 74
75#endif 75#endif
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 81e0d99..3d0c275 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,718 +1,718 @@
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 <qwidgetstack.h> 63#include <qwidgetstack.h>
64 64
65#include <kabc/addressbook.h> 65#include <kabc/addressbook.h>
66#include "filtereditdialog.h" 66#include "filtereditdialog.h"
67#include "addviewdialog.h" 67#include "addviewdialog.h"
68#include "kabcore.h" 68#include "kabcore.h"
69#include "kabprefs.h" 69#include "kabprefs.h"
70#include "viewmanager.h" 70#include "viewmanager.h"
71 71
72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
74{ 74{
75 initGUI(); 75 initGUI();
76 initActions(); 76 initActions();
77 77
78 mViewDict.setAutoDelete( true ); 78 mViewDict.setAutoDelete( true );
79 79
80 createViewFactories(); 80 createViewFactories();
81} 81}
82 82
83ViewManager::~ViewManager() 83ViewManager::~ViewManager()
84{ 84{
85 unloadViews(); 85 unloadViews();
86 mViewFactoryDict.clear(); 86 mViewFactoryDict.clear();
87} 87}
88void ViewManager::scrollUP() 88void ViewManager::scrollUP()
89{ 89{
90 if ( mActiveView ) 90 if ( mActiveView )
91 mActiveView->scrollUP(); 91 mActiveView->scrollUP();
92} 92}
93void ViewManager::scrollDOWN() 93void ViewManager::scrollDOWN()
94{ 94{
95 if ( mActiveView ) 95 if ( mActiveView )
96 mActiveView->scrollDOWN(); 96 mActiveView->scrollDOWN();
97} 97}
98void ViewManager::restoreSettings() 98void ViewManager::restoreSettings()
99{ 99{
100 mViewNameList = KABPrefs::instance()->mViewNames; 100 mViewNameList = KABPrefs::instance()->mViewNames;
101 QString activeViewName = KABPrefs::instance()->mCurrentView; 101 QString activeViewName = KABPrefs::instance()->mCurrentView;
102 102
103 mActionSelectView->setItems( mViewNameList ); 103 mActionSelectView->setItems( mViewNameList );
104 104
105 // Filter 105 // Filter
106 mFilterList = Filter::restore( mCore->config(), "Filter" ); 106 mFilterList = Filter::restore( mCore->config(), "Filter" );
107 mActionSelectFilter->setItems( filterNames() ); 107 mActionSelectFilter->setItems( filterNames() );
108 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 108 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
109 109 mActionSelectFilter->setComboWidth( 100 );
110 // Tell the views to reread their config, since they may have 110 // Tell the views to reread their config, since they may have
111 // been modified by global settings 111 // been modified by global settings
112 QString _oldgroup = mCore->config()->group(); 112 QString _oldgroup = mCore->config()->group();
113 113
114 QDictIterator<KAddressBookView> it( mViewDict ); 114 QDictIterator<KAddressBookView> it( mViewDict );
115 for ( it.toFirst(); it.current(); ++it ) { 115 for ( it.toFirst(); it.current(); ++it ) {
116 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 116 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
117 it.current()->readConfig( mCore->config() ); 117 it.current()->readConfig( mCore->config() );
118 } 118 }
119 setActiveView( activeViewName ); 119 setActiveView( activeViewName );
120 120
121 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 121 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
122} 122}
123 123
124void ViewManager::saveSettings() 124void ViewManager::saveSettings()
125{ 125{
126 QString _oldgroup = mCore->config()->group(); 126 QString _oldgroup = mCore->config()->group();
127 127
128 QDictIterator<KAddressBookView> it( mViewDict ); 128 QDictIterator<KAddressBookView> it( mViewDict );
129 for ( it.toFirst(); it.current(); ++it ) { 129 for ( it.toFirst(); it.current(); ++it ) {
130 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 130 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132 (*it)->writeConfig( mCore->config() ); 132 (*it)->writeConfig( mCore->config() );
133#else 133#else
134 (*it).writeConfig( mCore->config() ); 134 (*it).writeConfig( mCore->config() );
135#endif 135#endif
136 } 136 }
137 137
138 Filter::save( mCore->config(), "Filter", mFilterList ); 138 Filter::save( mCore->config(), "Filter", mFilterList );
139 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 139 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
140 140
141 // write the view name list 141 // write the view name list
142 KABPrefs::instance()->mViewNames = mViewNameList; 142 KABPrefs::instance()->mViewNames = mViewNameList;
143 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 143 KABPrefs::instance()->mCurrentView = mActiveView->caption();
144 144
145} 145}
146 146
147QStringList ViewManager::selectedUids() const 147QStringList ViewManager::selectedUids() const
148{ 148{
149 if ( mActiveView ) 149 if ( mActiveView )
150 return mActiveView->selectedUids(); 150 return mActiveView->selectedUids();
151 else 151 else
152 return QStringList(); 152 return QStringList();
153} 153}
154 154
155QStringList ViewManager::selectedEmails() const 155QStringList ViewManager::selectedEmails() const
156{ 156{
157 if ( mActiveView ) 157 if ( mActiveView )
158 return mActiveView->selectedEmails(); 158 return mActiveView->selectedEmails();
159 else 159 else
160 return QStringList(); 160 return QStringList();
161} 161}
162 162
163KABC::Addressee::List ViewManager::selectedAddressees() const 163KABC::Addressee::List ViewManager::selectedAddressees() const
164{ 164{
165 KABC::Addressee::List list; 165 KABC::Addressee::List list;
166 if ( mActiveView ) { 166 if ( mActiveView ) {
167 QStringList uids = mActiveView->selectedUids(); 167 QStringList uids = mActiveView->selectedUids();
168 QStringList::Iterator it; 168 QStringList::Iterator it;
169 for ( it = uids.begin(); it != uids.end(); ++it ) { 169 for ( it = uids.begin(); it != uids.end(); ++it ) {
170 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 170 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
171 if ( !addr.isEmpty() ) 171 if ( !addr.isEmpty() )
172 list.append( addr ); 172 list.append( addr );
173 } 173 }
174 } 174 }
175 175
176 return list; 176 return list;
177} 177}
178//US added another method with no parameter, since my moc compiler does not support default parameters. 178//US added another method with no parameter, since my moc compiler does not support default parameters.
179void ViewManager::setSelected() 179void ViewManager::setSelected()
180{ 180{
181 setSelected( QString::null, true ); 181 setSelected( QString::null, true );
182} 182}
183 183
184void ViewManager::setSelected( const QString &uid, bool selected ) 184void ViewManager::setSelected( const QString &uid, bool selected )
185{ 185{
186 if ( mActiveView ) 186 if ( mActiveView )
187 mActiveView->setSelected( uid, selected ); 187 mActiveView->setSelected( uid, selected );
188} 188}
189 189
190void ViewManager::setListSelected(QStringList list) 190void ViewManager::setListSelected(QStringList list)
191{ 191{
192 int i, count = list.count(); 192 int i, count = list.count();
193 for ( i = 0; i < count;++i ) 193 for ( i = 0; i < count;++i )
194 setSelected( list[i], true ); 194 setSelected( list[i], true );
195 195
196} 196}
197void ViewManager::unloadViews() 197void ViewManager::unloadViews()
198{ 198{
199 mViewDict.clear(); 199 mViewDict.clear();
200 mActiveView = 0; 200 mActiveView = 0;
201} 201}
202 202
203void ViewManager::setActiveView( const QString &name ) 203void ViewManager::setActiveView( const QString &name )
204{ 204{
205 KAddressBookView *view = 0; 205 KAddressBookView *view = 0;
206 206
207 // Check that this isn't the same as the current active view 207 // Check that this isn't the same as the current active view
208 if ( mActiveView && ( mActiveView->caption() == name ) ) 208 if ( mActiveView && ( mActiveView->caption() == name ) )
209 return; 209 return;
210 210
211 // At this point we know the view that should be active is not 211 // At this point we know the view that should be active is not
212 // currently active. We will try to find the new on in the list. If 212 // currently active. We will try to find the new on in the list. If
213 // we can't find it, it means it hasn't been instantiated, so we will 213 // we can't find it, it means it hasn't been instantiated, so we will
214 // create it on demand. 214 // create it on demand.
215 215
216 view = mViewDict.find( name ); 216 view = mViewDict.find( name );
217 217
218 // Check if we found the view. If we didn't, then we need to create it 218 // Check if we found the view. If we didn't, then we need to create it
219 if ( view == 0 ) { 219 if ( view == 0 ) {
220 KConfig *config = mCore->config(); 220 KConfig *config = mCore->config();
221 221
222 KConfigGroupSaver saver( config, name ); 222 KConfigGroupSaver saver( config, name );
223 223
224 QString type = config->readEntry( "Type", "Table" ); 224 QString type = config->readEntry( "Type", "Table" );
225 225
226 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 226 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
227 227
228 ViewFactory *factory = mViewFactoryDict.find( type ); 228 ViewFactory *factory = mViewFactoryDict.find( type );
229 if ( factory ) 229 if ( factory )
230 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 230 view = factory->view( mCore->addressBook(), mViewWidgetStack );
231 231
232 if ( view ) { 232 if ( view ) {
233 view->setCaption( name ); 233 view->setCaption( name );
234 mViewDict.insert( name, view ); 234 mViewDict.insert( name, view );
235//US my version needs an int as second parameter to addWidget 235//US my version needs an int as second parameter to addWidget
236 mViewWidgetStack->addWidget( view, -1 ); 236 mViewWidgetStack->addWidget( view, -1 );
237 view->readConfig( config ); 237 view->readConfig( config );
238 238
239 // The manager just relays the signals 239 // The manager just relays the signals
240 connect( view, SIGNAL( selected( const QString& ) ), 240 connect( view, SIGNAL( selected( const QString& ) ),
241 SIGNAL( selected( const QString & ) ) ); 241 SIGNAL( selected( const QString & ) ) );
242 connect( view, SIGNAL( executed( const QString& ) ), 242 connect( view, SIGNAL( executed( const QString& ) ),
243 SIGNAL( executed( const QString& ) ) ); 243 SIGNAL( executed( const QString& ) ) );
244 244
245 connect( view, SIGNAL( deleteRequest( ) ), 245 connect( view, SIGNAL( deleteRequest( ) ),
246 SIGNAL( deleteRequest( ) ) ); 246 SIGNAL( deleteRequest( ) ) );
247 247
248 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 248 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
249 connect( view, SIGNAL( dropped( QDropEvent* ) ), 249 connect( view, SIGNAL( dropped( QDropEvent* ) ),
250 SLOT( dropped( QDropEvent* ) ) ); 250 SLOT( dropped( QDropEvent* ) ) );
251 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 251 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
252 } 252 }
253 } 253 }
254 254
255 // If we found or created the view, raise it and refresh it 255 // If we found or created the view, raise it and refresh it
256 if ( view ) { 256 if ( view ) {
257 mActiveView = view; 257 mActiveView = view;
258 mViewWidgetStack->raiseWidget( view ); 258 mViewWidgetStack->raiseWidget( view );
259 // Set the proper filter in the view. By setting the combo 259 // Set the proper filter in the view. By setting the combo
260 // box, the activated slot will be called, which will push 260 // box, the activated slot will be called, which will push
261 // the filter to the view and refresh it. 261 // the filter to the view and refresh it.
262 262
263 if ( view->defaultFilterType() == KAddressBookView::None ) { 263 if ( view->defaultFilterType() == KAddressBookView::None ) {
264 264
265 mActionSelectFilter->setCurrentItem( 0 ); 265 mActionSelectFilter->setCurrentItem( 0 );
266 setActiveFilter( 0 ); 266 setActiveFilter( 0 );
267 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 267 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
268 setActiveFilter( mActionSelectFilter->currentItem() ); 268 setActiveFilter( mActionSelectFilter->currentItem() );
269 } else { 269 } else {
270 uint pos = filterPosition( view->defaultFilterName() ); 270 uint pos = filterPosition( view->defaultFilterName() );
271 mActionSelectFilter->setCurrentItem( pos ); 271 mActionSelectFilter->setCurrentItem( pos );
272 setActiveFilter( pos ); 272 setActiveFilter( pos );
273 } 273 }
274//US qDebug("ViewManager::setActiveView 6" ); 274//US qDebug("ViewManager::setActiveView 6" );
275 275
276 // Update the inc search widget to show the fields in the new active 276 // Update the inc search widget to show the fields in the new active
277 // view. 277 // view.
278 mCore->setSearchFields( mActiveView->fields() ); 278 mCore->setSearchFields( mActiveView->fields() );
279 279
280//US performance optimization. setActiveFilter calls also mActiveView->refresh() 280//US performance optimization. setActiveFilter calls also mActiveView->refresh()
281//US mActiveView->refresh(); 281//US mActiveView->refresh();
282 282
283 } 283 }
284 else 284 else
285 { 285 {
286 qDebug("ViewManager::setActiveView: unable to find view" ); 286 qDebug("ViewManager::setActiveView: unable to find view" );
287 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; 287 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
288 } 288 }
289} 289}
290 290
291//US added another method with no parameter, since my moc compiler does not support default parameters. 291//US added another method with no parameter, since my moc compiler does not support default parameters.
292void ViewManager::refreshView() 292void ViewManager::refreshView()
293{ 293{
294 refreshView( QString::null ); 294 refreshView( QString::null );
295} 295}
296 296
297void ViewManager::refreshView( const QString &uid ) 297void ViewManager::refreshView( const QString &uid )
298{ 298{
299 if ( mActiveView ) 299 if ( mActiveView )
300 mActiveView->refresh( uid ); 300 mActiveView->refresh( uid );
301} 301}
302 302
303void ViewManager::setFocusAV() 303void ViewManager::setFocusAV()
304{ 304{
305 if ( mActiveView ) 305 if ( mActiveView )
306 mActiveView->setFocus(); 306 mActiveView->setFocusAV();
307} 307}
308void ViewManager::editView() 308void ViewManager::editView()
309{ 309{
310 if ( !mActiveView ) 310 if ( !mActiveView )
311 return; 311 return;
312 312
313 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 313 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
314 ViewConfigureWidget *wdg = 0; 314 ViewConfigureWidget *wdg = 0;
315 ViewConfigureDialog* dlg = 0; 315 ViewConfigureDialog* dlg = 0;
316 if ( factory ) { 316 if ( factory ) {
317 // Save the filters so the dialog has the latest set 317 // Save the filters so the dialog has the latest set
318 Filter::save( mCore->config(), "Filter", mFilterList ); 318 Filter::save( mCore->config(), "Filter", mFilterList );
319 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 319 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
320 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 320 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
321 } else { 321 } else {
322 qDebug("ViewManager::editView()::cannot find viewfactory "); 322 qDebug("ViewManager::editView()::cannot find viewfactory ");
323 return; 323 return;
324 } 324 }
325 if ( wdg ) { 325 if ( wdg ) {
326 dlg->setWidget( wdg ); 326 dlg->setWidget( wdg );
327 327
328#ifndef DESKTOP_VERSION 328#ifndef DESKTOP_VERSION
329 //dlg.setMaximumSize( 640, 480 ); 329 //dlg.setMaximumSize( 640, 480 );
330 //dlg->setGeometry( 40,40, 400, 300); 330 //dlg->setGeometry( 40,40, 400, 300);
331 dlg->showMaximized(); 331 dlg->showMaximized();
332#endif 332#endif
333 333
334 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 334 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
335 335
336 dlg->restoreSettings( mCore->config() ); 336 dlg->restoreSettings( mCore->config() );
337 337
338 if ( dlg->exec() ) { 338 if ( dlg->exec() ) {
339 dlg->saveSettings( mCore->config() ); 339 dlg->saveSettings( mCore->config() );
340 mActiveView->readConfig( mCore->config() ); 340 mActiveView->readConfig( mCore->config() );
341 341
342 // Set the proper filter in the view. By setting the combo 342 // Set the proper filter in the view. By setting the combo
343 // box, the activated slot will be called, which will push 343 // box, the activated slot will be called, which will push
344 // the filter to the view and refresh it. 344 // the filter to the view and refresh it.
345 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 345 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
346 mActionSelectFilter->setCurrentItem( 0 ); 346 mActionSelectFilter->setCurrentItem( 0 );
347 setActiveFilter( 0 ); 347 setActiveFilter( 0 );
348 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 348 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
349 setActiveFilter( mActionSelectFilter->currentItem() ); 349 setActiveFilter( mActionSelectFilter->currentItem() );
350 } else { 350 } else {
351 uint pos = filterPosition( mActiveView->defaultFilterName() ); 351 uint pos = filterPosition( mActiveView->defaultFilterName() );
352 mActionSelectFilter->setCurrentItem( pos ); 352 mActionSelectFilter->setCurrentItem( pos );
353 setActiveFilter( pos ); 353 setActiveFilter( pos );
354 } 354 }
355 mCore->setSearchFields( mActiveView->fields() ); 355 mCore->setSearchFields( mActiveView->fields() );
356//US performance optimization. setActiveFilter calls also mActiveView->refresh() 356//US performance optimization. setActiveFilter calls also mActiveView->refresh()
357//US mActiveView->refresh(); 357//US mActiveView->refresh();
358 358
359 359
360 //US this is a bugfix, that we get notified if we change a views configuration 360 //US this is a bugfix, that we get notified if we change a views configuration
361 emit modified(); 361 emit modified();
362 362
363 } 363 }
364 364
365 } 365 }
366 delete dlg; 366 delete dlg;
367} 367}
368 368
369void ViewManager::deleteView() 369void ViewManager::deleteView()
370{ 370{
371 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 371 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
372 .arg( mActiveView->caption() ); 372 .arg( mActiveView->caption() );
373 QString caption = i18n( "Confirm Delete" ); 373 QString caption = i18n( "Confirm Delete" );
374 374
375 375
376 if (QMessageBox::information( this, caption, 376 if (QMessageBox::information( this, caption,
377 text, 377 text,
378 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 378 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
379 { 379 {
380 mViewNameList.remove( mActiveView->caption() ); 380 mViewNameList.remove( mActiveView->caption() );
381 381
382 // remove the view from the config file 382 // remove the view from the config file
383 KConfig *config = mCore->config(); 383 KConfig *config = mCore->config();
384 config->deleteGroup( mActiveView->caption() ); 384 config->deleteGroup( mActiveView->caption() );
385 385
386 mViewDict.remove( mActiveView->caption() ); 386 mViewDict.remove( mActiveView->caption() );
387 mActiveView = 0; 387 mActiveView = 0;
388 388
389 // we are in an invalid state now, but that should be fixed after 389 // we are in an invalid state now, but that should be fixed after
390 // we emit the signal 390 // we emit the signal
391 mActionSelectView->setItems( mViewNameList ); 391 mActionSelectView->setItems( mViewNameList );
392 if ( mViewNameList.count() > 0 ) { 392 if ( mViewNameList.count() > 0 ) {
393 mActionSelectView->setCurrentItem( 0 ); 393 mActionSelectView->setCurrentItem( 0 );
394 setActiveView( mViewNameList[ 0 ] ); 394 setActiveView( mViewNameList[ 0 ] );
395 } 395 }
396 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 396 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
397 } 397 }
398} 398}
399 399
400void ViewManager::addView() 400void ViewManager::addView()
401{ 401{
402 AddViewDialog dialog( &mViewFactoryDict, this ); 402 AddViewDialog dialog( &mViewFactoryDict, this );
403 403
404 if ( dialog.exec() ) { 404 if ( dialog.exec() ) {
405 QString newName = dialog.viewName(); 405 QString newName = dialog.viewName();
406 QString type = dialog.viewType(); 406 QString type = dialog.viewType();
407 407
408 // Check for name conflicts 408 // Check for name conflicts
409 bool firstConflict = true; 409 bool firstConflict = true;
410 int numTries = 1; 410 int numTries = 1;
411 while ( mViewNameList.contains( newName ) > 0 ) { 411 while ( mViewNameList.contains( newName ) > 0 ) {
412 if ( !firstConflict ) { 412 if ( !firstConflict ) {
413 newName = newName.left( newName.length() - 4 ); 413 newName = newName.left( newName.length() - 4 );
414 firstConflict = false; 414 firstConflict = false;
415 } 415 }
416 416
417 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 417 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
418 numTries++; 418 numTries++;
419 } 419 }
420 420
421 // Add the new one to the list 421 // Add the new one to the list
422 mViewNameList.append( newName ); 422 mViewNameList.append( newName );
423 423
424 // write the view to the config file, 424 // write the view to the config file,
425 KConfig *config = mCore->config(); 425 KConfig *config = mCore->config();
426 426
427 config->deleteGroup( newName ); 427 config->deleteGroup( newName );
428 428
429 KConfigGroupSaver saver( config, newName ); 429 KConfigGroupSaver saver( config, newName );
430 430
431 config->writeEntry( "Type", type ); 431 config->writeEntry( "Type", type );
432 432
433 // try to set the active view 433 // try to set the active view
434 mActionSelectView->setItems( mViewNameList ); 434 mActionSelectView->setItems( mViewNameList );
435 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 435 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
436 setActiveView( newName ); 436 setActiveView( newName );
437 437
438 editView(); 438 editView();
439 439
440 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 440 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
441 } 441 }
442} 442}
443 443
444void ViewManager::createViewFactories() 444void ViewManager::createViewFactories()
445{ 445{
446#ifndef KAB_EMBEDDED 446#ifndef KAB_EMBEDDED
447 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 447 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
448 KTrader::OfferList::ConstIterator it; 448 KTrader::OfferList::ConstIterator it;
449 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 449 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
450 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 450 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
451 continue; 451 continue;
452 452
453 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 453 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
454 454
455 if ( !factory ) { 455 if ( !factory ) {
456 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 456 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
457 continue; 457 continue;
458 } 458 }
459 459
460 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 460 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
461 461
462 if ( !viewFactory ) { 462 if ( !viewFactory ) {
463 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 463 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
464 continue; 464 continue;
465 } 465 }
466 466
467 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 467 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
468 } 468 }
469 469
470#else //KAB_EMBEDDED 470#else //KAB_EMBEDDED
471 ViewFactory* viewFactory = new IconViewFactory(); 471 ViewFactory* viewFactory = new IconViewFactory();
472 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 472 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
473// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 473// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
474 474
475 viewFactory = new TableViewFactory(); 475 viewFactory = new TableViewFactory();
476 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 476 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
478 478
479 viewFactory = new CardViewFactory(); 479 viewFactory = new CardViewFactory();
480 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 480 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
482 482
483#endif //KAB_EMBEDDED 483#endif //KAB_EMBEDDED
484 484
485} 485}
486 486
487void ViewManager::dropped( QDropEvent *e ) 487void ViewManager::dropped( QDropEvent *e )
488{ 488{
489 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 489 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
490 490
491#ifndef KAB_EMBEDDED 491#ifndef KAB_EMBEDDED
492 492
493 QString clipText, vcards; 493 QString clipText, vcards;
494 KURL::List urls; 494 KURL::List urls;
495 495
496 if ( KURLDrag::decode( e, urls) ) { 496 if ( KURLDrag::decode( e, urls) ) {
497 KURL::List::Iterator it = urls.begin(); 497 KURL::List::Iterator it = urls.begin();
498 int c = urls.count(); 498 int c = urls.count();
499 if ( c > 1 ) { 499 if ( c > 1 ) {
500 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 500 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
501 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 501 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
502 for ( ; it != urls.end(); ++it ) 502 for ( ; it != urls.end(); ++it )
503 emit urlDropped( *it ); 503 emit urlDropped( *it );
504 } 504 }
505 } else if ( c == 1 ) 505 } else if ( c == 1 )
506 emit urlDropped( *it ); 506 emit urlDropped( *it );
507 } else if ( KVCardDrag::decode( e, vcards ) ) { 507 } else if ( KVCardDrag::decode( e, vcards ) ) {
508 KABC::Addressee addr; 508 KABC::Addressee addr;
509 KABC::VCardConverter converter; 509 KABC::VCardConverter converter;
510 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 510 QStringList list = QStringList::split( "\r\n\r\n", vcards );
511 QStringList::Iterator it; 511 QStringList::Iterator it;
512 for ( it = list.begin(); it != list.end(); ++it ) { 512 for ( it = list.begin(); it != list.end(); ++it ) {
513 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 513 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
514 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 514 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
515 if ( a.isEmpty() ) { 515 if ( a.isEmpty() ) {
516 mCore->addressBook()->insertAddressee( addr ); 516 mCore->addressBook()->insertAddressee( addr );
517 emit modified(); 517 emit modified();
518 } 518 }
519 } 519 }
520 } 520 }
521 521
522 mActiveView->refresh(); 522 mActiveView->refresh();
523 } 523 }
524#else //KAB_EMBEDDED 524#else //KAB_EMBEDDED
525qDebug("ViewManager::dropped() has to be changed!!" ); 525qDebug("ViewManager::dropped() has to be changed!!" );
526#endif //KAB_EMBEDDED 526#endif //KAB_EMBEDDED
527 527
528} 528}
529 529
530void ViewManager::startDrag() 530void ViewManager::startDrag()
531{ 531{
532 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 532 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
533 533
534#ifndef KAB_EMBEDDED 534#ifndef KAB_EMBEDDED
535 535
536 // Get the list of all the selected addressees 536 // Get the list of all the selected addressees
537 KABC::Addressee::List addrList; 537 KABC::Addressee::List addrList;
538 QStringList uidList = selectedUids(); 538 QStringList uidList = selectedUids();
539 QStringList::Iterator iter; 539 QStringList::Iterator iter;
540 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 540 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
541 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 541 addrList.append( mCore->addressBook()->findByUid( *iter ) );
542 542
543 KMultipleDrag *drag = new KMultipleDrag( this ); 543 KMultipleDrag *drag = new KMultipleDrag( this );
544 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 544 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
545 KABC::Addressee::List::Iterator it; 545 KABC::Addressee::List::Iterator it;
546 QStringList vcards; 546 QStringList vcards;
547 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 547 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
548 QString vcard = QString::null; 548 QString vcard = QString::null;
549 KABC::VCardConverter converter; 549 KABC::VCardConverter converter;
550 if ( converter.addresseeToVCard( *it, vcard ) ) 550 if ( converter.addresseeToVCard( *it, vcard ) )
551 vcards.append( vcard ); 551 vcards.append( vcard );
552 } 552 }
553 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 553 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
554 554
555 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 555 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
556 drag->dragCopy(); 556 drag->dragCopy();
557 557
558#else //KAB_EMBEDDED 558#else //KAB_EMBEDDED
559qDebug("ViewManager::startDrag() has to be changed!!" ); 559qDebug("ViewManager::startDrag() has to be changed!!" );
560#endif //KAB_EMBEDDED 560#endif //KAB_EMBEDDED
561 561
562} 562}
563void ViewManager::doSearch( const QString& s,KABC::Field *field ) 563void ViewManager::doSearch( const QString& s,KABC::Field *field )
564{ 564{
565 if ( mActiveView ) 565 if ( mActiveView )
566 mActiveView->doSearch( s, field ); 566 mActiveView->doSearch( s, field );
567 567
568} 568}
569void ViewManager::setActiveFilter( int index ) 569void ViewManager::setActiveFilter( int index )
570{ 570{
571 Filter currentFilter; 571 Filter currentFilter;
572 572
573 if ( ( index - 1 ) < 0 ) 573 if ( ( index - 1 ) < 0 )
574 currentFilter = Filter(); 574 currentFilter = Filter();
575 else 575 else
576 currentFilter = mFilterList[ index - 1 ]; 576 currentFilter = mFilterList[ index - 1 ];
577 577
578 // Check if we have a view. Since the filter combo is created before 578 // Check if we have a view. Since the filter combo is created before
579 // the view, this slot could be called before there is a valid view. 579 // the view, this slot could be called before there is a valid view.
580 if ( mActiveView ) { 580 if ( mActiveView ) {
581 mActiveView->setFilter( currentFilter ); 581 mActiveView->setFilter( currentFilter );
582 mActiveView->refresh(); 582 mActiveView->refresh();
583 emit selected( QString::null ); 583 emit selected( QString::null );
584 } 584 }
585} 585}
586 586
587void ViewManager::configureFilters() 587void ViewManager::configureFilters()
588{ 588{
589 FilterDialog dlg( this ); 589 FilterDialog dlg( this );
590 590
591 dlg.setFilters( mFilterList ); 591 dlg.setFilters( mFilterList );
592 592
593 if ( dlg.exec() ) 593 if ( dlg.exec() )
594 mFilterList = dlg.filters(); 594 mFilterList = dlg.filters();
595 595
596 uint pos = mActionSelectFilter->currentItem(); 596 uint pos = mActionSelectFilter->currentItem();
597 mActionSelectFilter->setItems( filterNames() ); 597 mActionSelectFilter->setItems( filterNames() );
598 mActionSelectFilter->setCurrentItem( pos ); 598 mActionSelectFilter->setCurrentItem( pos );
599 setActiveFilter( pos ); 599 setActiveFilter( pos );
600 //mActionSelectFilter->setComboWidth( 150 );
600} 601}
601 602
602QStringList ViewManager::filterNames() const 603QStringList ViewManager::filterNames() const
603{ 604{
604 QStringList names( i18n( "No Filter" ) ); 605 QStringList names( i18n( "No Filter" ) );
605 606
606 Filter::List::ConstIterator it; 607 Filter::List::ConstIterator it;
607 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 608 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
608 names.append( (*it).name() ); 609 names.append( (*it).name() );
609 610
610 return names; 611 return names;
611} 612}
612 613
613int ViewManager::filterPosition( const QString &name ) const 614int ViewManager::filterPosition( const QString &name ) const
614{ 615{
615 int pos = 0; 616 int pos = 0;
616 617
617 Filter::List::ConstIterator it; 618 Filter::List::ConstIterator it;
618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 619 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
619 if ( name == (*it).name() ) 620 if ( name == (*it).name() )
620 return pos + 1; 621 return pos + 1;
621 622
622 return 0; 623 return 0;
623} 624}
624 625
625void ViewManager::initActions() 626void ViewManager::initActions()
626{ 627{
627//US <ActionList name="view_loadedviews"/> 628//US <ActionList name="view_loadedviews"/>
628//US <Separator/> 629//US <Separator/>
629 630
630#ifdef KAB_EMBEDDED 631#ifdef KAB_EMBEDDED
631 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 632 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
632 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 633 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
633 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 634 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
634#endif //KAB_EMBEDDED 635#endif //KAB_EMBEDDED
635 636
636 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 637 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
637#if KDE_VERSION >= 309 638#if KDE_VERSION >= 309
638 mActionSelectView->setMenuAccelsEnabled( false ); 639 mActionSelectView->setMenuAccelsEnabled( false );
639#endif 640#endif
640 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 641 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
641 SLOT( setActiveView( const QString& ) ) ); 642 SLOT( setActiveView( const QString& ) ) );
642 643
643 644
644#ifdef KAB_EMBEDDED 645#ifdef KAB_EMBEDDED
645 mActionSelectView->plug(viewmenu); 646 mActionSelectView->plug(viewmenu);
646 viewmenu->insertSeparator(); 647 viewmenu->insertSeparator();
647#endif //KAB_EMBEDDED 648#endif //KAB_EMBEDDED
648 649
649 KAction *action; 650 KAction *action;
650 651
651 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 652 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
652 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 653 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
653#ifndef KAB_EMBEDDED 654#ifndef KAB_EMBEDDED
654 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." ) ); 655 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
655#else //KAB_EMBEDDED 656#else //KAB_EMBEDDED
656 action->plug(viewmenu); 657 action->plug(viewmenu);
657#endif //KAB_EMBEDDED 658#endif //KAB_EMBEDDED
658 659
659 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 660 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
660 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 661 SLOT( addView() ), mCore->actionCollection(), "view_add" );
661#ifndef KAB_EMBEDDED 662#ifndef KAB_EMBEDDED
662 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." ) ); 663 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
663#else //KAB_EMBEDDED 664#else //KAB_EMBEDDED
664 action->plug(viewmenu); 665 action->plug(viewmenu);
665#endif //KAB_EMBEDDED 666#endif //KAB_EMBEDDED
666 667
667 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 668 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
668 this, SLOT( deleteView() ), 669 this, SLOT( deleteView() ),
669 mCore->actionCollection(), "view_delete" ); 670 mCore->actionCollection(), "view_delete" );
670#ifndef KAB_EMBEDDED 671#ifndef KAB_EMBEDDED
671 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 672 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
672#else //KAB_EMBEDDED 673#else //KAB_EMBEDDED
673 mActionDeleteView->plug(viewmenu); 674 mActionDeleteView->plug(viewmenu);
674 viewmenu->insertSeparator(); 675 viewmenu->insertSeparator();
675#endif //KAB_EMBEDDED 676#endif //KAB_EMBEDDED
676 677
677#ifndef KAB_EMBEDDED 678#ifndef KAB_EMBEDDED
678 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 679 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
679 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 680 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
680 "view_refresh" ); 681 "view_refresh" );
681 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 682 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
682#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
683 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 684 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
684 SLOT( refreshView()), mCore->actionCollection(), 685 SLOT( refreshView()), mCore->actionCollection(),
685 "view_refresh" ); 686 "view_refresh" );
686 action->plug(viewmenu); 687 action->plug(viewmenu);
687 viewmenu->insertSeparator(); 688 viewmenu->insertSeparator();
688#endif //KAB_EMBEDDED 689#endif //KAB_EMBEDDED
689 690
690 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 691 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
691 SLOT( configureFilters() ), mCore->actionCollection(), 692 SLOT( configureFilters() ), mCore->actionCollection(),
692 "options_edit_filters" ); 693 "options_edit_filters" );
693 694
694 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 695 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
695
696#if KDE_VERSION >= 309 696#if KDE_VERSION >= 309
697 mActionSelectFilter->setMenuAccelsEnabled( false ); 697 mActionSelectFilter->setMenuAccelsEnabled( false );
698#endif 698#endif
699 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 699 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
700 SLOT( setActiveFilter( int ) ) ); 700 SLOT( setActiveFilter( int ) ) );
701 701
702#ifdef KAB_EMBEDDED 702#ifdef KAB_EMBEDDED
703 action->plug(settingsmenu); 703 action->plug(settingsmenu);
704 mActionSelectFilter->plug(viewmenu); 704 mActionSelectFilter->plug(viewmenu);
705#endif //KAB_EMBEDDED 705#endif //KAB_EMBEDDED
706 706
707} 707}
708 708
709void ViewManager::initGUI() 709void ViewManager::initGUI()
710{ 710{
711 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 711 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
712 mViewWidgetStack = new QWidgetStack( this ); 712 mViewWidgetStack = new QWidgetStack( this );
713 layout->addWidget( mViewWidgetStack ); 713 layout->addWidget( mViewWidgetStack );
714} 714}
715 715
716#ifndef KAB_EMBEDDED 716#ifndef KAB_EMBEDDED
717#include "viewmanager.moc" 717#include "viewmanager.moc"
718#endif //KAB_EMBEDDED 718#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index a7bf6c9..7f33bb4 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,464 +1,469 @@
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 <qdragobject.h> 24#include <qdragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <qiconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kabc/addressee.h> 33#include <kabc/addressee.h>
34#include <kconfig.h> 34#include <kconfig.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabprefs.h" 38#include "kabprefs.h"
39#include "viewmanager.h" 39#include "viewmanager.h"
40 40
41#include "kaddressbookcardview.h" 41#include "kaddressbookcardview.h"
42 42
43#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
44extern "C" { 44extern "C" {
45 void *init_libkaddrbk_cardview() 45 void *init_libkaddrbk_cardview()
46 { 46 {
47 return ( new CardViewFactory ); 47 return ( new CardViewFactory );
48 } 48 }
49} 49}
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51 51
52//////////////////////////////// 52////////////////////////////////
53// AddresseeCardViewItem (internal class) 53// AddresseeCardViewItem (internal class)
54class AddresseeCardViewItem : public CardViewItem 54class AddresseeCardViewItem : public CardViewItem
55{ 55{
56 public: 56 public:
57 AddresseeCardViewItem(const KABC::Field::List &fields, 57 AddresseeCardViewItem(const KABC::Field::List &fields,
58 bool showEmptyFields, 58 bool showEmptyFields,
59 KABC::AddressBook *doc, const KABC::Addressee &a, 59 KABC::AddressBook *doc, const KABC::Addressee &a,
60 CardView *parent) 60 CardView *parent)
61 : CardViewItem(parent, a.formattedName()), 61 : CardViewItem(parent, a.formattedName()),
62 mFields( fields ), mShowEmptyFields(showEmptyFields), 62 mFields( fields ), mShowEmptyFields(showEmptyFields),
63 mDocument(doc), mAddressee(a) 63 mDocument(doc), mAddressee(a)
64 { 64 {
65 if ( mFields.isEmpty() ) { 65 if ( mFields.isEmpty() ) {
66 mFields = KABC::Field::defaultFields(); 66 mFields = KABC::Field::defaultFields();
67 } 67 }
68 refresh(); 68 refresh();
69 } 69 }
70 70
71 const KABC::Addressee &addressee() const { return mAddressee; } 71 const KABC::Addressee &addressee() const { return mAddressee; }
72 72
73 void refresh() 73 void refresh()
74 { 74 {
75 // Update our addressee, since it may have changed elsewhere 75 // Update our addressee, since it may have changed elsewhere
76 mAddressee = mDocument->findByUid(mAddressee.uid()); 76 mAddressee = mDocument->findByUid(mAddressee.uid());
77 77
78 if (!mAddressee.isEmpty()) 78 if (!mAddressee.isEmpty())
79 { 79 {
80 clearFields(); 80 clearFields();
81 81
82 // Try all the selected fields until we find one with text. 82 // Try all the selected fields until we find one with text.
83 // This will limit the number of unlabeled icons in the view 83 // This will limit the number of unlabeled icons in the view
84 KABC::Field::List::Iterator iter; 84 KABC::Field::List::Iterator iter;
85 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 85 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
86 { 86 {
87 // insert empty fields or not? not doing so saves a bit of memory and CPU 87 // insert empty fields or not? not doing so saves a bit of memory and CPU
88 // (during geometry calculations), but prevents having equally 88 // (during geometry calculations), but prevents having equally
89 // wide label columns in all cards, unless CardViewItem/CardView search 89 // wide label columns in all cards, unless CardViewItem/CardView search
90 // globally for the widest label. (anders) 90 // globally for the widest label. (anders)
91 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 91 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
92 insertField((*iter)->label(), (*iter)->value( mAddressee )); 92 insertField((*iter)->label(), (*iter)->value( mAddressee ));
93 } 93 }
94 94
95 // We might want to make this the first field. hmm... -mpilone 95 // We might want to make this the first field. hmm... -mpilone
96 setCaption( mAddressee.realName() ); 96 setCaption( mAddressee.realName() );
97 } 97 }
98 } 98 }
99 99
100 private: 100 private:
101 KABC::Field::List mFields; 101 KABC::Field::List mFields;
102 bool mShowEmptyFields; 102 bool mShowEmptyFields;
103 KABC::AddressBook *mDocument; 103 KABC::AddressBook *mDocument;
104 KABC::Addressee mAddressee; 104 KABC::Addressee mAddressee;
105}; 105};
106 106
107/////////////////////////////// 107///////////////////////////////
108// AddresseeCardView 108// AddresseeCardView
109 109
110AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 110AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
111 : CardView(parent, name) 111 : CardView(parent, name)
112{ 112{
113 setAcceptDrops(true); 113 setAcceptDrops(true);
114} 114}
115 115
116AddresseeCardView::~AddresseeCardView() 116AddresseeCardView::~AddresseeCardView()
117{ 117{
118} 118}
119 119
120 120
121void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 121void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
122{ 122{
123#ifndef KAB_EMBEDDED 123#ifndef KAB_EMBEDDED
124 if (QTextDrag::canDecode(e)) 124 if (QTextDrag::canDecode(e))
125 e->accept(); 125 e->accept();
126#else //KAB_EMBEDDED 126#else //KAB_EMBEDDED
127qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 127qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
128#endif //KAB_EMBEDDED 128#endif //KAB_EMBEDDED
129} 129}
130 130
131void AddresseeCardView::dropEvent(QDropEvent *e) 131void AddresseeCardView::dropEvent(QDropEvent *e)
132{ 132{
133 emit addresseeDropped(e); 133 emit addresseeDropped(e);
134} 134}
135 135
136void AddresseeCardView::startDrag() 136void AddresseeCardView::startDrag()
137{ 137{
138 emit startAddresseeDrag(); 138 emit startAddresseeDrag();
139} 139}
140 140
141 141
142/////////////////////////////// 142///////////////////////////////
143// KAddressBookCardView 143// KAddressBookCardView
144 144
145KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 145KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
146 QWidget *parent, const char *name ) 146 QWidget *parent, const char *name )
147 : KAddressBookView( ab, parent, name ) 147 : KAddressBookView( ab, parent, name )
148{ 148{
149 mShowEmptyFields = false; 149 mShowEmptyFields = false;
150 150
151 // Init the GUI 151 // Init the GUI
152 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 152 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
153 153
154 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 154 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
155 mCardView->setSelectionMode(CardView::Extended); 155 mCardView->setSelectionMode(CardView::Extended);
156 layout->addWidget(mCardView); 156 layout->addWidget(mCardView);
157 157
158 // Connect up the signals 158 // Connect up the signals
159 connect(mCardView, SIGNAL(executed(CardViewItem *)), 159 connect(mCardView, SIGNAL(executed(CardViewItem *)),
160 this, SLOT(addresseeExecuted(CardViewItem *))); 160 this, SLOT(addresseeExecuted(CardViewItem *)));
161 connect(mCardView, SIGNAL(selectionChanged()), 161 connect(mCardView, SIGNAL(selectionChanged()),
162 this, SLOT(addresseeSelected())); 162 this, SLOT(addresseeSelected()));
163 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 163 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
164 this, SIGNAL(dropped(QDropEvent*))); 164 this, SIGNAL(dropped(QDropEvent*)));
165 connect(mCardView, SIGNAL(startAddresseeDrag()), 165 connect(mCardView, SIGNAL(startAddresseeDrag()),
166 this, SIGNAL(startDrag())); 166 this, SIGNAL(startDrag()));
167} 167}
168 168
169KAddressBookCardView::~KAddressBookCardView() 169KAddressBookCardView::~KAddressBookCardView()
170{ 170{
171} 171}
172void KAddressBookCardView::setFocusAV()
173{
174 if ( mCardView )
175 mCardView->setFocus();
172 176
177}
173void KAddressBookCardView::scrollUP() 178void KAddressBookCardView::scrollUP()
174{ 179{
175 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 180 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
176 QApplication::postEvent( mCardView, ev ); 181 QApplication::postEvent( mCardView, ev );
177 182
178} 183}
179void KAddressBookCardView::scrollDOWN() 184void KAddressBookCardView::scrollDOWN()
180{ 185{
181 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 186 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
182 QApplication::postEvent( mCardView, ev ); 187 QApplication::postEvent( mCardView, ev );
183} 188}
184void KAddressBookCardView::readConfig(KConfig *config) 189void KAddressBookCardView::readConfig(KConfig *config)
185{ 190{
186 KAddressBookView::readConfig(config); 191 KAddressBookView::readConfig(config);
187 192
188 // costum colors? 193 // costum colors?
189 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 194 if ( config->readBoolEntry( "EnableCustomColors", false ) )
190 { 195 {
191 QPalette p( mCardView->palette() ); 196 QPalette p( mCardView->palette() );
192 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 197 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
193 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 198 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
194 c = p.color(QPalette::Normal, QColorGroup::Text ); 199 c = p.color(QPalette::Normal, QColorGroup::Text );
195 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 200 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
196 c = p.color(QPalette::Normal, QColorGroup::Button ); 201 c = p.color(QPalette::Normal, QColorGroup::Button );
197 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 202 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
198 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 203 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
199 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 204 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
200 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 205 c = p.color(QPalette::Normal, QColorGroup::Highlight );
201 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 206 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
202 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 207 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
203 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 208 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
204 mCardView->viewport()->setPalette( p ); 209 mCardView->viewport()->setPalette( p );
205 } 210 }
206 else 211 else
207 { 212 {
208 // needed if turned off during a session. 213 // needed if turned off during a session.
209 mCardView->viewport()->setPalette( mCardView->palette() ); 214 mCardView->viewport()->setPalette( mCardView->palette() );
210 } 215 }
211 216
212 //custom fonts? 217 //custom fonts?
213 QFont f( font() ); 218 QFont f( font() );
214 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 219 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
215 { 220 {
216 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 221 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
217 f.setBold( true ); 222 f.setBold( true );
218 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 223 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
219 } 224 }
220 else 225 else
221 { 226 {
222 mCardView->setFont( f ); 227 mCardView->setFont( f );
223 f.setBold( true ); 228 f.setBold( true );
224 mCardView->setHeaderFont( f ); 229 mCardView->setHeaderFont( f );
225 } 230 }
226 231
227 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 232 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
228 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 233 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
229 true)); 234 true));
230 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 235 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
231 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 236 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
232 237
233 mCardView->setShowEmptyFields( mShowEmptyFields ); 238 mCardView->setShowEmptyFields( mShowEmptyFields );
234 239
235 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 240 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
236 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 241 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
237 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 242 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
238 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 243 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
239 244
240 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 245 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
241 this, SLOT(addresseeExecuted(CardViewItem *))); 246 this, SLOT(addresseeExecuted(CardViewItem *)));
242 247
243 if (KABPrefs::instance()->mHonorSingleClick) 248 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mCardView, SIGNAL(executed(CardViewItem *)), 249 connect(mCardView, SIGNAL(executed(CardViewItem *)),
245 this, SLOT(addresseeExecuted(CardViewItem *))); 250 this, SLOT(addresseeExecuted(CardViewItem *)));
246 else 251 else
247 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 252 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
248 this, SLOT(addresseeExecuted(CardViewItem *))); 253 this, SLOT(addresseeExecuted(CardViewItem *)));
249 254
250} 255}
251 256
252void KAddressBookCardView::writeConfig( KConfig *config ) 257void KAddressBookCardView::writeConfig( KConfig *config )
253{ 258{
254 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 259 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
255 KAddressBookView::writeConfig( config ); 260 KAddressBookView::writeConfig( config );
256} 261}
257void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 262void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
258{ 263{
259 mCardView->clear(); 264 mCardView->clear();
260 if ( s.isEmpty() || s == "*" ) { 265 if ( s.isEmpty() || s == "*" ) {
261 refresh(); 266 refresh();
262 return; 267 return;
263 } 268 }
264 QString pattern = s.lower()+"*"; 269 QString pattern = s.lower()+"*";
265 QRegExp re; 270 QRegExp re;
266 re.setWildcard(true); // most people understand these better. 271 re.setWildcard(true); // most people understand these better.
267 re.setCaseSensitive(false); 272 re.setCaseSensitive(false);
268 re.setPattern( pattern ); 273 re.setPattern( pattern );
269 if (!re.isValid()) 274 if (!re.isValid())
270 return; 275 return;
271 mCardView->viewport()->setUpdatesEnabled( false ); 276 mCardView->viewport()->setUpdatesEnabled( false );
272 KABC::Addressee::List addresseeList = addressees(); 277 KABC::Addressee::List addresseeList = addressees();
273 KABC::Addressee::List::Iterator it; 278 KABC::Addressee::List::Iterator it;
274 if ( field ) { 279 if ( field ) {
275 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 280 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
276#if QT_VERSION >= 300 281#if QT_VERSION >= 300
277 if (re.search(field->value( *it ).lower()) != -1) 282 if (re.search(field->value( *it ).lower()) != -1)
278#else 283#else
279 if (re.match(field->value( *it ).lower()) != -1) 284 if (re.match(field->value( *it ).lower()) != -1)
280#endif 285#endif
281 new AddresseeCardViewItem(fields(), mShowEmptyFields, 286 new AddresseeCardViewItem(fields(), mShowEmptyFields,
282 addressBook(), *it, mCardView); 287 addressBook(), *it, mCardView);
283 288
284 } 289 }
285 } else { 290 } else {
286 KABC::Field::List fieldList = fields(); 291 KABC::Field::List fieldList = fields();
287 KABC::Field::List::ConstIterator fieldIt; 292 KABC::Field::List::ConstIterator fieldIt;
288 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 293 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
289 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 294 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
290#if QT_VERSION >= 300 295#if QT_VERSION >= 300
291 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 296 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
292#else 297#else
293 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 298 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
294#endif 299#endif
295 { 300 {
296 new AddresseeCardViewItem(fields(), mShowEmptyFields, 301 new AddresseeCardViewItem(fields(), mShowEmptyFields,
297 addressBook(), *it, mCardView); 302 addressBook(), *it, mCardView);
298 continue; 303 continue;
299 } 304 }
300 } 305 }
301 } 306 }
302 } 307 }
303 mCardView->viewport()->setUpdatesEnabled( true ); 308 mCardView->viewport()->setUpdatesEnabled( true );
304 mCardView->viewport()->update(); 309 mCardView->viewport()->update();
305 if ( mCardView->firstItem() ) { 310 if ( mCardView->firstItem() ) {
306 mCardView->setCurrentItem ( mCardView->firstItem() ); 311 mCardView->setCurrentItem ( mCardView->firstItem() );
307 mCardView->setSelected ( mCardView->firstItem() , true ); 312 mCardView->setSelected ( mCardView->firstItem() , true );
308 } 313 }
309 else 314 else
310 emit selected(QString::null); 315 emit selected(QString::null);
311} 316}
312QStringList KAddressBookCardView::selectedUids() 317QStringList KAddressBookCardView::selectedUids()
313{ 318{
314 QStringList uidList; 319 QStringList uidList;
315 CardViewItem *item; 320 CardViewItem *item;
316 AddresseeCardViewItem *aItem; 321 AddresseeCardViewItem *aItem;
317 322
318 for (item = mCardView->firstItem(); item; item = item->nextItem()) 323 for (item = mCardView->firstItem(); item; item = item->nextItem())
319 { 324 {
320 if (item->isSelected()) 325 if (item->isSelected())
321 { 326 {
322#ifndef KAB_EMBEDDED 327#ifndef KAB_EMBEDDED
323 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 328 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
324#else //KAB_EMBEDDED 329#else //KAB_EMBEDDED
325 aItem = (AddresseeCardViewItem*)(item); 330 aItem = (AddresseeCardViewItem*)(item);
326#endif //KAB_EMBEDDED 331#endif //KAB_EMBEDDED
327 if (aItem) 332 if (aItem)
328 uidList << aItem->addressee().uid(); 333 uidList << aItem->addressee().uid();
329 } 334 }
330 } 335 }
331 336
332 return uidList; 337 return uidList;
333} 338}
334 339
335void KAddressBookCardView::refresh(QString uid) 340void KAddressBookCardView::refresh(QString uid)
336{ 341{
337 CardViewItem *item; 342 CardViewItem *item;
338 AddresseeCardViewItem *aItem; 343 AddresseeCardViewItem *aItem;
339 344
340 if (uid.isNull()) 345 if (uid.isNull())
341 { 346 {
342 // Rebuild the view 347 // Rebuild the view
343 mCardView->viewport()->setUpdatesEnabled( false ); 348 mCardView->viewport()->setUpdatesEnabled( false );
344 mCardView->clear(); 349 mCardView->clear();
345 350
346 KABC::Addressee::List addresseeList = addressees(); 351 KABC::Addressee::List addresseeList = addressees();
347 KABC::Addressee::List::Iterator iter; 352 KABC::Addressee::List::Iterator iter;
348 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 353 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
349 { 354 {
350 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 355 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
351 continue; 356 continue;
352 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 357 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
353 addressBook(), *iter, mCardView); 358 addressBook(), *iter, mCardView);
354 } 359 }
355 mCardView->viewport()->setUpdatesEnabled( true ); 360 mCardView->viewport()->setUpdatesEnabled( true );
356 mCardView->viewport()->update(); 361 mCardView->viewport()->update();
357 362
358 // by default nothing is selected 363 // by default nothing is selected
359 emit selected(QString::null); 364 emit selected(QString::null);
360 } 365 }
361 else 366 else
362 { 367 {
363 // Try to find the one to refresh 368 // Try to find the one to refresh
364 bool found = false; 369 bool found = false;
365 for (item = mCardView->firstItem(); item && !found; 370 for (item = mCardView->firstItem(); item && !found;
366 item = item->nextItem()) 371 item = item->nextItem())
367 { 372 {
368#ifndef KAB_EMBEDDED 373#ifndef KAB_EMBEDDED
369 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 374 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
370#else //KAB_EMBEDDED 375#else //KAB_EMBEDDED
371 aItem = (AddresseeCardViewItem*)(item); 376 aItem = (AddresseeCardViewItem*)(item);
372#endif //KAB_EMBEDDED 377#endif //KAB_EMBEDDED
373 378
374 if ((aItem) && (aItem->addressee().uid() == uid)) 379 if ((aItem) && (aItem->addressee().uid() == uid))
375 { 380 {
376 aItem->refresh(); 381 aItem->refresh();
377 found = true; 382 found = true;
378 } 383 }
379 } 384 }
380 } 385 }
381} 386}
382 387
383void KAddressBookCardView::setSelected(QString uid, bool selected) 388void KAddressBookCardView::setSelected(QString uid, bool selected)
384{ 389{
385 CardViewItem *item; 390 CardViewItem *item;
386 AddresseeCardViewItem *aItem; 391 AddresseeCardViewItem *aItem;
387 392
388 if (uid.isNull()) 393 if (uid.isNull())
389 { 394 {
390 mCardView->selectAll(selected); 395 mCardView->selectAll(selected);
391 } 396 }
392 else 397 else
393 { 398 {
394 bool found = false; 399 bool found = false;
395 for (item = mCardView->firstItem(); item && !found; 400 for (item = mCardView->firstItem(); item && !found;
396 item = item->nextItem()) 401 item = item->nextItem())
397 { 402 {
398#ifndef KAB_EMBEDDED 403#ifndef KAB_EMBEDDED
399 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 404 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
400#else //KAB_EMBEDDED 405#else //KAB_EMBEDDED
401 aItem = (AddresseeCardViewItem*)(item); 406 aItem = (AddresseeCardViewItem*)(item);
402#endif //KAB_EMBEDDED 407#endif //KAB_EMBEDDED
403 408
404 if ((aItem) && (aItem->addressee().uid() == uid)) 409 if ((aItem) && (aItem->addressee().uid() == uid))
405 { 410 {
406 mCardView->setSelected(aItem, selected); 411 mCardView->setSelected(aItem, selected);
407 mCardView->ensureItemVisible(item); 412 mCardView->ensureItemVisible(item);
408 found = true; 413 found = true;
409 } 414 }
410 } 415 }
411 } 416 }
412} 417}
413 418
414//US added an additional method without parameter 419//US added an additional method without parameter
415void KAddressBookCardView::setSelected() 420void KAddressBookCardView::setSelected()
416{ 421{
417 setSelected(QString::null, true); 422 setSelected(QString::null, true);
418} 423}
419 424
420void KAddressBookCardView::addresseeExecuted(CardViewItem *item) 425void KAddressBookCardView::addresseeExecuted(CardViewItem *item)
421{ 426{
422#ifndef KAB_EMBEDDED 427#ifndef KAB_EMBEDDED
423 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); 428 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item);
424#else //KAB_EMBEDDED 429#else //KAB_EMBEDDED
425 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); 430 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item);
426#endif //KAB_EMBEDDED 431#endif //KAB_EMBEDDED
427 if (aItem) 432 if (aItem)
428 { 433 {
429 //kdDebug()<<"... even has a valid item:)"<<endl; 434 //kdDebug()<<"... even has a valid item:)"<<endl;
430 emit executed(aItem->addressee().uid()); 435 emit executed(aItem->addressee().uid());
431 } 436 }
432} 437}
433 438
434void KAddressBookCardView::addresseeSelected() 439void KAddressBookCardView::addresseeSelected()
435{ 440{
436 CardViewItem *item; 441 CardViewItem *item;
437 AddresseeCardViewItem *aItem; 442 AddresseeCardViewItem *aItem;
438 443
439 bool found = false; 444 bool found = false;
440 for (item = mCardView->firstItem(); item && !found; 445 for (item = mCardView->firstItem(); item && !found;
441 item = item->nextItem()) 446 item = item->nextItem())
442 { 447 {
443 if (item->isSelected()) 448 if (item->isSelected())
444 { 449 {
445#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
446 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 451 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
447#else //KAB_EMBEDDED 452#else //KAB_EMBEDDED
448 aItem = (AddresseeCardViewItem*)(item); 453 aItem = (AddresseeCardViewItem*)(item);
449#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
450 if ( aItem ) 455 if ( aItem )
451 { 456 {
452 emit selected(aItem->addressee().uid()); 457 emit selected(aItem->addressee().uid());
453 found = true; 458 found = true;
454 } 459 }
455 } 460 }
456 } 461 }
457 462
458 if (!found) 463 if (!found)
459 emit selected(QString::null); 464 emit selected(QString::null);
460 465
461} 466}
462#ifndef KAB_EMBEDDED 467#ifndef KAB_EMBEDDED
463#include "kaddressbookcardview.moc" 468#include "kaddressbookcardview.moc"
464#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 45a9781..8f22d54 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -1,119 +1,120 @@
1#ifndef KADDRESSBOOKCARDVIEW_H 1#ifndef KADDRESSBOOKCARDVIEW_H
2#define KADDRESSBOOKCARDVIEW_H 2#define KADDRESSBOOKCARDVIEW_H
3 3
4/* 4/*
5 This file is part of KAddressBook. 5 This file is part of KAddressBook.
6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#include <qstring.h> 27#include <qstring.h>
28#ifndef KAB_EMBEDDED 28#ifndef KAB_EMBEDDED
29#include <kiconview.h> 29#include <kiconview.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <klocale.h> 31#include <klocale.h>
32#endif //KAB_EMBEDDED 32#endif //KAB_EMBEDDED
33 33
34#include "cardview.h" 34#include "cardview.h"
35#include "kaddressbookview.h" 35#include "kaddressbookview.h"
36#include "configurecardviewdialog.h" 36#include "configurecardviewdialog.h"
37 37
38class QDragEnterEvent; 38class QDragEnterEvent;
39class QDragEntryEvent; 39class QDragEntryEvent;
40class QDropEvent; 40class QDropEvent;
41class KConfig; 41class KConfig;
42class AddresseeCardView; 42class AddresseeCardView;
43 43
44/** 44/**
45 This view uses the CardView class to create a card view. At some 45 This view uses the CardView class to create a card view. At some
46 point in the future I think this will be the default view of 46 point in the future I think this will be the default view of
47 KAddressBook. 47 KAddressBook.
48 */ 48 */
49class KAddressBookCardView : public KAddressBookView 49class KAddressBookCardView : public KAddressBookView
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53 public: 53 public:
54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, 54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent,
55 const char *name = 0 ); 55 const char *name = 0 );
56 virtual ~KAddressBookCardView(); 56 virtual ~KAddressBookCardView();
57 void doSearch( const QString& s,KABC::Field *field ); 57 void doSearch( const QString& s,KABC::Field *field );
58 virtual QStringList selectedUids(); 58 virtual QStringList selectedUids();
59 virtual QString type() const { return "Card"; } 59 virtual QString type() const { return "Card"; }
60 60
61 virtual void readConfig(KConfig *config); 61 virtual void readConfig(KConfig *config);
62 virtual void writeConfig(KConfig *); 62 virtual void writeConfig(KConfig *);
63 virtual void scrollUP(); 63 virtual void scrollUP();
64 virtual void scrollDOWN(); 64 virtual void scrollDOWN();
65 virtual void setFocusAV();
65 66
66 public slots: 67 public slots:
67 void refresh(QString uid = QString::null); 68 void refresh(QString uid = QString::null);
68 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); 69 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
69//US added an additional method without parameter 70//US added an additional method without parameter
70 void setSelected(); 71 void setSelected();
71 72
72 protected slots: 73 protected slots:
73 void addresseeExecuted(CardViewItem *item); 74 void addresseeExecuted(CardViewItem *item);
74 void addresseeSelected(); 75 void addresseeSelected();
75 76
76 private: 77 private:
77 AddresseeCardView *mCardView; 78 AddresseeCardView *mCardView;
78 bool mShowEmptyFields; 79 bool mShowEmptyFields;
79}; 80};
80 81
81class AddresseeCardView : public CardView 82class AddresseeCardView : public CardView
82{ 83{
83 Q_OBJECT 84 Q_OBJECT
84 public: 85 public:
85 AddresseeCardView(QWidget *parent, const char *name = 0); 86 AddresseeCardView(QWidget *parent, const char *name = 0);
86 ~AddresseeCardView(); 87 ~AddresseeCardView();
87 88
88 signals: 89 signals:
89 void startAddresseeDrag(); 90 void startAddresseeDrag();
90 void addresseeDropped(QDropEvent *); 91 void addresseeDropped(QDropEvent *);
91 92
92 protected: 93 protected:
93 virtual void dragEnterEvent(QDragEnterEvent *); 94 virtual void dragEnterEvent(QDragEnterEvent *);
94 virtual void dropEvent(QDropEvent *); 95 virtual void dropEvent(QDropEvent *);
95 virtual void startDrag(); 96 virtual void startDrag();
96}; 97};
97 98
98 99
99class CardViewFactory : public ViewFactory 100class CardViewFactory : public ViewFactory
100{ 101{
101 public: 102 public:
102 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 103 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
103 { 104 {
104 return new KAddressBookCardView( ab, parent, name ); 105 return new KAddressBookCardView( ab, parent, name );
105 } 106 }
106 107
107 QString type() const { return "Card"; } 108 QString type() const { return "Card"; }
108 109
109 QString description() const { return i18n( "Rolodex style cards represent contacts." ); } 110 QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
110 111
111 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 112 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
112 const char *name = 0 ) 113 const char *name = 0 )
113 { 114 {
114 return new ConfigureCardViewWidget( ab, parent, name ); 115 return new ConfigureCardViewWidget( ab, parent, name );
115 } 116 }
116}; 117};
117 118
118 119
119#endif 120#endif
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index f4c68b8..41c3cb2 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -1,446 +1,452 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qiconview.h> 25#include <qiconview.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28#include <kabc/addressee.h> 28#include <kabc/addressee.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#else //KAB_EMBEDDED 35#else //KAB_EMBEDDED
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38#include <kabc/addressbook.h> 38#include <kabc/addressbook.h>
39#include "kabprefs.h" 39#include "kabprefs.h"
40#include "viewmanager.h" 40#include "viewmanager.h"
41#include "kaddressbookiconview.h" 41#include "kaddressbookiconview.h"
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qapplication.h> 44#include <qapplication.h>
45#include <kglobal.h> 45#include <kglobal.h>
46/*US transfered to the headerfile 46/*US transfered to the headerfile
47class IconViewFactory : public ViewFactory 47class IconViewFactory : public ViewFactory
48{ 48{
49 public: 49 public:
50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
51 { 51 {
52 return new KAddressBookIconView( ab, parent, name ); 52 return new KAddressBookIconView( ab, parent, name );
53 } 53 }
54 54
55 QString type() const { return "Icon"; } 55 QString type() const { return "Icon"; }
56 56
57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
58}; 58};
59 59
60*/ 60*/
61 61
62extern "C" { 62extern "C" {
63 void *init_libkaddrbk_iconview() 63 void *init_libkaddrbk_iconview()
64 { 64 {
65 return ( new IconViewFactory ); 65 return ( new IconViewFactory );
66 } 66 }
67} 67}
68 68
69//////////////////////////////// 69////////////////////////////////
70// AddresseeIconView (internal class) 70// AddresseeIconView (internal class)
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
73 : KIconView(parent, name) 73 : KIconView(parent, name)
74#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
76 : QIconView(parent, name) 76 : QIconView(parent, name)
77#endif //KAB_EMBEDDED 77#endif //KAB_EMBEDDED
78 78
79{ 79{
80 setSelectionMode( QIconView::Extended ); 80 setSelectionMode( QIconView::Extended );
81 setResizeMode( QIconView::Adjust ); 81 setResizeMode( QIconView::Adjust );
82 setWordWrapIconText( true ); 82 setWordWrapIconText( true );
83 setGridX( 100 ); 83 setGridX( 100 );
84 setItemsMovable(false); 84 setItemsMovable(false);
85 setSorting(true, true); 85 setSorting(true, true);
86 86
87 87
88//US ??? setMode( KIconView::Select ); 88//US ??? setMode( KIconView::Select );
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 91
92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95} 95}
96 96
97AddresseeIconView::~AddresseeIconView() 97AddresseeIconView::~AddresseeIconView()
98{ 98{
99} 99}
100 100
101 101
102void AddresseeIconView::itemDropped(QDropEvent *e, 102void AddresseeIconView::itemDropped(QDropEvent *e,
103 const QValueList<QIconDragItem> &) 103 const QValueList<QIconDragItem> &)
104{ 104{
105 emit addresseeDropped(e); 105 emit addresseeDropped(e);
106} 106}
107 107
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *AddresseeIconView::dragObject()
109{ 109{
110 emit startAddresseeDrag(); 110 emit startAddresseeDrag();
111 111
112 // We never want IconView to start the drag 112 // We never want IconView to start the drag
113 return 0; 113 return 0;
114} 114}
115//////////////////////////////// 115////////////////////////////////
116// AddresseeIconViewItem (internal class) 116// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class AddresseeIconViewItem : public QIconViewItem
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
122{ 122{
123 public: 123 public:
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 125 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 126 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 127 QIconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 129#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 130 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 131 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 132 QIconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 { 135 {
136 if ( mFields.isEmpty() ) { 136 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 137 mFields = KABC::Field::defaultFields();
138 } 138 }
139 refresh(); 139 refresh();
140 } 140 }
141 141
142 const KABC::Addressee &addressee() const { return mAddressee; } 142 const KABC::Addressee &addressee() const { return mAddressee; }
143 143
144 void refresh() 144 void refresh()
145 { 145 {
146 // Update our addressee, since it may have changed elsewhere 146 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 147 mAddressee = mDocument->findByUid(mAddressee.uid());
148 148
149 if (!mAddressee.isEmpty()) 149 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 150 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 151
152 QPixmap icon; 152 QPixmap icon;
153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) );
154 KABC::Picture pic = mAddressee.photo(); 154 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 155 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 156 pic = mAddressee.logo();
157 157
158 if ( pic.isIntern() && !pic.data().isNull() ) { 158 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 159 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 161 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 162 icon = img.scaleWidth( 32 );
163 else 163 else
164 icon = img.scaleHeight( 32 ); 164 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 165#else //KAB_EMBEDDED
166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
167 icon.convertFromImage(img.smoothScale(32, 32)); 167 icon.convertFromImage(img.smoothScale(32, 32));
168#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
169 169
170 } else 170 } else
171 icon = defaultIcon; 171 icon = defaultIcon;
172 172
173 setPixmap( icon ); 173 setPixmap( icon );
174 } 174 }
175 175
176 private: 176 private:
177 KABC::Field::List mFields; 177 KABC::Field::List mFields;
178 KABC::AddressBook *mDocument; 178 KABC::AddressBook *mDocument;
179 KABC::Addressee mAddressee; 179 KABC::Addressee mAddressee;
180}; 180};
181 181
182/////////////////////////////// 182///////////////////////////////
183// KAddressBookView 183// KAddressBookView
184 184
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
186 QWidget *parent, const char *name) 186 QWidget *parent, const char *name)
187 : KAddressBookView( ab, parent, name ) 187 : KAddressBookView( ab, parent, name )
188{ 188{
189 // Init the GUI 189 // Init the GUI
190 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 190 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
191 191
192 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 192 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
193 layout->addWidget(mIconView); 193 layout->addWidget(mIconView);
194 194
195 // Connect up the signals 195 // Connect up the signals
196 196
197//US method executed is part of KIconView 197//US method executed is part of KIconView
198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
199//US this, SLOT(addresseeExecuted(QIconViewItem *))); 199//US this, SLOT(addresseeExecuted(QIconViewItem *)));
200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
201 this, SLOT(addresseeExecuted(QIconViewItem *))); 201 this, SLOT(addresseeExecuted(QIconViewItem *)));
202 202
203 connect(mIconView, SIGNAL(selectionChanged()), 203 connect(mIconView, SIGNAL(selectionChanged()),
204 this, SLOT(addresseeSelected())); 204 this, SLOT(addresseeSelected()));
205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
206 this, SIGNAL(dropped(QDropEvent*))); 206 this, SIGNAL(dropped(QDropEvent*)));
207 connect(mIconView, SIGNAL(startAddresseeDrag()), 207 connect(mIconView, SIGNAL(startAddresseeDrag()),
208 this, SIGNAL(startDrag())); 208 this, SIGNAL(startDrag()));
209} 209}
210 210
211KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
212{ 212{
213} 213}
214void KAddressBookIconView::setFocusAV()
215{
216 if ( mIconView )
217 mIconView->setFocus();
218}
219
214 220
215void KAddressBookIconView::scrollUP() 221void KAddressBookIconView::scrollUP()
216{ 222{
217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
218 QApplication::postEvent( mIconView, ev ); 224 QApplication::postEvent( mIconView, ev );
219} 225}
220void KAddressBookIconView::scrollDOWN() 226void KAddressBookIconView::scrollDOWN()
221{ 227{
222 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
223 QApplication::postEvent( mIconView, ev ); 229 QApplication::postEvent( mIconView, ev );
224} 230}
225void KAddressBookIconView::readConfig(KConfig *config) 231void KAddressBookIconView::readConfig(KConfig *config)
226{ 232{
227 KAddressBookView::readConfig(config); 233 KAddressBookView::readConfig(config);
228 234
229//US method executed is part of KIconView 235//US method executed is part of KIconView
230//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
231//US this, SLOT(addresseeExecuted(QIconViewItem *))); 237//US this, SLOT(addresseeExecuted(QIconViewItem *)));
232 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
233 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
234 240
235//US method executed is part of KIconView. Use selectionChanged instead 241//US method executed is part of KIconView. Use selectionChanged instead
236/*US 242/*US
237 if (KABPrefs::instance()->mHonorSingleClick) 243 if (KABPrefs::instance()->mHonorSingleClick)
238 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 244 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 else 246 else
241 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
242 this, SLOT(addresseeExecuted(QIconViewItem *))); 248 this, SLOT(addresseeExecuted(QIconViewItem *)));
243*/ 249*/
244 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 251 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 252
247} 253}
248void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
249{ 255{
250 mIconView->clear(); 256 mIconView->clear();
251 mIconList.clear(); 257 mIconList.clear();
252 if ( s.isEmpty() || s == "*" ) { 258 if ( s.isEmpty() || s == "*" ) {
253 refresh(); 259 refresh();
254 return; 260 return;
255 } 261 }
256 QString pattern = s.lower()+"*"; 262 QString pattern = s.lower()+"*";
257 QRegExp re; 263 QRegExp re;
258 re.setWildcard(true); // most people understand these better. 264 re.setWildcard(true); // most people understand these better.
259 re.setCaseSensitive(false); 265 re.setCaseSensitive(false);
260 re.setPattern( pattern ); 266 re.setPattern( pattern );
261 if (!re.isValid()) 267 if (!re.isValid())
262 return; 268 return;
263 KABC::Addressee::List addresseeList = addressees(); 269 KABC::Addressee::List addresseeList = addressees();
264 KABC::Addressee::List::Iterator it; 270 KABC::Addressee::List::Iterator it;
265 if ( field ) { 271 if ( field ) {
266 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
267#if QT_VERSION >= 300 273#if QT_VERSION >= 300
268 if (re.search(field->value( *it ).lower()) != -1) 274 if (re.search(field->value( *it ).lower()) != -1)
269#else 275#else
270 if (re.match(field->value( *it ).lower()) != -1) 276 if (re.match(field->value( *it ).lower()) != -1)
271#endif 277#endif
272 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 278 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
273 279
274 280
275 } 281 }
276 } else { 282 } else {
277 KABC::Field::List fieldList = fields(); 283 KABC::Field::List fieldList = fields();
278 KABC::Field::List::ConstIterator fieldIt; 284 KABC::Field::List::ConstIterator fieldIt;
279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 285 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
280 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 286 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
281#if QT_VERSION >= 300 287#if QT_VERSION >= 300
282 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 288 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
283#else 289#else
284 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 290 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
285#endif 291#endif
286 { 292 {
287 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 293 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
288 continue; 294 continue;
289 } 295 }
290 } 296 }
291 } 297 }
292 } 298 }
293 mIconView->arrangeItemsInGrid( true ); 299 mIconView->arrangeItemsInGrid( true );
294 if ( mIconView->firstItem() ) { 300 if ( mIconView->firstItem() ) {
295 mIconView->setCurrentItem ( mIconView->firstItem() ); 301 mIconView->setCurrentItem ( mIconView->firstItem() );
296 mIconView->setSelected ( mIconView->firstItem() , true ); 302 mIconView->setSelected ( mIconView->firstItem() , true );
297 } 303 }
298 else 304 else
299 emit selected(QString::null); 305 emit selected(QString::null);
300} 306}
301QStringList KAddressBookIconView::selectedUids() 307QStringList KAddressBookIconView::selectedUids()
302{ 308{
303 QStringList uidList; 309 QStringList uidList;
304 QIconViewItem *item; 310 QIconViewItem *item;
305 AddresseeIconViewItem *aItem; 311 AddresseeIconViewItem *aItem;
306 312
307 for (item = mIconView->firstItem(); item; item = item->nextItem()) 313 for (item = mIconView->firstItem(); item; item = item->nextItem())
308 { 314 {
309 if (item->isSelected()) 315 if (item->isSelected())
310 { 316 {
311#ifndef KAB_EMBEDDED 317#ifndef KAB_EMBEDDED
312 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 318 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
313#else //KAB_EMBEDDED 319#else //KAB_EMBEDDED
314 aItem = (AddresseeIconViewItem*)(item); 320 aItem = (AddresseeIconViewItem*)(item);
315#endif //KAB_EMBEDDED 321#endif //KAB_EMBEDDED
316 if (aItem) 322 if (aItem)
317 uidList << aItem->addressee().uid(); 323 uidList << aItem->addressee().uid();
318 } 324 }
319 } 325 }
320 326
321 return uidList; 327 return uidList;
322} 328}
323 329
324void KAddressBookIconView::refresh(QString uid) 330void KAddressBookIconView::refresh(QString uid)
325{ 331{
326 QIconViewItem *item; 332 QIconViewItem *item;
327 AddresseeIconViewItem *aItem; 333 AddresseeIconViewItem *aItem;
328 334
329 if ( uid.isNull() ) { 335 if ( uid.isNull() ) {
330 // Rebuild the view 336 // Rebuild the view
331 mIconView->clear(); 337 mIconView->clear();
332 mIconList.clear(); 338 mIconList.clear();
333 339
334 KABC::Addressee::List addresseeList = addressees(); 340 KABC::Addressee::List addresseeList = addressees();
335 KABC::Addressee::List::Iterator iter; 341 KABC::Addressee::List::Iterator iter;
336 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 342 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
337 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 343 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
338 continue; 344 continue;
339 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 345 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
340 } 346 }
341 347
342 mIconView->arrangeItemsInGrid( true ); 348 mIconView->arrangeItemsInGrid( true );
343 349
344 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 350 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
345 { 351 {
346#ifndef KAB_EMBEDDED 352#ifndef KAB_EMBEDDED
347 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 353 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
348#else //KAB_EMBEDDED 354#else //KAB_EMBEDDED
349 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 355 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
350#endif //KAB_EMBEDDED 356#endif //KAB_EMBEDDED
351 mIconList.append( aivi ); 357 mIconList.append( aivi );
352 } 358 }
353 359
354 } else { 360 } else {
355 // Try to find the one to refresh 361 // Try to find the one to refresh
356 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 362 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
357#ifndef KAB_EMBEDDED 363#ifndef KAB_EMBEDDED
358 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 364 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
359#else //KAB_EMBEDDED 365#else //KAB_EMBEDDED
360 aItem = (AddresseeIconViewItem*)(item); 366 aItem = (AddresseeIconViewItem*)(item);
361#endif //KAB_EMBEDDED 367#endif //KAB_EMBEDDED
362 if ((aItem) && (aItem->addressee().uid() == uid)) { 368 if ((aItem) && (aItem->addressee().uid() == uid)) {
363 aItem->refresh(); 369 aItem->refresh();
364 mIconView->arrangeItemsInGrid( true ); 370 mIconView->arrangeItemsInGrid( true );
365 return; 371 return;
366 } 372 }
367 } 373 }
368 refresh( QString::null ); 374 refresh( QString::null );
369 } 375 }
370} 376}
371 377
372void KAddressBookIconView::setSelected(QString uid, bool selected) 378void KAddressBookIconView::setSelected(QString uid, bool selected)
373{ 379{
374 QIconViewItem *item; 380 QIconViewItem *item;
375 AddresseeIconViewItem *aItem; 381 AddresseeIconViewItem *aItem;
376 382
377 if (uid.isNull()) 383 if (uid.isNull())
378 { 384 {
379 mIconView->selectAll(selected); 385 mIconView->selectAll(selected);
380 } 386 }
381 else 387 else
382 { 388 {
383 bool found = false; 389 bool found = false;
384 for (item = mIconView->firstItem(); item && !found; 390 for (item = mIconView->firstItem(); item && !found;
385 item = item->nextItem()) 391 item = item->nextItem())
386 { 392 {
387#ifndef KAB_EMBEDDED 393#ifndef KAB_EMBEDDED
388 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 394 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
389#else //KAB_EMBEDDED 395#else //KAB_EMBEDDED
390 aItem = (AddresseeIconViewItem*)(item); 396 aItem = (AddresseeIconViewItem*)(item);
391#endif //KAB_EMBEDDED 397#endif //KAB_EMBEDDED
392 398
393 if ((aItem) && (aItem->addressee().uid() == uid)) 399 if ((aItem) && (aItem->addressee().uid() == uid))
394 { 400 {
395 mIconView->setSelected(aItem, selected); 401 mIconView->setSelected(aItem, selected);
396 mIconView->ensureItemVisible( aItem ); 402 mIconView->ensureItemVisible( aItem );
397 found = true; 403 found = true;
398 } 404 }
399 } 405 }
400 } 406 }
401} 407}
402 408
403void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 409void KAddressBookIconView::addresseeExecuted(QIconViewItem *item)
404{ 410{
405#ifndef KAB_EMBEDDED 411#ifndef KAB_EMBEDDED
406 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); 412 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item);
407#else //KAB_EMBEDDED 413#else //KAB_EMBEDDED
408 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); 414 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item);
409#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
410 416
411 if (aItem) { 417 if (aItem) {
412 emit executed(aItem->addressee().uid()); 418 emit executed(aItem->addressee().uid());
413 } 419 }
414} 420}
415 421
416void KAddressBookIconView::addresseeSelected() 422void KAddressBookIconView::addresseeSelected()
417{ 423{
418 QIconViewItem *item; 424 QIconViewItem *item;
419 AddresseeIconViewItem *aItem; 425 AddresseeIconViewItem *aItem;
420 426
421 bool found = false; 427 bool found = false;
422 for (item = mIconView->firstItem(); item && !found; 428 for (item = mIconView->firstItem(); item && !found;
423 item = item->nextItem()) 429 item = item->nextItem())
424 { 430 {
425 if (item->isSelected()) 431 if (item->isSelected())
426 { 432 {
427#ifndef KAB_EMBEDDED 433#ifndef KAB_EMBEDDED
428 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 434 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
429#else //KAB_EMBEDDED 435#else //KAB_EMBEDDED
430 aItem = (AddresseeIconViewItem*)(item); 436 aItem = (AddresseeIconViewItem*)(item);
431#endif //KAB_EMBEDDED 437#endif //KAB_EMBEDDED
432 if (aItem) 438 if (aItem)
433 { 439 {
434 emit selected(aItem->addressee().uid()); 440 emit selected(aItem->addressee().uid());
435 found = true; 441 found = true;
436 } 442 }
437 } 443 }
438 } 444 }
439 445
440 if (!found) 446 if (!found)
441 emit selected(QString::null); 447 emit selected(QString::null);
442} 448}
443 449
444#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
445#include "kaddressbookiconview.moc" 451#include "kaddressbookiconview.moc"
446#endif //KAB_EMBEDDED 452#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h
index acfcd71..b0b9fea 100644
--- a/kaddressbook/views/kaddressbookiconview.h
+++ b/kaddressbook/views/kaddressbookiconview.h
@@ -1,133 +1,134 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKICONVIEW_H 24#ifndef KADDRESSBOOKICONVIEW_H
25#define KADDRESSBOOKICONVIEW_H 25#define KADDRESSBOOKICONVIEW_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28#ifndef KAB_EMBEDDED 28#ifndef KAB_EMBEDDED
29#include <kiconview.h> 29#include <kiconview.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <qiconview.h> 31#include <qiconview.h>
32#include <qptrlist.h> 32#include <qptrlist.h>
33#include <klocale.h> 33#include <klocale.h>
34#endif //KAB_EMBEDDED 34#endif //KAB_EMBEDDED
35#include "kaddressbookview.h" 35#include "kaddressbookview.h"
36 36
37class QIconViewItem; 37class QIconViewItem;
38class KConfig; 38class KConfig;
39class AddresseeIconView; 39class AddresseeIconView;
40class AddresseeIconViewItem; 40class AddresseeIconViewItem;
41class QIconDragItem; 41class QIconDragItem;
42class KAddressBookIconView; 42class KAddressBookIconView;
43 43
44namespace KABC { class AddressBook; } 44namespace KABC { class AddressBook; }
45 45
46/** This is an example kaddressbook view that is implemented using 46/** This is an example kaddressbook view that is implemented using
47* KIconView. This view is not the most useful view, but it displays 47* KIconView. This view is not the most useful view, but it displays
48* how simple implementing a new view can be. 48* how simple implementing a new view can be.
49*/ 49*/
50class KAddressBookIconView : public KAddressBookView 50class KAddressBookIconView : public KAddressBookView
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 public: 54 public:
55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, 55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 56 const char *name = 0 );
57 virtual ~KAddressBookIconView(); 57 virtual ~KAddressBookIconView();
58 58
59 virtual QStringList selectedUids(); 59 virtual QStringList selectedUids();
60 virtual QString type() const { return "Icon"; } 60 virtual QString type() const { return "Icon"; }
61 void doSearch( const QString& s ,KABC::Field *field ); 61 void doSearch( const QString& s ,KABC::Field *field );
62 62
63 virtual void readConfig(KConfig *config); 63 virtual void readConfig(KConfig *config);
64 virtual void scrollUP(); 64 virtual void scrollUP();
65 virtual void scrollDOWN(); 65 virtual void scrollDOWN();
66 virtual void setFocusAV();
66 67
67 public slots: 68 public slots:
68 void refresh(QString uid = QString::null); 69 void refresh(QString uid = QString::null);
69#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
70//MOC_SKIP_BEGIN 71//MOC_SKIP_BEGIN
71 void setSelected(QString uid = QString::null, bool selected = true); 72 void setSelected(QString uid = QString::null, bool selected = true);
72//MOC_SKIP_END 73//MOC_SKIP_END
73#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
74//US my MOC do not like default parameters ??? 75//US my MOC do not like default parameters ???
75 void setSelected(QString uid, bool selected); 76 void setSelected(QString uid, bool selected);
76#endif //KAB_EMBEDDED 77#endif //KAB_EMBEDDED
77 78
78 protected slots: 79 protected slots:
79 void addresseeExecuted(QIconViewItem *item); 80 void addresseeExecuted(QIconViewItem *item);
80 void addresseeSelected(); 81 void addresseeSelected();
81 82
82 private: 83 private:
83 AddresseeIconView *mIconView; 84 AddresseeIconView *mIconView;
84 QPtrList<AddresseeIconViewItem> mIconList; 85 QPtrList<AddresseeIconViewItem> mIconList;
85}; 86};
86 87
87 88
88#ifndef KAB_EMBEDDED 89#ifndef KAB_EMBEDDED
89//MOC_SKIP_BEGIN 90//MOC_SKIP_BEGIN
90class AddresseeIconView : public KIconView 91class AddresseeIconView : public KIconView
91//MOC_SKIP_END 92//MOC_SKIP_END
92#else //KAB_EMBEDDED 93#else //KAB_EMBEDDED
93class AddresseeIconView : public QIconView 94class AddresseeIconView : public QIconView
94#endif //KAB_EMBEDDED 95#endif //KAB_EMBEDDED
95{ 96{
96 Q_OBJECT 97 Q_OBJECT
97 98
98 public: 99 public:
99 AddresseeIconView(QWidget *parent, const char *name); 100 AddresseeIconView(QWidget *parent, const char *name);
100 ~AddresseeIconView(); 101 ~AddresseeIconView();
101 102
102 signals: 103 signals:
103 void addresseeDropped(QDropEvent *); 104 void addresseeDropped(QDropEvent *);
104 void startAddresseeDrag(); 105 void startAddresseeDrag();
105 106
106 protected: 107 protected:
107 virtual QDragObject *dragObject(); 108 virtual QDragObject *dragObject();
108 109
109 protected slots: 110 protected slots:
110 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); 111 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &);
111}; 112};
112 113
113class IconViewFactory : public ViewFactory 114class IconViewFactory : public ViewFactory
114{ 115{
115 public: 116 public:
116 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 117 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
117 { 118 {
118 return new KAddressBookIconView( ab, parent, name ); 119 return new KAddressBookIconView( ab, parent, name );
119 } 120 }
120 121
121 QString type() const { return "Icon"; } 122 QString type() const { return "Icon"; }
122 123
123 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 124 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
124}; 125};
125/* 126/*
126extern "C" { 127extern "C" {
127 void *init_libkaddrbk_iconview() 128 void *init_libkaddrbk_iconview()
128 { 129 {
129 return ( new IconViewFactory ); 130 return ( new IconViewFactory );
130 } 131 }
131} 132}
132*/ 133*/
133#endif 134#endif
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 2412170..e40eb9e 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,459 +1,465 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <qdragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
39 39
40 40
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV()
55{
56 if ( mListView )
57 mListView->setFocus();
58
59}
54void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
55{ 61{
56 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
57 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
58} 64}
59void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
60{ 66{
61 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
62 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
63} 69}
64void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
65{ 71{
66 if (mListView) 72 if (mListView)
67 { 73 {
68 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
69 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
70 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
71 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
72 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
73 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
74 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
75 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
76 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
78 84
79 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
80 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
81 delete mListView; 87 delete mListView;
82 } 88 }
83 89
84 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
85 91
86 // Add the columns 92 // Add the columns
87 KABC::Field::List fieldList = fields(); 93 KABC::Field::List fieldList = fields();
88 KABC::Field::List::ConstIterator it; 94 KABC::Field::List::ConstIterator it;
89 95
90 int c = 0; 96 int c = 0;
91 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 97 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
92 mListView->addColumn( (*it)->label() ); 98 mListView->addColumn( (*it)->label() );
93 mListView->setColumnWidthMode(c++, QListView::Manual); 99 mListView->setColumnWidthMode(c++, QListView::Manual);
94//US 100//US
95 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 101 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
96 } 102 }
97 103
98 connect(mListView, SIGNAL(selectionChanged()), 104 connect(mListView, SIGNAL(selectionChanged()),
99 this, SLOT(addresseeSelected())); 105 this, SLOT(addresseeSelected()));
100 connect(mListView, SIGNAL(startAddresseeDrag()), this, 106 connect(mListView, SIGNAL(startAddresseeDrag()), this,
101 SIGNAL(startDrag())); 107 SIGNAL(startDrag()));
102 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 108 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
103 SIGNAL(dropped(QDropEvent*))); 109 SIGNAL(dropped(QDropEvent*)));
104 110
105 if (KABPrefs::instance()->mHonorSingleClick) 111 if (KABPrefs::instance()->mHonorSingleClick)
106 connect(mListView, SIGNAL(executed(QListViewItem*)), 112 connect(mListView, SIGNAL(executed(QListViewItem*)),
107 this, SLOT(addresseeExecuted(QListViewItem*))); 113 this, SLOT(addresseeExecuted(QListViewItem*)));
108 else 114 else
109 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 115 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
110 this, SLOT(addresseeExecuted(QListViewItem*))); 116 this, SLOT(addresseeExecuted(QListViewItem*)));
111 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 117 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
112 this, SLOT(addresseeExecuted(QListViewItem*))); 118 this, SLOT(addresseeExecuted(QListViewItem*)));
113 connect(mListView, SIGNAL(signalDelete()), 119 connect(mListView, SIGNAL(signalDelete()),
114 this, SLOT(addresseeDeleted())); 120 this, SLOT(addresseeDeleted()));
115 121
116//US performceimprovement. Refresh is done from the outside 122//US performceimprovement. Refresh is done from the outside
117//US refresh(); 123//US refresh();
118 124
119 mListView->setSorting( 0, true ); 125 mListView->setSorting( 0, true );
120 mainLayout->addWidget( mListView ); 126 mainLayout->addWidget( mListView );
121 mainLayout->activate(); 127 mainLayout->activate();
122 mListView->show(); 128 mListView->show();
123} 129}
124 130
125void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 131void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
126{ 132{
127 mListView->clear(); 133 mListView->clear();
128 if ( s.isEmpty() || s == "*" ) { 134 if ( s.isEmpty() || s == "*" ) {
129 refresh(); 135 refresh();
130 return; 136 return;
131 } 137 }
132 QString pattern = s.lower()+"*"; 138 QString pattern = s.lower()+"*";
133 QRegExp re; 139 QRegExp re;
134 re.setWildcard(true); // most people understand these better. 140 re.setWildcard(true); // most people understand these better.
135 re.setCaseSensitive(false); 141 re.setCaseSensitive(false);
136 re.setPattern( pattern ); 142 re.setPattern( pattern );
137 if (!re.isValid()) 143 if (!re.isValid())
138 return; 144 return;
139 KABC::Addressee::List addresseeList = addressees(); 145 KABC::Addressee::List addresseeList = addressees();
140 KABC::Addressee::List::Iterator it; 146 KABC::Addressee::List::Iterator it;
141 if ( field ) { 147 if ( field ) {
142 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 148 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
143#if QT_VERSION >= 300 149#if QT_VERSION >= 300
144 if (re.search(field->value( *it ).lower()) != -1) 150 if (re.search(field->value( *it ).lower()) != -1)
145#else 151#else
146 if (re.match(field->value( *it ).lower()) != -1) 152 if (re.match(field->value( *it ).lower()) != -1)
147#endif 153#endif
148 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 154 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
149 155
150 } 156 }
151 } else { 157 } else {
152 KABC::Field::List fieldList = fields(); 158 KABC::Field::List fieldList = fields();
153 KABC::Field::List::ConstIterator fieldIt; 159 KABC::Field::List::ConstIterator fieldIt;
154 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 160 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
155 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 161 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
156#if QT_VERSION >= 300 162#if QT_VERSION >= 300
157 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 163 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
158#else 164#else
159 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 165 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
160#endif 166#endif
161 { 167 {
162 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 168 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
163 break; 169 break;
164 } 170 }
165 } 171 }
166 } 172 }
167 } 173 }
168 // Sometimes the background pixmap gets messed up when we add lots 174 // Sometimes the background pixmap gets messed up when we add lots
169 // of items. 175 // of items.
170 mListView->repaint(); 176 mListView->repaint();
171 if ( mListView->firstChild() ) { 177 if ( mListView->firstChild() ) {
172 mListView->setCurrentItem ( mListView->firstChild() ); 178 mListView->setCurrentItem ( mListView->firstChild() );
173 mListView->setSelected ( mListView->firstChild(), true ); 179 mListView->setSelected ( mListView->firstChild(), true );
174 } 180 }
175 else 181 else
176 emit selected(QString::null); 182 emit selected(QString::null);
177 183
178} 184}
179void KAddressBookTableView::writeConfig(KConfig *config) 185void KAddressBookTableView::writeConfig(KConfig *config)
180{ 186{
181 KAddressBookView::writeConfig(config); 187 KAddressBookView::writeConfig(config);
182 188
183 mListView->saveLayout(config, config->group()); 189 mListView->saveLayout(config, config->group());
184} 190}
185 191
186void KAddressBookTableView::readConfig(KConfig *config) 192void KAddressBookTableView::readConfig(KConfig *config)
187{ 193{
188 KAddressBookView::readConfig( config ); 194 KAddressBookView::readConfig( config );
189 // The config could have changed the fields, so we need to reconstruct 195 // The config could have changed the fields, so we need to reconstruct
190 // the listview. 196 // the listview.
191 reconstructListView(); 197 reconstructListView();
192 198
193 // costum colors? 199 // costum colors?
194 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 200 if ( config->readBoolEntry( "EnableCustomColors", false ) )
195 { 201 {
196 QPalette p( mListView->palette() ); 202 QPalette p( mListView->palette() );
197 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 203 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
198 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 204 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
199 c = p.color(QPalette::Normal, QColorGroup::Text ); 205 c = p.color(QPalette::Normal, QColorGroup::Text );
200 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 206 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
201 c = p.color(QPalette::Normal, QColorGroup::Button ); 207 c = p.color(QPalette::Normal, QColorGroup::Button );
202 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 208 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
203 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 209 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
204 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 210 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
205 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 211 c = p.color(QPalette::Normal, QColorGroup::Highlight );
206 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 212 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
207 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 213 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
208 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 214 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
209#ifndef KAB_EMBEDDED 215#ifndef KAB_EMBEDDED
210 c = KGlobalSettings::alternateBackgroundColor(); 216 c = KGlobalSettings::alternateBackgroundColor();
211#else //KAB_EMBEDDED 217#else //KAB_EMBEDDED
212 c = QColor(240, 240, 240); 218 c = QColor(240, 240, 240);
213#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
214 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 220 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
215 mListView->setAlternateColor(c); 221 mListView->setAlternateColor(c);
216 222
217 223
218 //US mListView->viewport()->setPalette( p ); 224 //US mListView->viewport()->setPalette( p );
219 mListView->setPalette( p ); 225 mListView->setPalette( p );
220 } 226 }
221 else 227 else
222 { 228 {
223 // needed if turned off during a session. 229 // needed if turned off during a session.
224 //US mListView->viewport()->setPalette( mListView->palette() ); 230 //US mListView->viewport()->setPalette( mListView->palette() );
225 mListView->setPalette( mListView->palette() ); 231 mListView->setPalette( mListView->palette() );
226 } 232 }
227 233
228 //custom fonts? 234 //custom fonts?
229 QFont f( font() ); 235 QFont f( font() );
230 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 236 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
231 { 237 {
232 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 238 mListView->setFont( config->readFontEntry( "TextFont", &f) );
233 f.setBold( true ); 239 f.setBold( true );
234 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 240 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
235 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 241 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
236 } 242 }
237 else 243 else
238 { 244 {
239 mListView->setFont( f ); 245 mListView->setFont( f );
240 f.setBold( true ); 246 f.setBold( true );
241 //US mListView->setHeaderFont( f ); 247 //US mListView->setHeaderFont( f );
242 mListView->header()->setFont( f ); 248 mListView->header()->setFont( f );
243 } 249 }
244 250
245 251
246 252
247 253
248 254
249 // Set the list view options 255 // Set the list view options
250 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 256 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
251 true)); 257 true));
252 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 258 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
253 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 259 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
254 260
255 if (config->readBoolEntry("Background", false)) 261 if (config->readBoolEntry("Background", false))
256 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 262 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
257 263
258 // Restore the layout of the listview 264 // Restore the layout of the listview
259 mListView->restoreLayout(config, config->group()); 265 mListView->restoreLayout(config, config->group());
260} 266}
261 267
262void KAddressBookTableView::refresh(QString uid) 268void KAddressBookTableView::refresh(QString uid)
263{ 269{
264 // For now just repopulate. In reality this method should 270 // For now just repopulate. In reality this method should
265 // check the value of uid, and if valid iterate through 271 // check the value of uid, and if valid iterate through
266 // the listview to find the entry, then tell it to refresh. 272 // the listview to find the entry, then tell it to refresh.
267 273
268 if (uid.isNull()) { 274 if (uid.isNull()) {
269 // Clear the list view 275 // Clear the list view
270 QString currentUID, nextUID; 276 QString currentUID, nextUID;
271#ifndef KAB_EMBEDDED 277#ifndef KAB_EMBEDDED
272 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 278 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
273#else //KAB_EMBEDDED 279#else //KAB_EMBEDDED
274 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 280 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
275#endif //KAB_EMBEDDED 281#endif //KAB_EMBEDDED
276 282
277 if ( currentItem ) { 283 if ( currentItem ) {
278#ifndef KAB_EMBEDDED 284#ifndef KAB_EMBEDDED
279 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 285 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
280#else //KAB_EMBEDDED 286#else //KAB_EMBEDDED
281 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 287 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
282#endif //KAB_EMBEDDED 288#endif //KAB_EMBEDDED
283 if ( nextItem ) 289 if ( nextItem )
284 nextUID = nextItem->addressee().uid(); 290 nextUID = nextItem->addressee().uid();
285 currentUID = currentItem->addressee().uid(); 291 currentUID = currentItem->addressee().uid();
286 } 292 }
287 293
288 mListView->clear(); 294 mListView->clear();
289 295
290 currentItem = 0; 296 currentItem = 0;
291 KABC::Addressee::List addresseeList = addressees(); 297 KABC::Addressee::List addresseeList = addressees();
292 KABC::Addressee::List::Iterator it; 298 KABC::Addressee::List::Iterator it;
293 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 299 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
294 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 300 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
295 continue; 301 continue;
296 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 302 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
297 if ( (*it).uid() == currentUID ) 303 if ( (*it).uid() == currentUID )
298 currentItem = item; 304 currentItem = item;
299 else if ( (*it).uid() == nextUID && !currentItem ) 305 else if ( (*it).uid() == nextUID && !currentItem )
300 currentItem = item; 306 currentItem = item;
301 } 307 }
302 308
303 // Sometimes the background pixmap gets messed up when we add lots 309 // Sometimes the background pixmap gets messed up when we add lots
304 // of items. 310 // of items.
305 mListView->repaint(); 311 mListView->repaint();
306 312
307 if ( currentItem ) { 313 if ( currentItem ) {
308 mListView->setCurrentItem( currentItem ); 314 mListView->setCurrentItem( currentItem );
309 mListView->ensureItemVisible( currentItem ); 315 mListView->ensureItemVisible( currentItem );
310 } 316 }
311 } else { 317 } else {
312 // Only need to update on entry. Iterate through and try to find it 318 // Only need to update on entry. Iterate through and try to find it
313 ContactListViewItem *ceItem; 319 ContactListViewItem *ceItem;
314 QListViewItemIterator it( mListView ); 320 QListViewItemIterator it( mListView );
315 while ( it.current() ) { 321 while ( it.current() ) {
316#ifndef KAB_EMBEDDED 322#ifndef KAB_EMBEDDED
317 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 323 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
318#else //KAB_EMBEDDED 324#else //KAB_EMBEDDED
319 ceItem = (ContactListViewItem*)( it.current() ); 325 ceItem = (ContactListViewItem*)( it.current() );
320#endif //KAB_EMBEDDED 326#endif //KAB_EMBEDDED
321 327
322 if ( ceItem && ceItem->addressee().uid() == uid ) { 328 if ( ceItem && ceItem->addressee().uid() == uid ) {
323 ceItem->refresh(); 329 ceItem->refresh();
324 return; 330 return;
325 } 331 }
326 ++it; 332 ++it;
327 } 333 }
328 334
329 refresh( QString::null ); 335 refresh( QString::null );
330 } 336 }
331} 337}
332 338
333QStringList KAddressBookTableView::selectedUids() 339QStringList KAddressBookTableView::selectedUids()
334{ 340{
335 QStringList uidList; 341 QStringList uidList;
336 QListViewItem *item; 342 QListViewItem *item;
337 ContactListViewItem *ceItem; 343 ContactListViewItem *ceItem;
338 344
339 for(item = mListView->firstChild(); item; item = item->itemBelow()) 345 for(item = mListView->firstChild(); item; item = item->itemBelow())
340 { 346 {
341 if (mListView->isSelected( item )) 347 if (mListView->isSelected( item ))
342 { 348 {
343#ifndef KAB_EMBEDDED 349#ifndef KAB_EMBEDDED
344 ceItem = dynamic_cast<ContactListViewItem*>(item); 350 ceItem = dynamic_cast<ContactListViewItem*>(item);
345#else //KAB_EMBEDDED 351#else //KAB_EMBEDDED
346 ceItem = (ContactListViewItem*)(item); 352 ceItem = (ContactListViewItem*)(item);
347#endif //KAB_EMBEDDED 353#endif //KAB_EMBEDDED
348 354
349 if (ceItem != 0L) 355 if (ceItem != 0L)
350 uidList << ceItem->addressee().uid(); 356 uidList << ceItem->addressee().uid();
351 } 357 }
352 } 358 }
353 if ( uidList.count() == 0 ) 359 if ( uidList.count() == 0 )
354 if ( mListView->currentItem() ) { 360 if ( mListView->currentItem() ) {
355 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 361 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
356 uidList << ceItem->addressee().uid(); 362 uidList << ceItem->addressee().uid();
357 } 363 }
358 364
359 return uidList; 365 return uidList;
360} 366}
361 367
362void KAddressBookTableView::setSelected(QString uid, bool selected) 368void KAddressBookTableView::setSelected(QString uid, bool selected)
363{ 369{
364 QListViewItem *item; 370 QListViewItem *item;
365 ContactListViewItem *ceItem; 371 ContactListViewItem *ceItem;
366 372
367 if (uid.isNull()) 373 if (uid.isNull())
368 { 374 {
369 mListView->selectAll(selected); 375 mListView->selectAll(selected);
370 } 376 }
371 else 377 else
372 { 378 {
373 for(item = mListView->firstChild(); item; item = item->itemBelow()) 379 for(item = mListView->firstChild(); item; item = item->itemBelow())
374 { 380 {
375#ifndef KAB_EMBEDDED 381#ifndef KAB_EMBEDDED
376 ceItem = dynamic_cast<ContactListViewItem*>(item); 382 ceItem = dynamic_cast<ContactListViewItem*>(item);
377#else //KAB_EMBEDDED 383#else //KAB_EMBEDDED
378 ceItem = (ContactListViewItem*)(item); 384 ceItem = (ContactListViewItem*)(item);
379#endif //KAB_EMBEDDED 385#endif //KAB_EMBEDDED
380 386
381 387
382 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 388 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
383 { 389 {
384 mListView->setSelected(item, selected); 390 mListView->setSelected(item, selected);
385 391
386 if (selected) 392 if (selected)
387 mListView->ensureItemVisible(item); 393 mListView->ensureItemVisible(item);
388 } 394 }
389 } 395 }
390 } 396 }
391} 397}
392 398
393void KAddressBookTableView::addresseeSelected() 399void KAddressBookTableView::addresseeSelected()
394{ 400{
395 // We need to try to find the first selected item. This might not be the 401 // We need to try to find the first selected item. This might not be the
396 // last selected item, but when QListView is in multiselection mode, 402 // last selected item, but when QListView is in multiselection mode,
397 // there is no way to figure out which one was 403 // there is no way to figure out which one was
398 // selected last. 404 // selected last.
399 QListViewItem *item; 405 QListViewItem *item;
400 bool found =false; 406 bool found =false;
401 for (item = mListView->firstChild(); item && !found; 407 for (item = mListView->firstChild(); item && !found;
402 item = item->nextSibling()) 408 item = item->nextSibling())
403 { 409 {
404 if (item->isSelected()) 410 if (item->isSelected())
405 { 411 {
406 found = true; 412 found = true;
407#ifndef KAB_EMBEDDED 413#ifndef KAB_EMBEDDED
408 ContactListViewItem *ceItem 414 ContactListViewItem *ceItem
409 = dynamic_cast<ContactListViewItem*>(item); 415 = dynamic_cast<ContactListViewItem*>(item);
410#else //KAB_EMBEDDED 416#else //KAB_EMBEDDED
411 ContactListViewItem *ceItem 417 ContactListViewItem *ceItem
412 = (ContactListViewItem*)(item); 418 = (ContactListViewItem*)(item);
413#endif //KAB_EMBEDDED 419#endif //KAB_EMBEDDED
414 420
415 if ( ceItem ) emit selected(ceItem->addressee().uid()); 421 if ( ceItem ) emit selected(ceItem->addressee().uid());
416 } 422 }
417 } 423 }
418 424
419 if (!found) 425 if (!found)
420 emit selected(QString::null); 426 emit selected(QString::null);
421} 427}
422 428
423void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 429void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
424{ 430{
425 if (item) 431 if (item)
426 { 432 {
427#ifndef KAB_EMBEDDED 433#ifndef KAB_EMBEDDED
428 ContactListViewItem *ceItem 434 ContactListViewItem *ceItem
429 = dynamic_cast<ContactListViewItem*>(item); 435 = dynamic_cast<ContactListViewItem*>(item);
430#else //KAB_EMBEDDED 436#else //KAB_EMBEDDED
431 ContactListViewItem *ceItem 437 ContactListViewItem *ceItem
432 = (ContactListViewItem*)(item); 438 = (ContactListViewItem*)(item);
433#endif //KAB_EMBEDDED 439#endif //KAB_EMBEDDED
434 440
435 if (ceItem) 441 if (ceItem)
436 { 442 {
437 emit executed(ceItem->addressee().uid()); 443 emit executed(ceItem->addressee().uid());
438 } 444 }
439 } 445 }
440 else 446 else
441 { 447 {
442 emit executed(QString::null); 448 emit executed(QString::null);
443 } 449 }
444} 450}
445 451
446void KAddressBookTableView::addresseeDeleted() 452void KAddressBookTableView::addresseeDeleted()
447{ 453{
448 454
449 emit deleteRequest(); 455 emit deleteRequest();
450 456
451} 457}
452 458
453 459
454 460
455 461
456 462
457#ifndef KAB_EMBEDDED 463#ifndef KAB_EMBEDDED
458#include "kaddressbooktableview.moc" 464#include "kaddressbooktableview.moc"
459#endif //KAB_EMBEDDED 465#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h
index 865f8d5..38db7b4 100644
--- a/kaddressbook/views/kaddressbooktableview.h
+++ b/kaddressbook/views/kaddressbooktableview.h
@@ -1,117 +1,118 @@
1#ifndef KADDRESSBOOKTABLEVIEW_H 1#ifndef KADDRESSBOOKTABLEVIEW_H
2#define KADDRESSBOOKTABLEVIEW_H 2#define KADDRESSBOOKTABLEVIEW_H
3 3
4 4
5#ifndef KAB_EMBEDDED 5#ifndef KAB_EMBEDDED
6 6
7 7
8#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
9#include <config.h> 9#include <config.h>
10#endif 10#endif
11 11
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qlistview.h> 13#include <qlistview.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qdialog.h> 15#include <qdialog.h>
16#include <qtabdialog.h> 16#include <qtabdialog.h>
17#include <qstringlist.h> 17#include <qstringlist.h>
18#include <qvaluelist.h> 18#include <qvaluelist.h>
19 19
20#include "undo.h" 20#include "undo.h"
21 21
22#else //KAB_EMBEDDED 22#else //KAB_EMBEDDED
23#include "views/configuretableviewdialog.h" 23#include "views/configuretableviewdialog.h"
24#endif //KAB_EMBEDDED 24#endif //KAB_EMBEDDED
25 25
26#include "klocale.h" 26#include "klocale.h"
27#include "kaddressbookview.h" 27#include "kaddressbookview.h"
28 28
29class QListViewItem; 29class QListViewItem;
30class QListBox; 30class QListBox;
31class QVBoxLayout; 31class QVBoxLayout;
32class KConfig; 32class KConfig;
33 33
34class ContactListViewItem; 34class ContactListViewItem;
35class ContactListView; 35class ContactListView;
36 36
37 37
38namespace KABC { class AddressBook; } 38namespace KABC { class AddressBook; }
39 39
40/** 40/**
41 * This class is the table view for kaddressbook. This view is a KListView 41 * This class is the table view for kaddressbook. This view is a KListView
42 * with multiple columns for the selected fields. 42 * with multiple columns for the selected fields.
43 * 43 *
44 * @short Table View 44 * @short Table View
45 * @author Don Sanders <dsanders@kde.org> 45 * @author Don Sanders <dsanders@kde.org>
46 * @version 0.1 46 * @version 0.1
47 */ 47 */
48class KAddressBookTableView : public KAddressBookView 48class KAddressBookTableView : public KAddressBookView
49{ 49{
50friend class ContactListView; 50friend class ContactListView;
51 51
52 Q_OBJECT 52 Q_OBJECT
53 53
54 public: 54 public:
55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, 55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 56 const char *name = 0 );
57 virtual ~KAddressBookTableView(); 57 virtual ~KAddressBookTableView();
58 58
59 virtual void refresh(QString uid = QString::null); 59 virtual void refresh(QString uid = QString::null);
60 virtual QStringList selectedUids(); 60 virtual QStringList selectedUids();
61 virtual void setSelected(QString uid = QString::null, bool selected = false); 61 virtual void setSelected(QString uid = QString::null, bool selected = false);
62 virtual void readConfig(KConfig *config); 62 virtual void readConfig(KConfig *config);
63 virtual void writeConfig(KConfig *config); 63 virtual void writeConfig(KConfig *config);
64 virtual QString type() const { return "Table"; } 64 virtual QString type() const { return "Table"; }
65 void doSearch( const QString& s ,KABC::Field *field ); 65 void doSearch( const QString& s ,KABC::Field *field );
66 virtual void scrollUP(); 66 virtual void scrollUP();
67 virtual void scrollDOWN(); 67 virtual void scrollDOWN();
68 virtual void setFocusAV();
68 69
69 public slots: 70 public slots:
70 virtual void reconstructListView(); 71 virtual void reconstructListView();
71 72
72 protected slots: 73 protected slots:
73 /** Called whenever the user selects an addressee in the list view. 74 /** Called whenever the user selects an addressee in the list view.
74 */ 75 */
75 void addresseeSelected(); 76 void addresseeSelected();
76 void addresseeDeleted(); 77 void addresseeDeleted();
77 78
78 /** Called whenever the user executes an addressee. In terms of the 79 /** Called whenever the user executes an addressee. In terms of the
79 * list view, this is probably a double click 80 * list view, this is probably a double click
80 */ 81 */
81 void addresseeExecuted(QListViewItem*); 82 void addresseeExecuted(QListViewItem*);
82 83
83 private: 84 private:
84 QVBoxLayout *mainLayout; 85 QVBoxLayout *mainLayout;
85 ContactListView *mListView; 86 ContactListView *mListView;
86}; 87};
87 88
88 89
89class TableViewFactory : public ViewFactory 90class TableViewFactory : public ViewFactory
90{ 91{
91 public: 92 public:
92 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 93 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
93 { 94 {
94 return new KAddressBookTableView( ab, parent, name ); 95 return new KAddressBookTableView( ab, parent, name );
95 } 96 }
96 97
97 QString type() const { return "Table"; } 98 QString type() const { return "Table"; }
98 99
99 QString description() const { return i18n( "A listing of contacts in a table. Each cell of " 100 QString description() const { return i18n( "A listing of contacts in a table. Each cell of "
100 "the table holds a field of the contact." ); } 101 "the table holds a field of the contact." ); }
101 102
102 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 103 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
103 const char *name = 0 ) 104 const char *name = 0 )
104 { 105 {
105 return new ConfigureTableViewWidget( ab, parent, name ); 106 return new ConfigureTableViewWidget( ab, parent, name );
106 } 107 }
107}; 108};
108/*US 109/*US
109extern "C" { 110extern "C" {
110 void *init_libkaddrbk_tableview() 111 void *init_libkaddrbk_tableview()
111 { 112 {
112 return ( new TableViewFactory ); 113 return ( new TableViewFactory );
113 } 114 }
114} 115}
115*/ 116*/
116 117
117#endif 118#endif
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index 7ad4ec8..c931e45 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -1,662 +1,662 @@
1 1
2#include "defines.h" 2#include "defines.h"
3#include "editaccounts.h" 3#include "editaccounts.h"
4#include "kapplication.h" 4#include "kapplication.h"
5/* OPIE */ 5/* OPIE */
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8/* QT */ 8/* QT */
9#include <qstringlist.h> 9#include <qstringlist.h>
10 10
11#include <qcombobox.h> 11#include <qcombobox.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14#include <qpushbutton.h> 14#include <qpushbutton.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qtabwidget.h> 17#include <qtabwidget.h>
18#include <qlistview.h> 18#include <qlistview.h>
19#include <qspinbox.h> 19#include <qspinbox.h>
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libmailwrapper/nntpwrapper.h> 22#include <libmailwrapper/nntpwrapper.h>
23 23
24using namespace Opie::Core; 24using namespace Opie::Core;
25 25
26AccountListItem::AccountListItem( QListView *parent, Account *a) 26AccountListItem::AccountListItem( QListView *parent, Account *a)
27 : QListViewItem( parent ) 27 : QListViewItem( parent )
28{ 28{
29 account = a; 29 account = a;
30 setText( 0, account->getAccountName() ); 30 setText( 0, account->getAccountName() );
31 QString ttext = ""; 31 QString ttext = "";
32 switch (account->getType()) { 32 switch (account->getType()) {
33 case MAILLIB::A_NNTP: 33 case MAILLIB::A_NNTP:
34 ttext="NNTP"; 34 ttext="NNTP";
35 break; 35 break;
36 case MAILLIB::A_POP3: 36 case MAILLIB::A_POP3:
37 ttext = "POP3"; 37 ttext = "POP3";
38 break; 38 break;
39 case MAILLIB::A_IMAP: 39 case MAILLIB::A_IMAP:
40 ttext = "IMAP"; 40 ttext = "IMAP";
41 break; 41 break;
42 case MAILLIB::A_SMTP: 42 case MAILLIB::A_SMTP:
43 ttext = "SMTP"; 43 ttext = "SMTP";
44 break; 44 break;
45 default: 45 default:
46 ttext = "UNKNOWN"; 46 ttext = "UNKNOWN";
47 break; 47 break;
48 } 48 }
49 setText( 1, ttext); 49 setText( 1, ttext);
50} 50}
51 51
52EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 52EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
53 : EditAccountsUI( parent, name, modal, flags ) 53 : EditAccountsUI( parent, name, modal, flags )
54{ 54{
55 settings = s; 55 settings = s;
56 56
57 mailList->addColumn( i18n( "Account" ) ); 57 mailList->addColumn( i18n( "Account" ) );
58 mailList->addColumn( i18n( "Type" ) ); 58 mailList->addColumn( i18n( "Type" ) );
59 59
60 newsList->addColumn( i18n( "Account" ) ); 60 newsList->addColumn( i18n( "Account" ) );
61 61
62 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 62 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
63 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 63 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
64 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 64 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
65 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 65 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
66 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 66 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
67 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 67 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
68 68
69 slotFillLists(); 69 slotFillLists();
70} 70}
71 71
72void EditAccounts::slotFillLists() 72void EditAccounts::slotFillLists()
73{ 73{
74 mailList->clear(); 74 mailList->clear();
75 newsList->clear(); 75 newsList->clear();
76 76
77 QList<Account> accounts = settings->getAccounts(); 77 QList<Account> accounts = settings->getAccounts();
78 Account *it; 78 Account *it;
79 for ( it = accounts.first(); it; it = accounts.next() ) 79 for ( it = accounts.first(); it; it = accounts.next() )
80 { 80 {
81 if ( it->getType()==MAILLIB::A_NNTP ) 81 if ( it->getType()==MAILLIB::A_NNTP )
82 { 82 {
83 (void) new AccountListItem( newsList, it ); 83 (void) new AccountListItem( newsList, it );
84 } 84 }
85 else 85 else
86 { 86 {
87 (void) new AccountListItem( mailList, it ); 87 (void) new AccountListItem( mailList, it );
88 } 88 }
89 } 89 }
90} 90}
91 91
92void EditAccounts::slotNewMail() 92void EditAccounts::slotNewMail()
93{ 93{
94 QString *selection = new QString(); 94 QString *selection = new QString();
95 SelectMailType selType( selection, this, 0, true ); 95 SelectMailType selType( selection, this, 0, true );
96 selType.show(); 96 selType.show();
97 if ( QDialog::Accepted == selType.exec() ) 97 if ( QDialog::Accepted == selType.exec() )
98 { 98 {
99 slotNewAccount( *selection ); 99 slotNewAccount( *selection );
100 } 100 }
101} 101}
102 102
103void EditAccounts::slotNewAccount( const QString &type ) 103void EditAccounts::slotNewAccount( const QString &type )
104{ 104{
105 if ( type.compare( "IMAP" ) == 0 ) 105 if ( type.compare( i18n("IMAP") ) == 0 )
106 { 106 {
107 IMAPaccount *account = new IMAPaccount(); 107 IMAPaccount *account = new IMAPaccount();
108 IMAPconfig imap( account, this, 0, true ); 108 IMAPconfig imap( account, this, 0, true );
109 imap.showMaximized(); 109 imap.showMaximized();
110 if ( QDialog::Accepted == imap.exec() ) 110 if ( QDialog::Accepted == imap.exec() )
111 { 111 {
112 settings->addAccount( account ); 112 settings->addAccount( account );
113 account->save(); 113 account->save();
114 slotFillLists(); 114 slotFillLists();
115 } 115 }
116 else 116 else
117 { 117 {
118 account->remove(); 118 account->remove();
119 } 119 }
120 } 120 }
121 else if ( type.compare( "POP3" ) == 0 ) 121 else if ( type.compare( i18n("POP3") ) == 0 )
122 { 122 {
123 POP3account *account = new POP3account(); 123 POP3account *account = new POP3account();
124 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 124 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
125 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 125 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
126 { 126 {
127 settings->addAccount( account ); 127 settings->addAccount( account );
128 account->save(); 128 account->save();
129 slotFillLists(); 129 slotFillLists();
130 } 130 }
131 else 131 else
132 { 132 {
133 account->remove(); 133 account->remove();
134 } 134 }
135 } 135 }
136 else if ( type.compare( "SMTP" ) == 0 ) 136 else if ( type.compare( i18n("SMTP") ) == 0 )
137 { 137 {
138 SMTPaccount *account = new SMTPaccount(); 138 SMTPaccount *account = new SMTPaccount();
139 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 139 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
140 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 140 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
141 { 141 {
142 settings->addAccount( account ); 142 settings->addAccount( account );
143 account->save(); 143 account->save();
144 slotFillLists(); 144 slotFillLists();
145 145
146 } 146 }
147 else 147 else
148 { 148 {
149 account->remove(); 149 account->remove();
150 } 150 }
151 } 151 }
152 else if ( type.compare( "NNTP" ) == 0 ) 152 else if ( type.compare( i18n("NNTP") ) == 0 )
153 { 153 {
154 NNTPaccount *account = new NNTPaccount(); 154 NNTPaccount *account = new NNTPaccount();
155 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 155 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
156 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 156 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
157 { 157 {
158 settings->addAccount( account ); 158 settings->addAccount( account );
159 account->save(); 159 account->save();
160 slotFillLists(); 160 slotFillLists();
161 } 161 }
162 else 162 else
163 { 163 {
164 account->remove(); 164 account->remove();
165 } 165 }
166 } 166 }
167} 167}
168 168
169void EditAccounts::slotEditAccount( Account *account ) 169void EditAccounts::slotEditAccount( Account *account )
170{ 170{
171 if ( account->getType() == MAILLIB::A_IMAP ) 171 if ( account->getType() == MAILLIB::A_IMAP )
172 { 172 {
173 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 173 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
174 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 174 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
175 if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) 175 if ( QDialog::Accepted == KApplication::execDialog( &imap ) )
176 { 176 {
177 slotFillLists(); 177 slotFillLists();
178 } 178 }
179 } 179 }
180 else if ( account->getType()==MAILLIB::A_POP3 ) 180 else if ( account->getType()==MAILLIB::A_POP3 )
181 { 181 {
182 POP3account *pop3Acc = static_cast<POP3account *>(account); 182 POP3account *pop3Acc = static_cast<POP3account *>(account);
183 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 183 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
184 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 184 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
185 { 185 {
186 slotFillLists(); 186 slotFillLists();
187 } 187 }
188 } 188 }
189 else if ( account->getType()==MAILLIB::A_SMTP ) 189 else if ( account->getType()==MAILLIB::A_SMTP )
190 { 190 {
191 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 191 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
192 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 192 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
193 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 193 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
194 { 194 {
195 slotFillLists(); 195 slotFillLists();
196 } 196 }
197 } 197 }
198 else if ( account->getType()==MAILLIB::A_NNTP) 198 else if ( account->getType()==MAILLIB::A_NNTP)
199 { 199 {
200 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 200 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
201 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 201 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
202 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 202 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
203 { 203 {
204 slotFillLists(); 204 slotFillLists();
205 } 205 }
206 } 206 }
207} 207}
208 208
209void EditAccounts::slotDeleteAccount( Account *account ) 209void EditAccounts::slotDeleteAccount( Account *account )
210{ 210{
211 if ( QMessageBox::information( this, i18n( "Question" ), 211 if ( QMessageBox::information( this, i18n( "Question" ),
212 i18n( "<p>Do you really want to delete the selected Account?</p>" ), 212 i18n( "<p>Do you really want to delete the selected Account?</p>" ),
213 i18n( "Yes" ), i18n( "No" ) ) == 0 ) 213 i18n( "Yes" ), i18n( "No" ) ) == 0 )
214 { 214 {
215 settings->delAccount( account ); 215 settings->delAccount( account );
216 slotFillLists(); 216 slotFillLists();
217 } 217 }
218} 218}
219 219
220void EditAccounts::slotEditMail() 220void EditAccounts::slotEditMail()
221{ 221{
222 if ( !mailList->currentItem() ) 222 if ( !mailList->currentItem() )
223 { 223 {
224 QMessageBox::information( this, i18n( "Error" ), 224 QMessageBox::information( this, i18n( "Error" ),
225 i18n( "<p>Please select an account.</p>" ), 225 i18n( "<p>Please select an account.</p>" ),
226 i18n( "Ok" ) ); 226 i18n( "Ok" ) );
227 return; 227 return;
228 } 228 }
229 229
230 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 230 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
231 slotEditAccount( a ); 231 slotEditAccount( a );
232} 232}
233 233
234void EditAccounts::slotDeleteMail() 234void EditAccounts::slotDeleteMail()
235{ 235{
236 if ( !mailList->currentItem() ) 236 if ( !mailList->currentItem() )
237 { 237 {
238 QMessageBox::information( this, i18n( "Error" ), 238 QMessageBox::information( this, i18n( "Error" ),
239 i18n( "<p>Please select an account.</p>" ), 239 i18n( "<p>Please select an account.</p>" ),
240 i18n( "Ok" ) ); 240 i18n( "Ok" ) );
241 return; 241 return;
242 } 242 }
243 243
244 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 244 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
245 slotDeleteAccount( a ); 245 slotDeleteAccount( a );
246} 246}
247 247
248void EditAccounts::slotNewNews() 248void EditAccounts::slotNewNews()
249{ 249{
250 slotNewAccount( "NNTP" ); 250 slotNewAccount( "NNTP" );
251} 251}
252 252
253void EditAccounts::slotEditNews() 253void EditAccounts::slotEditNews()
254{ 254{
255 if ( !newsList->currentItem() ) 255 if ( !newsList->currentItem() )
256 { 256 {
257 QMessageBox::information( this, i18n( "Error" ), 257 QMessageBox::information( this, i18n( "Error" ),
258 i18n( "<p>Please select an account.</p>" ), 258 i18n( "<p>Please select an account.</p>" ),
259 i18n( "Ok" ) ); 259 i18n( "Ok" ) );
260 return; 260 return;
261 } 261 }
262 262
263 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 263 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
264 slotEditAccount( a ); 264 slotEditAccount( a );
265} 265}
266 266
267void EditAccounts::slotDeleteNews() 267void EditAccounts::slotDeleteNews()
268{ 268{
269 if ( !newsList->currentItem() ) 269 if ( !newsList->currentItem() )
270 { 270 {
271 QMessageBox::information( this, i18n( "Error" ), 271 QMessageBox::information( this, i18n( "Error" ),
272 i18n( "<p>Please select an account.</p>" ), 272 i18n( "<p>Please select an account.</p>" ),
273 i18n( "Ok" ) ); 273 i18n( "Ok" ) );
274 return; 274 return;
275 } 275 }
276 276
277 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 277 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
278 slotDeleteAccount( a ); 278 slotDeleteAccount( a );
279} 279}
280 280
281void EditAccounts::slotAdjustColumns() 281void EditAccounts::slotAdjustColumns()
282{ 282{
283 int currPage = configTab->currentPageIndex(); 283 int currPage = configTab->currentPageIndex();
284 284
285 configTab->showPage( mailTab ); 285 configTab->showPage( mailTab );
286 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 286 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
287 mailList->setColumnWidth( 1, 50 ); 287 mailList->setColumnWidth( 1, 50 );
288 288
289 configTab->showPage( newsTab ); 289 configTab->showPage( newsTab );
290 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 290 newsList->setColumnWidth( 0, newsList->visibleWidth() );
291 291
292 configTab->setCurrentPage( currPage ); 292 configTab->setCurrentPage( currPage );
293} 293}
294 294
295void EditAccounts::accept() 295void EditAccounts::accept()
296{ 296{
297 settings->saveAccounts(); 297 settings->saveAccounts();
298 298
299 QDialog::accept(); 299 QDialog::accept();
300} 300}
301 301
302/** 302/**
303 * SelectMailType 303 * SelectMailType
304 */ 304 */
305 305
306SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 306SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
307 : SelectMailTypeUI( parent, name, modal, flags ) 307 : SelectMailTypeUI( parent, name, modal, flags )
308{ 308{
309 selected = selection; 309 selected = selection;
310 selected->replace( 0, selected->length(), typeBox->currentText() ); 310 selected->replace( 0, selected->length(), typeBox->currentText() );
311 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 311 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
312} 312}
313 313
314void SelectMailType::slotSelection( const QString &sel ) 314void SelectMailType::slotSelection( const QString &sel )
315{ 315{
316 selected->replace( 0, selected->length(), sel ); 316 selected->replace( 0, selected->length(), sel );
317} 317}
318 318
319/** 319/**
320 * IMAPconfig 320 * IMAPconfig
321 */ 321 */
322 322
323IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 323IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
324 : IMAPconfigUI( parent, name, modal, flags ) 324 : IMAPconfigUI( parent, name, modal, flags )
325{ 325{
326 data = account; 326 data = account;
327 327
328 fillValues(); 328 fillValues();
329 329
330 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 330 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
331 ComboBox1->insertItem( "Only if available", 0 ); 331 ComboBox1->insertItem( "Only if available", 0 );
332 ComboBox1->insertItem( "Always, Negotiated", 1 ); 332 ComboBox1->insertItem( "Always, Negotiated", 1 );
333 ComboBox1->insertItem( "Connect on secure port", 2 ); 333 ComboBox1->insertItem( "Connect on secure port", 2 );
334 ComboBox1->insertItem( "Run command instead", 3 ); 334 ComboBox1->insertItem( "Run command instead", 3 );
335 CommandEdit->hide(); 335 CommandEdit->hide();
336 ComboBox1->setCurrentItem( data->ConnectionType() ); 336 ComboBox1->setCurrentItem( data->ConnectionType() );
337} 337}
338 338
339void IMAPconfig::slotConnectionToggle( int index ) 339void IMAPconfig::slotConnectionToggle( int index )
340{ 340{
341 if ( index == 2 ) 341 if ( index == 2 )
342 { 342 {
343 portLine->setText( IMAP_SSL_PORT ); 343 portLine->setText( IMAP_SSL_PORT );
344 } 344 }
345 else if ( index == 3 ) 345 else if ( index == 3 )
346 { 346 {
347 portLine->setText( IMAP_PORT ); 347 portLine->setText( IMAP_PORT );
348 CommandEdit->show(); 348 CommandEdit->show();
349 } 349 }
350 else 350 else
351 { 351 {
352 portLine->setText( IMAP_PORT ); 352 portLine->setText( IMAP_PORT );
353 } 353 }
354} 354}
355 355
356void IMAPconfig::fillValues() 356void IMAPconfig::fillValues()
357{ 357{
358 accountLine->setText( data->getAccountName() ); 358 accountLine->setText( data->getAccountName() );
359 serverLine->setText( data->getServer() ); 359 serverLine->setText( data->getServer() );
360 portLine->setText( data->getPort() ); 360 portLine->setText( data->getPort() );
361 ComboBox1->setCurrentItem( data->ConnectionType() ); 361 ComboBox1->setCurrentItem( data->ConnectionType() );
362 userLine->setText( data->getUser() ); 362 userLine->setText( data->getUser() );
363 passLine->setText( data->getPassword() ); 363 passLine->setText( data->getPassword() );
364 prefixLine->setText(data->getPrefix()); 364 prefixLine->setText(data->getPrefix());
365 localFolder->setText( data->getLocalFolder() ); 365 localFolder->setText( data->getLocalFolder() );
366 int max = data->getMaxMailSize() ; 366 int max = data->getMaxMailSize() ;
367 if ( max ) { 367 if ( max ) {
368 CheckBoxDown->setChecked( true ); 368 CheckBoxDown->setChecked( true );
369 SpinBoxDown->setValue ( max ); 369 SpinBoxDown->setValue ( max );
370 } else { 370 } else {
371 CheckBoxDown->setChecked( false ); 371 CheckBoxDown->setChecked( false );
372 SpinBoxDown->setValue ( 5 ); 372 SpinBoxDown->setValue ( 5 );
373 } 373 }
374 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 374 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
375} 375}
376 376
377void IMAPconfig::accept() 377void IMAPconfig::accept()
378{ 378{
379 data->setAccountName( accountLine->text() ); 379 data->setAccountName( accountLine->text() );
380 data->setServer( serverLine->text() ); 380 data->setServer( serverLine->text() );
381 data->setPort( portLine->text() ); 381 data->setPort( portLine->text() );
382 data->setConnectionType( ComboBox1->currentItem() ); 382 data->setConnectionType( ComboBox1->currentItem() );
383 data->setUser( userLine->text() ); 383 data->setUser( userLine->text() );
384 data->setPassword( passLine->text() ); 384 data->setPassword( passLine->text() );
385 data->setPrefix(prefixLine->text()); 385 data->setPrefix(prefixLine->text());
386 data->setLocalFolder( localFolder->text() ); 386 data->setLocalFolder( localFolder->text() );
387 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 387 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
388 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 388 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
389 389
390 QDialog::accept(); 390 QDialog::accept();
391} 391}
392 392
393/** 393/**
394 * POP3config 394 * POP3config
395 */ 395 */
396 396
397POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 397POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
398 : POP3configUI( parent, name, modal, flags ) 398 : POP3configUI( parent, name, modal, flags )
399{ 399{
400 data = account; 400 data = account;
401 fillValues(); 401 fillValues();
402 402
403 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 403 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
404 ComboBox1->insertItem( "Only if available", 0 ); 404 ComboBox1->insertItem( "Only if available", 0 );
405 ComboBox1->insertItem( "Always, Negotiated", 1 ); 405 ComboBox1->insertItem( "Always, Negotiated", 1 );
406 ComboBox1->insertItem( "Connect on secure port", 2 ); 406 ComboBox1->insertItem( "Connect on secure port", 2 );
407 ComboBox1->insertItem( "Run command instead", 3 ); 407 ComboBox1->insertItem( "Run command instead", 3 );
408 CommandEdit->hide(); 408 CommandEdit->hide();
409 ComboBox1->setCurrentItem( data->ConnectionType() ); 409 ComboBox1->setCurrentItem( data->ConnectionType() );
410} 410}
411 411
412void POP3config::slotConnectionToggle( int index ) 412void POP3config::slotConnectionToggle( int index )
413{ 413{
414 // 2 is ssl connection 414 // 2 is ssl connection
415 if ( index == 2 ) 415 if ( index == 2 )
416 { 416 {
417 portLine->setText( POP3_SSL_PORT ); 417 portLine->setText( POP3_SSL_PORT );
418 } 418 }
419 else if ( index == 3 ) 419 else if ( index == 3 )
420 { 420 {
421 portLine->setText( POP3_PORT ); 421 portLine->setText( POP3_PORT );
422 CommandEdit->show(); 422 CommandEdit->show();
423 } 423 }
424 else 424 else
425 { 425 {
426 portLine->setText( POP3_PORT ); 426 portLine->setText( POP3_PORT );
427 } 427 }
428} 428}
429 429
430void POP3config::fillValues() 430void POP3config::fillValues()
431{ 431{
432 accountLine->setText( data->getAccountName() ); 432 accountLine->setText( data->getAccountName() );
433 serverLine->setText( data->getServer() ); 433 serverLine->setText( data->getServer() );
434 portLine->setText( data->getPort() ); 434 portLine->setText( data->getPort() );
435 ComboBox1->setCurrentItem( data->ConnectionType() ); 435 ComboBox1->setCurrentItem( data->ConnectionType() );
436 userLine->setText( data->getUser() ); 436 userLine->setText( data->getUser() );
437 passLine->setText( data->getPassword() ); 437 passLine->setText( data->getPassword() );
438 localFolder->setText( data->getLocalFolder() ); 438 localFolder->setText( data->getLocalFolder() );
439 int max = data->getMaxMailSize() ; 439 int max = data->getMaxMailSize() ;
440 if ( max ) { 440 if ( max ) {
441 CheckBoxDown->setChecked( true ); 441 CheckBoxDown->setChecked( true );
442 SpinBoxDown->setValue ( max ); 442 SpinBoxDown->setValue ( max );
443 } else { 443 } else {
444 CheckBoxDown->setChecked( false ); 444 CheckBoxDown->setChecked( false );
445 SpinBoxDown->setValue ( 5 ); 445 SpinBoxDown->setValue ( 5 );
446 } 446 }
447 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 447 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
448} 448}
449 449
450void POP3config::accept() 450void POP3config::accept()
451{ 451{
452 data->setAccountName( accountLine->text() ); 452 data->setAccountName( accountLine->text() );
453 data->setServer( serverLine->text() ); 453 data->setServer( serverLine->text() );
454 data->setPort( portLine->text() ); 454 data->setPort( portLine->text() );
455 data->setConnectionType( ComboBox1->currentItem() ); 455 data->setConnectionType( ComboBox1->currentItem() );
456 data->setUser( userLine->text() ); 456 data->setUser( userLine->text() );
457 data->setPassword( passLine->text() ); 457 data->setPassword( passLine->text() );
458 data->setLocalFolder( localFolder->text() ); 458 data->setLocalFolder( localFolder->text() );
459 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 459 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
460 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 460 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
461 461
462 QDialog::accept(); 462 QDialog::accept();
463} 463}
464 464
465/** 465/**
466 * SMTPconfig 466 * SMTPconfig
467 */ 467 */
468 468
469SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 469SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
470 : SMTPconfigUI( parent, name, modal, flags ) 470 : SMTPconfigUI( parent, name, modal, flags )
471{ 471{
472 data = account; 472 data = account;
473 473
474 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 474 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
475 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 475 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
476 476
477 fillValues(); 477 fillValues();
478 478
479 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 479 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
480 ComboBox1->insertItem( "Only if available", 0 ); 480 ComboBox1->insertItem( "Only if available", 0 );
481 ComboBox1->insertItem( "Always, Negotiated", 1 ); 481 ComboBox1->insertItem( "Always, Negotiated", 1 );
482 ComboBox1->insertItem( "Connect on secure port", 2 ); 482 ComboBox1->insertItem( "Connect on secure port", 2 );
483 ComboBox1->insertItem( "Run command instead", 3 ); 483 ComboBox1->insertItem( "Run command instead", 3 );
484 CommandEdit->hide(); 484 CommandEdit->hide();
485 ComboBox1->setCurrentItem( data->ConnectionType() ); 485 ComboBox1->setCurrentItem( data->ConnectionType() );
486} 486}
487 487
488void SMTPconfig::slotConnectionToggle( int index ) 488void SMTPconfig::slotConnectionToggle( int index )
489{ 489{
490 // 2 is ssl connection 490 // 2 is ssl connection
491 if ( index == 2 ) 491 if ( index == 2 )
492 { 492 {
493 portLine->setText( SMTP_SSL_PORT ); 493 portLine->setText( SMTP_SSL_PORT );
494 } 494 }
495 else if ( index == 3 ) 495 else if ( index == 3 )
496 { 496 {
497 portLine->setText( SMTP_PORT ); 497 portLine->setText( SMTP_PORT );
498 CommandEdit->show(); 498 CommandEdit->show();
499 } 499 }
500 else 500 else
501 { 501 {
502 portLine->setText( SMTP_PORT ); 502 portLine->setText( SMTP_PORT );
503 } 503 }
504} 504}
505 505
506void SMTPconfig::fillValues() 506void SMTPconfig::fillValues()
507{ 507{
508 accountLine->setText( data->getAccountName() ); 508 accountLine->setText( data->getAccountName() );
509 serverLine->setText( data->getServer() ); 509 serverLine->setText( data->getServer() );
510 portLine->setText( data->getPort() ); 510 portLine->setText( data->getPort() );
511 ComboBox1->setCurrentItem( data->ConnectionType() ); 511 ComboBox1->setCurrentItem( data->ConnectionType() );
512 loginBox->setChecked( data->getLogin() ); 512 loginBox->setChecked( data->getLogin() );
513 userLine->setText( data->getUser() ); 513 userLine->setText( data->getUser() );
514 passLine->setText( data->getPassword() ); 514 passLine->setText( data->getPassword() );
515} 515}
516 516
517void SMTPconfig::accept() 517void SMTPconfig::accept()
518{ 518{
519 data->setAccountName( accountLine->text() ); 519 data->setAccountName( accountLine->text() );
520 data->setServer( serverLine->text() ); 520 data->setServer( serverLine->text() );
521 data->setPort( portLine->text() ); 521 data->setPort( portLine->text() );
522 data->setConnectionType( ComboBox1->currentItem() ); 522 data->setConnectionType( ComboBox1->currentItem() );
523 data->setLogin( loginBox->isChecked() ); 523 data->setLogin( loginBox->isChecked() );
524 data->setUser( userLine->text() ); 524 data->setUser( userLine->text() );
525 data->setPassword( passLine->text() ); 525 data->setPassword( passLine->text() );
526 526
527 QDialog::accept(); 527 QDialog::accept();
528} 528}
529 529
530/** 530/**
531 * NNTPconfig 531 * NNTPconfig
532 */ 532 */
533 533
534NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 534NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
535 : NNTPconfigUI( parent, name, modal, flags ) 535 : NNTPconfigUI( parent, name, modal, flags )
536{ 536{
537 data = account; 537 data = account;
538 538
539 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 539 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
540 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 540 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
541 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 541 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
542 connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); 542 connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) );
543 connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); 543 connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) );
544 fillValues(); 544 fillValues();
545 545
546 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 546 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
547} 547}
548 548
549void NNTPconfig::slotShowSub() 549void NNTPconfig::slotShowSub()
550{ 550{
551 save(); 551 save();
552 data->save(); 552 data->save();
553 ListViewGroups->clear(); 553 ListViewGroups->clear();
554 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 554 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
555 QCheckListItem *item; 555 QCheckListItem *item;
556 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 556 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
557 item->setOn( true ); 557 item->setOn( true );
558 } 558 }
559 topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count())); 559 topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count()));
560} 560}
561void NNTPconfig::slotShowFilter() 561void NNTPconfig::slotShowFilter()
562{ 562{
563 save(); 563 save();
564 data->save(); 564 data->save();
565 ListViewGroups->clear(); 565 ListViewGroups->clear();
566 int count = 0; 566 int count = 0;
567 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { 567 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
568 QCheckListItem *item; 568 QCheckListItem *item;
569 if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { 569 if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) {
570 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 570 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
571 ++count; 571 ++count;
572 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 572 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
573 item->setOn( true ); 573 item->setOn( true );
574 } 574 }
575 } 575 }
576 } 576 }
577 topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count)); 577 topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count));
578} 578}
579void NNTPconfig::slotGetNG() { 579void NNTPconfig::slotGetNG() {
580 save(); 580 save();
581 data->save(); 581 data->save();
582 topLevelWidget()->setCaption( i18n("Fetching group list...")); 582 topLevelWidget()->setCaption( i18n("Fetching group list..."));
583 qApp->processEvents(); 583 qApp->processEvents();
584 NNTPwrapper* tmp = new NNTPwrapper( data ); 584 NNTPwrapper* tmp = new NNTPwrapper( data );
585 allGroups = tmp->listAllNewsgroups(); 585 allGroups = tmp->listAllNewsgroups();
586 topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count())); 586 topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count()));
587 587
588 ListViewGroups->clear(); 588 ListViewGroups->clear();
589 589
590 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { 590 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
591 QCheckListItem *item; 591 QCheckListItem *item;
592 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 592 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
593 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 593 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
594 item->setOn( true ); 594 item->setOn( true );
595 595
596 } 596 }
597 } 597 }
598 delete tmp; 598 delete tmp;
599} 599}
600 600
601void NNTPconfig::slotSSL( bool enabled ) 601void NNTPconfig::slotSSL( bool enabled )
602{ 602{
603 if ( enabled ) 603 if ( enabled )
604 { 604 {
605 portLine->setText( NNTP_SSL_PORT ); 605 portLine->setText( NNTP_SSL_PORT );
606 } 606 }
607 else 607 else
608 { 608 {
609 portLine->setText( NNTP_PORT ); 609 portLine->setText( NNTP_PORT );
610 } 610 }
611} 611}
612 612
613void NNTPconfig::fillValues() 613void NNTPconfig::fillValues()
614{ 614{
615 accountLine->setText( data->getAccountName() ); 615 accountLine->setText( data->getAccountName() );
616 serverLine->setText( data->getServer() ); 616 serverLine->setText( data->getServer() );
617 portLine->setText( data->getPort() ); 617 portLine->setText( data->getPort() );
618 sslBox->setChecked( data->getSSL() ); 618 sslBox->setChecked( data->getSSL() );
619 loginBox->setChecked( data->getLogin() ); 619 loginBox->setChecked( data->getLogin() );
620 userLine->setText( data->getUser() ); 620 userLine->setText( data->getUser() );
621 passLine->setText( data->getPassword() ); 621 passLine->setText( data->getPassword() );
622 subscribedGroups = data->getGroups(); 622 subscribedGroups = data->getGroups();
623 /* don't forget that - you will overwrite values if user clicks cancel! */ 623 /* don't forget that - you will overwrite values if user clicks cancel! */
624 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 624 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
625 QCheckListItem *item; 625 QCheckListItem *item;
626 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 626 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
627 item->setOn( true ); 627 item->setOn( true );
628 } 628 }
629} 629}
630 630
631void NNTPconfig::save() 631void NNTPconfig::save()
632{ 632{
633 data->setAccountName( accountLine->text() ); 633 data->setAccountName( accountLine->text() );
634 data->setServer( serverLine->text() ); 634 data->setServer( serverLine->text() );
635 data->setPort( portLine->text() ); 635 data->setPort( portLine->text() );
636 data->setSSL( sslBox->isChecked() ); 636 data->setSSL( sslBox->isChecked() );
637 data->setLogin( loginBox->isChecked() ); 637 data->setLogin( loginBox->isChecked() );
638 data->setUser( userLine->text() ); 638 data->setUser( userLine->text() );
639 data->setPassword( passLine->text() ); 639 data->setPassword( passLine->text() );
640 640
641 QListViewItemIterator list_it( ListViewGroups ); 641 QListViewItemIterator list_it( ListViewGroups );
642 642
643 for ( ; list_it.current(); ++list_it ) { 643 for ( ; list_it.current(); ++list_it ) {
644 644
645 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 645 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
646 if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) 646 if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 )
647 subscribedGroups.append( list_it.current()->text(0) ); 647 subscribedGroups.append( list_it.current()->text(0) );
648 } else { 648 } else {
649 if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) 649 if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 )
650 subscribedGroups.remove( list_it.current()->text(0) ); 650 subscribedGroups.remove( list_it.current()->text(0) );
651 } 651 }
652 652
653 } 653 }
654 data->setGroups( subscribedGroups ); 654 data->setGroups( subscribedGroups );
655} 655}
656 656
657void NNTPconfig::accept() 657void NNTPconfig::accept()
658{ 658{
659 save(); 659 save();
660 QDialog::accept(); 660 QDialog::accept();
661} 661}
662 662