summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-21 22:20:39 (UTC)
committer zautrix <zautrix>2004-10-21 22:20:39 (UTC)
commitd6f9bd535e8cabe653bdff329500f9153e5e11fb (patch) (unidiff)
tree6f83c692713c41896a165e399f259a744f125e5c
parentbb235c5a639b914574e1e247d2de6e479517585f (diff)
downloadkdepimpi-d6f9bd535e8cabe653bdff329500f9153e5e11fb.zip
kdepimpi-d6f9bd535e8cabe653bdff329500f9153e5e11fb.tar.gz
kdepimpi-d6f9bd535e8cabe653bdff329500f9153e5e11fb.tar.bz2
small fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--kaddressbook/mainembedded.cpp124
-rw-r--r--kaddressbook/views/contactlistview.cpp2
-rw-r--r--korganizer/koeventviewer.cpp5
-rw-r--r--korganizer/kolistview.cpp13
-rw-r--r--korganizer/main.cpp2
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp11
7 files changed, 35 insertions, 128 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1074a62..c4382d6 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2903 +1,2907 @@
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 = 0; 316 mBRdisabled = 0;
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 )
392 setModified( true );
391 mViewManager->refreshView(); 393 mViewManager->refreshView();
392 message(i18n("%1 contact(s) received!").arg( count )); 394 message(i18n("%1 contact(s) received!").arg( count ));
393 topLevelWidget()->showMaximized(); 395 topLevelWidget()->showMaximized();
394 topLevelWidget()->raise(); 396 topLevelWidget()->raise();
395} 397}
396void KABCore::restoreSettings() 398void KABCore::restoreSettings()
397{ 399{
398 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 400 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
399 401
400 bool state; 402 bool state;
401 403
402 if (mMultipleViewsAtOnce) 404 if (mMultipleViewsAtOnce)
403 state = KABPrefs::instance()->mDetailsPageVisible; 405 state = KABPrefs::instance()->mDetailsPageVisible;
404 else 406 else
405 state = false; 407 state = false;
406 408
407 mActionDetails->setChecked( state ); 409 mActionDetails->setChecked( state );
408 setDetailsVisible( state ); 410 setDetailsVisible( state );
409 411
410 state = KABPrefs::instance()->mJumpButtonBarVisible; 412 state = KABPrefs::instance()->mJumpButtonBarVisible;
411 413
412 mActionJumpBar->setChecked( state ); 414 mActionJumpBar->setChecked( state );
413 setJumpButtonBarVisible( state ); 415 setJumpButtonBarVisible( state );
414/*US 416/*US
415 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 417 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
416 if ( splitterSize.count() == 0 ) { 418 if ( splitterSize.count() == 0 ) {
417 splitterSize.append( width() / 2 ); 419 splitterSize.append( width() / 2 );
418 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
419 } 421 }
420 mMiniSplitter->setSizes( splitterSize ); 422 mMiniSplitter->setSizes( splitterSize );
421 if ( mExtensionBarSplitter ) { 423 if ( mExtensionBarSplitter ) {
422 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 424 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
423 if ( splitterSize.count() == 0 ) { 425 if ( splitterSize.count() == 0 ) {
424 splitterSize.append( width() / 2 ); 426 splitterSize.append( width() / 2 );
425 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
426 } 428 }
427 mExtensionBarSplitter->setSizes( splitterSize ); 429 mExtensionBarSplitter->setSizes( splitterSize );
428 430
429 } 431 }
430*/ 432*/
431 mViewManager->restoreSettings(); 433 mViewManager->restoreSettings();
432 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 434 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
433 mExtensionManager->restoreSettings(); 435 mExtensionManager->restoreSettings();
434#ifdef DESKTOP_VERSION 436#ifdef DESKTOP_VERSION
435 int wid = width(); 437 int wid = width();
436 if ( wid < 10 ) 438 if ( wid < 10 )
437 wid = 400; 439 wid = 400;
438#else 440#else
439 int wid = QApplication::desktop()->width(); 441 int wid = QApplication::desktop()->width();
440 if ( wid < 640 ) 442 if ( wid < 640 )
441 wid = QApplication::desktop()->height(); 443 wid = QApplication::desktop()->height();
442#endif 444#endif
443 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 445 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
444 if ( true /*splitterSize.count() == 0*/ ) { 446 if ( true /*splitterSize.count() == 0*/ ) {
445 splitterSize.append( wid / 2 ); 447 splitterSize.append( wid / 2 );
446 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
447 } 449 }
448 mMiniSplitter->setSizes( splitterSize ); 450 mMiniSplitter->setSizes( splitterSize );
449 if ( mExtensionBarSplitter ) { 451 if ( mExtensionBarSplitter ) {
450 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 452 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
451 if ( true /*splitterSize.count() == 0*/ ) { 453 if ( true /*splitterSize.count() == 0*/ ) {
452 splitterSize.append( wid / 2 ); 454 splitterSize.append( wid / 2 );
453 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
454 } 456 }
455 mExtensionBarSplitter->setSizes( splitterSize ); 457 mExtensionBarSplitter->setSizes( splitterSize );
456 458
457 } 459 }
458 460
459 461
460} 462}
461 463
462void KABCore::saveSettings() 464void KABCore::saveSettings()
463{ 465{
464 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 466 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
465 if ( mExtensionBarSplitter ) 467 if ( mExtensionBarSplitter )
466 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 468 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
467 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 469 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
468 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 470 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
469#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
470 472
471 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 473 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
472 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 474 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
473#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
474 mExtensionManager->saveSettings(); 476 mExtensionManager->saveSettings();
475 mViewManager->saveSettings(); 477 mViewManager->saveSettings();
476 478
477 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 479 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
478} 480}
479 481
480KABC::AddressBook *KABCore::addressBook() const 482KABC::AddressBook *KABCore::addressBook() const
481{ 483{
482 return mAddressBook; 484 return mAddressBook;
483} 485}
484 486
485KConfig *KABCore::config() 487KConfig *KABCore::config()
486{ 488{
487#ifndef KAB_EMBEDDED 489#ifndef KAB_EMBEDDED
488 return KABPrefs::instance()->config(); 490 return KABPrefs::instance()->config();
489#else //KAB_EMBEDDED 491#else //KAB_EMBEDDED
490 return KABPrefs::instance()->getConfig(); 492 return KABPrefs::instance()->getConfig();
491#endif //KAB_EMBEDDED 493#endif //KAB_EMBEDDED
492} 494}
493 495
494KActionCollection *KABCore::actionCollection() const 496KActionCollection *KABCore::actionCollection() const
495{ 497{
496 return mGUIClient->actionCollection(); 498 return mGUIClient->actionCollection();
497} 499}
498 500
499KABC::Field *KABCore::currentSearchField() const 501KABC::Field *KABCore::currentSearchField() const
500{ 502{
501 if (mIncSearchWidget) 503 if (mIncSearchWidget)
502 return mIncSearchWidget->currentField(); 504 return mIncSearchWidget->currentField();
503 else 505 else
504 return 0; 506 return 0;
505} 507}
506 508
507QStringList KABCore::selectedUIDs() const 509QStringList KABCore::selectedUIDs() const
508{ 510{
509 return mViewManager->selectedUids(); 511 return mViewManager->selectedUids();
510} 512}
511 513
512KABC::Resource *KABCore::requestResource( QWidget *parent ) 514KABC::Resource *KABCore::requestResource( QWidget *parent )
513{ 515{
514 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 516 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
515 517
516 QPtrList<KRES::Resource> kresResources; 518 QPtrList<KRES::Resource> kresResources;
517 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 519 QPtrListIterator<KABC::Resource> resIt( kabcResources );
518 KABC::Resource *resource; 520 KABC::Resource *resource;
519 while ( ( resource = resIt.current() ) != 0 ) { 521 while ( ( resource = resIt.current() ) != 0 ) {
520 ++resIt; 522 ++resIt;
521 if ( !resource->readOnly() ) { 523 if ( !resource->readOnly() ) {
522 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 524 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
523 if ( res ) 525 if ( res )
524 kresResources.append( res ); 526 kresResources.append( res );
525 } 527 }
526 } 528 }
527 529
528 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 530 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
529 return static_cast<KABC::Resource*>( res ); 531 return static_cast<KABC::Resource*>( res );
530} 532}
531 533
532#ifndef KAB_EMBEDDED 534#ifndef KAB_EMBEDDED
533KAboutData *KABCore::createAboutData() 535KAboutData *KABCore::createAboutData()
534#else //KAB_EMBEDDED 536#else //KAB_EMBEDDED
535void KABCore::createAboutData() 537void KABCore::createAboutData()
536#endif //KAB_EMBEDDED 538#endif //KAB_EMBEDDED
537{ 539{
538#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
539 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 541 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
540 "3.1", I18N_NOOP( "The KDE Address Book" ), 542 "3.1", I18N_NOOP( "The KDE Address Book" ),
541 KAboutData::License_GPL_V2, 543 KAboutData::License_GPL_V2,
542 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 544 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
543 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 545 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
544 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 546 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
545 about->addAuthor( "Cornelius Schumacher", 547 about->addAuthor( "Cornelius Schumacher",
546 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 548 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
547 "schumacher@kde.org" ); 549 "schumacher@kde.org" );
548 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 550 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
549 "mpilone@slac.com" ); 551 "mpilone@slac.com" );
550 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 552 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
551 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 553 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
552 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" ),
553 "michel@klaralvdalens-datakonsult.se" ); 555 "michel@klaralvdalens-datakonsult.se" );
554 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 556 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
555 "hansen@kde.org" ); 557 "hansen@kde.org" );
556 558
557 return about; 559 return about;
558#endif //KAB_EMBEDDED 560#endif //KAB_EMBEDDED
559 561
560 QString version; 562 QString version;
561#include <../version> 563#include <../version>
562 QMessageBox::about( this, "About KAddressbook/Pi", 564 QMessageBox::about( this, "About KAddressbook/Pi",
563 "KAddressbook/Platform-independent\n" 565 "KAddressbook/Platform-independent\n"
564 "(KA/Pi) " +version + " - " + 566 "(KA/Pi) " +version + " - " +
565#ifdef DESKTOP_VERSION 567#ifdef DESKTOP_VERSION
566 "Desktop Edition\n" 568 "Desktop Edition\n"
567#else 569#else
568 "PDA-Edition\n" 570 "PDA-Edition\n"
569 "for: Zaurus 5500 / 7x0 / 8x0\n" 571 "for: Zaurus 5500 / 7x0 / 8x0\n"
570#endif 572#endif
571 573
572 "(c) 2004 Ulf Schenk\n" 574 "(c) 2004 Ulf Schenk\n"
573 "(c) 2004 Lutz Rogowski\n" 575 "(c) 2004 Lutz Rogowski\n"
574 "(c) 1997-2003, The KDE PIM Team\n" 576 "(c) 1997-2003, The KDE PIM Team\n"
575 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 577 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
576 "Don Sanders Original author\n" 578 "Don Sanders Original author\n"
577 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 579 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
578 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 580 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
579 "Greg Stern DCOP interface\n" 581 "Greg Stern DCOP interface\n"
580 "Mark Westcot Contact pinning\n" 582 "Mark Westcot Contact pinning\n"
581 "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"
582 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 584 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
583#ifdef _WIN32_ 585#ifdef _WIN32_
584 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 586 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
585#endif 587#endif
586 ); 588 );
587} 589}
588 590
589void KABCore::setContactSelected( const QString &uid ) 591void KABCore::setContactSelected( const QString &uid )
590{ 592{
591 KABC::Addressee addr = mAddressBook->findByUid( uid ); 593 KABC::Addressee addr = mAddressBook->findByUid( uid );
592 if ( !mDetails->isHidden() ) 594 if ( !mDetails->isHidden() )
593 mDetails->setAddressee( addr ); 595 mDetails->setAddressee( addr );
594 596
595 if ( !addr.isEmpty() ) { 597 if ( !addr.isEmpty() ) {
596 emit contactSelected( addr.formattedName() ); 598 emit contactSelected( addr.formattedName() );
597 KABC::Picture pic = addr.photo(); 599 KABC::Picture pic = addr.photo();
598 if ( pic.isIntern() ) { 600 if ( pic.isIntern() ) {
599//US emit contactSelected( pic.data() ); 601//US emit contactSelected( pic.data() );
600//US instead use: 602//US instead use:
601 QPixmap px; 603 QPixmap px;
602 if (pic.data().isNull() != true) 604 if (pic.data().isNull() != true)
603 { 605 {
604 px.convertFromImage(pic.data()); 606 px.convertFromImage(pic.data());
605 } 607 }
606 608
607 emit contactSelected( px ); 609 emit contactSelected( px );
608 } 610 }
609 } 611 }
610 612
611 613
612 mExtensionManager->setSelectionChanged(); 614 mExtensionManager->setSelectionChanged();
613 615
614 // update the actions 616 // update the actions
615 bool selected = !uid.isEmpty(); 617 bool selected = !uid.isEmpty();
616 618
617 if ( mReadWrite ) { 619 if ( mReadWrite ) {
618 mActionCut->setEnabled( selected ); 620 mActionCut->setEnabled( selected );
619 mActionPaste->setEnabled( selected ); 621 mActionPaste->setEnabled( selected );
620 } 622 }
621 623
622 mActionCopy->setEnabled( selected ); 624 mActionCopy->setEnabled( selected );
623 mActionDelete->setEnabled( selected ); 625 mActionDelete->setEnabled( selected );
624 mActionEditAddressee->setEnabled( selected ); 626 mActionEditAddressee->setEnabled( selected );
625 mActionMail->setEnabled( selected ); 627 mActionMail->setEnabled( selected );
626 mActionMailVCard->setEnabled( selected ); 628 mActionMailVCard->setEnabled( selected );
627 //if (mActionBeam) 629 //if (mActionBeam)
628 //mActionBeam->setEnabled( selected ); 630 //mActionBeam->setEnabled( selected );
629 631
630 if (mActionBeamVCard) 632 if (mActionBeamVCard)
631 mActionBeamVCard->setEnabled( selected ); 633 mActionBeamVCard->setEnabled( selected );
632 634
633 mActionExport2phone->setEnabled( selected ); 635 mActionExport2phone->setEnabled( selected );
634 mActionWhoAmI->setEnabled( selected ); 636 mActionWhoAmI->setEnabled( selected );
635 mActionCategories->setEnabled( selected ); 637 mActionCategories->setEnabled( selected );
636} 638}
637 639
638void KABCore::sendMail() 640void KABCore::sendMail()
639{ 641{
640 sendMail( mViewManager->selectedEmails().join( ", " ) ); 642 sendMail( mViewManager->selectedEmails().join( ", " ) );
641} 643}
642 644
643void KABCore::sendMail( const QString& emaillist ) 645void KABCore::sendMail( const QString& emaillist )
644{ 646{
645 // 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>;... "
646 if (emaillist.contains(",") > 0) 648 if (emaillist.contains(",") > 0)
647 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 649 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
648 else 650 else
649 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 651 ExternalAppHandler::instance()->mailToOneContact( emaillist );
650} 652}
651 653
652 654
653 655
654void KABCore::mailVCard() 656void KABCore::mailVCard()
655{ 657{
656 QStringList uids = mViewManager->selectedUids(); 658 QStringList uids = mViewManager->selectedUids();
657 if ( !uids.isEmpty() ) 659 if ( !uids.isEmpty() )
658 mailVCard( uids ); 660 mailVCard( uids );
659} 661}
660 662
661void KABCore::mailVCard( const QStringList& uids ) 663void KABCore::mailVCard( const QStringList& uids )
662{ 664{
663 QStringList urls; 665 QStringList urls;
664 666
665// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 667// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
666 668
667 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 669 QString dirName = "/tmp/" + KApplication::randomString( 8 );
668 670
669 671
670 672
671 QDir().mkdir( dirName, true ); 673 QDir().mkdir( dirName, true );
672 674
673 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 675 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
674 KABC::Addressee a = mAddressBook->findByUid( *it ); 676 KABC::Addressee a = mAddressBook->findByUid( *it );
675 677
676 if ( a.isEmpty() ) 678 if ( a.isEmpty() )
677 continue; 679 continue;
678 680
679 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 681 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
680 682
681 QString fileName = dirName + "/" + name; 683 QString fileName = dirName + "/" + name;
682 684
683 QFile outFile(fileName); 685 QFile outFile(fileName);
684 686
685 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 687 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
686 KABC::VCardConverter converter; 688 KABC::VCardConverter converter;
687 QString vcard; 689 QString vcard;
688 690
689 converter.addresseeToVCard( a, vcard ); 691 converter.addresseeToVCard( a, vcard );
690 692
691 QTextStream t( &outFile ); // use a text stream 693 QTextStream t( &outFile ); // use a text stream
692 t.setEncoding( QTextStream::UnicodeUTF8 ); 694 t.setEncoding( QTextStream::UnicodeUTF8 );
693 t << vcard; 695 t << vcard;
694 696
695 outFile.close(); 697 outFile.close();
696 698
697 urls.append( fileName ); 699 urls.append( fileName );
698 } 700 }
699 } 701 }
700 702
701 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 703 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
702 704
703 705
704/*US 706/*US
705 kapp->invokeMailer( QString::null, QString::null, QString::null, 707 kapp->invokeMailer( QString::null, QString::null, QString::null,
706 QString::null, // subject 708 QString::null, // subject
707 QString::null, // body 709 QString::null, // body
708 QString::null, 710 QString::null,
709 urls ); // attachments 711 urls ); // attachments
710*/ 712*/
711 713
712} 714}
713 715
714/** 716/**
715 Beams the "WhoAmI contact. 717 Beams the "WhoAmI contact.
716*/ 718*/
717void KABCore::beamMySelf() 719void KABCore::beamMySelf()
718{ 720{
719 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 721 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
720 if (!a.isEmpty()) 722 if (!a.isEmpty())
721 { 723 {
722 QStringList uids; 724 QStringList uids;
723 uids << a.uid(); 725 uids << a.uid();
724 726
725 beamVCard(uids); 727 beamVCard(uids);
726 } else { 728 } else {
727 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" ) );
728 730
729 731
730 } 732 }
731} 733}
732 734
733void KABCore::export2phone() 735void KABCore::export2phone()
734{ 736{
735 737
736 KAex2phonePrefs ex2phone; 738 KAex2phonePrefs ex2phone;
737 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 739 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
738 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 740 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
739 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 741 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
740 742
741 if ( !ex2phone.exec() ) { 743 if ( !ex2phone.exec() ) {
742 return; 744 return;
743 } 745 }
744 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 746 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
745 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
746 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
747 749
748 750
749 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 751 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
750 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 752 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
751 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 753 KPimGlobalPrefs::instance()->mEx2PhoneModel );
752 754
753 QStringList uids = mViewManager->selectedUids(); 755 QStringList uids = mViewManager->selectedUids();
754 if ( uids.isEmpty() ) 756 if ( uids.isEmpty() )
755 return; 757 return;
756 758
757 QString fileName = getPhoneFile(); 759 QString fileName = getPhoneFile();
758 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 760 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
759 return; 761 return;
760 762
761 message(i18n("Exporting to phone...")); 763 message(i18n("Exporting to phone..."));
762 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 764 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
763 765
764} 766}
765QString KABCore::getPhoneFile() 767QString KABCore::getPhoneFile()
766{ 768{
767#ifdef DESKTOP_VERSION 769#ifdef DESKTOP_VERSION
768 return locateLocal("tmp", "phonefile.vcf"); 770 return locateLocal("tmp", "phonefile.vcf");
769#else 771#else
770 return "/tmp/phonefile.vcf"; 772 return "/tmp/phonefile.vcf";
771#endif 773#endif
772 774
773} 775}
774void KABCore::writeToPhone( ) 776void KABCore::writeToPhone( )
775{ 777{
776 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 778 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
777 message(i18n("Export to phone finished!")); 779 message(i18n("Export to phone finished!"));
778 else 780 else
779 qDebug(i18n("Error exporting to phone")); 781 qDebug(i18n("Error exporting to phone"));
780} 782}
781void KABCore::beamVCard() 783void KABCore::beamVCard()
782{ 784{
783 QStringList uids = mViewManager->selectedUids(); 785 QStringList uids = mViewManager->selectedUids();
784 if ( !uids.isEmpty() ) 786 if ( !uids.isEmpty() )
785 beamVCard( uids ); 787 beamVCard( uids );
786} 788}
787 789
788 790
789void KABCore::beamVCard(const QStringList& uids) 791void KABCore::beamVCard(const QStringList& uids)
790{ 792{
791 793
792 // LR: we should use the /tmp dir on the Zaurus, 794 // LR: we should use the /tmp dir on the Zaurus,
793 // because: /tmp = RAM, (HOME)/kdepim = flash memory 795 // because: /tmp = RAM, (HOME)/kdepim = flash memory
794 796
795#ifdef DESKTOP_VERSION 797#ifdef DESKTOP_VERSION
796 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 798 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
797#else 799#else
798 QString fileName = "/tmp/kapibeamfile.vcf"; 800 QString fileName = "/tmp/kapibeamfile.vcf";
799#endif 801#endif
800 802
801 KABC::VCardConverter converter; 803 KABC::VCardConverter converter;
802 QString description; 804 QString description;
803 QString datastream; 805 QString datastream;
804 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 806 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
805 KABC::Addressee a = mAddressBook->findByUid( *it ); 807 KABC::Addressee a = mAddressBook->findByUid( *it );
806 808
807 if ( a.isEmpty() ) 809 if ( a.isEmpty() )
808 continue; 810 continue;
809 811
810 if (description.isEmpty()) 812 if (description.isEmpty())
811 description = a.formattedName(); 813 description = a.formattedName();
812 814
813 QString vcard; 815 QString vcard;
814 converter.addresseeToVCard( a, vcard ); 816 converter.addresseeToVCard( a, vcard );
815 int start = 0; 817 int start = 0;
816 int next; 818 int next;
817 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 819 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
818 int semi = vcard.find(";", next); 820 int semi = vcard.find(";", next);
819 int dopp = vcard.find(":", next); 821 int dopp = vcard.find(":", next);
820 int sep; 822 int sep;
821 if ( semi < dopp && semi >= 0 ) 823 if ( semi < dopp && semi >= 0 )
822 sep = semi ; 824 sep = semi ;
823 else 825 else
824 sep = dopp; 826 sep = dopp;
825 datastream +=vcard.mid( start, next - start); 827 datastream +=vcard.mid( start, next - start);
826 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 828 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
827 start = sep; 829 start = sep;
828 } 830 }
829 datastream += vcard.mid( start,vcard.length() ); 831 datastream += vcard.mid( start,vcard.length() );
830 } 832 }
831#ifndef DESKTOP_VERSION 833#ifndef DESKTOP_VERSION
832 QFile outFile(fileName); 834 QFile outFile(fileName);
833 if ( outFile.open(IO_WriteOnly) ) { 835 if ( outFile.open(IO_WriteOnly) ) {
834 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 836 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
835 QTextStream t( &outFile ); // use a text stream 837 QTextStream t( &outFile ); // use a text stream
836 //t.setEncoding( QTextStream::UnicodeUTF8 ); 838 //t.setEncoding( QTextStream::UnicodeUTF8 );
837 t.setEncoding( QTextStream::Latin1 ); 839 t.setEncoding( QTextStream::Latin1 );
838 t <<datastream.latin1(); 840 t <<datastream.latin1();
839 outFile.close(); 841 outFile.close();
840 Ir *ir = new Ir( this ); 842 Ir *ir = new Ir( this );
841 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 843 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
842 ir->send( fileName, description, "text/x-vCard" ); 844 ir->send( fileName, description, "text/x-vCard" );
843 } else { 845 } else {
844 qDebug("Error open temp beam file "); 846 qDebug("Error open temp beam file ");
845 return; 847 return;
846 } 848 }
847#endif 849#endif
848 850
849} 851}
850 852
851void KABCore::beamDone( Ir *ir ) 853void KABCore::beamDone( Ir *ir )
852{ 854{
853#ifndef DESKTOP_VERSION 855#ifndef DESKTOP_VERSION
854 delete ir; 856 delete ir;
855#endif 857#endif
856 topLevelWidget()->raise(); 858 topLevelWidget()->raise();
857 message( i18n("Beaming finished!") ); 859 message( i18n("Beaming finished!") );
858} 860}
859 861
860 862
861void KABCore::browse( const QString& url ) 863void KABCore::browse( const QString& url )
862{ 864{
863#ifndef KAB_EMBEDDED 865#ifndef KAB_EMBEDDED
864 kapp->invokeBrowser( url ); 866 kapp->invokeBrowser( url );
865#else //KAB_EMBEDDED 867#else //KAB_EMBEDDED
866 qDebug("KABCore::browse must be fixed"); 868 qDebug("KABCore::browse must be fixed");
867#endif //KAB_EMBEDDED 869#endif //KAB_EMBEDDED
868} 870}
869 871
870void KABCore::selectAllContacts() 872void KABCore::selectAllContacts()
871{ 873{
872 mViewManager->setSelected( QString::null, true ); 874 mViewManager->setSelected( QString::null, true );
873} 875}
874 876
875void KABCore::deleteContacts() 877void KABCore::deleteContacts()
876{ 878{
877 QStringList uidList = mViewManager->selectedUids(); 879 QStringList uidList = mViewManager->selectedUids();
878 deleteContacts( uidList ); 880 deleteContacts( uidList );
879} 881}
880 882
881void KABCore::deleteContacts( const QStringList &uids ) 883void KABCore::deleteContacts( const QStringList &uids )
882{ 884{
883 if ( uids.count() > 0 ) { 885 if ( uids.count() > 0 ) {
884 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 886 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
885 UndoStack::instance()->push( command ); 887 UndoStack::instance()->push( command );
886 RedoStack::instance()->clear(); 888 RedoStack::instance()->clear();
887 889
888 // now if we deleted anything, refresh 890 // now if we deleted anything, refresh
889 setContactSelected( QString::null ); 891 setContactSelected( QString::null );
890 setModified( true ); 892 setModified( true );
891 } 893 }
892} 894}
893 895
894void KABCore::copyContacts() 896void KABCore::copyContacts()
895{ 897{
896 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 898 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
897 899
898 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 900 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
899 901
900 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 902 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
901 903
902 QClipboard *cb = QApplication::clipboard(); 904 QClipboard *cb = QApplication::clipboard();
903 cb->setText( clipText ); 905 cb->setText( clipText );
904} 906}
905 907
906void KABCore::cutContacts() 908void KABCore::cutContacts()
907{ 909{
908 QStringList uidList = mViewManager->selectedUids(); 910 QStringList uidList = mViewManager->selectedUids();
909 911
910//US if ( uidList.size() > 0 ) { 912//US if ( uidList.size() > 0 ) {
911 if ( uidList.count() > 0 ) { 913 if ( uidList.count() > 0 ) {
912 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 914 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
913 UndoStack::instance()->push( command ); 915 UndoStack::instance()->push( command );
914 RedoStack::instance()->clear(); 916 RedoStack::instance()->clear();
915 917
916 setModified( true ); 918 setModified( true );
917 } 919 }
918} 920}
919 921
920void KABCore::pasteContacts() 922void KABCore::pasteContacts()
921{ 923{
922 QClipboard *cb = QApplication::clipboard(); 924 QClipboard *cb = QApplication::clipboard();
923 925
924 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 926 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
925 927
926 pasteContacts( list ); 928 pasteContacts( list );
927} 929}
928 930
929void KABCore::pasteContacts( KABC::Addressee::List &list ) 931void KABCore::pasteContacts( KABC::Addressee::List &list )
930{ 932{
931 KABC::Resource *resource = requestResource( this ); 933 KABC::Resource *resource = requestResource( this );
932 KABC::Addressee::List::Iterator it; 934 KABC::Addressee::List::Iterator it;
933 for ( it = list.begin(); it != list.end(); ++it ) 935 for ( it = list.begin(); it != list.end(); ++it )
934 (*it).setResource( resource ); 936 (*it).setResource( resource );
935 937
936 PwPasteCommand *command = new PwPasteCommand( this, list ); 938 PwPasteCommand *command = new PwPasteCommand( this, list );
937 UndoStack::instance()->push( command ); 939 UndoStack::instance()->push( command );
938 RedoStack::instance()->clear(); 940 RedoStack::instance()->clear();
939 941
940 setModified( true ); 942 setModified( true );
941} 943}
942 944
943void KABCore::setWhoAmI() 945void KABCore::setWhoAmI()
944{ 946{
945 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 947 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
946 948
947 if ( addrList.count() > 1 ) { 949 if ( addrList.count() > 1 ) {
948 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 950 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
949 return; 951 return;
950 } 952 }
951 953
952 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>" ) );
953 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 955 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
954 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 956 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
955} 957}
956 958
957void KABCore::setCategories() 959void KABCore::setCategories()
958{ 960{
959 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 961 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
960 if ( !dlg.exec() ) 962 if ( !dlg.exec() )
961 return; 963 return;
962 964
963 bool merge = false; 965 bool merge = false;
964 QString msg = i18n( "Merge with existing categories?" ); 966 QString msg = i18n( "Merge with existing categories?" );
965 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 967 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
966 merge = true; 968 merge = true;
967 969
968 QStringList categories = dlg.selectedCategories(); 970 QStringList categories = dlg.selectedCategories();
969 971
970 QStringList uids = mViewManager->selectedUids(); 972 QStringList uids = mViewManager->selectedUids();
971 QStringList::Iterator it; 973 QStringList::Iterator it;
972 for ( it = uids.begin(); it != uids.end(); ++it ) { 974 for ( it = uids.begin(); it != uids.end(); ++it ) {
973 KABC::Addressee addr = mAddressBook->findByUid( *it ); 975 KABC::Addressee addr = mAddressBook->findByUid( *it );
974 if ( !addr.isEmpty() ) { 976 if ( !addr.isEmpty() ) {
975 if ( !merge ) 977 if ( !merge )
976 addr.setCategories( categories ); 978 addr.setCategories( categories );
977 else { 979 else {
978 QStringList addrCategories = addr.categories(); 980 QStringList addrCategories = addr.categories();
979 QStringList::Iterator catIt; 981 QStringList::Iterator catIt;
980 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
981 if ( !addrCategories.contains( *catIt ) ) 983 if ( !addrCategories.contains( *catIt ) )
982 addrCategories.append( *catIt ); 984 addrCategories.append( *catIt );
983 } 985 }
984 addr.setCategories( addrCategories ); 986 addr.setCategories( addrCategories );
985 } 987 }
986 988
987 mAddressBook->insertAddressee( addr ); 989 mAddressBook->insertAddressee( addr );
988 } 990 }
989 } 991 }
990 992
991 if ( uids.count() > 0 ) 993 if ( uids.count() > 0 )
992 setModified( true ); 994 setModified( true );
993} 995}
994 996
995void KABCore::setSearchFields( const KABC::Field::List &fields ) 997void KABCore::setSearchFields( const KABC::Field::List &fields )
996{ 998{
997 mIncSearchWidget->setFields( fields ); 999 mIncSearchWidget->setFields( fields );
998} 1000}
999 1001
1000void KABCore::incrementalSearch( const QString& text ) 1002void KABCore::incrementalSearch( const QString& text )
1001{ 1003{
1002 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1003} 1005}
1004 1006
1005void KABCore::setModified() 1007void KABCore::setModified()
1006{ 1008{
1007 setModified( true ); 1009 setModified( true );
1008} 1010}
1009 1011
1010void KABCore::setModifiedWOrefresh() 1012void KABCore::setModifiedWOrefresh()
1011{ 1013{
1012 // qDebug("KABCore::setModifiedWOrefresh() "); 1014 // qDebug("KABCore::setModifiedWOrefresh() ");
1013 mModified = true; 1015 mModified = true;
1014 mActionSave->setEnabled( mModified ); 1016 mActionSave->setEnabled( mModified );
1015#ifdef DESKTOP_VERSION 1017#ifdef DESKTOP_VERSION
1016 mDetails->refreshView(); 1018 mDetails->refreshView();
1017#endif 1019#endif
1018 1020
1019} 1021}
1020void KABCore::setModified( bool modified ) 1022void KABCore::setModified( bool modified )
1021{ 1023{
1022 mModified = modified; 1024 mModified = modified;
1023 mActionSave->setEnabled( mModified ); 1025 mActionSave->setEnabled( mModified );
1024 1026
1025 if ( modified ) 1027 if ( modified )
1026 mJumpButtonBar->recreateButtons(); 1028 mJumpButtonBar->recreateButtons();
1027 1029
1028 mViewManager->refreshView(); 1030 mViewManager->refreshView();
1029 mDetails->refreshView(); 1031 mDetails->refreshView();
1030 1032
1031} 1033}
1032 1034
1033bool KABCore::modified() const 1035bool KABCore::modified() const
1034{ 1036{
1035 return mModified; 1037 return mModified;
1036} 1038}
1037 1039
1038void KABCore::contactModified( const KABC::Addressee &addr ) 1040void KABCore::contactModified( const KABC::Addressee &addr )
1039{ 1041{
1040 1042
1041 Command *command = 0; 1043 Command *command = 0;
1042 QString uid; 1044 QString uid;
1043 1045
1044 // check if it exists already 1046 // check if it exists already
1045 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1046 if ( origAddr.isEmpty() ) 1048 if ( origAddr.isEmpty() )
1047 command = new PwNewCommand( mAddressBook, addr ); 1049 command = new PwNewCommand( mAddressBook, addr );
1048 else { 1050 else {
1049 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1051 command = new PwEditCommand( mAddressBook, origAddr, addr );
1050 uid = addr.uid(); 1052 uid = addr.uid();
1051 } 1053 }
1052 1054
1053 UndoStack::instance()->push( command ); 1055 UndoStack::instance()->push( command );
1054 RedoStack::instance()->clear(); 1056 RedoStack::instance()->clear();
1055 1057
1056 setModified( true ); 1058 setModified( true );
1057} 1059}
1058 1060
1059void KABCore::newContact() 1061void KABCore::newContact()
1060{ 1062{
1061 1063
1062 1064
1063 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1064 1066
1065 QPtrList<KRES::Resource> kresResources; 1067 QPtrList<KRES::Resource> kresResources;
1066 QPtrListIterator<KABC::Resource> it( kabcResources ); 1068 QPtrListIterator<KABC::Resource> it( kabcResources );
1067 KABC::Resource *resource; 1069 KABC::Resource *resource;
1068 while ( ( resource = it.current() ) != 0 ) { 1070 while ( ( resource = it.current() ) != 0 ) {
1069 ++it; 1071 ++it;
1070 if ( !resource->readOnly() ) { 1072 if ( !resource->readOnly() ) {
1071 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1072 if ( res ) 1074 if ( res )
1073 kresResources.append( res ); 1075 kresResources.append( res );
1074 } 1076 }
1075 } 1077 }
1076 1078
1077 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1078 resource = static_cast<KABC::Resource*>( res ); 1080 resource = static_cast<KABC::Resource*>( res );
1079 1081
1080 if ( resource ) { 1082 if ( resource ) {
1081 KABC::Addressee addr; 1083 KABC::Addressee addr;
1082 addr.setResource( resource ); 1084 addr.setResource( resource );
1083 mEditorDialog->setAddressee( addr ); 1085 mEditorDialog->setAddressee( addr );
1084 KApplication::execDialog ( mEditorDialog ); 1086 KApplication::execDialog ( mEditorDialog );
1085 1087
1086 } else 1088 } else
1087 return; 1089 return;
1088 1090
1089 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1091 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1090 1092
1091 1093
1092} 1094}
1093 1095
1094void KABCore::addEmail( QString aStr ) 1096void KABCore::addEmail( QString aStr )
1095{ 1097{
1096#ifndef KAB_EMBEDDED 1098#ifndef KAB_EMBEDDED
1097 QString fullName, email; 1099 QString fullName, email;
1098 1100
1099 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1100 1102
1101 // Try to lookup the addressee matching the email address 1103 // Try to lookup the addressee matching the email address
1102 bool found = false; 1104 bool found = false;
1103 QStringList emailList; 1105 QStringList emailList;
1104 KABC::AddressBook::Iterator it; 1106 KABC::AddressBook::Iterator it;
1105 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1106 emailList = (*it).emails(); 1108 emailList = (*it).emails();
1107 if ( emailList.contains( email ) > 0 ) { 1109 if ( emailList.contains( email ) > 0 ) {
1108 found = true; 1110 found = true;
1109 (*it).setNameFromString( fullName ); 1111 (*it).setNameFromString( fullName );
1110 editContact( (*it).uid() ); 1112 editContact( (*it).uid() );
1111 } 1113 }
1112 } 1114 }
1113 1115
1114 if ( !found ) { 1116 if ( !found ) {
1115 KABC::Addressee addr; 1117 KABC::Addressee addr;
1116 addr.setNameFromString( fullName ); 1118 addr.setNameFromString( fullName );
1117 addr.insertEmail( email, true ); 1119 addr.insertEmail( email, true );
1118 1120
1119 mAddressBook->insertAddressee( addr ); 1121 mAddressBook->insertAddressee( addr );
1120 mViewManager->refreshView( addr.uid() ); 1122 mViewManager->refreshView( addr.uid() );
1121 editContact( addr.uid() ); 1123 editContact( addr.uid() );
1122 } 1124 }
1123#else //KAB_EMBEDDED 1125#else //KAB_EMBEDDED
1124 qDebug("KABCore::addEmail finsih method"); 1126 qDebug("KABCore::addEmail finsih method");
1125#endif //KAB_EMBEDDED 1127#endif //KAB_EMBEDDED
1126} 1128}
1127 1129
1128void KABCore::importVCard( const KURL &url, bool showPreview ) 1130void KABCore::importVCard( const KURL &url, bool showPreview )
1129{ 1131{
1130 mXXPortManager->importVCard( url, showPreview ); 1132 mXXPortManager->importVCard( url, showPreview );
1131} 1133}
1132void KABCore::importFromOL() 1134void KABCore::importFromOL()
1133{ 1135{
1134#ifdef _WIN32_ 1136#ifdef _WIN32_
1135 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1136 idgl->exec(); 1138 idgl->exec();
1137 KABC::Addressee::List list = idgl->getAddressList(); 1139 KABC::Addressee::List list = idgl->getAddressList();
1138 if ( list.count() > 0 ) { 1140 if ( list.count() > 0 ) {
1139 KABC::Addressee::List listNew; 1141 KABC::Addressee::List listNew;
1140 KABC::Addressee::List listExisting; 1142 KABC::Addressee::List listExisting;
1141 KABC::Addressee::List::Iterator it; 1143 KABC::Addressee::List::Iterator it;
1142 KABC::AddressBook::Iterator iter; 1144 KABC::AddressBook::Iterator iter;
1143 for ( it = list.begin(); it != list.end(); ++it ) { 1145 for ( it = list.begin(); it != list.end(); ++it ) {
1144 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1145 listNew.append( (*it) ); 1147 listNew.append( (*it) );
1146 else 1148 else
1147 listExisting.append( (*it) ); 1149 listExisting.append( (*it) );
1148 } 1150 }
1149 if ( listExisting.count() > 0 ) 1151 if ( listExisting.count() > 0 )
1150 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() ));
1151 if ( listNew.count() > 0 ) { 1153 if ( listNew.count() > 0 ) {
1152 pasteWithNewUid = false; 1154 pasteWithNewUid = false;
1153 pasteContacts( listNew ); 1155 pasteContacts( listNew );
1154 pasteWithNewUid = true; 1156 pasteWithNewUid = true;
1155 } 1157 }
1156 } 1158 }
1157 delete idgl; 1159 delete idgl;
1158#endif 1160#endif
1159} 1161}
1160 1162
1161void KABCore::importVCard( const QString &vCard, bool showPreview ) 1163void KABCore::importVCard( const QString &vCard, bool showPreview )
1162{ 1164{
1163 mXXPortManager->importVCard( vCard, showPreview ); 1165 mXXPortManager->importVCard( vCard, showPreview );
1164} 1166}
1165 1167
1166//US added a second method without defaultparameter 1168//US added a second method without defaultparameter
1167void KABCore::editContact2() { 1169void KABCore::editContact2() {
1168 editContact( QString::null ); 1170 editContact( QString::null );
1169} 1171}
1170 1172
1171void KABCore::editContact( const QString &uid ) 1173void KABCore::editContact( const QString &uid )
1172{ 1174{
1173 1175
1174 if ( mExtensionManager->isQuickEditVisible() ) 1176 if ( mExtensionManager->isQuickEditVisible() )
1175 return; 1177 return;
1176 1178
1177 // First, locate the contact entry 1179 // First, locate the contact entry
1178 QString localUID = uid; 1180 QString localUID = uid;
1179 if ( localUID.isNull() ) { 1181 if ( localUID.isNull() ) {
1180 QStringList uidList = mViewManager->selectedUids(); 1182 QStringList uidList = mViewManager->selectedUids();
1181 if ( uidList.count() > 0 ) 1183 if ( uidList.count() > 0 )
1182 localUID = *( uidList.at( 0 ) ); 1184 localUID = *( uidList.at( 0 ) );
1183 } 1185 }
1184 1186
1185 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1187 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1186 if ( !addr.isEmpty() ) { 1188 if ( !addr.isEmpty() ) {
1187 mEditorDialog->setAddressee( addr ); 1189 mEditorDialog->setAddressee( addr );
1188 KApplication::execDialog ( mEditorDialog ); 1190 KApplication::execDialog ( mEditorDialog );
1189 } 1191 }
1190} 1192}
1191 1193
1192/** 1194/**
1193 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,
1194 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.
1195 */ 1197 */
1196void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1197{ 1199{
1198 if ( mMultipleViewsAtOnce ) 1200 if ( mMultipleViewsAtOnce )
1199 { 1201 {
1200 editContact( uid ); 1202 editContact( uid );
1201 } 1203 }
1202 else 1204 else
1203 { 1205 {
1204 setDetailsVisible( true ); 1206 setDetailsVisible( true );
1205 mActionDetails->setChecked(true); 1207 mActionDetails->setChecked(true);
1206 } 1208 }
1207 1209
1208} 1210}
1209 1211
1210void KABCore::save() 1212void KABCore::save()
1211{ 1213{
1212 if (syncManager->blockSave()) 1214 if (syncManager->blockSave())
1213 return; 1215 return;
1214 if ( !mModified ) 1216 if ( !mModified )
1215 return; 1217 return;
1216 1218
1217 syncManager->setBlockSave(true); 1219 syncManager->setBlockSave(true);
1218 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 "
1219 "address book. Please check that some \nother application is " 1221 "address book. Please check that some \nother application is "
1220 "not using it. " ); 1222 "not using it. " );
1221 message(i18n("Saving addressbook ... ")); 1223 message(i18n("Saving addressbook ... "));
1222#ifndef KAB_EMBEDDED 1224#ifndef KAB_EMBEDDED
1223 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1224 if ( !b || !b->save() ) { 1226 if ( !b || !b->save() ) {
1225 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1226 } 1228 }
1227#else //KAB_EMBEDDED 1229#else //KAB_EMBEDDED
1228 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1229 if ( !b || !b->save() ) { 1231 if ( !b || !b->save() ) {
1230 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1231 } 1233 }
1232#endif //KAB_EMBEDDED 1234#endif //KAB_EMBEDDED
1233 1235
1234 message(i18n("Addressbook saved!")); 1236 message(i18n("Addressbook saved!"));
1235 setModified( false ); 1237 setModified( false );
1236 syncManager->setBlockSave(false); 1238 syncManager->setBlockSave(false);
1237} 1239}
1238 1240
1239 1241
1240void KABCore::undo() 1242void KABCore::undo()
1241{ 1243{
1242 UndoStack::instance()->undo(); 1244 UndoStack::instance()->undo();
1243 1245
1244 // Refresh the view 1246 // Refresh the view
1245 mViewManager->refreshView(); 1247 mViewManager->refreshView();
1246} 1248}
1247 1249
1248void KABCore::redo() 1250void KABCore::redo()
1249{ 1251{
1250 RedoStack::instance()->redo(); 1252 RedoStack::instance()->redo();
1251 1253
1252 // Refresh the view 1254 // Refresh the view
1253 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1254} 1256}
1255 1257
1256void KABCore::setJumpButtonBarVisible( bool visible ) 1258void KABCore::setJumpButtonBarVisible( bool visible )
1257{ 1259{
1258 if (mMultipleViewsAtOnce) 1260 if (mMultipleViewsAtOnce)
1259 { 1261 {
1260 if ( visible ) 1262 if ( visible )
1261 mJumpButtonBar->show(); 1263 mJumpButtonBar->show();
1262 else 1264 else
1263 mJumpButtonBar->hide(); 1265 mJumpButtonBar->hide();
1264 } 1266 }
1265 else 1267 else
1266 { 1268 {
1267 // 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"
1268 if (mViewManager->isVisible()) 1270 if (mViewManager->isVisible())
1269 { 1271 {
1270 if ( visible ) 1272 if ( visible )
1271 mJumpButtonBar->show(); 1273 mJumpButtonBar->show();
1272 else 1274 else
1273 mJumpButtonBar->hide(); 1275 mJumpButtonBar->hide();
1274 } 1276 }
1275 else 1277 else
1276 { 1278 {
1277 mJumpButtonBar->hide(); 1279 mJumpButtonBar->hide();
1278 } 1280 }
1279 } 1281 }
1280} 1282}
1281 1283
1282 1284
1283void KABCore::setDetailsToState() 1285void KABCore::setDetailsToState()
1284{ 1286{
1285 setDetailsVisible( mActionDetails->isChecked() ); 1287 setDetailsVisible( mActionDetails->isChecked() );
1286} 1288}
1287 1289
1288 1290
1289 1291
1290void KABCore::setDetailsVisible( bool visible ) 1292void KABCore::setDetailsVisible( bool visible )
1291{ 1293{
1292 if (visible && mDetails->isHidden()) 1294 if (visible && mDetails->isHidden())
1293 { 1295 {
1294 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1295 if ( addrList.count() > 0 ) 1297 if ( addrList.count() > 0 )
1296 mDetails->setAddressee( addrList[ 0 ] ); 1298 mDetails->setAddressee( addrList[ 0 ] );
1297 } 1299 }
1298 1300
1299 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1300 // 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.
1301 if (mMultipleViewsAtOnce) 1303 if (mMultipleViewsAtOnce)
1302 { 1304 {
1303 if ( visible ) 1305 if ( visible )
1304 mDetails->show(); 1306 mDetails->show();
1305 else 1307 else
1306 mDetails->hide(); 1308 mDetails->hide();
1307 } 1309 }
1308 else 1310 else
1309 { 1311 {
1310 if ( visible ) { 1312 if ( visible ) {
1311 mViewManager->hide(); 1313 mViewManager->hide();
1312 mDetails->show(); 1314 mDetails->show();
1313 } 1315 }
1314 else { 1316 else {
1315 mViewManager->show(); 1317 mViewManager->show();
1316 mDetails->hide(); 1318 mDetails->hide();
1317 } 1319 }
1318 setJumpButtonBarVisible( !visible ); 1320 setJumpButtonBarVisible( !visible );
1319 } 1321 }
1320 1322
1321} 1323}
1322 1324
1323void KABCore::extensionChanged( int id ) 1325void KABCore::extensionChanged( int id )
1324{ 1326{
1325 //change the details view only for non desktop systems 1327 //change the details view only for non desktop systems
1326#ifndef DESKTOP_VERSION 1328#ifndef DESKTOP_VERSION
1327 1329
1328 if (id == 0) 1330 if (id == 0)
1329 { 1331 {
1330 //the user disabled the extension. 1332 //the user disabled the extension.
1331 1333
1332 if (mMultipleViewsAtOnce) 1334 if (mMultipleViewsAtOnce)
1333 { // enable detailsview again 1335 { // enable detailsview again
1334 setDetailsVisible( true ); 1336 setDetailsVisible( true );
1335 mActionDetails->setChecked( true ); 1337 mActionDetails->setChecked( true );
1336 } 1338 }
1337 else 1339 else
1338 { //go back to the listview 1340 { //go back to the listview
1339 setDetailsVisible( false ); 1341 setDetailsVisible( false );
1340 mActionDetails->setChecked( false ); 1342 mActionDetails->setChecked( false );
1341 mActionDetails->setEnabled(true); 1343 mActionDetails->setEnabled(true);
1342 } 1344 }
1343 1345
1344 } 1346 }
1345 else 1347 else
1346 { 1348 {
1347 //the user enabled the extension. 1349 //the user enabled the extension.
1348 setDetailsVisible( false ); 1350 setDetailsVisible( false );
1349 mActionDetails->setChecked( false ); 1351 mActionDetails->setChecked( false );
1350 1352
1351 if (!mMultipleViewsAtOnce) 1353 if (!mMultipleViewsAtOnce)
1352 { 1354 {
1353 mActionDetails->setEnabled(false); 1355 mActionDetails->setEnabled(false);
1354 } 1356 }
1355 1357
1356 mExtensionManager->setSelectionChanged(); 1358 mExtensionManager->setSelectionChanged();
1357 1359
1358 } 1360 }
1359 1361
1360#endif// DESKTOP_VERSION 1362#endif// DESKTOP_VERSION
1361 1363
1362} 1364}
1363 1365
1364 1366
1365void KABCore::extensionModified( const KABC::Addressee::List &list ) 1367void KABCore::extensionModified( const KABC::Addressee::List &list )
1366{ 1368{
1367 1369
1368 if ( list.count() != 0 ) { 1370 if ( list.count() != 0 ) {
1369 KABC::Addressee::List::ConstIterator it; 1371 KABC::Addressee::List::ConstIterator it;
1370 for ( it = list.begin(); it != list.end(); ++it ) 1372 for ( it = list.begin(); it != list.end(); ++it )
1371 mAddressBook->insertAddressee( *it ); 1373 mAddressBook->insertAddressee( *it );
1372 if ( list.count() > 1 ) 1374 if ( list.count() > 1 )
1373 setModified(); 1375 setModified();
1374 else 1376 else
1375 setModifiedWOrefresh(); 1377 setModifiedWOrefresh();
1376 } 1378 }
1377 if ( list.count() == 0 ) 1379 if ( list.count() == 0 )
1378 mViewManager->refreshView(); 1380 mViewManager->refreshView();
1379 else 1381 else
1380 mViewManager->refreshView( list[ 0 ].uid() ); 1382 mViewManager->refreshView( list[ 0 ].uid() );
1381 1383
1382 1384
1383 1385
1384} 1386}
1385 1387
1386QString KABCore::getNameByPhone( const QString &phone ) 1388QString KABCore::getNameByPhone( const QString &phone )
1387{ 1389{
1388#ifndef KAB_EMBEDDED 1390#ifndef KAB_EMBEDDED
1389 QRegExp r( "[/*/-/ ]" ); 1391 QRegExp r( "[/*/-/ ]" );
1390 QString localPhone( phone ); 1392 QString localPhone( phone );
1391 1393
1392 bool found = false; 1394 bool found = false;
1393 QString ownerName = ""; 1395 QString ownerName = "";
1394 KABC::AddressBook::Iterator iter; 1396 KABC::AddressBook::Iterator iter;
1395 KABC::PhoneNumber::List::Iterator phoneIter; 1397 KABC::PhoneNumber::List::Iterator phoneIter;
1396 KABC::PhoneNumber::List phoneList; 1398 KABC::PhoneNumber::List phoneList;
1397 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1399 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1398 phoneList = (*iter).phoneNumbers(); 1400 phoneList = (*iter).phoneNumbers();
1399 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1401 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1400 ++phoneIter) { 1402 ++phoneIter) {
1401 // Get rid of separator chars so just the numbers are compared. 1403 // Get rid of separator chars so just the numbers are compared.
1402 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1404 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1403 ownerName = (*iter).formattedName(); 1405 ownerName = (*iter).formattedName();
1404 found = true; 1406 found = true;
1405 } 1407 }
1406 } 1408 }
1407 } 1409 }
1408 1410
1409 return ownerName; 1411 return ownerName;
1410#else //KAB_EMBEDDED 1412#else //KAB_EMBEDDED
1411 qDebug("KABCore::getNameByPhone finsih method"); 1413 qDebug("KABCore::getNameByPhone finsih method");
1412 return ""; 1414 return "";
1413#endif //KAB_EMBEDDED 1415#endif //KAB_EMBEDDED
1414 1416
1415} 1417}
1416 1418
1417void KABCore::openConfigDialog() 1419void KABCore::openConfigDialog()
1418{ 1420{
1419 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1421 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1420 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1422 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1421 ConfigureDialog->addModule(kabcfg ); 1423 ConfigureDialog->addModule(kabcfg );
1422 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1424 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1423 ConfigureDialog->addModule(kdelibcfg ); 1425 ConfigureDialog->addModule(kdelibcfg );
1424 1426
1425 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1427 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1426 this, SLOT( configurationChanged() ) ); 1428 this, SLOT( configurationChanged() ) );
1427 connect( ConfigureDialog, SIGNAL( okClicked() ), 1429 connect( ConfigureDialog, SIGNAL( okClicked() ),
1428 this, SLOT( configurationChanged() ) ); 1430 this, SLOT( configurationChanged() ) );
1429 saveSettings(); 1431 saveSettings();
1430#ifndef DESKTOP_VERSION 1432#ifndef DESKTOP_VERSION
1431 ConfigureDialog->showMaximized(); 1433 ConfigureDialog->showMaximized();
1432#endif 1434#endif
1433 if ( ConfigureDialog->exec() ) 1435 if ( ConfigureDialog->exec() )
1434 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1436 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1435 delete ConfigureDialog; 1437 delete ConfigureDialog;
1436} 1438}
1437 1439
1438void KABCore::openLDAPDialog() 1440void KABCore::openLDAPDialog()
1439{ 1441{
1440#ifndef KAB_EMBEDDED 1442#ifndef KAB_EMBEDDED
1441 if ( !mLdapSearchDialog ) { 1443 if ( !mLdapSearchDialog ) {
1442 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1444 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1443 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1445 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1444 SLOT( refreshView() ) ); 1446 SLOT( refreshView() ) );
1445 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1446 SLOT( setModified() ) ); 1448 SLOT( setModified() ) );
1447 } else 1449 } else
1448 mLdapSearchDialog->restoreSettings(); 1450 mLdapSearchDialog->restoreSettings();
1449 1451
1450 if ( mLdapSearchDialog->isOK() ) 1452 if ( mLdapSearchDialog->isOK() )
1451 mLdapSearchDialog->exec(); 1453 mLdapSearchDialog->exec();
1452#else //KAB_EMBEDDED 1454#else //KAB_EMBEDDED
1453 qDebug("KABCore::openLDAPDialog() finsih method"); 1455 qDebug("KABCore::openLDAPDialog() finsih method");
1454#endif //KAB_EMBEDDED 1456#endif //KAB_EMBEDDED
1455} 1457}
1456 1458
1457void KABCore::print() 1459void KABCore::print()
1458{ 1460{
1459#ifndef KAB_EMBEDDED 1461#ifndef KAB_EMBEDDED
1460 KPrinter printer; 1462 KPrinter printer;
1461 if ( !printer.setup( this ) ) 1463 if ( !printer.setup( this ) )
1462 return; 1464 return;
1463 1465
1464 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1466 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1465 mViewManager->selectedUids(), this ); 1467 mViewManager->selectedUids(), this );
1466 1468
1467 wizard.exec(); 1469 wizard.exec();
1468#else //KAB_EMBEDDED 1470#else //KAB_EMBEDDED
1469 qDebug("KABCore::print() finsih method"); 1471 qDebug("KABCore::print() finsih method");
1470#endif //KAB_EMBEDDED 1472#endif //KAB_EMBEDDED
1471 1473
1472} 1474}
1473 1475
1474 1476
1475void KABCore::addGUIClient( KXMLGUIClient *client ) 1477void KABCore::addGUIClient( KXMLGUIClient *client )
1476{ 1478{
1477 if ( mGUIClient ) 1479 if ( mGUIClient )
1478 mGUIClient->insertChildClient( client ); 1480 mGUIClient->insertChildClient( client );
1479 else 1481 else
1480 KMessageBox::error( this, "no KXMLGUICLient"); 1482 KMessageBox::error( this, "no KXMLGUICLient");
1481} 1483}
1482 1484
1483 1485
1484void KABCore::configurationChanged() 1486void KABCore::configurationChanged()
1485{ 1487{
1486 mExtensionManager->reconfigure(); 1488 mExtensionManager->reconfigure();
1487} 1489}
1488 1490
1489void KABCore::addressBookChanged() 1491void KABCore::addressBookChanged()
1490{ 1492{
1491/*US 1493/*US
1492 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1494 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1493 while ( it.current() ) { 1495 while ( it.current() ) {
1494 if ( it.current()->dirty() ) { 1496 if ( it.current()->dirty() ) {
1495 QString text = i18n( "Data has been changed externally. Unsaved " 1497 QString text = i18n( "Data has been changed externally. Unsaved "
1496 "changes will be lost." ); 1498 "changes will be lost." );
1497 KMessageBox::information( this, text ); 1499 KMessageBox::information( this, text );
1498 } 1500 }
1499 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1501 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1500 ++it; 1502 ++it;
1501 } 1503 }
1502*/ 1504*/
1503 if (mEditorDialog) 1505 if (mEditorDialog)
1504 { 1506 {
1505 if (mEditorDialog->dirty()) 1507 if (mEditorDialog->dirty())
1506 { 1508 {
1507 QString text = i18n( "Data has been changed externally. Unsaved " 1509 QString text = i18n( "Data has been changed externally. Unsaved "
1508 "changes will be lost." ); 1510 "changes will be lost." );
1509 KMessageBox::information( this, text ); 1511 KMessageBox::information( this, text );
1510 } 1512 }
1511 QString currentuid = mEditorDialog->addressee().uid(); 1513 QString currentuid = mEditorDialog->addressee().uid();
1512 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1514 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1513 } 1515 }
1514 mViewManager->refreshView(); 1516 mViewManager->refreshView();
1515// mDetails->refreshView(); 1517// mDetails->refreshView();
1516 1518
1517 1519
1518} 1520}
1519 1521
1520AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1522AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1521 const char *name ) 1523 const char *name )
1522{ 1524{
1523 1525
1524 if ( mEditorDialog == 0 ) { 1526 if ( mEditorDialog == 0 ) {
1525 mEditorDialog = new AddresseeEditorDialog( this, parent, 1527 mEditorDialog = new AddresseeEditorDialog( this, parent,
1526 name ? name : "editorDialog" ); 1528 name ? name : "editorDialog" );
1527 1529
1528 1530
1529 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1531 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1530 SLOT( contactModified( const KABC::Addressee& ) ) ); 1532 SLOT( contactModified( const KABC::Addressee& ) ) );
1531 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1533 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1532 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1534 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1533 } 1535 }
1534 1536
1535 return mEditorDialog; 1537 return mEditorDialog;
1536} 1538}
1537 1539
1538void KABCore::slotEditorDestroyed( const QString &uid ) 1540void KABCore::slotEditorDestroyed( const QString &uid )
1539{ 1541{
1540 //mEditorDict.remove( uid ); 1542 //mEditorDict.remove( uid );
1541} 1543}
1542 1544
1543void KABCore::initGUI() 1545void KABCore::initGUI()
1544{ 1546{
1545#ifndef KAB_EMBEDDED 1547#ifndef KAB_EMBEDDED
1546 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1548 QHBoxLayout *topLayout = new QHBoxLayout( this );
1547 topLayout->setSpacing( KDialogBase::spacingHint() ); 1549 topLayout->setSpacing( KDialogBase::spacingHint() );
1548 1550
1549 mExtensionBarSplitter = new QSplitter( this ); 1551 mExtensionBarSplitter = new QSplitter( this );
1550 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1552 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1551 1553
1552 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1554 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1553 1555
1554 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1556 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1555 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1557 mIncSearchWidget = new IncSearchWidget( viewSpace );
1556 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1558 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1557 SLOT( incrementalSearch( const QString& ) ) ); 1559 SLOT( incrementalSearch( const QString& ) ) );
1558 1560
1559 mViewManager = new ViewManager( this, viewSpace ); 1561 mViewManager = new ViewManager( this, viewSpace );
1560 viewSpace->setStretchFactor( mViewManager, 1 ); 1562 viewSpace->setStretchFactor( mViewManager, 1 );
1561 1563
1562 mDetails = new ViewContainer( mDetailsSplitter ); 1564 mDetails = new ViewContainer( mDetailsSplitter );
1563 1565
1564 mJumpButtonBar = new JumpButtonBar( this, this ); 1566 mJumpButtonBar = new JumpButtonBar( this, this );
1565 1567
1566 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1568 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1567 1569
1568 topLayout->addWidget( mExtensionBarSplitter ); 1570 topLayout->addWidget( mExtensionBarSplitter );
1569 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1571 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1570 topLayout->addWidget( mJumpButtonBar ); 1572 topLayout->addWidget( mJumpButtonBar );
1571 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1573 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1572 1574
1573 mXXPortManager = new XXPortManager( this, this ); 1575 mXXPortManager = new XXPortManager( this, this );
1574 1576
1575#else //KAB_EMBEDDED 1577#else //KAB_EMBEDDED
1576 //US initialize viewMenu before settingup viewmanager. 1578 //US initialize viewMenu before settingup viewmanager.
1577 // Viewmanager needs this menu to plugin submenues. 1579 // Viewmanager needs this menu to plugin submenues.
1578 viewMenu = new QPopupMenu( this ); 1580 viewMenu = new QPopupMenu( this );
1579 settingsMenu = new QPopupMenu( this ); 1581 settingsMenu = new QPopupMenu( this );
1580 //filterMenu = new QPopupMenu( this ); 1582 //filterMenu = new QPopupMenu( this );
1581 ImportMenu = new QPopupMenu( this ); 1583 ImportMenu = new QPopupMenu( this );
1582 ExportMenu = new QPopupMenu( this ); 1584 ExportMenu = new QPopupMenu( this );
1583 syncMenu = new QPopupMenu( this ); 1585 syncMenu = new QPopupMenu( this );
1584 changeMenu= new QPopupMenu( this ); 1586 changeMenu= new QPopupMenu( this );
1585 1587
1586//US since we have no splitter for the embedded system, setup 1588//US since we have no splitter for the embedded system, setup
1587// a layout with two frames. One left and one right. 1589// a layout with two frames. One left and one right.
1588 1590
1589 QBoxLayout *topLayout; 1591 QBoxLayout *topLayout;
1590 1592
1591 // = new QHBoxLayout( this ); 1593 // = new QHBoxLayout( this );
1592// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1594// QBoxLayout *topLayout = (QBoxLayout*)layout();
1593 1595
1594// QWidget *mainBox = new QWidget( this ); 1596// QWidget *mainBox = new QWidget( this );
1595// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1597// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1596 1598
1597#ifdef DESKTOP_VERSION 1599#ifdef DESKTOP_VERSION
1598 topLayout = new QHBoxLayout( this ); 1600 topLayout = new QHBoxLayout( this );
1599 1601
1600 1602
1601 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1603 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1602 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1604 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1603 1605
1604 topLayout->addWidget(mMiniSplitter ); 1606 topLayout->addWidget(mMiniSplitter );
1605 1607
1606 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1608 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1607 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1609 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1608 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1610 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1609 mDetails = new ViewContainer( mMiniSplitter ); 1611 mDetails = new ViewContainer( mMiniSplitter );
1610 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1612 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1611#else 1613#else
1612 if ( QApplication::desktop()->width() > 480 ) { 1614 if ( QApplication::desktop()->width() > 480 ) {
1613 topLayout = new QHBoxLayout( this ); 1615 topLayout = new QHBoxLayout( this );
1614 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1616 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1615 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1617 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1616 } else { 1618 } else {
1617 1619
1618 topLayout = new QHBoxLayout( this ); 1620 topLayout = new QHBoxLayout( this );
1619 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1621 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1620 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1622 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1621 } 1623 }
1622 1624
1623 topLayout->addWidget(mMiniSplitter ); 1625 topLayout->addWidget(mMiniSplitter );
1624 mViewManager = new ViewManager( this, mMiniSplitter ); 1626 mViewManager = new ViewManager( this, mMiniSplitter );
1625 mDetails = new ViewContainer( mMiniSplitter ); 1627 mDetails = new ViewContainer( mMiniSplitter );
1626 1628
1627 1629
1628 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1630 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1629#endif 1631#endif
1630 //eh->hide(); 1632 //eh->hide();
1631 // topLayout->addWidget(mExtensionManager ); 1633 // topLayout->addWidget(mExtensionManager );
1632 1634
1633 1635
1634/*US 1636/*US
1635#ifndef KAB_NOSPLITTER 1637#ifndef KAB_NOSPLITTER
1636 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1638 QHBoxLayout *topLayout = new QHBoxLayout( this );
1637//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1639//US topLayout->setSpacing( KDialogBase::spacingHint() );
1638 topLayout->setSpacing( 10 ); 1640 topLayout->setSpacing( 10 );
1639 1641
1640 mDetailsSplitter = new QSplitter( this ); 1642 mDetailsSplitter = new QSplitter( this );
1641 1643
1642 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1644 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1643 1645
1644 mViewManager = new ViewManager( this, viewSpace ); 1646 mViewManager = new ViewManager( this, viewSpace );
1645 viewSpace->setStretchFactor( mViewManager, 1 ); 1647 viewSpace->setStretchFactor( mViewManager, 1 );
1646 1648
1647 mDetails = new ViewContainer( mDetailsSplitter ); 1649 mDetails = new ViewContainer( mDetailsSplitter );
1648 1650
1649 topLayout->addWidget( mDetailsSplitter ); 1651 topLayout->addWidget( mDetailsSplitter );
1650 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1652 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1651#else //KAB_NOSPLITTER 1653#else //KAB_NOSPLITTER
1652 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1654 QHBoxLayout *topLayout = new QHBoxLayout( this );
1653//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1655//US topLayout->setSpacing( KDialogBase::spacingHint() );
1654 topLayout->setSpacing( 10 ); 1656 topLayout->setSpacing( 10 );
1655 1657
1656// mDetailsSplitter = new QSplitter( this ); 1658// mDetailsSplitter = new QSplitter( this );
1657 1659
1658 QVBox *viewSpace = new QVBox( this ); 1660 QVBox *viewSpace = new QVBox( this );
1659 1661
1660 mViewManager = new ViewManager( this, viewSpace ); 1662 mViewManager = new ViewManager( this, viewSpace );
1661 viewSpace->setStretchFactor( mViewManager, 1 ); 1663 viewSpace->setStretchFactor( mViewManager, 1 );
1662 1664
1663 mDetails = new ViewContainer( this ); 1665 mDetails = new ViewContainer( this );
1664 1666
1665 topLayout->addWidget( viewSpace ); 1667 topLayout->addWidget( viewSpace );
1666// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1668// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1667 topLayout->addWidget( mDetails ); 1669 topLayout->addWidget( mDetails );
1668#endif //KAB_NOSPLITTER 1670#endif //KAB_NOSPLITTER
1669*/ 1671*/
1670 1672
1671 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1673 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1672 syncManager->setBlockSave(false); 1674 syncManager->setBlockSave(false);
1673 1675
1674 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1676 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1675 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1677 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1676 syncManager->setDefaultFileName( sentSyncFile()); 1678 syncManager->setDefaultFileName( sentSyncFile());
1677 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1679 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1678 1680
1679#endif //KAB_EMBEDDED 1681#endif //KAB_EMBEDDED
1680 initActions(); 1682 initActions();
1681 1683
1682#ifdef KAB_EMBEDDED 1684#ifdef KAB_EMBEDDED
1683 addActionsManually(); 1685 addActionsManually();
1684 //US make sure the export and import menues are initialized before creating the xxPortManager. 1686 //US make sure the export and import menues are initialized before creating the xxPortManager.
1685 mXXPortManager = new XXPortManager( this, this ); 1687 mXXPortManager = new XXPortManager( this, this );
1686 1688
1687 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1689 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1688 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1690 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1689 // mActionQuit->plug ( mMainWindow->toolBar()); 1691 // mActionQuit->plug ( mMainWindow->toolBar());
1690 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1692 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1691 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1693 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1692 // mIncSearchWidget->hide(); 1694 // mIncSearchWidget->hide();
1693 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1695 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1694 SLOT( incrementalSearch( const QString& ) ) ); 1696 SLOT( incrementalSearch( const QString& ) ) );
1695 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1697 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1696 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1698 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1697 1699
1698 mJumpButtonBar = new JumpButtonBar( this, this ); 1700 mJumpButtonBar = new JumpButtonBar( this, this );
1699 1701
1700 topLayout->addWidget( mJumpButtonBar ); 1702 topLayout->addWidget( mJumpButtonBar );
1701//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1703//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1702 1704
1703// mMainWindow->getIconToolBar()->raise(); 1705// mMainWindow->getIconToolBar()->raise();
1704 1706
1705#endif //KAB_EMBEDDED 1707#endif //KAB_EMBEDDED
1706 1708
1707} 1709}
1708void KABCore::initActions() 1710void KABCore::initActions()
1709{ 1711{
1710//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1712//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1711 1713
1712#ifndef KAB_EMBEDDED 1714#ifndef KAB_EMBEDDED
1713 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1715 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1714 SLOT( clipboardDataChanged() ) ); 1716 SLOT( clipboardDataChanged() ) );
1715#endif //KAB_EMBEDDED 1717#endif //KAB_EMBEDDED
1716 1718
1717 // file menu 1719 // file menu
1718 if ( mIsPart ) { 1720 if ( mIsPart ) {
1719 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1721 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1720 SLOT( sendMail() ), actionCollection(), 1722 SLOT( sendMail() ), actionCollection(),
1721 "kaddressbook_mail" ); 1723 "kaddressbook_mail" );
1722 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1724 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1723 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1725 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1724 1726
1725 } else { 1727 } else {
1726 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1728 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1727 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1729 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1728 } 1730 }
1729 1731
1730 1732
1731 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1733 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1732 SLOT( save() ), actionCollection(), "file_sync" ); 1734 SLOT( save() ), actionCollection(), "file_sync" );
1733 1735
1734 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1736 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1735 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1737 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1736 1738
1737 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1739 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1738 this, SLOT( mailVCard() ), 1740 this, SLOT( mailVCard() ),
1739 actionCollection(), "file_mail_vcard"); 1741 actionCollection(), "file_mail_vcard");
1740 1742
1741 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1743 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1742 SLOT( export2phone() ), actionCollection(), 1744 SLOT( export2phone() ), actionCollection(),
1743 "kaddressbook_ex2phone" ); 1745 "kaddressbook_ex2phone" );
1744 1746
1745 mActionBeamVCard = 0; 1747 mActionBeamVCard = 0;
1746 mActionBeam = 0; 1748 mActionBeam = 0;
1747 1749
1748#ifndef DESKTOP_VERSION 1750#ifndef DESKTOP_VERSION
1749 if ( Ir::supported() ) { 1751 if ( Ir::supported() ) {
1750 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1752 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1751 SLOT( beamVCard() ), actionCollection(), 1753 SLOT( beamVCard() ), actionCollection(),
1752 "kaddressbook_beam_vcard" ); 1754 "kaddressbook_beam_vcard" );
1753 1755
1754 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1756 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1755 SLOT( beamMySelf() ), actionCollection(), 1757 SLOT( beamMySelf() ), actionCollection(),
1756 "kaddressbook_beam_myself" ); 1758 "kaddressbook_beam_myself" );
1757 } 1759 }
1758#endif 1760#endif
1759 1761
1760 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1762 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1761 this, SLOT( editContact2() ), 1763 this, SLOT( editContact2() ),
1762 actionCollection(), "file_properties" ); 1764 actionCollection(), "file_properties" );
1763 1765
1764#ifdef KAB_EMBEDDED 1766#ifdef KAB_EMBEDDED
1765 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1767 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1766 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1768 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1767 mMainWindow, SLOT( exit() ), 1769 mMainWindow, SLOT( exit() ),
1768 actionCollection(), "quit" ); 1770 actionCollection(), "quit" );
1769#endif //KAB_EMBEDDED 1771#endif //KAB_EMBEDDED
1770 1772
1771 // edit menu 1773 // edit menu
1772 if ( mIsPart ) { 1774 if ( mIsPart ) {
1773 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1775 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1774 SLOT( copyContacts() ), actionCollection(), 1776 SLOT( copyContacts() ), actionCollection(),
1775 "kaddressbook_copy" ); 1777 "kaddressbook_copy" );
1776 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1778 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1777 SLOT( cutContacts() ), actionCollection(), 1779 SLOT( cutContacts() ), actionCollection(),
1778 "kaddressbook_cut" ); 1780 "kaddressbook_cut" );
1779 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1781 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1780 SLOT( pasteContacts() ), actionCollection(), 1782 SLOT( pasteContacts() ), actionCollection(),
1781 "kaddressbook_paste" ); 1783 "kaddressbook_paste" );
1782 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1784 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1783 SLOT( selectAllContacts() ), actionCollection(), 1785 SLOT( selectAllContacts() ), actionCollection(),
1784 "kaddressbook_select_all" ); 1786 "kaddressbook_select_all" );
1785 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1787 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1786 SLOT( undo() ), actionCollection(), 1788 SLOT( undo() ), actionCollection(),
1787 "kaddressbook_undo" ); 1789 "kaddressbook_undo" );
1788 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1790 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1789 this, SLOT( redo() ), actionCollection(), 1791 this, SLOT( redo() ), actionCollection(),
1790 "kaddressbook_redo" ); 1792 "kaddressbook_redo" );
1791 } else { 1793 } else {
1792 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1794 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1793 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1795 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1794 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1796 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1795 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1797 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1796 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1798 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1797 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1799 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1798 } 1800 }
1799 1801
1800 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1802 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1801 Key_Delete, this, SLOT( deleteContacts() ), 1803 Key_Delete, this, SLOT( deleteContacts() ),
1802 actionCollection(), "edit_delete" ); 1804 actionCollection(), "edit_delete" );
1803 1805
1804 mActionUndo->setEnabled( false ); 1806 mActionUndo->setEnabled( false );
1805 mActionRedo->setEnabled( false ); 1807 mActionRedo->setEnabled( false );
1806 1808
1807 // settings menu 1809 // settings menu
1808#ifdef KAB_EMBEDDED 1810#ifdef KAB_EMBEDDED
1809//US special menuentry to configure the addressbook resources. On KDE 1811//US special menuentry to configure the addressbook resources. On KDE
1810// you do that through the control center !!! 1812// you do that through the control center !!!
1811 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1813 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1812 SLOT( configureResources() ), actionCollection(), 1814 SLOT( configureResources() ), actionCollection(),
1813 "kaddressbook_configure_resources" ); 1815 "kaddressbook_configure_resources" );
1814#endif //KAB_EMBEDDED 1816#endif //KAB_EMBEDDED
1815 1817
1816 if ( mIsPart ) { 1818 if ( mIsPart ) {
1817 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1819 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1818 SLOT( openConfigDialog() ), actionCollection(), 1820 SLOT( openConfigDialog() ), actionCollection(),
1819 "kaddressbook_configure" ); 1821 "kaddressbook_configure" );
1820 1822
1821 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1823 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1822 this, SLOT( configureKeyBindings() ), actionCollection(), 1824 this, SLOT( configureKeyBindings() ), actionCollection(),
1823 "kaddressbook_configure_shortcuts" ); 1825 "kaddressbook_configure_shortcuts" );
1824#ifdef KAB_EMBEDDED 1826#ifdef KAB_EMBEDDED
1825 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1827 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1826 mActionConfigureToolbars->setEnabled( false ); 1828 mActionConfigureToolbars->setEnabled( false );
1827#endif //KAB_EMBEDDED 1829#endif //KAB_EMBEDDED
1828 1830
1829 } else { 1831 } else {
1830 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1832 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1831 1833
1832 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1834 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1833 } 1835 }
1834 1836
1835 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1837 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1836 actionCollection(), "options_show_jump_bar" ); 1838 actionCollection(), "options_show_jump_bar" );
1837 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1839 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1838 1840
1839 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1841 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1840 actionCollection(), "options_show_details" ); 1842 actionCollection(), "options_show_details" );
1841 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1843 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1842 1844
1843 1845
1844 mActionBR = new KToggleAction( i18n( "Beam receice enabled" ), "beam", 0, this, 1846 mActionBR = new KToggleAction( i18n( "Beam receice enabled" ), "beam", 0, this,
1845 SLOT( toggleBeamReceive() ), actionCollection(), 1847 SLOT( toggleBeamReceive() ), actionCollection(),
1846 "kaddressbook_beam_rec" ); 1848 "kaddressbook_beam_rec" );
1847 1849
1848 1850
1849 // misc 1851 // misc
1850 // only enable LDAP lookup if we can handle the protocol 1852 // only enable LDAP lookup if we can handle the protocol
1851#ifndef KAB_EMBEDDED 1853#ifndef KAB_EMBEDDED
1852 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1854 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1853 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1855 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1854 this, SLOT( openLDAPDialog() ), actionCollection(), 1856 this, SLOT( openLDAPDialog() ), actionCollection(),
1855 "ldap_lookup" ); 1857 "ldap_lookup" );
1856 } 1858 }
1857#else //KAB_EMBEDDED 1859#else //KAB_EMBEDDED
1858 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1860 //qDebug("KABCore::initActions() LDAP has to be implemented");
1859#endif //KAB_EMBEDDED 1861#endif //KAB_EMBEDDED
1860 1862
1861 1863
1862 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1864 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1863 SLOT( setWhoAmI() ), actionCollection(), 1865 SLOT( setWhoAmI() ), actionCollection(),
1864 "set_personal" ); 1866 "set_personal" );
1865 1867
1866 1868
1867 1869
1868 1870
1869 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1871 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1870 SLOT( setCategories() ), actionCollection(), 1872 SLOT( setCategories() ), actionCollection(),
1871 "edit_set_categories" ); 1873 "edit_set_categories" );
1872 1874
1873 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1875 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1874 SLOT( removeVoice() ), actionCollection(), 1876 SLOT( removeVoice() ), actionCollection(),
1875 "remove_voice" ); 1877 "remove_voice" );
1876 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1878 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1877 SLOT( importFromOL() ), actionCollection(), 1879 SLOT( importFromOL() ), actionCollection(),
1878 "import_OL" ); 1880 "import_OL" );
1879#ifdef KAB_EMBEDDED 1881#ifdef KAB_EMBEDDED
1880 mActionLicence = new KAction( i18n( "Licence" ), 0, 1882 mActionLicence = new KAction( i18n( "Licence" ), 0,
1881 this, SLOT( showLicence() ), actionCollection(), 1883 this, SLOT( showLicence() ), actionCollection(),
1882 "licence_about_data" ); 1884 "licence_about_data" );
1883 mActionFaq = new KAction( i18n( "Faq" ), 0, 1885 mActionFaq = new KAction( i18n( "Faq" ), 0,
1884 this, SLOT( faq() ), actionCollection(), 1886 this, SLOT( faq() ), actionCollection(),
1885 "faq_about_data" ); 1887 "faq_about_data" );
1886 mActionWN = new KAction( i18n( "What's New?" ), 0, 1888 mActionWN = new KAction( i18n( "What's New?" ), 0,
1887 this, SLOT( whatsnew() ), actionCollection(), 1889 this, SLOT( whatsnew() ), actionCollection(),
1888 "wn" ); 1890 "wn" );
1889 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1891 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1890 this, SLOT( synchowto() ), actionCollection(), 1892 this, SLOT( synchowto() ), actionCollection(),
1891 "sync" ); 1893 "sync" );
1892 1894
1893 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1895 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1894 this, SLOT( createAboutData() ), actionCollection(), 1896 this, SLOT( createAboutData() ), actionCollection(),
1895 "kaddressbook_about_data" ); 1897 "kaddressbook_about_data" );
1896#endif //KAB_EMBEDDED 1898#endif //KAB_EMBEDDED
1897 1899
1898 clipboardDataChanged(); 1900 clipboardDataChanged();
1899 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1901 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1900 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1902 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1901} 1903}
1902 1904
1903//US we need this function, to plug all actions into the correct menues. 1905//US we need this function, to plug all actions into the correct menues.
1904// KDE uses a XML format to plug the actions, but we work her without this overhead. 1906// KDE uses a XML format to plug the actions, but we work her without this overhead.
1905void KABCore::addActionsManually() 1907void KABCore::addActionsManually()
1906{ 1908{
1907//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1909//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1908 1910
1909#ifdef KAB_EMBEDDED 1911#ifdef KAB_EMBEDDED
1910 QPopupMenu *fileMenu = new QPopupMenu( this ); 1912 QPopupMenu *fileMenu = new QPopupMenu( this );
1911 QPopupMenu *editMenu = new QPopupMenu( this ); 1913 QPopupMenu *editMenu = new QPopupMenu( this );
1912 QPopupMenu *helpMenu = new QPopupMenu( this ); 1914 QPopupMenu *helpMenu = new QPopupMenu( this );
1913 1915
1914 KToolBar* tb = mMainWindow->toolBar(); 1916 KToolBar* tb = mMainWindow->toolBar();
1915 1917
1916#ifdef DESKTOP_VERSION 1918#ifdef DESKTOP_VERSION
1917 QMenuBar* mb = mMainWindow->menuBar(); 1919 QMenuBar* mb = mMainWindow->menuBar();
1918 1920
1919 //US setup menubar. 1921 //US setup menubar.
1920 //Disable the following block if you do not want to have a menubar. 1922 //Disable the following block if you do not want to have a menubar.
1921 mb->insertItem( "&File", fileMenu ); 1923 mb->insertItem( "&File", fileMenu );
1922 mb->insertItem( "&Edit", editMenu ); 1924 mb->insertItem( "&Edit", editMenu );
1923 mb->insertItem( "&View", viewMenu ); 1925 mb->insertItem( "&View", viewMenu );
1924 mb->insertItem( "&Settings", settingsMenu ); 1926 mb->insertItem( "&Settings", settingsMenu );
1925 mb->insertItem( i18n("Synchronize"), syncMenu ); 1927 mb->insertItem( i18n("Synchronize"), syncMenu );
1926 mb->insertItem( "&Change selected", changeMenu ); 1928 mb->insertItem( "&Change selected", changeMenu );
1927 mb->insertItem( "&Help", helpMenu ); 1929 mb->insertItem( "&Help", helpMenu );
1928 mIncSearchWidget = new IncSearchWidget( tb ); 1930 mIncSearchWidget = new IncSearchWidget( tb );
1929 // tb->insertWidget(-1, 0, mIncSearchWidget); 1931 // tb->insertWidget(-1, 0, mIncSearchWidget);
1930 1932
1931#else 1933#else
1932 //US setup toolbar 1934 //US setup toolbar
1933 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1935 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1934 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1936 QPopupMenu *popupBarTB = new QPopupMenu( this );
1935 menuBarTB->insertItem( "ME", popupBarTB); 1937 menuBarTB->insertItem( "ME", popupBarTB);
1936 tb->insertWidget(-1, 0, menuBarTB); 1938 tb->insertWidget(-1, 0, menuBarTB);
1937 mIncSearchWidget = new IncSearchWidget( tb ); 1939 mIncSearchWidget = new IncSearchWidget( tb );
1938 1940
1939 tb->enableMoving(false); 1941 tb->enableMoving(false);
1940 popupBarTB->insertItem( "&File", fileMenu ); 1942 popupBarTB->insertItem( "&File", fileMenu );
1941 popupBarTB->insertItem( "&Edit", editMenu ); 1943 popupBarTB->insertItem( "&Edit", editMenu );
1942 popupBarTB->insertItem( "&View", viewMenu ); 1944 popupBarTB->insertItem( "&View", viewMenu );
1943 popupBarTB->insertItem( "&Settings", settingsMenu ); 1945 popupBarTB->insertItem( "&Settings", settingsMenu );
1944 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1946 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1945 mViewManager->getFilterAction()->plug ( popupBarTB); 1947 mViewManager->getFilterAction()->plug ( popupBarTB);
1946 popupBarTB->insertItem( "&Change selected", changeMenu ); 1948 popupBarTB->insertItem( "&Change selected", changeMenu );
1947 popupBarTB->insertItem( "&Help", helpMenu ); 1949 popupBarTB->insertItem( "&Help", helpMenu );
1948 if (QApplication::desktop()->width() > 320 ) { 1950 if (QApplication::desktop()->width() > 320 ) {
1949 // mViewManager->getFilterAction()->plug ( tb); 1951 // mViewManager->getFilterAction()->plug ( tb);
1950 } 1952 }
1951#endif 1953#endif
1952 // mActionQuit->plug ( mMainWindow->toolBar()); 1954 // mActionQuit->plug ( mMainWindow->toolBar());
1953 1955
1954 1956
1955 1957
1956 //US Now connect the actions with the menue entries. 1958 //US Now connect the actions with the menue entries.
1957 mActionPrint->plug( fileMenu ); 1959 mActionPrint->plug( fileMenu );
1958 mActionMail->plug( fileMenu ); 1960 mActionMail->plug( fileMenu );
1959 fileMenu->insertSeparator(); 1961 fileMenu->insertSeparator();
1960 1962
1961 mActionNewContact->plug( fileMenu ); 1963 mActionNewContact->plug( fileMenu );
1962 mActionNewContact->plug( tb ); 1964 mActionNewContact->plug( tb );
1963 1965
1964 mActionEditAddressee->plug( fileMenu ); 1966 mActionEditAddressee->plug( fileMenu );
1965 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1967 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1966 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1968 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1967 mActionEditAddressee->plug( tb ); 1969 mActionEditAddressee->plug( tb );
1968 1970
1969 fileMenu->insertSeparator(); 1971 fileMenu->insertSeparator();
1970 mActionSave->plug( fileMenu ); 1972 mActionSave->plug( fileMenu );
1971 fileMenu->insertItem( "&Import", ImportMenu ); 1973 fileMenu->insertItem( "&Import", ImportMenu );
1972 fileMenu->insertItem( "&Export", ExportMenu ); 1974 fileMenu->insertItem( "&Export", ExportMenu );
1973 fileMenu->insertSeparator(); 1975 fileMenu->insertSeparator();
1974 mActionMailVCard->plug( fileMenu ); 1976 mActionMailVCard->plug( fileMenu );
1975#ifndef DESKTOP_VERSION 1977#ifndef DESKTOP_VERSION
1976 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1978 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1977 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1979 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1978#endif 1980#endif
1979 fileMenu->insertSeparator(); 1981 fileMenu->insertSeparator();
1980 mActionQuit->plug( fileMenu ); 1982 mActionQuit->plug( fileMenu );
1981#ifdef _WIN32_ 1983#ifdef _WIN32_
1982 mActionImportOL->plug( ImportMenu ); 1984 mActionImportOL->plug( ImportMenu );
1983#endif 1985#endif
1984 // edit menu 1986 // edit menu
1985 mActionUndo->plug( editMenu ); 1987 mActionUndo->plug( editMenu );
1986 mActionRedo->plug( editMenu ); 1988 mActionRedo->plug( editMenu );
1987 editMenu->insertSeparator(); 1989 editMenu->insertSeparator();
1988 mActionCut->plug( editMenu ); 1990 mActionCut->plug( editMenu );
1989 mActionCopy->plug( editMenu ); 1991 mActionCopy->plug( editMenu );
1990 mActionPaste->plug( editMenu ); 1992 mActionPaste->plug( editMenu );
1991 mActionDelete->plug( editMenu ); 1993 mActionDelete->plug( editMenu );
1992 editMenu->insertSeparator(); 1994 editMenu->insertSeparator();
1993 mActionSelectAll->plug( editMenu ); 1995 mActionSelectAll->plug( editMenu );
1994 1996
1995 mActionRemoveVoice->plug( changeMenu ); 1997 mActionRemoveVoice->plug( changeMenu );
1996 // settings menu 1998 // settings menu
1997//US special menuentry to configure the addressbook resources. On KDE 1999//US special menuentry to configure the addressbook resources. On KDE
1998// you do that through the control center !!! 2000// you do that through the control center !!!
1999 mActionConfigResources->plug( settingsMenu ); 2001 mActionConfigResources->plug( settingsMenu );
2000 settingsMenu->insertSeparator(); 2002 settingsMenu->insertSeparator();
2001 2003
2002 mActionConfigKAddressbook->plug( settingsMenu ); 2004 mActionConfigKAddressbook->plug( settingsMenu );
2003 2005
2004 if ( mIsPart ) { 2006 if ( mIsPart ) {
2005 mActionConfigShortcuts->plug( settingsMenu ); 2007 mActionConfigShortcuts->plug( settingsMenu );
2006 mActionConfigureToolbars->plug( settingsMenu ); 2008 mActionConfigureToolbars->plug( settingsMenu );
2007 2009
2008 } else { 2010 } else {
2009 mActionKeyBindings->plug( settingsMenu ); 2011 mActionKeyBindings->plug( settingsMenu );
2010 } 2012 }
2011 2013
2012 settingsMenu->insertSeparator(); 2014 settingsMenu->insertSeparator();
2013 2015
2014 mActionJumpBar->plug( settingsMenu ); 2016 mActionJumpBar->plug( settingsMenu );
2015 mActionDetails->plug( settingsMenu ); 2017 mActionDetails->plug( settingsMenu );
2016 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2018 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2017 mActionDetails->plug( tb ); 2019 mActionDetails->plug( tb );
2018 settingsMenu->insertSeparator(); 2020 settingsMenu->insertSeparator();
2019 mActionBR->plug(settingsMenu ); 2021 mActionBR->plug(settingsMenu );
2020 settingsMenu->insertSeparator(); 2022 settingsMenu->insertSeparator();
2021 2023
2022 mActionWhoAmI->plug( settingsMenu ); 2024 mActionWhoAmI->plug( settingsMenu );
2023 mActionCategories->plug( settingsMenu ); 2025 mActionCategories->plug( settingsMenu );
2024 2026
2025 2027
2026 mActionWN->plug( helpMenu ); 2028 mActionWN->plug( helpMenu );
2027 mActionSyncHowto->plug( helpMenu ); 2029 mActionSyncHowto->plug( helpMenu );
2028 mActionLicence->plug( helpMenu ); 2030 mActionLicence->plug( helpMenu );
2029 mActionFaq->plug( helpMenu ); 2031 mActionFaq->plug( helpMenu );
2030 mActionAboutKAddressbook->plug( helpMenu ); 2032 mActionAboutKAddressbook->plug( helpMenu );
2031 2033
2032 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2034 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2033 2035
2034 mActionSave->plug( tb ); 2036 mActionSave->plug( tb );
2035 mViewManager->getFilterAction()->plug ( tb); 2037 mViewManager->getFilterAction()->plug ( tb);
2036 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2038 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2037 mActionUndo->plug( tb ); 2039 mActionUndo->plug( tb );
2038 mActionDelete->plug( tb ); 2040 mActionDelete->plug( tb );
2039 mActionRedo->plug( tb ); 2041 mActionRedo->plug( tb );
2040 } 2042 }
2041 } 2043 }
2042 //mActionQuit->plug ( tb ); 2044 //mActionQuit->plug ( tb );
2043 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2045 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2044 2046
2045 //US link the searchwidget first to this. 2047 //US link the searchwidget first to this.
2046 // The real linkage to the toolbar happens later. 2048 // The real linkage to the toolbar happens later.
2047//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2049//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2048//US tb->insertItem( mIncSearchWidget ); 2050//US tb->insertItem( mIncSearchWidget );
2049/*US 2051/*US
2050 mIncSearchWidget = new IncSearchWidget( tb ); 2052 mIncSearchWidget = new IncSearchWidget( tb );
2051 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2053 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2052 SLOT( incrementalSearch( const QString& ) ) ); 2054 SLOT( incrementalSearch( const QString& ) ) );
2053 2055
2054 mJumpButtonBar = new JumpButtonBar( this, this ); 2056 mJumpButtonBar = new JumpButtonBar( this, this );
2055 2057
2056//US topLayout->addWidget( mJumpButtonBar ); 2058//US topLayout->addWidget( mJumpButtonBar );
2057 this->layout()->add( mJumpButtonBar ); 2059 this->layout()->add( mJumpButtonBar );
2058*/ 2060*/
2059 2061
2060#endif //KAB_EMBEDDED 2062#endif //KAB_EMBEDDED
2061 2063
2062 mActionExport2phone->plug( ExportMenu ); 2064 mActionExport2phone->plug( ExportMenu );
2063 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2065 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2064 syncManager->fillSyncMenu(); 2066 syncManager->fillSyncMenu();
2065 2067
2066} 2068}
2067void KABCore::showLicence() 2069void KABCore::showLicence()
2068{ 2070{
2069 KApplication::showLicence(); 2071 KApplication::showLicence();
2070} 2072}
2071void KABCore::removeVoice() 2073void KABCore::removeVoice()
2072{ 2074{
2073 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 ) 2075 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 )
2074 return; 2076 return;
2075 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2077 KABC::Addressee::List list = mViewManager->selectedAddressees();
2076 KABC::Addressee::List::Iterator it; 2078 KABC::Addressee::List::Iterator it;
2077 for ( it = list.begin(); it != list.end(); ++it ) { 2079 for ( it = list.begin(); it != list.end(); ++it ) {
2078 2080
2079 if ( (*it).removeVoice() ) 2081 if ( (*it).removeVoice() )
2080 contactModified((*it) ); 2082 contactModified((*it) );
2081 } 2083 }
2082} 2084}
2083 2085
2084 2086
2085 2087
2086void KABCore::clipboardDataChanged() 2088void KABCore::clipboardDataChanged()
2087{ 2089{
2088 2090
2089 if ( mReadWrite ) 2091 if ( mReadWrite )
2090 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2092 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2091 2093
2092} 2094}
2093 2095
2094void KABCore::updateActionMenu() 2096void KABCore::updateActionMenu()
2095{ 2097{
2096 UndoStack *undo = UndoStack::instance(); 2098 UndoStack *undo = UndoStack::instance();
2097 RedoStack *redo = RedoStack::instance(); 2099 RedoStack *redo = RedoStack::instance();
2098 2100
2099 if ( undo->isEmpty() ) 2101 if ( undo->isEmpty() )
2100 mActionUndo->setText( i18n( "Undo" ) ); 2102 mActionUndo->setText( i18n( "Undo" ) );
2101 else 2103 else
2102 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2104 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2103 2105
2104 mActionUndo->setEnabled( !undo->isEmpty() ); 2106 mActionUndo->setEnabled( !undo->isEmpty() );
2105 2107
2106 if ( !redo->top() ) 2108 if ( !redo->top() )
2107 mActionRedo->setText( i18n( "Redo" ) ); 2109 mActionRedo->setText( i18n( "Redo" ) );
2108 else 2110 else
2109 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2111 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2110 2112
2111 mActionRedo->setEnabled( !redo->isEmpty() ); 2113 mActionRedo->setEnabled( !redo->isEmpty() );
2112} 2114}
2113 2115
2114void KABCore::configureKeyBindings() 2116void KABCore::configureKeyBindings()
2115{ 2117{
2116#ifndef KAB_EMBEDDED 2118#ifndef KAB_EMBEDDED
2117 KKeyDialog::configure( actionCollection(), true ); 2119 KKeyDialog::configure( actionCollection(), true );
2118#else //KAB_EMBEDDED 2120#else //KAB_EMBEDDED
2119 qDebug("KABCore::configureKeyBindings() not implemented"); 2121 qDebug("KABCore::configureKeyBindings() not implemented");
2120#endif //KAB_EMBEDDED 2122#endif //KAB_EMBEDDED
2121} 2123}
2122 2124
2123#ifdef KAB_EMBEDDED 2125#ifdef KAB_EMBEDDED
2124void KABCore::configureResources() 2126void KABCore::configureResources()
2125{ 2127{
2126 KRES::KCMKResources dlg( this, "" , 0 ); 2128 KRES::KCMKResources dlg( this, "" , 0 );
2127 2129
2128 if ( !dlg.exec() ) 2130 if ( !dlg.exec() )
2129 return; 2131 return;
2130 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2132 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2131} 2133}
2132#endif //KAB_EMBEDDED 2134#endif //KAB_EMBEDDED
2133 2135
2134 2136
2135/* this method will be called through the QCop interface from Ko/Pi to select addresses 2137/* this method will be called through the QCop interface from Ko/Pi to select addresses
2136 * for the attendees list of an event. 2138 * for the attendees list of an event.
2137 */ 2139 */
2138void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2140void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2139{ 2141{
2140 QStringList nameList; 2142 QStringList nameList;
2141 QStringList emailList; 2143 QStringList emailList;
2142 QStringList uidList; 2144 QStringList uidList;
2143 2145
2144 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2146 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2145 uint i=0; 2147 uint i=0;
2146 for (i=0; i < list.count(); i++) 2148 for (i=0; i < list.count(); i++)
2147 { 2149 {
2148 nameList.append(list[i].realName()); 2150 nameList.append(list[i].realName());
2149 emailList.append(list[i].preferredEmail()); 2151 emailList.append(list[i].preferredEmail());
2150 uidList.append(list[i].uid()); 2152 uidList.append(list[i].uid());
2151 } 2153 }
2152 2154
2153 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2155 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2154 2156
2155} 2157}
2156 2158
2157/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2159/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2158 * to put them into the calendar. 2160 * to put them into the calendar.
2159 */ 2161 */
2160void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2162void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2161{ 2163{
2162 // qDebug("KABCore::requestForBirthdayList"); 2164 // qDebug("KABCore::requestForBirthdayList");
2163 QStringList birthdayList; 2165 QStringList birthdayList;
2164 QStringList anniversaryList; 2166 QStringList anniversaryList;
2165 QStringList realNameList; 2167 QStringList realNameList;
2166 QStringList preferredEmailList; 2168 QStringList preferredEmailList;
2167 QStringList assembledNameList; 2169 QStringList assembledNameList;
2168 QStringList uidList; 2170 QStringList uidList;
2169 2171
2170 KABC::AddressBook::Iterator it; 2172 KABC::AddressBook::Iterator it;
2171 2173
2172 int count = 0; 2174 int count = 0;
2173 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2175 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2174 ++count; 2176 ++count;
2175 } 2177 }
2176 QProgressBar bar(count,0 ); 2178 QProgressBar bar(count,0 );
2177 int w = 300; 2179 int w = 300;
2178 if ( QApplication::desktop()->width() < 320 ) 2180 if ( QApplication::desktop()->width() < 320 )
2179 w = 220; 2181 w = 220;
2180 int h = bar.sizeHint().height() ; 2182 int h = bar.sizeHint().height() ;
2181 int dw = QApplication::desktop()->width(); 2183 int dw = QApplication::desktop()->width();
2182 int dh = QApplication::desktop()->height(); 2184 int dh = QApplication::desktop()->height();
2183 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2185 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2184 bar.show(); 2186 bar.show();
2185 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2187 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2186 qApp->processEvents(); 2188 qApp->processEvents();
2187 2189
2188 QDate bday; 2190 QDate bday;
2189 QString anni; 2191 QString anni;
2190 QString formattedbday; 2192 QString formattedbday;
2191 2193
2192 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2194 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2193 { 2195 {
2194 if ( ! bar.isVisible() ) 2196 if ( ! bar.isVisible() )
2195 return; 2197 return;
2196 bar.setProgress( count++ ); 2198 bar.setProgress( count++ );
2197 qApp->processEvents(); 2199 qApp->processEvents();
2198 bday = (*it).birthday().date(); 2200 bday = (*it).birthday().date();
2199 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2201 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2200 2202
2201 if ( bday.isValid() || !anni.isEmpty()) 2203 if ( bday.isValid() || !anni.isEmpty())
2202 { 2204 {
2203 if (bday.isValid()) 2205 if (bday.isValid())
2204 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2206 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2205 else 2207 else
2206 formattedbday = "NOTVALID"; 2208 formattedbday = "NOTVALID";
2207 if (anni.isEmpty()) 2209 if (anni.isEmpty())
2208 anni = "INVALID"; 2210 anni = "INVALID";
2209 2211
2210 birthdayList.append(formattedbday); 2212 birthdayList.append(formattedbday);
2211 anniversaryList.append(anni); //should be ISODate 2213 anniversaryList.append(anni); //should be ISODate
2212 realNameList.append((*it).realName()); 2214 realNameList.append((*it).realName());
2213 preferredEmailList.append((*it).preferredEmail()); 2215 preferredEmailList.append((*it).preferredEmail());
2214 assembledNameList.append((*it).assembledName()); 2216 assembledNameList.append((*it).assembledName());
2215 uidList.append((*it).uid()); 2217 uidList.append((*it).uid());
2216 2218
2217 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() ); 2219 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() );
2218 } 2220 }
2219 } 2221 }
2220 2222
2221 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2223 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2222 2224
2223} 2225}
2224 2226
2225/* this method will be called through the QCop interface from other apps to show details of a contact. 2227/* this method will be called through the QCop interface from other apps to show details of a contact.
2226 */ 2228 */
2227void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2229void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2228{ 2230{
2229 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2231 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2230 2232
2231 QString foundUid = QString::null; 2233 QString foundUid = QString::null;
2232 if ( ! uid.isEmpty() ) { 2234 if ( ! uid.isEmpty() ) {
2233 Addressee adrr = mAddressBook->findByUid( uid ); 2235 Addressee adrr = mAddressBook->findByUid( uid );
2234 if ( !adrr.isEmpty() ) { 2236 if ( !adrr.isEmpty() ) {
2235 foundUid = uid; 2237 foundUid = uid;
2236 } 2238 }
2237 if ( email == "sendbacklist" ) { 2239 if ( email == "sendbacklist" ) {
2238 //qDebug("ssssssssssssssssssssssend "); 2240 //qDebug("ssssssssssssssssssssssend ");
2239 QStringList nameList; 2241 QStringList nameList;
2240 QStringList emailList; 2242 QStringList emailList;
2241 QStringList uidList; 2243 QStringList uidList;
2242 nameList.append(adrr.realName()); 2244 nameList.append(adrr.realName());
2243 emailList = adrr.emails(); 2245 emailList = adrr.emails();
2244 uidList.append( adrr.preferredEmail()); 2246 uidList.append( adrr.preferredEmail());
2245 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2247 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2246 return; 2248 return;
2247 } 2249 }
2248 2250
2249 } 2251 }
2250 2252
2251 if ( email == "sendbacklist" ) 2253 if ( email == "sendbacklist" )
2252 return; 2254 return;
2253 if (foundUid.isEmpty()) 2255 if (foundUid.isEmpty())
2254 { 2256 {
2255 //find the uid of the person first 2257 //find the uid of the person first
2256 Addressee::List namelist; 2258 Addressee::List namelist;
2257 Addressee::List emaillist; 2259 Addressee::List emaillist;
2258 2260
2259 if (!name.isEmpty()) 2261 if (!name.isEmpty())
2260 namelist = mAddressBook->findByName( name ); 2262 namelist = mAddressBook->findByName( name );
2261 2263
2262 if (!email.isEmpty()) 2264 if (!email.isEmpty())
2263 emaillist = mAddressBook->findByEmail( email ); 2265 emaillist = mAddressBook->findByEmail( email );
2264 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2266 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2265 //check if we have a match in Namelist and Emaillist 2267 //check if we have a match in Namelist and Emaillist
2266 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2268 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2267 foundUid = emaillist[0].uid(); 2269 foundUid = emaillist[0].uid();
2268 } 2270 }
2269 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2271 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2270 foundUid = namelist[0].uid(); 2272 foundUid = namelist[0].uid();
2271 else 2273 else
2272 { 2274 {
2273 for (int i = 0; i < namelist.count(); i++) 2275 for (int i = 0; i < namelist.count(); i++)
2274 { 2276 {
2275 for (int j = 0; j < emaillist.count(); j++) 2277 for (int j = 0; j < emaillist.count(); j++)
2276 { 2278 {
2277 if (namelist[i] == emaillist[j]) 2279 if (namelist[i] == emaillist[j])
2278 { 2280 {
2279 foundUid = namelist[i].uid(); 2281 foundUid = namelist[i].uid();
2280 } 2282 }
2281 } 2283 }
2282 } 2284 }
2283 } 2285 }
2284 } 2286 }
2285 else 2287 else
2286 { 2288 {
2287 foundUid = uid; 2289 foundUid = uid;
2288 } 2290 }
2289 2291
2290 if (!foundUid.isEmpty()) 2292 if (!foundUid.isEmpty())
2291 { 2293 {
2292 2294
2293 // raise Ka/Pi if it is in the background 2295 // raise Ka/Pi if it is in the background
2294#ifndef DESKTOP_VERSION 2296#ifndef DESKTOP_VERSION
2295#ifndef KORG_NODCOP 2297#ifndef KORG_NODCOP
2296 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2298 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2297#endif 2299#endif
2298#endif 2300#endif
2299 2301
2300 mMainWindow->showMaximized(); 2302 mMainWindow->showMaximized();
2301 mMainWindow-> raise(); 2303 mMainWindow-> raise();
2302 2304
2303 mViewManager->setSelected( "", false); 2305 mViewManager->setSelected( "", false);
2304 mViewManager->refreshView( "" ); 2306 mViewManager->refreshView( "" );
2305 mViewManager->setSelected( foundUid, true ); 2307 mViewManager->setSelected( foundUid, true );
2306 mViewManager->refreshView( foundUid ); 2308 mViewManager->refreshView( foundUid );
2307 2309
2308 if ( !mMultipleViewsAtOnce ) 2310 if ( !mMultipleViewsAtOnce )
2309 { 2311 {
2310 setDetailsVisible( true ); 2312 setDetailsVisible( true );
2311 mActionDetails->setChecked(true); 2313 mActionDetails->setChecked(true);
2312 } 2314 }
2313 } 2315 }
2314} 2316}
2315 2317
2316void KABCore::whatsnew() 2318void KABCore::whatsnew()
2317{ 2319{
2318 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2320 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2319} 2321}
2320void KABCore::synchowto() 2322void KABCore::synchowto()
2321{ 2323{
2322 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2324 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2323} 2325}
2324 2326
2325void KABCore::faq() 2327void KABCore::faq()
2326{ 2328{
2327 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2329 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2328} 2330}
2329 2331
2330#include <libkcal/syncdefines.h> 2332#include <libkcal/syncdefines.h>
2331 2333
2332KABC::Addressee KABCore::getLastSyncAddressee() 2334KABC::Addressee KABCore::getLastSyncAddressee()
2333{ 2335{
2334 Addressee lse; 2336 Addressee lse;
2335 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2337 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2336 2338
2337 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2339 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2338 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2340 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2339 if (lse.isEmpty()) { 2341 if (lse.isEmpty()) {
2340 qDebug("Creating new last-syncAddressee "); 2342 qDebug("Creating new last-syncAddressee ");
2341 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2343 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2342 QString sum = ""; 2344 QString sum = "";
2343 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2345 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2344 sum = "E: "; 2346 sum = "E: ";
2345 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2347 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2346 lse.setRevision( mLastAddressbookSync ); 2348 lse.setRevision( mLastAddressbookSync );
2347 lse.setCategories( i18n("SyncEvent") ); 2349 lse.setCategories( i18n("SyncEvent") );
2348 mAddressBook->insertAddressee( lse ); 2350 mAddressBook->insertAddressee( lse );
2349 } 2351 }
2350 return lse; 2352 return lse;
2351} 2353}
2352int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2354int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2353{ 2355{
2354 2356
2355 //void setZaurusId(int id); 2357 //void setZaurusId(int id);
2356 // int zaurusId() const; 2358 // int zaurusId() const;
2357 // void setZaurusUid(int id); 2359 // void setZaurusUid(int id);
2358 // int zaurusUid() const; 2360 // int zaurusUid() const;
2359 // void setZaurusStat(int id); 2361 // void setZaurusStat(int id);
2360 // int zaurusStat() const; 2362 // int zaurusStat() const;
2361 // 0 equal 2363 // 0 equal
2362 // 1 take local 2364 // 1 take local
2363 // 2 take remote 2365 // 2 take remote
2364 // 3 cancel 2366 // 3 cancel
2365 QDateTime lastSync = mLastAddressbookSync; 2367 QDateTime lastSync = mLastAddressbookSync;
2366 QDateTime localMod = local->revision(); 2368 QDateTime localMod = local->revision();
2367 QDateTime remoteMod = remote->revision(); 2369 QDateTime remoteMod = remote->revision();
2368 2370
2369 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2371 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2370 2372
2371 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2373 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2372 bool remCh, locCh; 2374 bool remCh, locCh;
2373 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2375 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2374 2376
2375 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2377 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2376 locCh = ( localMod > mLastAddressbookSync ); 2378 locCh = ( localMod > mLastAddressbookSync );
2377 if ( !remCh && ! locCh ) { 2379 if ( !remCh && ! locCh ) {
2378 //qDebug("both not changed "); 2380 //qDebug("both not changed ");
2379 lastSync = localMod.addDays(1); 2381 lastSync = localMod.addDays(1);
2380 if ( mode <= SYNC_PREF_ASK ) 2382 if ( mode <= SYNC_PREF_ASK )
2381 return 0; 2383 return 0;
2382 } else { 2384 } else {
2383 if ( locCh ) { 2385 if ( locCh ) {
2384 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2386 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2385 lastSync = localMod.addDays( -1 ); 2387 lastSync = localMod.addDays( -1 );
2386 if ( !remCh ) 2388 if ( !remCh )
2387 remoteMod =( lastSync.addDays( -1 ) ); 2389 remoteMod =( lastSync.addDays( -1 ) );
2388 } else { 2390 } else {
2389 //qDebug(" not loc changed "); 2391 //qDebug(" not loc changed ");
2390 lastSync = localMod.addDays( 1 ); 2392 lastSync = localMod.addDays( 1 );
2391 if ( remCh ) 2393 if ( remCh )
2392 remoteMod =( lastSync.addDays( 1 ) ); 2394 remoteMod =( lastSync.addDays( 1 ) );
2393 2395
2394 } 2396 }
2395 } 2397 }
2396 full = true; 2398 full = true;
2397 if ( mode < SYNC_PREF_ASK ) 2399 if ( mode < SYNC_PREF_ASK )
2398 mode = SYNC_PREF_ASK; 2400 mode = SYNC_PREF_ASK;
2399 } else { 2401 } else {
2400 if ( localMod == remoteMod ) 2402 if ( localMod == remoteMod )
2401 return 0; 2403 return 0;
2402 2404
2403 } 2405 }
2404 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2406 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2405 2407
2406 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2408 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2407 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2409 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2408 //full = true; //debug only 2410 //full = true; //debug only
2409 if ( full ) { 2411 if ( full ) {
2410 bool equ = ( (*local) == (*remote) ); 2412 bool equ = ( (*local) == (*remote) );
2411 if ( equ ) { 2413 if ( equ ) {
2412 //qDebug("equal "); 2414 //qDebug("equal ");
2413 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2415 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2414 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2416 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2415 } 2417 }
2416 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2418 if ( mode < SYNC_PREF_FORCE_LOCAL )
2417 return 0; 2419 return 0;
2418 2420
2419 }//else //debug only 2421 }//else //debug only
2420 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2422 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2421 } 2423 }
2422 int result; 2424 int result;
2423 bool localIsNew; 2425 bool localIsNew;
2424 //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() ); 2426 //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() );
2425 2427
2426 if ( full && mode < SYNC_PREF_NEWEST ) 2428 if ( full && mode < SYNC_PREF_NEWEST )
2427 mode = SYNC_PREF_ASK; 2429 mode = SYNC_PREF_ASK;
2428 2430
2429 switch( mode ) { 2431 switch( mode ) {
2430 case SYNC_PREF_LOCAL: 2432 case SYNC_PREF_LOCAL:
2431 if ( lastSync > remoteMod ) 2433 if ( lastSync > remoteMod )
2432 return 1; 2434 return 1;
2433 if ( lastSync > localMod ) 2435 if ( lastSync > localMod )
2434 return 2; 2436 return 2;
2435 return 1; 2437 return 1;
2436 break; 2438 break;
2437 case SYNC_PREF_REMOTE: 2439 case SYNC_PREF_REMOTE:
2438 if ( lastSync > remoteMod ) 2440 if ( lastSync > remoteMod )
2439 return 1; 2441 return 1;
2440 if ( lastSync > localMod ) 2442 if ( lastSync > localMod )
2441 return 2; 2443 return 2;
2442 return 2; 2444 return 2;
2443 break; 2445 break;
2444 case SYNC_PREF_NEWEST: 2446 case SYNC_PREF_NEWEST:
2445 if ( localMod > remoteMod ) 2447 if ( localMod > remoteMod )
2446 return 1; 2448 return 1;
2447 else 2449 else
2448 return 2; 2450 return 2;
2449 break; 2451 break;
2450 case SYNC_PREF_ASK: 2452 case SYNC_PREF_ASK:
2451 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2453 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2452 if ( lastSync > remoteMod ) 2454 if ( lastSync > remoteMod )
2453 return 1; 2455 return 1;
2454 if ( lastSync > localMod ) 2456 if ( lastSync > localMod )
2455 return 2; 2457 return 2;
2456 localIsNew = localMod >= remoteMod; 2458 localIsNew = localMod >= remoteMod;
2457 //qDebug("conflict! ************************************** "); 2459 //qDebug("conflict! ************************************** ");
2458 { 2460 {
2459 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2461 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2460 result = acd.executeD(localIsNew); 2462 result = acd.executeD(localIsNew);
2461 return result; 2463 return result;
2462 } 2464 }
2463 break; 2465 break;
2464 case SYNC_PREF_FORCE_LOCAL: 2466 case SYNC_PREF_FORCE_LOCAL:
2465 return 1; 2467 return 1;
2466 break; 2468 break;
2467 case SYNC_PREF_FORCE_REMOTE: 2469 case SYNC_PREF_FORCE_REMOTE:
2468 return 2; 2470 return 2;
2469 break; 2471 break;
2470 2472
2471 default: 2473 default:
2472 // SYNC_PREF_TAKE_BOTH not implemented 2474 // SYNC_PREF_TAKE_BOTH not implemented
2473 break; 2475 break;
2474 } 2476 }
2475 return 0; 2477 return 0;
2476} 2478}
2477 2479
2478 2480
2479bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2481bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2480{ 2482{
2481 bool syncOK = true; 2483 bool syncOK = true;
2482 int addedAddressee = 0; 2484 int addedAddressee = 0;
2483 int addedAddresseeR = 0; 2485 int addedAddresseeR = 0;
2484 int deletedAddresseeR = 0; 2486 int deletedAddresseeR = 0;
2485 int deletedAddresseeL = 0; 2487 int deletedAddresseeL = 0;
2486 int changedLocal = 0; 2488 int changedLocal = 0;
2487 int changedRemote = 0; 2489 int changedRemote = 0;
2488 2490
2489 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2491 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2490 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2492 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2491 2493
2492 //QPtrList<Addressee> el = local->rawAddressees(); 2494 //QPtrList<Addressee> el = local->rawAddressees();
2493 Addressee addresseeR; 2495 Addressee addresseeR;
2494 QString uid; 2496 QString uid;
2495 int take; 2497 int take;
2496 Addressee addresseeL; 2498 Addressee addresseeL;
2497 Addressee addresseeRSync; 2499 Addressee addresseeRSync;
2498 Addressee addresseeLSync; 2500 Addressee addresseeLSync;
2499 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2501 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2500 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2502 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2501 bool fullDateRange = false; 2503 bool fullDateRange = false;
2502 local->resetTempSyncStat(); 2504 local->resetTempSyncStat();
2503 mLastAddressbookSync = QDateTime::currentDateTime(); 2505 mLastAddressbookSync = QDateTime::currentDateTime();
2504 QDateTime modifiedCalendar = mLastAddressbookSync;; 2506 QDateTime modifiedCalendar = mLastAddressbookSync;;
2505 addresseeLSync = getLastSyncAddressee(); 2507 addresseeLSync = getLastSyncAddressee();
2506 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2508 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2507 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2509 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2508 if ( !addresseeR.isEmpty() ) { 2510 if ( !addresseeR.isEmpty() ) {
2509 addresseeRSync = addresseeR; 2511 addresseeRSync = addresseeR;
2510 remote->removeAddressee(addresseeR ); 2512 remote->removeAddressee(addresseeR );
2511 2513
2512 } else { 2514 } else {
2513 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2515 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2514 addresseeRSync = addresseeLSync ; 2516 addresseeRSync = addresseeLSync ;
2515 } else { 2517 } else {
2516 qDebug("FULLDATE 1"); 2518 qDebug("FULLDATE 1");
2517 fullDateRange = true; 2519 fullDateRange = true;
2518 Addressee newAdd; 2520 Addressee newAdd;
2519 addresseeRSync = newAdd; 2521 addresseeRSync = newAdd;
2520 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2522 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2521 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2523 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2522 addresseeRSync.setRevision( mLastAddressbookSync ); 2524 addresseeRSync.setRevision( mLastAddressbookSync );
2523 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2525 addresseeRSync.setCategories( i18n("SyncAddressee") );
2524 } 2526 }
2525 } 2527 }
2526 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2528 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2527 qDebug("FULLDATE 2"); 2529 qDebug("FULLDATE 2");
2528 fullDateRange = true; 2530 fullDateRange = true;
2529 } 2531 }
2530 if ( ! fullDateRange ) { 2532 if ( ! fullDateRange ) {
2531 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2533 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2532 2534
2533 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2535 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2534 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2536 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2535 fullDateRange = true; 2537 fullDateRange = true;
2536 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2538 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2537 } 2539 }
2538 } 2540 }
2539 // fullDateRange = true; // debug only! 2541 // fullDateRange = true; // debug only!
2540 if ( fullDateRange ) 2542 if ( fullDateRange )
2541 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2543 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2542 else 2544 else
2543 mLastAddressbookSync = addresseeLSync.revision(); 2545 mLastAddressbookSync = addresseeLSync.revision();
2544 // for resyncing if own file has changed 2546 // for resyncing if own file has changed
2545 // PENDING fixme later when implemented 2547 // PENDING fixme later when implemented
2546#if 0 2548#if 0
2547 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2549 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2548 mLastAddressbookSync = loadedFileVersion; 2550 mLastAddressbookSync = loadedFileVersion;
2549 qDebug("setting mLastAddressbookSync "); 2551 qDebug("setting mLastAddressbookSync ");
2550 } 2552 }
2551#endif 2553#endif
2552 2554
2553 //qDebug("*************************** "); 2555 //qDebug("*************************** ");
2554 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2556 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2555 QStringList er = remote->uidList(); 2557 QStringList er = remote->uidList();
2556 Addressee inR ;//= er.first(); 2558 Addressee inR ;//= er.first();
2557 Addressee inL; 2559 Addressee inL;
2558 2560
2559 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2561 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2560 2562
2561 int modulo = (er.count()/10)+1; 2563 int modulo = (er.count()/10)+1;
2562 int incCounter = 0; 2564 int incCounter = 0;
2563 while ( incCounter < er.count()) { 2565 while ( incCounter < er.count()) {
2564 if (syncManager->isProgressBarCanceled()) 2566 if (syncManager->isProgressBarCanceled())
2565 return false; 2567 return false;
2566 if ( incCounter % modulo == 0 ) 2568 if ( incCounter % modulo == 0 )
2567 syncManager->showProgressBar(incCounter); 2569 syncManager->showProgressBar(incCounter);
2568 2570
2569 uid = er[ incCounter ]; 2571 uid = er[ incCounter ];
2570 bool skipIncidence = false; 2572 bool skipIncidence = false;
2571 if ( uid.left(19) == QString("last-syncAddressee-") ) 2573 if ( uid.left(19) == QString("last-syncAddressee-") )
2572 skipIncidence = true; 2574 skipIncidence = true;
2573 QString idS,OidS; 2575 QString idS,OidS;
2574 qApp->processEvents(); 2576 qApp->processEvents();
2575 if ( !skipIncidence ) { 2577 if ( !skipIncidence ) {
2576 inL = local->findByUid( uid ); 2578 inL = local->findByUid( uid );
2577 inR = remote->findByUid( uid ); 2579 inR = remote->findByUid( uid );
2578 //inL.setResource( 0 ); 2580 //inL.setResource( 0 );
2579 //inR.setResource( 0 ); 2581 //inR.setResource( 0 );
2580 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2582 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2581 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2583 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2582 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2584 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2583 //qDebug("take %d %s ", take, inL.summary().latin1()); 2585 //qDebug("take %d %s ", take, inL.summary().latin1());
2584 if ( take == 3 ) 2586 if ( take == 3 )
2585 return false; 2587 return false;
2586 if ( take == 1 ) {// take local 2588 if ( take == 1 ) {// take local
2587 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2589 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2588 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2590 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2589 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2591 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2590 local->insertAddressee( inL, false ); 2592 local->insertAddressee( inL, false );
2591 idS = inR.externalUID(); 2593 idS = inR.externalUID();
2592 OidS = inR.originalExternalUID(); 2594 OidS = inR.originalExternalUID();
2593 } 2595 }
2594 else 2596 else
2595 idS = inR.IDStr(); 2597 idS = inR.IDStr();
2596 remote->removeAddressee( inR ); 2598 remote->removeAddressee( inR );
2597 inR = inL; 2599 inR = inL;
2598 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2600 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2601 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2600 inR.setOriginalExternalUID( OidS ); 2602 inR.setOriginalExternalUID( OidS );
2601 inR.setExternalUID( idS ); 2603 inR.setExternalUID( idS );
2602 } else { 2604 } else {
2603 inR.setIDStr( idS ); 2605 inR.setIDStr( idS );
2604 } 2606 }
2605 inR.setResource( 0 ); 2607 inR.setResource( 0 );
2606 remote->insertAddressee( inR , false); 2608 remote->insertAddressee( inR , false);
2607 ++changedRemote; 2609 ++changedRemote;
2608 } else { // take == 2 take remote 2610 } else { // take == 2 take remote
2609 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2611 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2610 if ( inR.revision().date().year() < 2004 ) 2612 if ( inR.revision().date().year() < 2004 )
2611 inR.setRevision( modifiedCalendar ); 2613 inR.setRevision( modifiedCalendar );
2612 } 2614 }
2613 idS = inL.IDStr(); 2615 idS = inL.IDStr();
2614 local->removeAddressee( inL ); 2616 local->removeAddressee( inL );
2615 inL = inR; 2617 inL = inR;
2616 inL.setIDStr( idS ); 2618 inL.setIDStr( idS );
2617 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2619 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2618 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2620 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2619 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2621 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2620 } 2622 }
2621 inL.setResource( 0 ); 2623 inL.setResource( 0 );
2622 local->insertAddressee( inL , false ); 2624 local->insertAddressee( inL , false );
2623 ++changedLocal; 2625 ++changedLocal;
2624 } 2626 }
2625 } 2627 }
2626 } 2628 }
2627 } else { // no conflict 2629 } else { // no conflict
2628 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2630 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2629 QString des = addresseeLSync.note(); 2631 QString des = addresseeLSync.note();
2630 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2632 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2631 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2633 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2632 remote->insertAddressee( inR, false ); 2634 remote->insertAddressee( inR, false );
2633 ++deletedAddresseeR; 2635 ++deletedAddresseeR;
2634 } else { 2636 } else {
2635 inR.setRevision( modifiedCalendar ); 2637 inR.setRevision( modifiedCalendar );
2636 remote->insertAddressee( inR, false ); 2638 remote->insertAddressee( inR, false );
2637 inL = inR; 2639 inL = inR;
2638 inL.setResource( 0 ); 2640 inL.setResource( 0 );
2639 local->insertAddressee( inL , false); 2641 local->insertAddressee( inL , false);
2640 ++addedAddressee; 2642 ++addedAddressee;
2641 } 2643 }
2642 } else { 2644 } else {
2643 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2645 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2644 inR.setRevision( modifiedCalendar ); 2646 inR.setRevision( modifiedCalendar );
2645 remote->insertAddressee( inR, false ); 2647 remote->insertAddressee( inR, false );
2646 inR.setResource( 0 ); 2648 inR.setResource( 0 );
2647 local->insertAddressee( inR, false ); 2649 local->insertAddressee( inR, false );
2648 ++addedAddressee; 2650 ++addedAddressee;
2649 } else { 2651 } else {
2650 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2652 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2651 remote->removeAddressee( inR ); 2653 remote->removeAddressee( inR );
2652 ++deletedAddresseeR; 2654 ++deletedAddresseeR;
2653 } 2655 }
2654 } 2656 }
2655 } 2657 }
2656 } 2658 }
2657 ++incCounter; 2659 ++incCounter;
2658 } 2660 }
2659 er.clear(); 2661 er.clear();
2660 QStringList el = local->uidList(); 2662 QStringList el = local->uidList();
2661 modulo = (el.count()/10)+1; 2663 modulo = (el.count()/10)+1;
2662 2664
2663 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2665 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2664 incCounter = 0; 2666 incCounter = 0;
2665 while ( incCounter < el.count()) { 2667 while ( incCounter < el.count()) {
2666 qApp->processEvents(); 2668 qApp->processEvents();
2667 if (syncManager->isProgressBarCanceled()) 2669 if (syncManager->isProgressBarCanceled())
2668 return false; 2670 return false;
2669 if ( incCounter % modulo == 0 ) 2671 if ( incCounter % modulo == 0 )
2670 syncManager->showProgressBar(incCounter); 2672 syncManager->showProgressBar(incCounter);
2671 uid = el[ incCounter ]; 2673 uid = el[ incCounter ];
2672 bool skipIncidence = false; 2674 bool skipIncidence = false;
2673 if ( uid.left(19) == QString("last-syncAddressee-") ) 2675 if ( uid.left(19) == QString("last-syncAddressee-") )
2674 skipIncidence = true; 2676 skipIncidence = true;
2675 if ( !skipIncidence ) { 2677 if ( !skipIncidence ) {
2676 inL = local->findByUid( uid ); 2678 inL = local->findByUid( uid );
2677 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2679 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2678 inR = remote->findByUid( uid ); 2680 inR = remote->findByUid( uid );
2679 if ( inR.isEmpty() ) { 2681 if ( inR.isEmpty() ) {
2680 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2682 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2681 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2683 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2682 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2684 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2683 local->removeAddressee( inL ); 2685 local->removeAddressee( inL );
2684 ++deletedAddresseeL; 2686 ++deletedAddresseeL;
2685 } else { 2687 } else {
2686 if ( ! syncManager->mWriteBackExistingOnly ) { 2688 if ( ! syncManager->mWriteBackExistingOnly ) {
2687 inL.removeID(mCurrentSyncDevice ); 2689 inL.removeID(mCurrentSyncDevice );
2688 ++addedAddresseeR; 2690 ++addedAddresseeR;
2689 inL.setRevision( modifiedCalendar ); 2691 inL.setRevision( modifiedCalendar );
2690 local->insertAddressee( inL, false ); 2692 local->insertAddressee( inL, false );
2691 inR = inL; 2693 inR = inL;
2692 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2694 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2693 inR.setResource( 0 ); 2695 inR.setResource( 0 );
2694 remote->insertAddressee( inR, false ); 2696 remote->insertAddressee( inR, false );
2695 } 2697 }
2696 } 2698 }
2697 } else { 2699 } else {
2698 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2700 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2699 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2701 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2700 local->removeAddressee( inL ); 2702 local->removeAddressee( inL );
2701 ++deletedAddresseeL; 2703 ++deletedAddresseeL;
2702 } else { 2704 } else {
2703 if ( ! syncManager->mWriteBackExistingOnly ) { 2705 if ( ! syncManager->mWriteBackExistingOnly ) {
2704 ++addedAddresseeR; 2706 ++addedAddresseeR;
2705 inL.setRevision( modifiedCalendar ); 2707 inL.setRevision( modifiedCalendar );
2706 local->insertAddressee( inL, false ); 2708 local->insertAddressee( inL, false );
2707 inR = inL; 2709 inR = inL;
2708 inR.setResource( 0 ); 2710 inR.setResource( 0 );
2709 remote->insertAddressee( inR, false ); 2711 remote->insertAddressee( inR, false );
2710 } 2712 }
2711 } 2713 }
2712 } 2714 }
2713 } 2715 }
2714 } 2716 }
2715 } 2717 }
2716 ++incCounter; 2718 ++incCounter;
2717 } 2719 }
2718 el.clear(); 2720 el.clear();
2719 syncManager->hideProgressBar(); 2721 syncManager->hideProgressBar();
2720 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2722 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2721 // get rid of micro seconds 2723 // get rid of micro seconds
2722 QTime t = mLastAddressbookSync.time(); 2724 QTime t = mLastAddressbookSync.time();
2723 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2725 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2724 addresseeLSync.setRevision( mLastAddressbookSync ); 2726 addresseeLSync.setRevision( mLastAddressbookSync );
2725 addresseeRSync.setRevision( mLastAddressbookSync ); 2727 addresseeRSync.setRevision( mLastAddressbookSync );
2726 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2728 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2727 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2729 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2728 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2730 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2729 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2731 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2730 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2732 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2731 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2733 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2732 addresseeRSync.setNote( "" ) ; 2734 addresseeRSync.setNote( "" ) ;
2733 addresseeLSync.setNote( "" ); 2735 addresseeLSync.setNote( "" );
2734 2736
2735 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2737 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2736 remote->insertAddressee( addresseeRSync, false ); 2738 remote->insertAddressee( addresseeRSync, false );
2737 local->insertAddressee( addresseeLSync, false ); 2739 local->insertAddressee( addresseeLSync, false );
2738 QString mes; 2740 QString mes;
2739 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 ); 2741 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 );
2740 if ( syncManager->mShowSyncSummary ) { 2742 if ( syncManager->mShowSyncSummary ) {
2741 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2743 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2742 } 2744 }
2743 qDebug( mes ); 2745 qDebug( mes );
2744 return syncOK; 2746 return syncOK;
2745} 2747}
2746 2748
2747 2749
2748//this is a overwritten callbackmethods from the syncinterface 2750//this is a overwritten callbackmethods from the syncinterface
2749bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2751bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2750{ 2752{
2751 2753
2752 //pending prepare addresseeview for output 2754 //pending prepare addresseeview for output
2753 //pending detect, if remote file has REV field. if not switch to external sync 2755 //pending detect, if remote file has REV field. if not switch to external sync
2754 mGlobalSyncMode = SYNC_MODE_NORMAL; 2756 mGlobalSyncMode = SYNC_MODE_NORMAL;
2755 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2757 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2756 2758
2757 AddressBook abLocal(filename,"syncContact"); 2759 AddressBook abLocal(filename,"syncContact");
2758 bool syncOK = false; 2760 bool syncOK = false;
2759 if ( abLocal.load() ) { 2761 if ( abLocal.load() ) {
2760 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2762 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2761 bool external = false; 2763 bool external = false;
2762 bool isXML = false; 2764 bool isXML = false;
2763 if ( filename.right(4) == ".xml") { 2765 if ( filename.right(4) == ".xml") {
2764 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2766 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2765 isXML = true; 2767 isXML = true;
2766 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2768 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2767 } else { 2769 } else {
2768 external = !manager->mIsKapiFile; 2770 external = !manager->mIsKapiFile;
2769 if ( external ) { 2771 if ( external ) {
2770 qDebug("Setting vcf mode to external "); 2772 qDebug("Setting vcf mode to external ");
2771 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2773 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2772 AddressBook::Iterator it; 2774 AddressBook::Iterator it;
2773 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2775 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2774 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2776 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2775 (*it).computeCsum( mCurrentSyncDevice ); 2777 (*it).computeCsum( mCurrentSyncDevice );
2776 } 2778 }
2777 } 2779 }
2778 } 2780 }
2779 //AddressBook::Iterator it; 2781 //AddressBook::Iterator it;
2780 //QStringList vcards; 2782 //QStringList vcards;
2781 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2783 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2782 // qDebug("Name %s ", (*it).familyName().latin1()); 2784 // qDebug("Name %s ", (*it).familyName().latin1());
2783 //} 2785 //}
2784 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2786 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2785 if ( syncOK ) { 2787 if ( syncOK ) {
2786 if ( syncManager->mWriteBackFile ) 2788 if ( syncManager->mWriteBackFile )
2787 { 2789 {
2788 if ( external ) 2790 if ( external )
2789 abLocal.removeSyncAddressees( !isXML); 2791 abLocal.removeSyncAddressees( !isXML);
2790 qDebug("Saving remote AB "); 2792 qDebug("Saving remote AB ");
2791 if ( ! abLocal.saveAB()) 2793 if ( ! abLocal.saveAB())
2792 qDebug("Error writing back AB to file "); 2794 qDebug("Error writing back AB to file ");
2793 if ( isXML ) { 2795 if ( isXML ) {
2794 // afterwrite processing 2796 // afterwrite processing
2795 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2797 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2796 } 2798 }
2797 } 2799 }
2798 } 2800 }
2799 setModified(); 2801 setModified();
2800 2802
2801 } 2803 }
2802 if ( syncOK ) 2804 if ( syncOK )
2803 mViewManager->refreshView(); 2805 mViewManager->refreshView();
2804 return syncOK; 2806 return syncOK;
2805 2807
2806} 2808}
2807 2809
2808 2810
2809//this is a overwritten callbackmethods from the syncinterface 2811//this is a overwritten callbackmethods from the syncinterface
2810bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2812bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2811{ 2813{
2812 if ( resource == "phone" ) 2814 if ( resource == "phone" )
2813 return syncPhone(); 2815 return syncPhone();
2814 disableBR( true ); 2816 disableBR( true );
2815 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2817 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2816 2818
2817 AddressBook abLocal( resource,"syncContact"); 2819 AddressBook abLocal( resource,"syncContact");
2818 bool syncOK = false; 2820 bool syncOK = false;
2819 if ( abLocal.load() ) { 2821 if ( abLocal.load() ) {
2820 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2822 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2821 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2823 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2822 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2824 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2823 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2825 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2824 if ( syncOK ) { 2826 if ( syncOK ) {
2825 if ( syncManager->mWriteBackFile ) { 2827 if ( syncManager->mWriteBackFile ) {
2826 abLocal.removeSyncAddressees( false ); 2828 abLocal.removeSyncAddressees( false );
2827 abLocal.saveAB(); 2829 abLocal.saveAB();
2828 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2830 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2829 } 2831 }
2830 } 2832 }
2831 setModified(); 2833 setModified();
2832 } 2834 }
2833 if ( syncOK ) 2835 if ( syncOK )
2834 mViewManager->refreshView(); 2836 mViewManager->refreshView();
2835 disableBR( false ); 2837 disableBR( false );
2836 return syncOK; 2838 return syncOK;
2837 2839
2838} 2840}
2839void KABCore::message( QString m ) 2841void KABCore::message( QString m )
2840{ 2842{
2841 topLevelWidget()->setCaption( m ); 2843 topLevelWidget()->setCaption( m );
2842 mMessageTimer->start( 15000, true ); 2844 mMessageTimer->start( 15000, true );
2843} 2845}
2844bool KABCore::syncPhone() 2846bool KABCore::syncPhone()
2845{ 2847{
2846 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2848 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2847 QString fileName = getPhoneFile(); 2849 QString fileName = getPhoneFile();
2848 if ( !PhoneAccess::readFromPhone( fileName) ) { 2850 if ( !PhoneAccess::readFromPhone( fileName) ) {
2849 message(i18n("Phone access failed!")); 2851 message(i18n("Phone access failed!"));
2850 return false; 2852 return false;
2851 } 2853 }
2852 AddressBook abLocal( fileName,"syncContact"); 2854 AddressBook abLocal( fileName,"syncContact");
2853 bool syncOK = false; 2855 bool syncOK = false;
2854 { 2856 {
2855 abLocal.importFromFile( fileName ); 2857 abLocal.importFromFile( fileName );
2856 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2858 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2857 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2859 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2858 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2860 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2859 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2861 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2860 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2862 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2861 if ( syncOK ) { 2863 if ( syncOK ) {
2862 if ( syncManager->mWriteBackFile ) { 2864 if ( syncManager->mWriteBackFile ) {
2863 abLocal.removeSyncAddressees( true ); 2865 abLocal.removeSyncAddressees( true );
2864 abLocal.saveABphone( fileName ); 2866 abLocal.saveABphone( fileName );
2865 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2867 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2866 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2868 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2867 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2869 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2868 } 2870 }
2869 } 2871 }
2870 setModified(); 2872 setModified();
2871 } 2873 }
2872 if ( syncOK ) 2874 if ( syncOK )
2873 mViewManager->refreshView(); 2875 mViewManager->refreshView();
2874 return syncOK; 2876 return syncOK;
2875} 2877}
2876void KABCore::getFile( bool success ) 2878void KABCore::getFile( bool success )
2877{ 2879{
2878 if ( ! success ) { 2880 if ( ! success ) {
2879 message( i18n("Error receiving file. Nothing changed!") ); 2881 message( i18n("Error receiving file. Nothing changed!") );
2880 return; 2882 return;
2881 } 2883 }
2882 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2884 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2885 if ( count )
2886 setModified( true );
2883 message( i18n("Pi-Sync successful!") ); 2887 message( i18n("Pi-Sync successful!") );
2884 mViewManager->refreshView(); 2888 mViewManager->refreshView();
2885} 2889}
2886void KABCore::syncFileRequest() 2890void KABCore::syncFileRequest()
2887{ 2891{
2888 mAddressBook->export2File( sentSyncFile() ); 2892 mAddressBook->export2File( sentSyncFile() );
2889} 2893}
2890QString KABCore::sentSyncFile() 2894QString KABCore::sentSyncFile()
2891{ 2895{
2892#ifdef DESKTOP_VERSION 2896#ifdef DESKTOP_VERSION
2893 return locateLocal( "tmp", "copysyncab.vcf" ); 2897 return locateLocal( "tmp", "copysyncab.vcf" );
2894#else 2898#else
2895 return QString( "/tmp/copysyncab.vcf" ); 2899 return QString( "/tmp/copysyncab.vcf" );
2896#endif 2900#endif
2897} 2901}
2898 2902
2899void KABCore::setCaptionBack() 2903void KABCore::setCaptionBack()
2900{ 2904{
2901 mMessageTimer->stop(); 2905 mMessageTimer->stop();
2902 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2906 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2903} 2907}
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index a2ff1e9..40089a1 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,215 +1,95 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#else 5#else
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
8#include <qplatinumstyle.h> 8#include <qplatinumstyle.h>
9#include <qmainwindow.h> 9#include <qmainwindow.h>
10#endif 10#endif
11 11
12#include <qtextcodec.h>
12#include <kstandarddirs.h> 13#include <kstandarddirs.h>
13#include <qregexp.h> 14#include <qregexp.h>
14#include <kglobal.h> 15#include <kglobal.h>
15#include <stdio.h> 16#include <stdio.h>
16#include <qdir.h> 17#include <qdir.h>
17#include "kaddressbookmain.h" 18#include "kaddressbookmain.h"
18#include "externalapphandler.h" 19#include "externalapphandler.h"
19#include <libkdepim/kpimglobalprefs.h> 20#include <libkdepim/kpimglobalprefs.h>
20 21
21int main( int argc, char **argv ) 22int main( int argc, char **argv )
22{ 23{
23#ifndef DESKTOP_VERSION 24#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 25 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 26 a.setKeepRunning ();
26#else 27#else
27 QApplication a( argc, argv ); 28 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 29 QApplication::setStyle( new QPlatinumStyle ());
29 QString hdir = QDir::homeDirPath(); 30 QString hdir = QDir::homeDirPath();
30 // there is a bug when creating dirs for WIN 98 31 // there is a bug when creating dirs for WIN 98
31 // it is difficult to fix, because we have no WIN 98 runnung 32 // it is difficult to fix, because we have no WIN 98 runnung
32 // such that we try it to create the dirs at startup here 33 // such that we try it to create the dirs at startup here
33 if ( hdir == "C:\\" ) { // win 98 or ME 34 if ( hdir == "C:\\" ) { // win 98 or ME
34 QDir app_dir; 35 QDir app_dir;
35 if ( !app_dir.exists("C:\\kdepim") ) 36 if ( !app_dir.exists("C:\\kdepim") )
36 app_dir.mkdir ("C:\\kdepim"); 37 app_dir.mkdir ("C:\\kdepim");
37 if ( !app_dir.exists("C:\\kdepim\\apps") ) 38 if ( !app_dir.exists("C:\\kdepim\\apps") )
38 app_dir.mkdir ("C:\\kdepim\\apps"); 39 app_dir.mkdir ("C:\\kdepim\\apps");
39 if ( !app_dir.exists("C:\\kdepim\\config") ) 40 if ( !app_dir.exists("C:\\kdepim\\config") )
40 app_dir.mkdir ("C:\\kdepim\\config"); 41 app_dir.mkdir ("C:\\kdepim\\config");
41 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 42 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
42 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 43 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
43 } 44 }
44#endif 45#endif
45 46
46 bool exitHelp = false; 47 bool exitHelp = false;
47 if ( argc > 1 ) { 48 if ( argc > 1 ) {
48 QString command = argv[1]; 49 QString command = argv[1];
49 if ( command == "-help" ){ 50 if ( command == "-help" ){
50 printf("KA/E command line commands:\n"); 51 printf("KA/E command line commands:\n");
51 printf(" no command: Start KA/E in usual way\n"); 52 printf(" no command: Start KA/E in usual way\n");
52 printf(" -help: This output\n"); 53 printf(" -help: This output\n");
53 printf(" KA/E is exiting now. Bye!\n"); 54 printf(" KA/E is exiting now. Bye!\n");
54 exitHelp = true; 55 exitHelp = true;
55 } 56 }
56 } 57 }
57 if ( ! exitHelp ) { 58 if ( ! exitHelp ) {
58 59
59 KGlobal::setAppName( "kaddressbook" ); 60 KGlobal::setAppName( "kaddressbook" );
60#ifndef DESKTOP_VERSION 61#ifndef DESKTOP_VERSION
61 if ( QApplication::desktop()->width() > 320 ) 62 if ( QApplication::desktop()->width() > 320 )
62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 63 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
63 else 64 else
64 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 65 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
65#else 66#else
66 QString fileName ; 67 QString fileName ;
67 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 68 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
68 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 69 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
69 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 70 QApplication::addLibraryPath ( qApp->applicationDirPath () );
70 71
71#endif 72#endif
72 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 73 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
73 KAddressBookMain m ; 74 KAddressBookMain m ;
74//US MainWindow m; 75//US MainWindow m;
75 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 76 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
76 77
77 { 78 {
78 KPimGlobalPrefs::instance()->setGlobalConfig(); 79 KPimGlobalPrefs::instance()->setGlobalConfig();
79 } 80 }
80#ifndef DESKTOP_VERSION 81#ifndef DESKTOP_VERSION
81 a.showMainWidget( &m ); 82 a.showMainWidget( &m );
82 83
83#else 84#else
84 a.setMainWidget( &m ); 85 a.setMainWidget( &m );
85 m.resize (640, 480 ); 86 m.resize (640, 480 );
86 m.show(); 87 m.show();
87#endif 88#endif
88 a.exec(); 89 a.exec();
89 90
90 91
91 } 92 }
92 qDebug("KA: Bye! "); 93 qDebug("KA: Bye! ");
93} 94}
94 95
95/*
96#include <stdlib.h>
97
98#include <qstring.h>
99
100#include <kabc/stdaddressbook.h>
101#include <kaboutdata.h>
102#include <kcmdlineargs.h>
103#include <kcrash.h>
104#include <kdebug.h>
105#include <klocale.h>
106#include <kstartupinfo.h>
107#include <kuniqueapplication.h>
108#include <kwin.h>
109
110#include "kaddressbookmain.h"
111#include "kabcore.h"
112
113extern "C" {
114
115void crashHandler( int )
116{
117 KABC::StdAddressBook::handleCrash();
118 ::exit( 0 );
119}
120
121}
122
123class KAddressBookApp : public KUniqueApplication {
124 public:
125 KAddressBookApp() : mMainWin( 0 ) {}
126 ~KAddressBookApp() {}
127
128 int newInstance();
129
130 private:
131 KAddressBookMain *mMainWin;
132};
133
134int KAddressBookApp::newInstance()
135{
136 if ( isRestored() ) {
137 // There can only be one main window
138 if ( KMainWindow::canBeRestored( 1 ) ) {
139 mMainWin = new KAddressBookMain;
140 mMainWin->show();
141 mMainWin->restore( 1 );
142 }
143 } else {
144 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
145
146 QCString addrStr = args->getOption( "addr" );
147 QCString uidStr = args->getOption( "uid" );
148 QString addr;
149 QString uid;
150 if ( !addrStr.isEmpty() )
151 addr = QString::fromLocal8Bit( addrStr );
152 if ( !uidStr.isEmpty() )
153 uid = QString::fromLocal8Bit( uidStr );
154
155
156 if ( args->isSet( "editor-only" ) ) {
157 if ( !mMainWin )
158 mMainWin = new KAddressBookMain;
159 KStartupInfo::appStarted();
160 mMainWin->hide();
161 } else {
162 if ( mMainWin ) {
163 mMainWin->show();
164 KWin::setActiveWindow( mMainWin->winId() );
165 } else {
166 mMainWin = new KAddressBookMain;
167 mMainWin->show();
168 }
169 }
170 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
171 if ( !addr.isEmpty() )
172 mMainWin->addEmail( addr );
173
174 if ( !uid.isEmpty() )
175 mMainWin->showContactEditor( uid );
176 if ( args->isSet( "new-contact" ) ) {
177 mMainWin->newContact();
178 }
179 }
180
181 KCrash::setEmergencySaveFunction( crashHandler );
182
183 return 0;
184}
185
186// the dummy argument is required, because KMail apparently sends an empty
187// argument.
188static KCmdLineOptions kmoptions[] =
189{
190 { "a", 0 , 0 },
191 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
192 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
193 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
194 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
195 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
196 { 0, 0, 0}
197};
198
199int main( int argc, char *argv[] )
200{
201 KLocale::setMainCatalogue( "kaddressbook" );
202
203 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
204 KCmdLineArgs::addCmdLineOptions( kmoptions );
205 KUniqueApplication::addCmdLineOptions();
206
207 if ( !KAddressBookApp::start() )
208 exit( 0 );
209
210 KAddressBookApp app;
211 KGlobal::locale()->insertCatalogue( "libkdepim" );
212
213 return app.exec();
214}
215*/
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index c74f8cf..5fb4163 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -1,371 +1,373 @@
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 <qheader.h> 24#include <qheader.h>
25#include <qiconset.h> 25#include <qiconset.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qdragobject.h> 27#include <qdragobject.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qbrush.h> 30#include <qbrush.h>
31#include <qevent.h> 31#include <qevent.h>
32 32
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobalsettings.h> 34#include <kglobalsettings.h>
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kconfig.h> 37#include <kconfig.h>
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kurl.h> 39#include <kurl.h>
40 40
41#include "kaddressbooktableview.h" 41#include "kaddressbooktableview.h"
42 42
43#include "contactlistview.h" 43#include "contactlistview.h"
44 44
45///////////////////////////////// 45/////////////////////////////////
46// DynamicTip Methods 46// DynamicTip Methods
47 47
48DynamicTip::DynamicTip( ContactListView *parent) 48DynamicTip::DynamicTip( ContactListView *parent)
49 : QToolTip( parent ) 49 : QToolTip( parent )
50{ 50{
51} 51}
52 52
53void DynamicTip::maybeTip( const QPoint &pos ) 53void DynamicTip::maybeTip( const QPoint &pos )
54{ 54{
55 static bool ishidden = true; 55 static bool ishidden = true;
56 if (!parentWidget()->inherits( "ContactListView" )) 56 if (!parentWidget()->inherits( "ContactListView" ))
57 return; 57 return;
58 58
59 ContactListView *plv = (ContactListView*)parentWidget(); 59 ContactListView *plv = (ContactListView*)parentWidget();
60 if (!plv->tooltips()) 60 if (!plv->tooltips())
61 return; 61 return;
62 62
63 QPoint posVp = plv->viewport()->pos(); 63 QPoint posVp = plv->viewport()->pos();
64 64
65 QListViewItem *lvi = plv->itemAt( pos - posVp ); 65 QListViewItem *lvi = plv->itemAt( pos - posVp );
66 if (!lvi) 66 if (!lvi)
67 return; 67 return;
68 68
69#ifndef KAB_EMBEDDED 69#ifndef KAB_EMBEDDED
70 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); 70 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi);
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72 ContactListViewItem *plvi = (ContactListViewItem*)(lvi); 72 ContactListViewItem *plvi = (ContactListViewItem*)(lvi);
73#endif //KAB_EMBEDDED 73#endif //KAB_EMBEDDED
74 74
75 if (!plvi) 75 if (!plvi)
76 return; 76 return;
77 77
78 if (ishidden) { 78 if (ishidden) {
79 QString s; 79 QString s;
80 QRect r = plv->itemRect( lvi ); 80 QRect r = plv->itemRect( lvi );
81 r.moveBy( posVp.x(), posVp.y() ); 81 r.moveBy( posVp.x(), posVp.y() );
82 82
83 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() 83 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width()
84 // << "," << r.height() << endl; 84 // << "," << r.height() << endl;
85 85
86 KABC::Addressee a = plvi->addressee(); 86 KABC::Addressee a = plvi->addressee();
87 if (a.isEmpty()) 87 if (a.isEmpty())
88 return; 88 return;
89 89
90 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) 90 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel())
91 .arg(a.formattedName()); 91 .arg(a.formattedName());
92 92
93 s += '\n'; 93 s += '\n';
94 s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) 94 s += i18n("label: value", "%1: %2").arg(a.organizationLabel())
95 .arg(a.organization()); 95 .arg(a.organization());
96 96
97 QString notes = a.note().stripWhiteSpace(); 97 QString notes = a.note().stripWhiteSpace();
98 if ( !notes.isEmpty() ) { 98 if ( !notes.isEmpty() ) {
99 notes += '\n'; 99 notes += '\n';
100 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); 100 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel());
101 QFontMetrics fm( font() ); 101 QFontMetrics fm( font() );
102 102
103 // Begin word wrap code based on QMultiLineEdit code 103 // Begin word wrap code based on QMultiLineEdit code
104 int i = 0; 104 int i = 0;
105 bool doBreak = false; 105 bool doBreak = false;
106 int linew = 0; 106 int linew = 0;
107 int lastSpace = -1; 107 int lastSpace = -1;
108 int a = 0; 108 int a = 0;
109 int lastw = 0; 109 int lastw = 0;
110 110
111 while ( i < int(notes.length()) ) { 111 while ( i < int(notes.length()) ) {
112 doBreak = FALSE; 112 doBreak = FALSE;
113 if ( notes[i] != '\n' ) 113 if ( notes[i] != '\n' )
114 linew += fm.width( notes[i] ); 114 linew += fm.width( notes[i] );
115 115
116 if ( lastSpace >= a && notes[i] != '\n' ) 116 if ( lastSpace >= a && notes[i] != '\n' )
117 if (linew >= parentWidget()->width()) { 117 if (linew >= parentWidget()->width()) {
118 doBreak = TRUE; 118 doBreak = TRUE;
119 if ( lastSpace > a ) { 119 if ( lastSpace > a ) {
120 i = lastSpace; 120 i = lastSpace;
121 linew = lastw; 121 linew = lastw;
122 } 122 }
123 else 123 else
124 i = QMAX( a, i-1 ); 124 i = QMAX( a, i-1 );
125 } 125 }
126 126
127 if ( notes[i] == '\n' || doBreak ) { 127 if ( notes[i] == '\n' || doBreak ) {
128 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; 128 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n";
129 129
130 a = i + 1; 130 a = i + 1;
131 lastSpace = a; 131 lastSpace = a;
132 linew = 0; 132 linew = 0;
133 } 133 }
134 134
135 if ( notes[i].isSpace() ) { 135 if ( notes[i].isSpace() ) {
136 lastSpace = i; 136 lastSpace = i;
137 lastw = linew; 137 lastw = linew;
138 } 138 }
139 139
140 if ( lastSpace <= a ) { 140 if ( lastSpace <= a ) {
141 lastw = linew; 141 lastw = linew;
142 } 142 }
143 143
144 ++i; 144 ++i;
145 } 145 }
146 } 146 }
147 147
148 tip( r, s ); 148 tip( r, s );
149 } 149 }
150 else 150 else
151 hide(); 151 hide();
152 ishidden = !ishidden; 152 ishidden = !ishidden;
153 153
154} 154}
155 155
156/////////////////////////// 156///////////////////////////
157// ContactListViewItem Methods 157// ContactListViewItem Methods
158 158
159ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, 159ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
160 ContactListView *parent, 160 ContactListView *parent,
161 KABC::AddressBook *doc, 161 KABC::AddressBook *doc,
162 const KABC::Field::List &fields ) 162 const KABC::Field::List &fields )
163 : KListViewItem(parent), mAddressee(a), mFields( fields ), 163 : KListViewItem(parent), mAddressee(a), mFields( fields ),
164 parentListView( parent ), mDocument(doc) 164 parentListView( parent ), mDocument(doc)
165{ 165{
166 refresh(); 166 refresh();
167} 167}
168 168
169QString ContactListViewItem::key(int column, bool ascending) const 169QString ContactListViewItem::key(int column, bool ascending) const
170{ 170{
171#ifndef DESKTOP_VERSION
171 int lan = KGlobal::locale()->language(); 172 int lan = KGlobal::locale()->language();
172 //qDebug("language %d ", lan); 173 //qDebug("language %d ", lan);
173 if ( lan == 1 ) { //GERMAN 174 if ( lan == 1 ) { //GERMAN
174 QString ret = QListViewItem::key(column, ascending).utf8(); 175 QString ret = QListViewItem::key(column, ascending).utf8();
175 int start = -1; 176 int start = -1;
176 while ( (start = ret.find( 'ä', start+1)) > 0 ) { 177 while ( (start = ret.find( 'ä', start+1)) > 0 ) {
177 ret.at(start-1) = 'a'; 178 ret.at(start-1) = 'a';
178 } 179 }
179 start = -1; 180 start = -1;
180 while ( (start = ret.find( 'ö', start+1)) > 0 ) { 181 while ( (start = ret.find( 'ö', start+1)) > 0 ) {
181 ret.at(start-1) = 'o'; 182 ret.at(start-1) = 'o';
182 } 183 }
183 start = -1; 184 start = -1;
184 while ( (start = ret.find( 'ü', start+1)) > 0 ) { 185 while ( (start = ret.find( 'ü', start+1)) > 0 ) {
185 ret.at(start-1) = 'o'; 186 ret.at(start-1) = 'o';
186 } 187 }
187 start = -1; 188 start = -1;
188 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 189 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
189 ret.at(start-1) = 's'; 190 ret.at(start-1) = 's';
190 } 191 }
191 //qDebug("conv string %s ", ret.latin1()); 192 //qDebug("conv string %s ", ret.latin1());
192 193
193 return ret; 194 return ret;
194 195
195 } 196 }
196 else 197 else
198#endif
197 return QListViewItem::key(column, ascending).lower(); 199 return QListViewItem::key(column, ascending).lower();
198} 200}
199 201
200void ContactListViewItem::paintCell(QPainter * p, 202void ContactListViewItem::paintCell(QPainter * p,
201 const QColorGroup & cg, 203 const QColorGroup & cg,
202 int column, 204 int column,
203 int width, 205 int width,
204 int align) 206 int align)
205{ 207{
206 KListViewItem::paintCell(p, cg, column, width, align); 208 KListViewItem::paintCell(p, cg, column, width, align);
207 209
208 if ( !p ) 210 if ( !p )
209 return; 211 return;
210 212
211 if (parentListView->singleLine()) { 213 if (parentListView->singleLine()) {
212 p->setPen( parentListView->alternateColor() ); 214 p->setPen( parentListView->alternateColor() );
213 p->drawLine( 0, height() - 1, width, height() - 1 ); 215 p->drawLine( 0, height() - 1, width, height() - 1 );
214 } 216 }
215} 217}
216 218
217 219
218ContactListView *ContactListViewItem::parent() 220ContactListView *ContactListViewItem::parent()
219{ 221{
220 return parentListView; 222 return parentListView;
221} 223}
222 224
223 225
224void ContactListViewItem::refresh() 226void ContactListViewItem::refresh()
225{ 227{
226 // Update our addressee, since it may have changed else were 228 // Update our addressee, since it may have changed else were
227 mAddressee = mDocument->findByUid(mAddressee.uid()); 229 mAddressee = mDocument->findByUid(mAddressee.uid());
228 if (mAddressee.isEmpty()) 230 if (mAddressee.isEmpty())
229 return; 231 return;
230 232
231 int i = 0; 233 int i = 0;
232 KABC::Field::List::ConstIterator it; 234 KABC::Field::List::ConstIterator it;
233 for( it = mFields.begin(); it != mFields.end(); ++it ) { 235 for( it = mFields.begin(); it != mFields.end(); ++it ) {
234 setText( i++, (*it)->value( mAddressee ) ); 236 setText( i++, (*it)->value( mAddressee ) );
235 } 237 }
236} 238}
237 239
238/////////////////////////////// 240///////////////////////////////
239// ContactListView 241// ContactListView
240 242
241ContactListView::ContactListView(KAddressBookTableView *view, 243ContactListView::ContactListView(KAddressBookTableView *view,
242 KABC::AddressBook* /* doc */, 244 KABC::AddressBook* /* doc */,
243 QWidget *parent, 245 QWidget *parent,
244 const char *name ) 246 const char *name )
245 : KListView( parent, name ), 247 : KListView( parent, name ),
246 pabWidget( view ), 248 pabWidget( view ),
247 oldColumn( 0 ) 249 oldColumn( 0 )
248{ 250{
249 mABackground = true; 251 mABackground = true;
250 mSingleLine = false; 252 mSingleLine = false;
251 mToolTips = true; 253 mToolTips = true;
252#ifndef KAB_EMBEDDED 254#ifndef KAB_EMBEDDED
253 mAlternateColor = KGlobalSettings::alternateBackgroundColor(); 255 mAlternateColor = KGlobalSettings::alternateBackgroundColor();
254#else //KAB_EMBEDDED 256#else //KAB_EMBEDDED
255 mAlternateColor = QColor(240, 240, 240); 257 mAlternateColor = QColor(240, 240, 240);
256#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
257 259
258 setAlternateBackgroundEnabled(mABackground); 260 setAlternateBackgroundEnabled(mABackground);
259 setAcceptDrops( true ); 261 setAcceptDrops( true );
260 viewport()->setAcceptDrops( true ); 262 viewport()->setAcceptDrops( true );
261 setAllColumnsShowFocus( true ); 263 setAllColumnsShowFocus( true );
262 setShowSortIndicator(true); 264 setShowSortIndicator(true);
263 265
264 setSelectionModeExt( KListView::Extended ); 266 setSelectionModeExt( KListView::Extended );
265 setDropVisualizer(false); 267 setDropVisualizer(false);
266 // setFrameStyle(QFrame::NoFrame); 268 // setFrameStyle(QFrame::NoFrame);
267 //setLineWidth ( 0 ); 269 //setLineWidth ( 0 );
268 //setMidLineWidth ( 0 ); 270 //setMidLineWidth ( 0 );
269 //setMargin ( 0 ); 271 //setMargin ( 0 );
270#ifndef KAB_EMBEDDED 272#ifndef KAB_EMBEDDED
271 connect(this, SIGNAL(dropped(QDropEvent*)), 273 connect(this, SIGNAL(dropped(QDropEvent*)),
272 this, SLOT(itemDropped(QDropEvent*))); 274 this, SLOT(itemDropped(QDropEvent*)));
273#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
274 276
275 277
276 new DynamicTip( this ); 278 new DynamicTip( this );
277} 279}
278 280
279void ContactListView::setAlternateColor(const QColor &m_AlternateColor) 281void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
280{ 282{
281 mAlternateColor = m_AlternateColor; 283 mAlternateColor = m_AlternateColor;
282} 284}
283 285
284void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 286void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
285{ 287{
286 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); 288 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
287 289
288 // Get the brush, which will have the background pixmap if there is one. 290 // Get the brush, which will have the background pixmap if there is one.
289 if (b.pixmap()) 291 if (b.pixmap())
290 { 292 {
291 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), 293 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
292 *(b.pixmap()), 294 *(b.pixmap()),
293 rect.left() + contentsX(), 295 rect.left() + contentsX(),
294 rect.top() + contentsY() ); 296 rect.top() + contentsY() );
295 } 297 }
296 298
297 else 299 else
298 { 300 {
299 // Do a normal paint 301 // Do a normal paint
300 KListView::paintEmptyArea(p, rect); 302 KListView::paintEmptyArea(p, rect);
301 } 303 }
302} 304}
303 305
304void ContactListView::contentsMousePressEvent(QMouseEvent* e) 306void ContactListView::contentsMousePressEvent(QMouseEvent* e)
305{ 307{
306 presspos = e->pos(); 308 presspos = e->pos();
307 KListView::contentsMousePressEvent(e); 309 KListView::contentsMousePressEvent(e);
308} 310}
309 311
310 312
311// To initiate a drag operation 313// To initiate a drag operation
312void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) 314void ContactListView::contentsMouseMoveEvent( QMouseEvent *e )
313{ 315{
314 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { 316 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) {
315 emit startAddresseeDrag(); 317 emit startAddresseeDrag();
316 } 318 }
317 else 319 else
318 KListView::contentsMouseMoveEvent( e ); 320 KListView::contentsMouseMoveEvent( e );
319} 321}
320 322
321bool ContactListView::acceptDrag(QDropEvent *e) const 323bool ContactListView::acceptDrag(QDropEvent *e) const
322{ 324{
323#ifndef KAB_EMBEDDED 325#ifndef KAB_EMBEDDED
324 return QTextDrag::canDecode(e); 326 return QTextDrag::canDecode(e);
325#else //KAB_EMBEDDED 327#else //KAB_EMBEDDED
326qDebug("ContactListView::acceptDrag has to be fixed"); 328qDebug("ContactListView::acceptDrag has to be fixed");
327 return false; 329 return false;
328#endif //KAB_EMBEDDED 330#endif //KAB_EMBEDDED
329} 331}
330 332
331void ContactListView::itemDropped(QDropEvent *e) 333void ContactListView::itemDropped(QDropEvent *e)
332{ 334{
333 contentsDropEvent(e); 335 contentsDropEvent(e);
334} 336}
335 337
336void ContactListView::contentsDropEvent( QDropEvent *e ) 338void ContactListView::contentsDropEvent( QDropEvent *e )
337{ 339{
338 emit addresseeDropped(e); 340 emit addresseeDropped(e);
339} 341}
340 342
341void ContactListView::setAlternateBackgroundEnabled(bool enabled) 343void ContactListView::setAlternateBackgroundEnabled(bool enabled)
342{ 344{
343 mABackground = enabled; 345 mABackground = enabled;
344 346
345 if (mABackground) 347 if (mABackground)
346 { 348 {
347 setAlternateBackground(mAlternateColor); 349 setAlternateBackground(mAlternateColor);
348 } 350 }
349 else 351 else
350 { 352 {
351 setAlternateBackground(QColor()); 353 setAlternateBackground(QColor());
352 } 354 }
353} 355}
354 356
355void ContactListView::setBackgroundPixmap(const QString &filename) 357void ContactListView::setBackgroundPixmap(const QString &filename)
356{ 358{
357 if (filename.isEmpty()) 359 if (filename.isEmpty())
358 { 360 {
359 unsetPalette(); 361 unsetPalette();
360 } 362 }
361 else 363 else
362 { 364 {
363 qDebug("ContactListView::setBackgroundPixmap has to be verified"); 365 qDebug("ContactListView::setBackgroundPixmap has to be verified");
364//US setPaletteBackgroundPixmap(QPixmap(filename)); 366//US setPaletteBackgroundPixmap(QPixmap(filename));
365 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); 367 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename));
366 } 368 }
367 369
368} 370}
369#ifndef KAB_EMBEDDED 371#ifndef KAB_EMBEDDED
370#include "contactlistview.moc" 372#include "contactlistview.moc"
371#endif //KAB_EMBEDDED 373#endif //KAB_EMBEDDED
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index e938e4e..1fcc977 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,580 +1,581 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KPIM::AddresseeView av ( &dia ); 90 KPIM::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 } 97 }
98 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
130 e << n.mid(7); 130 e << n.mid(7);
131#endif 131#endif
132 132
133 } 133 }
134 134
135 135
136#ifndef KORG_NODCOP 136#ifndef KORG_NODCOP
137 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 137 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
138 QString tmpStr; 138 QString tmpStr;
139 if (n.startsWith("mailto:")) { 139 if (n.startsWith("mailto:")) {
140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
141 //emit showIncidence(n); 141 //emit showIncidence(n);
142 return; 142 return;
143 } else if (n.startsWith("uid:")) { 143 } else if (n.startsWith("uid:")) {
144 DCOPClient *client = KApplication::kApplication()->dcopClient(); 144 DCOPClient *client = KApplication::kApplication()->dcopClient();
145 const QByteArray noParamData; 145 const QByteArray noParamData;
146 const QByteArray paramData; 146 const QByteArray paramData;
147 QByteArray replyData; 147 QByteArray replyData;
148 QCString replyTypeStr; 148 QCString replyTypeStr;
149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
150 bool foundAbbrowser = PING_ABBROWSER; 150 bool foundAbbrowser = PING_ABBROWSER;
151 151
152 if (foundAbbrowser) { 152 if (foundAbbrowser) {
153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
154 //client->send("kaddressbook","KAddressBookIface", 154 //client->send("kaddressbook","KAddressBookIface",
155 QDataStream arg(paramData, IO_WriteOnly); 155 QDataStream arg(paramData, IO_WriteOnly);
156 arg << n.mid(6); 156 arg << n.mid(6);
157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
158 return; 158 return;
159 } else { 159 } else {
160 /* 160 /*
161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
162 We start it without its main interface 162 We start it without its main interface
163 */ 163 */
164 KIconLoader* iconLoader = new KIconLoader(); 164 KIconLoader* iconLoader = new KIconLoader();
165 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 165 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
166 ActionManager::setStartedKAddressBook(true); 166 ActionManager::setStartedKAddressBook(true);
167 tmpStr = "kaddressbook --editor-only --uid "; 167 tmpStr = "kaddressbook --editor-only --uid ";
168 tmpStr += KProcess::quote(n.mid(6)); 168 tmpStr += KProcess::quote(n.mid(6));
169 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 169 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
170 return; 170 return;
171 } 171 }
172 } else { 172 } else {
173 //QTextBrowser::setSource(n); 173 //QTextBrowser::setSource(n);
174 } 174 }
175#endif 175#endif
176} 176}
177 177
178void KOEventViewer::addTag(const QString & tag,const QString & text) 178void KOEventViewer::addTag(const QString & tag,const QString & text)
179{ 179{
180 int number=text.contains("\n"); 180 int number=text.contains("\n");
181 QString str = "<" + tag + ">"; 181 QString str = "<" + tag + ">";
182 QString tmpText=text; 182 QString tmpText=text;
183 QString tmpStr=str; 183 QString tmpStr=str;
184 if(number !=-1) 184 if(number !=-1)
185 { 185 {
186 if (number > 0) { 186 if (number > 0) {
187 int pos=0; 187 int pos=0;
188 QString tmp; 188 QString tmp;
189 for(int i=0;i<=number;i++) { 189 for(int i=0;i<=number;i++) {
190 pos=tmpText.find("\n"); 190 pos=tmpText.find("\n");
191 tmp=tmpText.left(pos); 191 tmp=tmpText.left(pos);
192 tmpText=tmpText.right(tmpText.length()-pos-1); 192 tmpText=tmpText.right(tmpText.length()-pos-1);
193 tmpStr+=tmp+"<br>"; 193 tmpStr+=tmp+"<br>";
194 } 194 }
195 } 195 }
196 else tmpStr += tmpText; 196 else tmpStr += tmpText;
197 tmpStr+="</" + tag + ">"; 197 tmpStr+="</" + tag + ">";
198 mText.append(tmpStr); 198 mText.append(tmpStr);
199 } 199 }
200 else 200 else
201 { 201 {
202 str += text + "</" + tag + ">"; 202 str += text + "</" + tag + ">";
203 mText.append(str); 203 mText.append(str);
204 } 204 }
205} 205}
206 206
207void KOEventViewer::setColorMode( int m ) 207void KOEventViewer::setColorMode( int m )
208{ 208{
209 mColorMode = m; 209 mColorMode = m;
210} 210}
211void KOEventViewer::appendEvent(Event *event, int mode ) 211void KOEventViewer::appendEvent(Event *event, int mode )
212{ 212{
213 mMailSubject = ""; 213 mMailSubject = "";
214 mCurrentIncidence = event; 214 mCurrentIncidence = event;
215 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 215 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
216 topLevelWidget()->setCaption(i18n("Event Viewer")); 216 topLevelWidget()->setCaption(i18n("Event Viewer"));
217 if ( mode == 0 ) { 217 if ( mode == 0 ) {
218 addTag("h2",event->summary()); 218 addTag("h2",event->summary());
219 } 219 }
220 else { 220 else {
221 if ( mColorMode == 1 ) { 221 if ( mColorMode == 1 ) {
222 mText +="<font color=\"#00A000\">"; 222 mText +="<font color=\"#00A000\">";
223 } 223 }
224 if ( mColorMode == 2 ) { 224 if ( mColorMode == 2 ) {
225 mText +="<font color=\"#C00000\">"; 225 mText +="<font color=\"#C00000\">";
226 } 226 }
227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
228 if ( mode == 1 ) { 228 if ( mode == 1 ) {
229 addTag("h2",i18n( "Local: " ) +event->summary()); 229 addTag("h2",i18n( "Local: " ) +event->summary());
230 } else { 230 } else {
231 addTag("h2",i18n( "Remote: " ) +event->summary()); 231 addTag("h2",i18n( "Remote: " ) +event->summary());
232 } 232 }
233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
234 if ( mColorMode ) 234 if ( mColorMode )
235 mText += "</font>"; 235 mText += "</font>";
236 } 236 }
237 mMailSubject += i18n( "Meeting " )+ event->summary(); 237 mMailSubject += i18n( "Meeting " )+ event->summary();
238 if (event->cancelled ()) { 238 if (event->cancelled ()) {
239 mText +="<font color=\"#B00000\">"; 239 mText +="<font color=\"#B00000\">";
240 addTag("i",i18n("This event has been cancelled!")); 240 addTag("i",i18n("This event has been cancelled!"));
241 mText.append("<br>"); 241 mText.append("<br>");
242 mText += "</font>"; 242 mText += "</font>";
243 mMailSubject += i18n("(cancelled)"); 243 mMailSubject += i18n("(cancelled)");
244 } 244 }
245 if (!event->location().isEmpty()) { 245 if (!event->location().isEmpty()) {
246 addTag("b",i18n("Location: ")); 246 addTag("b",i18n("Location: "));
247 mText.append(event->location()+"<br>"); 247 mText.append(event->location()+"<br>");
248 mMailSubject += i18n(" at ") + event->location(); 248 mMailSubject += i18n(" at ") + event->location();
249 } 249 }
250 if (event->doesFloat()) { 250 if (event->doesFloat()) {
251 if (event->isMultiDay()) { 251 if (event->isMultiDay()) {
252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
253 .arg(event->dtStartDateStr(shortDate)) 253 .arg(event->dtStartDateStr(shortDate))
254 .arg(event->dtEndDateStr(shortDate))); 254 .arg(event->dtEndDateStr(shortDate)));
255 } else { 255 } else {
256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
257 } 257 }
258 } else { 258 } else {
259 if (event->isMultiDay()) { 259 if (event->isMultiDay()) {
260 mText.append(i18n("<p><b>From:</b> %1</p> ") 260 mText.append(i18n("<p><b>From:</b> %1</p> ")
261 .arg(event->dtStartStr( shortDate))); 261 .arg(event->dtStartStr( shortDate)));
262 mText.append(i18n("<p><b>To:</b> %1</p>") 262 mText.append(i18n("<p><b>To:</b> %1</p>")
263 .arg(event->dtEndStr(shortDate))); 263 .arg(event->dtEndStr(shortDate)));
264 } else { 264 } else {
265 mText.append(i18n("<p><b>On:</b> %1</p> ") 265 mText.append(i18n("<p><b>On:</b> %1</p> ")
266 .arg(event->dtStartDateStr( shortDate ))); 266 .arg(event->dtStartDateStr( shortDate )));
267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
268 .arg(event->dtStartTimeStr()) 268 .arg(event->dtStartTimeStr())
269 .arg(event->dtEndTimeStr())); 269 .arg(event->dtEndTimeStr()));
270 } 270 }
271 } 271 }
272 272
273 if (event->recurrence()->doesRecur()) { 273 if (event->recurrence()->doesRecur()) {
274 274
275 QString recurText = event->recurrence()->recurrenceText(); 275 QString recurText = event->recurrence()->recurrenceText();
276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
277 bool last; 277 bool last;
278 QDate start = QDate::currentDate(); 278 QDate start = QDate::currentDate();
279 QDate next; 279 QDate next;
280 next = event->recurrence()->getPreviousDate( start , &last ); 280 next = event->recurrence()->getPreviousDate( start , &last );
281 if ( !last ) { 281 if ( !last ) {
282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
283 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 283 addTag("p",i18n("<b>Next recurrence is on:</b>") );
284 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 284 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
285 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 285 QDateTime nextdt = QDateTime( next, event->dtStart().time());
286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
287 287
288 } else { 288 } else {
289 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 289 addTag("p",i18n("<b>Last recurrence was on:</b>") );
290 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 290 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
291 } 291 }
292 } else { 292 } else {
293 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
294 294
295 } 295 }
296 296
297 297
298 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
299 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
300 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
301 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
302 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
305 //addTag("p",s); 305 //addTag("p",s);
306 } 306 }
307 307
308 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
309 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
310 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
311 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
312 addTag("p",event->description()); 312 addTag("p",event->description());
313 } 313 }
314 314
315 formatCategories(event); 315 formatCategories(event);
316 316
317 formatReadOnly(event); 317 formatReadOnly(event);
318 formatAttendees(event); 318 formatAttendees(event);
319 319
320 setText(mText); 320 setText(mText);
321 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
322 322
323} 323}
324 324
325void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
326{ 326{
327 mMailSubject = ""; 327 mMailSubject = "";
328 mCurrentIncidence = event; 328 mCurrentIncidence = event;
329 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
330 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
331 if (mode == 0 ) 331 if (mode == 0 )
332 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
333 else { 333 else {
334 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
335 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
336 } 336 }
337 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350 if (event->cancelled ()) { 350 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 351 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 352 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 353 mText.append("<br>");
354 mText += "</font>"; 354 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 355 mMailSubject += i18n("(cancelled)");
356 } 356 }
357 357
358 if (!event->location().isEmpty()) { 358 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 359 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 360 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 361 mMailSubject += i18n(" at ") + event->location();
362 } 362 }
363 if (event->hasDueDate()) { 363 if (event->hasDueDate()) {
364 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 364 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
365 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 365 mMailSubject += i18n(" - " )+event->dtDueStr( true );
366 } 366 }
367 addTag("b",i18n("Access: ")); 367 addTag("b",i18n("Access: "));
368 mText.append(event->secrecyStr()+"<br>"); 368 mText.append(event->secrecyStr()+"<br>");
369 if (!event->description().isEmpty()) { 369 if (!event->description().isEmpty()) {
370 addTag("p",i18n("<b>Details: </b>")); 370 addTag("p",i18n("<b>Details: </b>"));
371 addTag("p",event->description()); 371 addTag("p",event->description());
372 } 372 }
373 373
374 formatCategories(event); 374 formatCategories(event);
375 375
376 mText.append(i18n("<p><b>Priority:</b> %2</p>") 376 mText.append(i18n("<p><b>Priority:</b> %2</p>")
377 .arg(QString::number(event->priority()))); 377 .arg(QString::number(event->priority())));
378 378
379 mText.append(i18n("<p><i>%1 % completed</i></p>") 379 mText.append(i18n("<p><i>%1 % completed</i></p>")
380 .arg(event->percentComplete())); 380 .arg(event->percentComplete()));
381 381
382 formatReadOnly(event); 382 formatReadOnly(event);
383 formatAttendees(event); 383 formatAttendees(event);
384 384
385 setText(mText); 385 setText(mText);
386} 386}
387 387
388void KOEventViewer::formatCategories(Incidence *event) 388void KOEventViewer::formatCategories(Incidence *event)
389{ 389{
390 if (!event->categoriesStr().isEmpty()) { 390 if (!event->categoriesStr().isEmpty()) {
391 if (event->categories().count() == 1) { 391 if (event->categories().count() == 1) {
392 addTag("h3",i18n("Category")); 392 addTag("h3",i18n("Category"));
393 } else { 393 } else {
394 addTag("h3",i18n("Categories")); 394 addTag("h3",i18n("Categories"));
395 } 395 }
396 addTag("p",event->categoriesStr()); 396 addTag("p",event->categoriesStr());
397 } 397 }
398} 398}
399void KOEventViewer::formatAttendees(Incidence *event) 399void KOEventViewer::formatAttendees(Incidence *event)
400{ 400{
401 QPtrList<Attendee> attendees = event->attendees(); 401 QPtrList<Attendee> attendees = event->attendees();
402 if (attendees.count()) { 402 if (attendees.count()) {
403 403
404 404
405 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 405 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
406 addTag("h3",i18n("Organizer")); 406 addTag("h3",i18n("Organizer"));
407 mText.append("<ul><li>"); 407 mText.append("<ul><li>");
408#ifndef KORG_NOKABC 408#ifndef KORG_NOKABC
409 409
410#ifdef DESKTOP_VERSION 410#ifdef DESKTOP_VERSION
411 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 411 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
412 KABC::Addressee::List addressList; 412 KABC::Addressee::List addressList;
413 addressList = add_book->findByEmail(event->organizer()); 413 addressList = add_book->findByEmail(event->organizer());
414 KABC::Addressee o = addressList.first(); 414 KABC::Addressee o = addressList.first();
415 if (!o.isEmpty() && addressList.size()<2) { 415 if (!o.isEmpty() && addressList.size()<2) {
416 mText += "<a href=\"uid:" + o.uid() + "\">"; 416 mText += "<a href=\"uid:" + o.uid() + "\">";
417 mText += o.formattedName(); 417 mText += o.formattedName();
418 mText += "</a>\n"; 418 mText += "</a>\n";
419 } else { 419 } else {
420 mText.append(event->organizer()); 420 mText.append(event->organizer());
421 } 421 }
422#else //DESKTOP_VERSION 422#else //DESKTOP_VERSION
423 mText += "<a href=\"uid:organizer\">"; 423 mText += "<a href=\"uid:organizer\">";
424 mText += event->organizer(); 424 mText += event->organizer();
425 mText += "</a>\n"; 425 mText += "</a>\n";
426#endif //DESKTOP_VERSION 426#endif //DESKTOP_VERSION
427 427
428 428
429#else 429#else
430 mText.append(event->organizer()); 430 mText.append(event->organizer());
431#endif 431#endif
432 432
433 if (iconPath) { 433 if (iconPath) {
434 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 434 mText += " <a href=\"mailto:" + event->organizer() + "\">";
435 mText += "<IMG src=\"" + iconPath + "\">"; 435 mText += "<IMG src=\"" + iconPath + "\">";
436 mText += "</a>\n"; 436 mText += "</a>\n";
437 } 437 }
438 mText.append("</li></ul>"); 438 mText.append("</li></ul>");
439 439
440 addTag("h3",i18n("Attendees")); 440 addTag("h3",i18n("Attendees"));
441 Attendee *a; 441 Attendee *a;
442 mText.append("<ul>"); 442 mText.append("<ul>");
443 for(a=attendees.first();a;a=attendees.next()) { 443 for(a=attendees.first();a;a=attendees.next()) {
444#ifndef KORG_NOKABC 444#ifndef KORG_NOKABC
445#ifdef DESKTOP_VERSION 445#ifdef DESKTOP_VERSION
446 if (a->name().isEmpty()) { 446 if (a->name().isEmpty()) {
447 addressList = add_book->findByEmail(a->email()); 447 addressList = add_book->findByEmail(a->email());
448 KABC::Addressee o = addressList.first(); 448 KABC::Addressee o = addressList.first();
449 if (!o.isEmpty() && addressList.size()<2) { 449 if (!o.isEmpty() && addressList.size()<2) {
450 mText += "<a href=\"uid:" + o.uid() + "\">"; 450 mText += "<a href=\"uid:" + o.uid() + "\">";
451 mText += o.formattedName(); 451 mText += o.formattedName();
452 mText += "</a>\n"; 452 mText += "</a>\n";
453 } else { 453 } else {
454 mText += "<li>"; 454 mText += "<li>";
455 mText.append(a->email()); 455 mText.append(a->email());
456 mText += "\n"; 456 mText += "\n";
457 } 457 }
458 } else { 458 } else {
459 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 459 mText += "<li><a href=\"uid:" + a->uid() + "\">";
460 if (!a->name().isEmpty()) mText += a->name(); 460 if (!a->name().isEmpty()) mText += a->name();
461 else mText += a->email(); 461 else mText += a->email();
462 mText += "</a>\n"; 462 mText += "</a>\n";
463 } 463 }
464#else //DESKTOP_VERSION 464#else //DESKTOP_VERSION
465 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 465 mText += "<li><a href=\"uid:" + a->uid() + "\">";
466 if (!a->name().isEmpty()) mText += a->name(); 466 if (!a->name().isEmpty()) mText += a->name();
467 else mText += a->email(); 467 else mText += a->email();
468 mText += "</a>\n"; 468 mText += "</a>\n";
469#endif //DESKTOP_VERSION 469#endif //DESKTOP_VERSION
470#else 470#else
471 //qDebug("nokabc "); 471 //qDebug("nokabc ");
472 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 472 mText += "<li><a href=\"uid:" + a->uid() + "\">";
473 if (!a->name().isEmpty()) mText += a->name(); 473 if (!a->name().isEmpty()) mText += a->name();
474 else mText += a->email(); 474 else mText += a->email();
475 mText += "</a>\n"; 475 mText += "</a>\n";
476#endif 476#endif
477 477
478 478
479 if (!a->email().isEmpty()) { 479 if (!a->email().isEmpty()) {
480 if (iconPath) { 480 if (iconPath) {
481 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 481 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
482 mText += "<IMG src=\"" + iconPath + "\">"; 482 mText += "<IMG src=\"" + iconPath + "\">";
483 mText += "</a>\n"; 483 mText += "</a>\n";
484 } 484 }
485 } 485 }
486 if (a->status() != Attendee::NeedsAction ) 486 if (a->status() != Attendee::NeedsAction )
487 mText +="[" + a->statusStr() + "] "; 487 mText +="[" + a->statusStr() + "] ";
488 if (a->role() == Attendee::Chair ) 488 if (a->role() == Attendee::Chair )
489 mText +="(" + a->roleStr().left(1) + ".)"; 489 mText +="(" + a->roleStr().left(1) + ".)";
490 } 490 }
491 mText.append("</li></ul>"); 491 mText.append("</li></ul>");
492 } 492 }
493 493
494} 494}
495void KOEventViewer::appendJournal(Journal *jour, int mode ) 495void KOEventViewer::appendJournal(Journal *jour, int mode )
496{ 496{
497 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 497 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
498 if (mode == 0 ) 498 if (mode == 0 ) {
499 addTag("h2",i18n("Journal from: ")); 499 addTag("h2",i18n("Journal from: "));
500 }
500 else { 501 else {
501 if ( mode == 1 ) { 502 if ( mode == 1 ) {
502 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 503 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
503 } else { 504 } else {
504 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 505 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
505 } 506 }
506 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
507 } 507 }
508 topLevelWidget()->setCaption("Journal Viewer"); 508 topLevelWidget()->setCaption("Journal Viewer");
509 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 509 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
510 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
510 if (!jour->description().isEmpty()) { 511 if (!jour->description().isEmpty()) {
511 addTag("p",jour->description()); 512 addTag("p",jour->description());
512 } 513 }
513 setText(mText); 514 setText(mText);
514} 515}
515 516
516void KOEventViewer::formatReadOnly(Incidence *event) 517void KOEventViewer::formatReadOnly(Incidence *event)
517{ 518{
518 if (event->isReadOnly()) { 519 if (event->isReadOnly()) {
519 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 520 addTag("p","<em>(" + i18n("read-only") + ")</em>");
520 } 521 }
521} 522}
522void KOEventViewer::setSyncMode( bool b ) 523void KOEventViewer::setSyncMode( bool b )
523{ 524{
524 mSyncMode = b; 525 mSyncMode = b;
525} 526}
526 527
527 528
528void KOEventViewer::setTodo(Todo *event, bool clearV ) 529void KOEventViewer::setTodo(Todo *event, bool clearV )
529{ 530{
530 if ( clearV ) 531 if ( clearV )
531 clearEvents(); 532 clearEvents();
532 if ( mSyncMode ) { 533 if ( mSyncMode ) {
533 if ( clearV ) 534 if ( clearV )
534 appendTodo(event,1 ); 535 appendTodo(event,1 );
535 else 536 else
536 appendTodo(event,2); 537 appendTodo(event,2);
537 } else 538 } else
538 appendTodo(event); 539 appendTodo(event);
539} 540}
540void KOEventViewer::setJournal(Journal *event, bool clearV ) 541void KOEventViewer::setJournal(Journal *event, bool clearV )
541{ 542{
542 if ( clearV ) 543 if ( clearV )
543 clearEvents(); 544 clearEvents();
544 if ( mSyncMode ) { 545 if ( mSyncMode ) {
545 if ( clearV ) 546 if ( clearV )
546 appendJournal(event, 1); 547 appendJournal(event, 1);
547 else 548 else
548 appendJournal(event, 2); 549 appendJournal(event, 2);
549 } else 550 } else
550 appendJournal(event); 551 appendJournal(event);
551} 552}
552 553
553void KOEventViewer::setEvent(Event *event) 554void KOEventViewer::setEvent(Event *event)
554{ 555{
555 clearEvents(); 556 clearEvents();
556 if ( mSyncMode ) 557 if ( mSyncMode )
557 appendEvent(event, 1); 558 appendEvent(event, 1);
558 else 559 else
559 appendEvent(event); 560 appendEvent(event);
560} 561}
561 562
562void KOEventViewer::addEvent(Event *event) 563void KOEventViewer::addEvent(Event *event)
563{ 564{
564 if ( mSyncMode ) 565 if ( mSyncMode )
565 appendEvent(event, 2); 566 appendEvent(event, 2);
566 else 567 else
567 appendEvent(event); 568 appendEvent(event);
568} 569}
569 570
570void KOEventViewer::clearEvents(bool now) 571void KOEventViewer::clearEvents(bool now)
571{ 572{
572 mText = ""; 573 mText = "";
573 if (now) setText(mText); 574 if (now) setText(mText);
574} 575}
575 576
576void KOEventViewer::addText(QString text) 577void KOEventViewer::addText(QString text)
577{ 578{
578 mText.append(text); 579 mText.append(text);
579 setText(mText); 580 setText(mText);
580} 581}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 9a3ba73..bafd349 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1061 +1,1072 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qregexp.h>
35 36
36#include <klocale.h> 37#include <klocale.h>
37#include <kdebug.h> 38#include <kdebug.h>
38#include <kiconloader.h> 39#include <kiconloader.h>
39#include <kglobal.h> 40#include <kglobal.h>
40 41
41#include <libkcal/calendar.h> 42#include <libkcal/calendar.h>
42#include <libkcal/calendarlocal.h> 43#include <libkcal/calendarlocal.h>
43#include <libkcal/icalformat.h> 44#include <libkcal/icalformat.h>
44#include <libkcal/vcalformat.h> 45#include <libkcal/vcalformat.h>
45#include <libkcal/recurrence.h> 46#include <libkcal/recurrence.h>
46#include <libkcal/filestorage.h> 47#include <libkcal/filestorage.h>
47#include <libkdepim/categoryselectdialog.h> 48#include <libkdepim/categoryselectdialog.h>
48#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
49#include <qpe/qpeapplication.h> 50#include <qpe/qpeapplication.h>
50#else 51#else
51#include <qapplication.h> 52#include <qapplication.h>
52#endif 53#endif
53 54
54#ifndef KORG_NOPRINTER 55#ifndef KORG_NOPRINTER
55#include "calprinter.h" 56#include "calprinter.h"
56#endif 57#endif
57#include "koglobals.h" 58#include "koglobals.h"
58#include "koprefs.h" 59#include "koprefs.h"
59#include "kfiledialog.h" 60#include "kfiledialog.h"
60 61
61#include "kolistview.h" 62#include "kolistview.h"
62 63
63ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 64ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
64{ 65{
65 mItem = item; 66 mItem = item;
66 mDate = date; 67 mDate = date;
67} 68}
68 69
69ListItemVisitor::~ListItemVisitor() 70ListItemVisitor::~ListItemVisitor()
70{ 71{
71} 72}
72 73
73bool ListItemVisitor::visit(Event *e) 74bool ListItemVisitor::visit(Event *e)
74{ 75{
75 76
76 bool ok = false; 77 bool ok = false;
77 QString start, end; 78 QString start, end;
78 if ( e->doesRecur() ) { 79 if ( e->doesRecur() ) {
79 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 80 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
80 if ( ok ) { 81 if ( ok ) {
81 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 82 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
82 start = KGlobal::locale()->formatDate(d,true); 83 start = KGlobal::locale()->formatDate(d,true);
83 end = KGlobal::locale()->formatDate(d.addDays( days),true); 84 end = KGlobal::locale()->formatDate(d.addDays( days),true);
84 } 85 }
85 86
86 } 87 }
87 if ( ! ok ) { 88 if ( ! ok ) {
88 start =e->dtStartDateStr(); 89 start =e->dtStartDateStr();
89 end = e->dtEndDateStr(); 90 end = e->dtEndDateStr();
90 } 91 }
91 mItem->setText(0,e->summary()); 92 mItem->setText(0,e->summary());
92 mItem->setText(1,start); 93 mItem->setText(1,start);
93 mItem->setText(2,e->dtStartTimeStr()); 94 mItem->setText(2,e->dtStartTimeStr());
94 mItem->setText(3,end); 95 mItem->setText(3,end);
95 mItem->setText(4,e->dtEndTimeStr()); 96 mItem->setText(4,e->dtEndTimeStr());
96 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 97 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
97 mItem->setText(6, e->recurrence()->recurrenceText()); 98 mItem->setText(6, e->recurrence()->recurrenceText());
98 mItem->setText(7,"---"); 99 mItem->setText(7,"---");
99 mItem->setText(8,"---"); 100 mItem->setText(8,"---");
100 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 101 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
101 mItem->setText(10,e->categoriesStr()); 102 mItem->setText(10,e->categoriesStr());
102 103
103 QString key; 104 QString key;
104 QDate d = e->dtStart().date(); 105 QDate d = e->dtStart().date();
105 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 106 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
106 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 107 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
107 mItem->setSortKey(1,key); 108 mItem->setSortKey(1,key);
108 109
109 d = e->dtEnd().date(); 110 d = e->dtEnd().date();
110 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 111 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
111 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 112 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
112 mItem->setSortKey(3,key); 113 mItem->setSortKey(3,key);
113 114
114 return true; 115 return true;
115} 116}
116 117
117bool ListItemVisitor::visit(Todo *t) 118bool ListItemVisitor::visit(Todo *t)
118{ 119{
119 mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); 120 mItem->setText(0,i18n("To-Do: %1").arg(t->summary()));
120 if (t->hasStartDate()) { 121 if (t->hasStartDate()) {
121 mItem->setText(1,t->dtStartDateStr()); 122 mItem->setText(1,t->dtStartDateStr());
122 if (t->doesFloat()) { 123 if (t->doesFloat()) {
123 mItem->setText(2,"---"); 124 mItem->setText(2,"---");
124 } else { 125 } else {
125 mItem->setText(2,t->dtStartTimeStr()); 126 mItem->setText(2,t->dtStartTimeStr());
126 } 127 }
127 } else { 128 } else {
128 mItem->setText(1,"---"); 129 mItem->setText(1,"---");
129 mItem->setText(2,"---"); 130 mItem->setText(2,"---");
130 } 131 }
131 mItem->setText(3,"---"); 132 mItem->setText(3,"---");
132 mItem->setText(4,"---"); 133 mItem->setText(4,"---");
133 mItem->setText(5,"---"); 134 mItem->setText(5,"---");
134 mItem->setText(6,"---"); 135 mItem->setText(6,"---");
135 if (t->hasDueDate()) { 136 if (t->hasDueDate()) {
136 mItem->setText(7,t->dtDueDateStr()); 137 mItem->setText(7,t->dtDueDateStr());
137 if (t->doesFloat()) { 138 if (t->doesFloat()) {
138 mItem->setText(8,"---"); 139 mItem->setText(8,"---");
139 } else { 140 } else {
140 mItem->setText(8,t->dtDueTimeStr()); 141 mItem->setText(8,t->dtDueTimeStr());
141 } 142 }
142 } else { 143 } else {
143 mItem->setText(7,"---"); 144 mItem->setText(7,"---");
144 mItem->setText(8,"---"); 145 mItem->setText(8,"---");
145 } 146 }
146 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 147 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
147 mItem->setText(10,t->categoriesStr()); 148 mItem->setText(10,t->categoriesStr());
148 149
149 QString key; 150 QString key;
150 QDate d; 151 QDate d;
151 if (t->hasDueDate()) { 152 if (t->hasDueDate()) {
152 d = t->dtDue().date(); 153 d = t->dtDue().date();
153 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 154 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
154 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 155 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
155 mItem->setSortKey(7,key); 156 mItem->setSortKey(7,key);
156 } 157 }
157 if ( t->hasStartDate() ) { 158 if ( t->hasStartDate() ) {
158 d = t->dtStart().date(); 159 d = t->dtStart().date();
159 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 160 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
160 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 161 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
161 mItem->setSortKey(1,key); 162 mItem->setSortKey(1,key);
162 } 163 }
163 return true; 164 return true;
164} 165}
165 166
166bool ListItemVisitor::visit(Journal * j) 167bool ListItemVisitor::visit(Journal * j)
167{ 168{
168 mItem->setText(0,i18n("Journal")); 169 QString des = j->description().left(50);
170 des = des.simplifyWhiteSpace ();
171 des.replace (QRegExp ("\\n"),"" );
172 des.replace (QRegExp ("\\r"),"" );
173 mItem->setText(0,i18n("Journal")+": "+des.left(25));
169 mItem->setText(1,j->dtStartDateStr()); 174 mItem->setText(1,j->dtStartDateStr());
170 mItem->setText(2,"---"); 175 mItem->setText(2,"---");
171 mItem->setText(3,"---"); 176 mItem->setText(3,"---");
172 mItem->setText(4,"---"); 177 mItem->setText(4,"---");
173 mItem->setText(5,"---"); 178 mItem->setText(5,"---");
174 mItem->setText(6,"---"); 179 mItem->setText(6,"---");
175 mItem->setText(7,j->dtStartDateStr()); 180 mItem->setText(7,j->dtStartDateStr());
176 mItem->setText(8,"---"); 181 mItem->setText(8,"---");
177 mItem->setText(9,"---"); 182 mItem->setText(9,"---");
183 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
178 184
179 QString key; 185 QString key;
180 QDate d = j->dtStart().date(); 186 QDate d = j->dtStart().date();
181 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 187 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
182 mItem->setSortKey(1,key); 188 mItem->setSortKey(1,key);
183 mItem->setSortKey(7,key); 189 mItem->setSortKey(7,key);
184 190
185 return true; 191 return true;
186} 192}
187 193
188KOListView::KOListView(Calendar *calendar, QWidget *parent, 194KOListView::KOListView(Calendar *calendar, QWidget *parent,
189 const char *name) 195 const char *name)
190 : KOEventView(calendar, parent, name) 196 : KOEventView(calendar, parent, name)
191{ 197{
192 mActiveItem = 0; 198 mActiveItem = 0;
193 mListView = new KOListViewListView(this); 199 mListView = new KOListViewListView(this);
194 mListView->addColumn(i18n("Summary")); 200 mListView->addColumn(i18n("Summary"));
195 mListView->addColumn(i18n("Start Date")); 201 mListView->addColumn(i18n("Start Date"));
196 mListView->addColumn(i18n("Start Time")); 202 mListView->addColumn(i18n("Start Time"));
197 mListView->addColumn(i18n("End Date")); 203 mListView->addColumn(i18n("End Date"));
198 mListView->addColumn(i18n("End Time")); 204 mListView->addColumn(i18n("End Time"));
199 mListView->addColumn(i18n("Alarm")); // alarm set? 205 mListView->addColumn(i18n("Alarm")); // alarm set?
200 mListView->addColumn(i18n("Recurs")); // recurs? 206 mListView->addColumn(i18n("Recurs")); // recurs?
201 mListView->addColumn(i18n("Due Date")); 207 mListView->addColumn(i18n("Due Date"));
202 mListView->addColumn(i18n("Due Time")); 208 mListView->addColumn(i18n("Due Time"));
203 mListView->addColumn(i18n("Cancelled")); 209 mListView->addColumn(i18n("Cancelled"));
204 mListView->addColumn(i18n("Categories")); 210 mListView->addColumn(i18n("Categories"));
205 211
206 mListView->setColumnAlignment(0,AlignLeft); 212 mListView->setColumnAlignment(0,AlignLeft);
207 mListView->setColumnAlignment(1,AlignLeft); 213 mListView->setColumnAlignment(1,AlignLeft);
208 mListView->setColumnAlignment(2,AlignHCenter); 214 mListView->setColumnAlignment(2,AlignHCenter);
209 mListView->setColumnAlignment(3,AlignLeft); 215 mListView->setColumnAlignment(3,AlignLeft);
210 mListView->setColumnAlignment(4,AlignHCenter); 216 mListView->setColumnAlignment(4,AlignHCenter);
211 mListView->setColumnAlignment(5,AlignLeft); 217 mListView->setColumnAlignment(5,AlignLeft);
212 mListView->setColumnAlignment(6,AlignLeft); 218 mListView->setColumnAlignment(6,AlignLeft);
213 mListView->setColumnAlignment(7,AlignLeft); 219 mListView->setColumnAlignment(7,AlignLeft);
214 mListView->setColumnAlignment(8,AlignLeft); 220 mListView->setColumnAlignment(8,AlignLeft);
215 mListView->setColumnAlignment(9,AlignLeft); 221 mListView->setColumnAlignment(9,AlignLeft);
216 mListView->setColumnAlignment(10,AlignLeft); 222 mListView->setColumnAlignment(10,AlignLeft);
217 223
218 int iii = 0; 224 int iii = 0;
219 for ( iii = 0; iii< 10 ; ++iii ) 225 for ( iii = 0; iii< 10 ; ++iii )
220 mListView->setColumnWidthMode( iii, QListView::Manual ); 226 mListView->setColumnWidthMode( iii, QListView::Manual );
221 227
222 QBoxLayout *layoutTop = new QVBoxLayout(this); 228 QBoxLayout *layoutTop = new QVBoxLayout(this);
223 layoutTop->addWidget(mListView); 229 layoutTop->addWidget(mListView);
224 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 230 mListView->setFont ( KOPrefs::instance()->mListViewFont );
225 mPopupMenu = eventPopup(); 231 mPopupMenu = eventPopup();
226 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 232 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
227 i18n("Select all"),this, 233 i18n("Select all"),this,
228 SLOT(allSelection()),true); 234 SLOT(allSelection()),true);
229 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 235 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
230 i18n("Deselect All"),this, 236 i18n("Deselect All"),this,
231 SLOT(clearSelection()),true); 237 SLOT(clearSelection()),true);
232 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 238 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
233 i18n("Delete all selected"),this, 239 i18n("Delete all selected"),this,
234 SLOT(deleteAll()),true); 240 SLOT(deleteAll()),true);
235 mPopupMenu->insertSeparator(); 241 mPopupMenu->insertSeparator();
236 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 242 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
237 i18n("Save selected to file..."),this, 243 i18n("Save selected to file..."),this,
238 SLOT(saveToFile()),true); 244 SLOT(saveToFile()),true);
239 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 245 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
240 i18n("Save Journal/Description..."),this, 246 i18n("Save Journal/Description..."),this,
241 SLOT(saveDescriptionToFile()),true); 247 SLOT(saveDescriptionToFile()),true);
242 mPopupMenu->insertSeparator(); 248 mPopupMenu->insertSeparator();
243 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 249 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
244 i18n("Add Categ. to selected..."),this, 250 i18n("Add Categ. to selected..."),this,
245 SLOT(addCat()),true); 251 SLOT(addCat()),true);
246 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 252 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
247 i18n("Set Categ. for selected..."),this, 253 i18n("Set Categ. for selected..."),this,
248 SLOT(setCat()),true); 254 SLOT(setCat()),true);
249 mPopupMenu->insertSeparator(); 255 mPopupMenu->insertSeparator();
250 256
251 257
252#ifndef DESKTOP_VERSION 258#ifndef DESKTOP_VERSION
253 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 259 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
254 i18n("Beam selected via IR"),this, 260 i18n("Beam selected via IR"),this,
255 SLOT(beamSelected()),true); 261 SLOT(beamSelected()),true);
256#endif 262#endif
257 /* 263 /*
258 mPopupMenu = new QPopupMenu; 264 mPopupMenu = new QPopupMenu;
259 mPopupMenu->insertItem(i18n("Edit Event"), this, 265 mPopupMenu->insertItem(i18n("Edit Event"), this,
260 SLOT (editEvent())); 266 SLOT (editEvent()));
261 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 267 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
262 SLOT (deleteEvent())); 268 SLOT (deleteEvent()));
263 mPopupMenu->insertSeparator(); 269 mPopupMenu->insertSeparator();
264 mPopupMenu->insertItem(i18n("Show Dates"), this, 270 mPopupMenu->insertItem(i18n("Show Dates"), this,
265 SLOT(showDates())); 271 SLOT(showDates()));
266 mPopupMenu->insertItem(i18n("Hide Dates"), this, 272 mPopupMenu->insertItem(i18n("Hide Dates"), this,
267 SLOT(hideDates())); 273 SLOT(hideDates()));
268 */ 274 */
269 QObject::connect(mListView,SIGNAL( newEvent()), 275 QObject::connect(mListView,SIGNAL( newEvent()),
270 this,SIGNAL(signalNewEvent())); 276 this,SIGNAL(signalNewEvent()));
271 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 277 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
272 this,SLOT(defaultItemAction(QListViewItem *))); 278 this,SLOT(defaultItemAction(QListViewItem *)));
273 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 279 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
274 const QPoint &, int )), 280 const QPoint &, int )),
275 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 281 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
276 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 282 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
277 SLOT(processSelectionChange(QListViewItem *))); 283 SLOT(processSelectionChange(QListViewItem *)));
278 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 284 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
279 SIGNAL(showIncidenceSignal(Incidence *)) ); 285 SIGNAL(showIncidenceSignal(Incidence *)) );
280 286
281 readSettings(KOGlobals::config(),"KOListView Layout"); 287 readSettings(KOGlobals::config(),"KOListView Layout");
282} 288}
283 289
284KOListView::~KOListView() 290KOListView::~KOListView()
285{ 291{
286 delete mPopupMenu; 292 delete mPopupMenu;
287} 293}
288 294
289void KOListView::updateList() 295void KOListView::updateList()
290{ 296{
291 // qDebug(" KOListView::updateList() "); 297 // qDebug(" KOListView::updateList() ");
292 298
293} 299}
294 300
295void KOListView::addCat( ) 301void KOListView::addCat( )
296{ 302{
297 setCategories( false ); 303 setCategories( false );
298} 304}
299void KOListView::setCat() 305void KOListView::setCat()
300{ 306{
301 setCategories( true ); 307 setCategories( true );
302} 308}
303void KOListView::setCategories( bool removeOld ) 309void KOListView::setCategories( bool removeOld )
304{ 310{
305 311
306 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 312 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
307 if (! csd->exec()) { 313 if (! csd->exec()) {
308 delete csd; 314 delete csd;
309 return; 315 return;
310 } 316 }
311 QStringList catList = csd->selectedCategories(); 317 QStringList catList = csd->selectedCategories();
312 delete csd; 318 delete csd;
313 // if ( catList.count() == 0 ) 319 // if ( catList.count() == 0 )
314 // return; 320 // return;
315 catList.sort(); 321 catList.sort();
316 QString categoriesStr = catList.join(","); 322 QString categoriesStr = catList.join(",");
317 int i; 323 int i;
318 QStringList itemList; 324 QStringList itemList;
319 QPtrList<KOListViewItem> sel ; 325 QPtrList<KOListViewItem> sel ;
320 QListViewItem *qitem = mListView->firstChild (); 326 QListViewItem *qitem = mListView->firstChild ();
321 while ( qitem ) { 327 while ( qitem ) {
322 if ( qitem->isSelected() ) { 328 if ( qitem->isSelected() ) {
323 sel.append(((KOListViewItem *)qitem)); 329 sel.append(((KOListViewItem *)qitem));
324 } 330 }
325 qitem = qitem->nextSibling(); 331 qitem = qitem->nextSibling();
326 } 332 }
327 KOListViewItem * item, *temp; 333 KOListViewItem * item, *temp;
328 item = sel.first(); 334 item = sel.first();
329 Incidence* inc; 335 Incidence* inc;
330 while ( item ) { 336 while ( item ) {
331 inc = item->data(); 337 inc = item->data();
332 if ( removeOld ) { 338 if ( removeOld ) {
333 inc->setCategories( categoriesStr ); 339 inc->setCategories( categoriesStr );
334 } else { 340 } else {
335 itemList = QStringList::split (",", inc->categoriesStr() ); 341 itemList = QStringList::split (",", inc->categoriesStr() );
336 for( i = 0; i< catList.count(); ++i ) { 342 for( i = 0; i< catList.count(); ++i ) {
337 if ( !itemList.contains (catList[i])) 343 if ( !itemList.contains (catList[i]))
338 itemList.append( catList[i] ); 344 itemList.append( catList[i] );
339 } 345 }
340 itemList.sort(); 346 itemList.sort();
341 inc->setCategories( itemList.join(",") ); 347 inc->setCategories( itemList.join(",") );
342 } 348 }
343 temp = item; 349 temp = item;
344 item = sel.next(); 350 item = sel.next();
345 mUidDict.remove( inc->uid() ); 351 mUidDict.remove( inc->uid() );
346 delete temp;; 352 delete temp;;
347 addIncidence( inc ); 353 addIncidence( inc );
348 } 354 }
349} 355}
350 356
351void KOListView::beamSelected() 357void KOListView::beamSelected()
352{ 358{
353 int icount = 0; 359 int icount = 0;
354 QPtrList<Incidence> delSel ; 360 QPtrList<Incidence> delSel ;
355 QListViewItem *item = mListView->firstChild (); 361 QListViewItem *item = mListView->firstChild ();
356 while ( item ) { 362 while ( item ) {
357 if ( item->isSelected() ) { 363 if ( item->isSelected() ) {
358 delSel.append(((KOListViewItem *)item)->data()); 364 delSel.append(((KOListViewItem *)item)->data());
359 ++icount; 365 ++icount;
360 } 366 }
361 367
362 item = item->nextSibling(); 368 item = item->nextSibling();
363 } 369 }
364 if ( icount ) { 370 if ( icount ) {
365 emit beamIncidenceList( delSel ); 371 emit beamIncidenceList( delSel );
366 return; 372 return;
367 QString fn ; 373 QString fn ;
368 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 374 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
369 QString mes; 375 QString mes;
370 bool createbup = true; 376 bool createbup = true;
371 if ( createbup ) { 377 if ( createbup ) {
372 QString description = "\n"; 378 QString description = "\n";
373 CalendarLocal* cal = new CalendarLocal(); 379 CalendarLocal* cal = new CalendarLocal();
374 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 380 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
375 Incidence *incidence = delSel.first(); 381 Incidence *incidence = delSel.first();
376 while ( incidence ) { 382 while ( incidence ) {
377 Incidence *in = incidence->clone(); 383 Incidence *in = incidence->clone();
378 description += in->summary() + "\n"; 384 description += in->summary() + "\n";
379 cal->addIncidence( in ); 385 cal->addIncidence( in );
380 incidence = delSel.next(); 386 incidence = delSel.next();
381 } 387 }
382 FileStorage storage( cal, fn, new VCalFormat ); 388 FileStorage storage( cal, fn, new VCalFormat );
383 storage.save(); 389 storage.save();
384 delete cal; 390 delete cal;
385 mes = i18n("KO/Pi: Ready for beaming"); 391 mes = i18n("KO/Pi: Ready for beaming");
386 topLevelWidget()->setCaption(mes); 392 topLevelWidget()->setCaption(mes);
387 393
388#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
389 Ir *ir = new Ir( this ); 395 Ir *ir = new Ir( this );
390 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 396 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
391 ir->send( fn, description, "text/x-vCalendar" ); 397 ir->send( fn, description, "text/x-vCalendar" );
392#endif 398#endif
393 } 399 }
394 } 400 }
395} 401}
396void KOListView::beamDone( Ir *ir ) 402void KOListView::beamDone( Ir *ir )
397{ 403{
398#ifndef DESKTOP_VERSION 404#ifndef DESKTOP_VERSION
399 delete ir; 405 delete ir;
400#endif 406#endif
401 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 407 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
402} 408}
403 409
404void KOListView::saveDescriptionToFile() 410void KOListView::saveDescriptionToFile()
405{ 411{
406 412
407 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 413 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
408 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 414 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
409 i18n("Continue"), i18n("Cancel"), 0, 415 i18n("Continue"), i18n("Cancel"), 0,
410 0, 1 ); 416 0, 1 );
411 if ( result != 0 ) { 417 if ( result != 0 ) {
412 return; 418 return;
413 } 419 }
414 int icount = 0; 420 int icount = 0;
415 QPtrList<Incidence> delSel ; 421 QPtrList<Incidence> delSel ;
416 QListViewItem *item = mListView->firstChild (); 422 QListViewItem *item = mListView->firstChild ();
417 while ( item ) { 423 while ( item ) {
418 if ( item->isSelected() ) { 424 if ( item->isSelected() ) {
419 delSel.append(((KOListViewItem *)item)->data()); 425 delSel.append(((KOListViewItem *)item)->data());
420 ++icount; 426 ++icount;
421 } 427 }
422 428
423 item = item->nextSibling(); 429 item = item->nextSibling();
424 } 430 }
425 if ( icount ) { 431 if ( icount ) {
426 QString fn = KOPrefs::instance()->mLastSaveFile; 432 QString fn = KOPrefs::instance()->mLastSaveFile;
427 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 433 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
428 434
429 if ( fn == "" ) 435 if ( fn == "" )
430 return; 436 return;
431 QFileInfo info; 437 QFileInfo info;
432 info.setFile( fn ); 438 info.setFile( fn );
433 QString mes; 439 QString mes;
434 bool createbup = true; 440 bool createbup = true;
435 if ( info. exists() ) { 441 if ( info. exists() ) {
436 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 442 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
437 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 443 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
438 i18n("Overwrite!"), i18n("Cancel"), 0, 444 i18n("Overwrite!"), i18n("Cancel"), 0,
439 0, 1 ); 445 0, 1 );
440 if ( result != 0 ) { 446 if ( result != 0 ) {
441 createbup = false; 447 createbup = false;
442 } 448 }
443 } 449 }
444 if ( createbup ) { 450 if ( createbup ) {
445 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 451 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
446 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 452 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
447 Incidence *incidence = delSel.first(); 453 Incidence *incidence = delSel.first();
448 icount = 0; 454 icount = 0;
449 while ( incidence ) { 455 while ( incidence ) {
450 if ( incidence->type() == "Journal" ) { 456 if ( incidence->type() == "Journal" ) {
451 text += "\n************************************\n"; 457 text += "\n************************************\n";
452 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 458 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
453 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 459 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
454 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 460 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
455 ++icount; 461 ++icount;
456 462
457 } else { 463 } else {
458 if ( !incidence->description().isEmpty() ) { 464 if ( !incidence->description().isEmpty() ) {
459 text += "\n************************************\n"; 465 text += "\n************************************\n";
460 if ( incidence->type() == "Todo" ) 466 if ( incidence->type() == "Todo" )
461 text += i18n("To-Do: "); 467 text += i18n("To-Do: ");
462 text += incidence->summary(); 468 text += incidence->summary();
463 if ( incidence->hasStartDate() ) 469 if ( incidence->hasStartDate() )
464 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 470 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
465 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 471 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
466 if ( !incidence->location().isEmpty() ) 472 if ( !incidence->location().isEmpty() )
467 text += "\n" +i18n("Location: ") + incidence->location(); 473 text += "\n" +i18n("Location: ") + incidence->location();
468 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 474 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
469 ++icount; 475 ++icount;
470 476
471 } 477 }
472 } 478 }
473 incidence = delSel.next(); 479 incidence = delSel.next();
474 } 480 }
475 QFile file( fn ); 481 QFile file( fn );
476 if (!file.open( IO_WriteOnly ) ) { 482 if (!file.open( IO_WriteOnly ) ) {
477 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 483 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
478 return; 484 return;
479 } 485 }
480 QTextStream ts( &file ); 486 QTextStream ts( &file );
481 ts << text; 487 ts << text;
482 file.close(); 488 file.close();
483 //qDebug("%s ", text.latin1()); 489 //qDebug("%s ", text.latin1());
484 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 490 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
485 KOPrefs::instance()->mLastSaveFile = fn; 491 KOPrefs::instance()->mLastSaveFile = fn;
486 topLevelWidget()->setCaption(mes); 492 topLevelWidget()->setCaption(mes);
487 } 493 }
488 } 494 }
489} 495}
490void KOListView::saveToFile() 496void KOListView::saveToFile()
491{ 497{
492 498
493 int icount = 0; 499 int icount = 0;
494 QPtrList<Incidence> delSel ; 500 QPtrList<Incidence> delSel ;
495 QListViewItem *item = mListView->firstChild (); 501 QListViewItem *item = mListView->firstChild ();
496 while ( item ) { 502 while ( item ) {
497 if ( item->isSelected() ) { 503 if ( item->isSelected() ) {
498 delSel.append(((KOListViewItem *)item)->data()); 504 delSel.append(((KOListViewItem *)item)->data());
499 ++icount; 505 ++icount;
500 } 506 }
501 507
502 item = item->nextSibling(); 508 item = item->nextSibling();
503 } 509 }
504 if ( icount ) { 510 if ( icount ) {
505 QString fn = KOPrefs::instance()->mLastSaveFile; 511 QString fn = KOPrefs::instance()->mLastSaveFile;
506 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 512 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
507 513
508 if ( fn == "" ) 514 if ( fn == "" )
509 return; 515 return;
510 QFileInfo info; 516 QFileInfo info;
511 info.setFile( fn ); 517 info.setFile( fn );
512 QString mes; 518 QString mes;
513 bool createbup = true; 519 bool createbup = true;
514 if ( info. exists() ) { 520 if ( info. exists() ) {
515 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 521 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
516 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 522 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
517 i18n("Overwrite!"), i18n("Cancel"), 0, 523 i18n("Overwrite!"), i18n("Cancel"), 0,
518 0, 1 ); 524 0, 1 );
519 if ( result != 0 ) { 525 if ( result != 0 ) {
520 createbup = false; 526 createbup = false;
521 } 527 }
522 } 528 }
523 if ( createbup ) { 529 if ( createbup ) {
524 CalendarLocal cal; 530 CalendarLocal cal;
525 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 531 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
526 Incidence *incidence = delSel.first(); 532 Incidence *incidence = delSel.first();
527 while ( incidence ) { 533 while ( incidence ) {
528 cal.addIncidence( incidence->clone() ); 534 cal.addIncidence( incidence->clone() );
529 incidence = delSel.next(); 535 incidence = delSel.next();
530 } 536 }
531 ICalFormat format; 537 ICalFormat format;
532 format.save( &cal, fn ); 538 format.save( &cal, fn );
533 mes = i18n("KO/Pi:Saved %1").arg(fn ); 539 mes = i18n("KO/Pi:Saved %1").arg(fn );
534 KOPrefs::instance()->mLastSaveFile = fn; 540 KOPrefs::instance()->mLastSaveFile = fn;
535 topLevelWidget()->setCaption(mes); 541 topLevelWidget()->setCaption(mes);
536 } 542 }
537 } 543 }
538} 544}
539void KOListView::deleteAll() 545void KOListView::deleteAll()
540{ 546{
541 int icount = 0; 547 int icount = 0;
542 QPtrList<Incidence> delSel ; 548 QPtrList<Incidence> delSel ;
543 QListViewItem *item = mListView->firstChild (); 549 QListViewItem *item = mListView->firstChild ();
544 while ( item ) { 550 while ( item ) {
545 if ( item->isSelected() ) { 551 if ( item->isSelected() ) {
546 delSel.append(((KOListViewItem *)item)->data()); 552 delSel.append(((KOListViewItem *)item)->data());
547 ++icount; 553 ++icount;
548 } 554 }
549 555
550 item = item->nextSibling(); 556 item = item->nextSibling();
551 } 557 }
552 if ( icount ) { 558 if ( icount ) {
553 Incidence *incidence = delSel.first(); 559 Incidence *incidence = delSel.first();
554 Incidence *toDelete; 560 Incidence *toDelete;
555 KOPrefs *p = KOPrefs::instance(); 561 KOPrefs *p = KOPrefs::instance();
556 bool confirm = p->mConfirm; 562 bool confirm = p->mConfirm;
557 QString mess; 563 QString mess;
558 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 564 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
559 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 565 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
560 p->mConfirm = false; 566 p->mConfirm = false;
561 int delCounter = 0; 567 int delCounter = 0;
562 QDialog dia ( this, "p-dialog", true ); 568 QDialog dia ( this, "p-dialog", true );
563 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 569 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
564 QVBoxLayout lay( &dia ); 570 QVBoxLayout lay( &dia );
565 lay.setMargin(7); 571 lay.setMargin(7);
566 lay.setSpacing(7); 572 lay.setSpacing(7);
567 lay.addWidget( &lab); 573 lay.addWidget( &lab);
568 QProgressBar bar( icount, &dia ); 574 QProgressBar bar( icount, &dia );
569 lay.addWidget( &bar); 575 lay.addWidget( &bar);
570 int w = 220; 576 int w = 220;
571 int h = 50; 577 int h = 50;
572 int dw = QApplication::desktop()->width(); 578 int dw = QApplication::desktop()->width();
573 int dh = QApplication::desktop()->height(); 579 int dh = QApplication::desktop()->height();
574 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 580 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
575 //dia.resize( 240,50 ); 581 //dia.resize( 240,50 );
576 dia.show(); 582 dia.show();
577 583
578 while ( incidence ) { 584 while ( incidence ) {
579 bar.setProgress( delCounter ); 585 bar.setProgress( delCounter );
580 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 586 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
581 dia.setCaption( mess ); 587 dia.setCaption( mess );
582 qApp->processEvents(); 588 qApp->processEvents();
583 toDelete = (incidence); 589 toDelete = (incidence);
584 incidence = delSel.next(); 590 incidence = delSel.next();
585 emit deleteIncidenceSignal(toDelete ); 591 emit deleteIncidenceSignal(toDelete );
586 if ( dia.result() != 0 ) 592 if ( dia.result() != 0 )
587 break; 593 break;
588 594
589 } 595 }
590 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 596 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
591 topLevelWidget ()->setCaption( mess ); 597 topLevelWidget ()->setCaption( mess );
592 p->mConfirm = confirm; 598 p->mConfirm = confirm;
593 } 599 }
594 } 600 }
595 601
596 602
597} 603}
598int KOListView::maxDatesHint() 604int KOListView::maxDatesHint()
599{ 605{
600 return 0; 606 return 0;
601} 607}
602 608
603int KOListView::currentDateCount() 609int KOListView::currentDateCount()
604{ 610{
605 return 0; 611 return 0;
606} 612}
607 613
608QPtrList<Incidence> KOListView::selectedIncidences() 614QPtrList<Incidence> KOListView::selectedIncidences()
609{ 615{
610 QPtrList<Incidence> eventList; 616 QPtrList<Incidence> eventList;
611 QListViewItem *item = mListView->firstChild (); 617 QListViewItem *item = mListView->firstChild ();
612 while ( item ) { 618 while ( item ) {
613 if ( item->isSelected() ) { 619 if ( item->isSelected() ) {
614 eventList.append(((KOListViewItem *)item)->data()); 620 eventList.append(((KOListViewItem *)item)->data());
615 } 621 }
616 622
617 item = item->nextSibling(); 623 item = item->nextSibling();
618 } 624 }
619 625
620 // // QListViewItem *item = mListView->selectedItem(); 626 // // QListViewItem *item = mListView->selectedItem();
621 //if (item) eventList.append(((KOListViewItem *)item)->data()); 627 //if (item) eventList.append(((KOListViewItem *)item)->data());
622 628
623 return eventList; 629 return eventList;
624} 630}
625 631
626DateList KOListView::selectedDates() 632DateList KOListView::selectedDates()
627{ 633{
628 DateList eventList; 634 DateList eventList;
629 return eventList; 635 return eventList;
630} 636}
631 637
632void KOListView::showDates(bool show) 638void KOListView::showDates(bool show)
633{ 639{
634 // Shouldn't we set it to a value greater 0? When showDates is called with 640 // Shouldn't we set it to a value greater 0? When showDates is called with
635 // show == true at first, then the columnwidths are set to zero. 641 // show == true at first, then the columnwidths are set to zero.
636 static int oldColWidth1 = 0; 642 static int oldColWidth1 = 0;
637 static int oldColWidth3 = 0; 643 static int oldColWidth3 = 0;
638 644
639 if (!show) { 645 if (!show) {
640 oldColWidth1 = mListView->columnWidth(1); 646 oldColWidth1 = mListView->columnWidth(1);
641 oldColWidth3 = mListView->columnWidth(3); 647 oldColWidth3 = mListView->columnWidth(3);
642 mListView->setColumnWidth(1, 0); 648 mListView->setColumnWidth(1, 0);
643 mListView->setColumnWidth(3, 0); 649 mListView->setColumnWidth(3, 0);
644 } else { 650 } else {
645 mListView->setColumnWidth(1, oldColWidth1); 651 mListView->setColumnWidth(1, oldColWidth1);
646 mListView->setColumnWidth(3, oldColWidth3); 652 mListView->setColumnWidth(3, oldColWidth3);
647 } 653 }
648 mListView->repaint(); 654 mListView->repaint();
649} 655}
650 656
651void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 657void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
652 const QDate &td) 658 const QDate &td)
653{ 659{
654#ifndef KORG_NOPRINTER 660#ifndef KORG_NOPRINTER
655 calPrinter->preview(CalPrinter::Day, fd, td); 661 calPrinter->preview(CalPrinter::Day, fd, td);
656#endif 662#endif
657} 663}
658 664
659void KOListView::showDates() 665void KOListView::showDates()
660{ 666{
661 showDates(true); 667 showDates(true);
662} 668}
663 669
664void KOListView::hideDates() 670void KOListView::hideDates()
665{ 671{
666 showDates(false); 672 showDates(false);
667} 673}
668 674
669void KOListView::updateView() 675void KOListView::updateView()
670{ 676{
671 mListView->setFocus(); 677 mListView->setFocus();
672 if ( mListView->firstChild () ) 678 if ( mListView->firstChild () )
673 mListView->setCurrentItem( mListView->firstChild () ); 679 mListView->setCurrentItem( mListView->firstChild () );
674} 680}
675void KOListView::updateConfig() 681void KOListView::updateConfig()
676{ 682{
677 683
678 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 684 mListView->setFont ( KOPrefs::instance()->mListViewFont );
679 updateView(); 685 updateView();
680 686
681} 687}
682void KOListView::setStartDate(const QDate &start) 688void KOListView::setStartDate(const QDate &start)
683{ 689{
684 mStartDate = start; 690 mStartDate = start;
685} 691}
686 692
687void KOListView::showDates(const QDate &start, const QDate &end) 693void KOListView::showDates(const QDate &start, const QDate &end)
688{ 694{
689 clear(); 695 clear();
690 mStartDate = start; 696 mStartDate = start;
691 QDate date = start; 697 QDate date = start;
698 QPtrList<Journal> j_list;
692 while( date <= end ) { 699 while( date <= end ) {
693 addEvents(calendar()->events(date)); 700 addEvents(calendar()->events(date));
694 addTodos(calendar()->todos(date)); 701 addTodos(calendar()->todos(date));
702 Journal* jo = calendar()->journal(date);
703 if ( jo )
704 j_list.append( jo );
695 date = date.addDays( 1 ); 705 date = date.addDays( 1 );
696 } 706 }
707 addJournals(j_list);
697 emit incidenceSelected( 0 ); 708 emit incidenceSelected( 0 );
698 updateView(); 709 updateView();
699 710
700} 711}
701 712
702void KOListView::addEvents(QPtrList<Event> eventList) 713void KOListView::addEvents(QPtrList<Event> eventList)
703{ 714{
704 Event *ev; 715 Event *ev;
705 for(ev = eventList.first(); ev; ev = eventList.next()) { 716 for(ev = eventList.first(); ev; ev = eventList.next()) {
706 addIncidence(ev); 717 addIncidence(ev);
707 } 718 }
708 if ( !mListView->currentItem() ){ 719 if ( !mListView->currentItem() ){
709 updateView(); 720 updateView();
710 } 721 }
711} 722}
712 723
713void KOListView::addTodos(QPtrList<Todo> eventList) 724void KOListView::addTodos(QPtrList<Todo> eventList)
714{ 725{
715 Todo *ev; 726 Todo *ev;
716 for(ev = eventList.first(); ev; ev = eventList.next()) { 727 for(ev = eventList.first(); ev; ev = eventList.next()) {
717 addIncidence(ev); 728 addIncidence(ev);
718 } 729 }
719 if ( !mListView->currentItem() ){ 730 if ( !mListView->currentItem() ){
720 updateView(); 731 updateView();
721 } 732 }
722} 733}
723void KOListView::addJournals(QPtrList<Journal> eventList) 734void KOListView::addJournals(QPtrList<Journal> eventList)
724{ 735{
725 Journal *ev; 736 Journal *ev;
726 for(ev = eventList.first(); ev; ev = eventList.next()) { 737 for(ev = eventList.first(); ev; ev = eventList.next()) {
727 addIncidence(ev); 738 addIncidence(ev);
728 } 739 }
729 if ( !mListView->currentItem() ){ 740 if ( !mListView->currentItem() ){
730 updateView(); 741 updateView();
731 } 742 }
732} 743}
733 744
734void KOListView::addIncidence(Incidence *incidence) 745void KOListView::addIncidence(Incidence *incidence)
735{ 746{
736 if ( mUidDict.find( incidence->uid() ) ) return; 747 if ( mUidDict.find( incidence->uid() ) ) return;
737 748
738 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 749 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
739 mUidDict.insert( incidence->uid(), incidence ); 750 mUidDict.insert( incidence->uid(), incidence );
740 751
741 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 752 KOListViewItem *item = new KOListViewItem( incidence, mListView );
742 ListItemVisitor v(item, mStartDate ); 753 ListItemVisitor v(item, mStartDate );
743 if (incidence->accept(v)) return; 754 if (incidence->accept(v)) return;
744 else delete item; 755 else delete item;
745 //qDebug("delete item "); 756 //qDebug("delete item ");
746} 757}
747 758
748void KOListView::showEvents(QPtrList<Event> eventList) 759void KOListView::showEvents(QPtrList<Event> eventList)
749{ 760{
750 clear(); 761 clear();
751 762
752 addEvents(eventList); 763 addEvents(eventList);
753 764
754 // After new creation of list view no events are selected. 765 // After new creation of list view no events are selected.
755 emit incidenceSelected( 0 ); 766 emit incidenceSelected( 0 );
756} 767}
757int KOListView::count() 768int KOListView::count()
758{ 769{
759 return mListView->childCount(); 770 return mListView->childCount();
760} 771}
761 772
762void KOListView::changeEventDisplay(Event *event, int action) 773void KOListView::changeEventDisplay(Event *event, int action)
763{ 774{
764 KOListViewItem *item; 775 KOListViewItem *item;
765 776
766 switch(action) { 777 switch(action) {
767 case KOGlobals::EVENTADDED: 778 case KOGlobals::EVENTADDED:
768 addIncidence( event ); 779 addIncidence( event );
769 break; 780 break;
770 case KOGlobals::EVENTEDITED: 781 case KOGlobals::EVENTEDITED:
771 item = getItemForEvent(event); 782 item = getItemForEvent(event);
772 if (item) { 783 if (item) {
773 mUidDict.remove( event->uid() ); 784 mUidDict.remove( event->uid() );
774 delete item; 785 delete item;
775 addIncidence( event ); 786 addIncidence( event );
776 } 787 }
777 break; 788 break;
778 case KOGlobals::EVENTDELETED: 789 case KOGlobals::EVENTDELETED:
779 item = getItemForEvent(event); 790 item = getItemForEvent(event);
780 if (item) { 791 if (item) {
781 mUidDict.remove( event->uid() ); 792 mUidDict.remove( event->uid() );
782 delete item; 793 delete item;
783 } 794 }
784 break; 795 break;
785 default: 796 default:
786 ; 797 ;
787 } 798 }
788} 799}
789 800
790KOListViewItem *KOListView::getItemForEvent(Event *event) 801KOListViewItem *KOListView::getItemForEvent(Event *event)
791{ 802{
792 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 803 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
793 while (item) { 804 while (item) {
794 if (item->data() == event) return item; 805 if (item->data() == event) return item;
795 item = (KOListViewItem *)item->nextSibling(); 806 item = (KOListViewItem *)item->nextSibling();
796 } 807 }
797 return 0; 808 return 0;
798} 809}
799 810
800void KOListView::defaultItemAction(QListViewItem *i) 811void KOListView::defaultItemAction(QListViewItem *i)
801{ 812{
802 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 813 KOListViewItem *item = static_cast<KOListViewItem *>( i );
803 if ( item ) defaultAction( item->data() ); 814 if ( item ) defaultAction( item->data() );
804 815
805} 816}
806 817
807void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 818void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
808{ 819{
809 mActiveItem = (KOListViewItem *)item; 820 mActiveItem = (KOListViewItem *)item;
810 if (mActiveItem) { 821 if (mActiveItem) {
811 Incidence *incidence = mActiveItem->data(); 822 Incidence *incidence = mActiveItem->data();
812 mPopupMenu->showIncidencePopup(incidence); 823 mPopupMenu->showIncidencePopup(incidence);
813 824
814 /* 825 /*
815 if ( incidence && incidence->type() == "Event" ) { 826 if ( incidence && incidence->type() == "Event" ) {
816 Event *event = static_cast<Event *>( incidence ); 827 Event *event = static_cast<Event *>( incidence );
817 mPopupMenu->showEventPopup(event); 828 mPopupMenu->showEventPopup(event);
818 } 829 }
819 */ 830 */
820 } 831 }
821} 832}
822 833
823void KOListView::readSettings(KConfig *config, QString setting) 834void KOListView::readSettings(KConfig *config, QString setting)
824{ 835{
825 // qDebug("KOListView::readSettings "); 836 // qDebug("KOListView::readSettings ");
826 mListView->restoreLayout(config,setting); 837 mListView->restoreLayout(config,setting);
827} 838}
828 839
829void KOListView::writeSettings(KConfig *config, QString setting) 840void KOListView::writeSettings(KConfig *config, QString setting)
830{ 841{
831 // qDebug("KOListView::writeSettings "); 842 // qDebug("KOListView::writeSettings ");
832 mListView->saveLayout(config, setting); 843 mListView->saveLayout(config, setting);
833} 844}
834 845
835void KOListView::processSelectionChange(QListViewItem *) 846void KOListView::processSelectionChange(QListViewItem *)
836{ 847{
837 848
838 KOListViewItem *item = 849 KOListViewItem *item =
839 static_cast<KOListViewItem *>( mListView->currentItem() ); 850 static_cast<KOListViewItem *>( mListView->currentItem() );
840 851
841 if ( !item ) { 852 if ( !item ) {
842 emit incidenceSelected( 0 ); 853 emit incidenceSelected( 0 );
843 } else { 854 } else {
844 emit incidenceSelected( item->data() ); 855 emit incidenceSelected( item->data() );
845 } 856 }
846} 857}
847 858
848void KOListView::clearSelection() 859void KOListView::clearSelection()
849{ 860{
850 mListView->selectAll( false ); 861 mListView->selectAll( false );
851} 862}
852void KOListView::allSelection() 863void KOListView::allSelection()
853{ 864{
854 mListView->selectAll( true ); 865 mListView->selectAll( true );
855} 866}
856 867
857void KOListView::clear() 868void KOListView::clear()
858{ 869{
859 mListView->clear(); 870 mListView->clear();
860 mUidDict.clear(); 871 mUidDict.clear();
861} 872}
862 873
863Incidence* KOListView::currentItem() 874Incidence* KOListView::currentItem()
864{ 875{
865 if ( mListView->currentItem() ) 876 if ( mListView->currentItem() )
866 return ((KOListViewItem*) mListView->currentItem())->data(); 877 return ((KOListViewItem*) mListView->currentItem())->data();
867 return 0; 878 return 0;
868} 879}
869void KOListView::keyPressEvent ( QKeyEvent *e) 880void KOListView::keyPressEvent ( QKeyEvent *e)
870{ 881{
871 882
872 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 883 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
873 deleteAll(); 884 deleteAll();
874 return; 885 return;
875 } 886 }
876 887
877 e->ignore(); 888 e->ignore();
878} 889}
879void KOListViewListView::keyPressEvent ( QKeyEvent *e) 890void KOListViewListView::keyPressEvent ( QKeyEvent *e)
880{ 891{
881 892
882 switch ( e->key() ) { 893 switch ( e->key() ) {
883 case Qt::Key_Down: 894 case Qt::Key_Down:
884 if ( e->state() == ShiftButton ) { 895 if ( e->state() == ShiftButton ) {
885 QListViewItem* cn = currentItem(); 896 QListViewItem* cn = currentItem();
886 if ( !cn ) 897 if ( !cn )
887 cn = firstChild(); 898 cn = firstChild();
888 if ( !cn ) 899 if ( !cn )
889 return; 900 return;
890 while ( cn->nextSibling() ) 901 while ( cn->nextSibling() )
891 cn = cn->nextSibling(); 902 cn = cn->nextSibling();
892 setCurrentItem ( cn ); 903 setCurrentItem ( cn );
893 ensureItemVisible ( cn ); 904 ensureItemVisible ( cn );
894 905
895 e->accept(); 906 e->accept();
896 return; 907 return;
897 } 908 }
898 if ( e->state() == ControlButton ) { 909 if ( e->state() == ControlButton ) {
899 int count = childCount (); 910 int count = childCount ();
900 int jump = count / 5; 911 int jump = count / 5;
901 QListViewItem* cn; 912 QListViewItem* cn;
902 cn = currentItem(); 913 cn = currentItem();
903 if ( ! cn ) 914 if ( ! cn )
904 return; 915 return;
905 if ( jump == 0 ) 916 if ( jump == 0 )
906 jump = 1; 917 jump = 1;
907 while ( jump && cn->nextSibling() ) { 918 while ( jump && cn->nextSibling() ) {
908 cn = cn->nextSibling(); 919 cn = cn->nextSibling();
909 --jump; 920 --jump;
910 } 921 }
911 setCurrentItem ( cn ); 922 setCurrentItem ( cn );
912 ensureItemVisible ( cn ); 923 ensureItemVisible ( cn );
913 924
914 } else 925 } else
915 QListView::keyPressEvent ( e ) ; 926 QListView::keyPressEvent ( e ) ;
916 e->accept(); 927 e->accept();
917 break; 928 break;
918 929
919 case Qt::Key_Up: 930 case Qt::Key_Up:
920 if ( e->state() == ShiftButton ) { 931 if ( e->state() == ShiftButton ) {
921 QListViewItem* cn = firstChild(); 932 QListViewItem* cn = firstChild();
922 if ( cn ) { 933 if ( cn ) {
923 setCurrentItem ( cn ); 934 setCurrentItem ( cn );
924 ensureItemVisible ( cn ); 935 ensureItemVisible ( cn );
925 } 936 }
926 e->accept(); 937 e->accept();
927 return; 938 return;
928 } 939 }
929 if ( e->state() == ControlButton ) { 940 if ( e->state() == ControlButton ) {
930 int count = childCount (); 941 int count = childCount ();
931 int jump = count / 5; 942 int jump = count / 5;
932 QListViewItem* cn; 943 QListViewItem* cn;
933 cn = currentItem(); 944 cn = currentItem();
934 if ( ! cn ) 945 if ( ! cn )
935 return; 946 return;
936 if ( jump == 0 ) 947 if ( jump == 0 )
937 jump = 1; 948 jump = 1;
938 while ( jump && cn->itemAbove ()) { 949 while ( jump && cn->itemAbove ()) {
939 cn = cn->itemAbove (); 950 cn = cn->itemAbove ();
940 --jump; 951 --jump;
941 } 952 }
942 setCurrentItem ( cn ); 953 setCurrentItem ( cn );
943 ensureItemVisible ( cn ); 954 ensureItemVisible ( cn );
944 } else 955 } else
945 QListView::keyPressEvent ( e ) ; 956 QListView::keyPressEvent ( e ) ;
946 e->accept(); 957 e->accept();
947 break; 958 break;
948 case Qt::Key_I: { 959 case Qt::Key_I: {
949 QListViewItem* cn; 960 QListViewItem* cn;
950 cn = currentItem(); 961 cn = currentItem();
951 if ( cn ) { 962 if ( cn ) {
952 KOListViewItem* ci = (KOListViewItem*)( cn ); 963 KOListViewItem* ci = (KOListViewItem*)( cn );
953 if ( ci ){ 964 if ( ci ){
954 emit showIncidence( ci->data()); 965 emit showIncidence( ci->data());
955 cn = cn->nextSibling(); 966 cn = cn->nextSibling();
956 if ( cn ) { 967 if ( cn ) {
957 setCurrentItem ( cn ); 968 setCurrentItem ( cn );
958 ensureItemVisible ( cn ); 969 ensureItemVisible ( cn );
959 } 970 }
960 } 971 }
961 } 972 }
962 e->accept(); 973 e->accept();
963 } 974 }
964 break; 975 break;
965 case Qt::Key_Return: 976 case Qt::Key_Return:
966 case Qt::Key_Enter: 977 case Qt::Key_Enter:
967 { 978 {
968 QListViewItem* cn; 979 QListViewItem* cn;
969 cn = currentItem(); 980 cn = currentItem();
970 if ( cn ) { 981 if ( cn ) {
971 KOListViewItem* ci = (KOListViewItem*)( cn ); 982 KOListViewItem* ci = (KOListViewItem*)( cn );
972 if ( ci ){ 983 if ( ci ){
973 if ( e->state() == ShiftButton ) 984 if ( e->state() == ShiftButton )
974 ci->setSelected( false ); 985 ci->setSelected( false );
975 else 986 else
976 ci->setSelected( true ); 987 ci->setSelected( true );
977 cn = cn->nextSibling(); 988 cn = cn->nextSibling();
978 if ( cn ) { 989 if ( cn ) {
979 setCurrentItem ( cn ); 990 setCurrentItem ( cn );
980 ensureItemVisible ( cn ); 991 ensureItemVisible ( cn );
981 } 992 }
982 } 993 }
983 } 994 }
984 e->accept(); 995 e->accept();
985 } 996 }
986 break; 997 break;
987 default: 998 default:
988 e->ignore(); 999 e->ignore();
989 } 1000 }
990} 1001}
991KOListViewListView::KOListViewListView(KOListView * lv ) 1002KOListViewListView::KOListViewListView(KOListView * lv )
992 : KListView( lv ) 1003 : KListView( lv )
993{ 1004{
994#ifndef DESKTOP_VERSION 1005#ifndef DESKTOP_VERSION
995 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1006 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
996#endif 1007#endif
997 setSelectionMode( QListView::Multi ); 1008 setSelectionMode( QListView::Multi );
998 setMultiSelection( true); 1009 setMultiSelection( true);
999 mAllowPopupMenu = true; 1010 mAllowPopupMenu = true;
1000 mMouseDown = false; 1011 mMouseDown = false;
1001 1012
1002} 1013}
1003void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1014void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1004{ 1015{
1005 if (!e) return; 1016 if (!e) return;
1006 QPoint vp = contentsToViewport(e->pos()); 1017 QPoint vp = contentsToViewport(e->pos());
1007 QListViewItem *item = itemAt(vp); 1018 QListViewItem *item = itemAt(vp);
1008 if (!item) { 1019 if (!item) {
1009 emit newEvent(); 1020 emit newEvent();
1010 return; 1021 return;
1011 } 1022 }
1012 KListView::contentsMouseDoubleClickEvent(e); 1023 KListView::contentsMouseDoubleClickEvent(e);
1013} 1024}
1014 1025
1015 1026
1016void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1027void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1017{ 1028{
1018 //qDebug("contentsMousePressEvent++++ "); 1029 //qDebug("contentsMousePressEvent++++ ");
1019 if (! mMouseDown ) { 1030 if (! mMouseDown ) {
1020 mAllowPopupMenu = true; 1031 mAllowPopupMenu = true;
1021 mYMousePos = mapToGlobal( (e->pos())).y(); 1032 mYMousePos = mapToGlobal( (e->pos())).y();
1022 } 1033 }
1023 if ( e->button() == RightButton && mMouseDown ) 1034 if ( e->button() == RightButton && mMouseDown )
1024 return; 1035 return;
1025 if ( e->button() == LeftButton ) 1036 if ( e->button() == LeftButton )
1026 mMouseDown = true; 1037 mMouseDown = true;
1027 KListView::contentsMousePressEvent( e ); 1038 KListView::contentsMousePressEvent( e );
1028} 1039}
1029void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1040void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1030{ 1041{
1031 //qDebug("contentsMouseReleaseEv---- "); 1042 //qDebug("contentsMouseReleaseEv---- ");
1032 if ( ! mMouseDown ) { 1043 if ( ! mMouseDown ) {
1033 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1044 if ( e->button() == RightButton && ! mAllowPopupMenu )
1034 return; 1045 return;
1035 QListViewItem* ci = currentItem(); 1046 QListViewItem* ci = currentItem();
1036 if ( ci ) 1047 if ( ci )
1037 ci->setSelected( true ); 1048 ci->setSelected( true );
1038 KListView::contentsMouseReleaseEvent(e); 1049 KListView::contentsMouseReleaseEvent(e);
1039 return; 1050 return;
1040 } 1051 }
1041 if ( e->button() == LeftButton ) 1052 if ( e->button() == LeftButton )
1042 mMouseDown = false; 1053 mMouseDown = false;
1043 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1054 if ( e->button() == RightButton && ! mAllowPopupMenu )
1044 return; 1055 return;
1045 if ( e->button() == RightButton ) { 1056 if ( e->button() == RightButton ) {
1046 QListViewItem* ci = currentItem(); 1057 QListViewItem* ci = currentItem();
1047 if ( ci ) 1058 if ( ci )
1048 ci->setSelected( true ); 1059 ci->setSelected( true );
1049 } 1060 }
1050 KListView::contentsMouseReleaseEvent(e); 1061 KListView::contentsMouseReleaseEvent(e);
1051} 1062}
1052void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1063void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1053{ 1064{
1054 // qDebug("contentsMouseMoveEv....... "); 1065 // qDebug("contentsMouseMoveEv....... ");
1055 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1066 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1056 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1067 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1057 if ( diff < 0 ) diff = -diff; 1068 if ( diff < 0 ) diff = -diff;
1058 if ( diff > 20 ) 1069 if ( diff > 20 )
1059 mAllowPopupMenu = false; 1070 mAllowPopupMenu = false;
1060 KListView::contentsMouseMoveEvent(e); 1071 KListView::contentsMouseMoveEvent(e);
1061} 1072}
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index c8a55d2..ca53828 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,104 +1,106 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qcopchannel_qws.h> 5#include <qcopchannel_qws.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#else 8#else
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qstring.h> 10#include <qstring.h>
11#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
12#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
13#include <qsgistyle.h> 13#include <qsgistyle.h>
14#endif 14#endif
15#include <qtextcodec.h>
15 16
16#include <qdir.h> 17#include <qdir.h>
17#include <kstandarddirs.h> 18#include <kstandarddirs.h>
18#include <kglobal.h> 19#include <kglobal.h>
19#include <stdio.h> 20#include <stdio.h>
20#include "mainwindow.h" 21#include "mainwindow.h"
21 22
22int main( int argc, char **argv ) 23int main( int argc, char **argv )
23{ 24{
24#ifndef DESKTOP_VERSION 25#ifndef DESKTOP_VERSION
25 QPEApplication a( argc, argv ); 26 QPEApplication a( argc, argv );
26 a.setKeepRunning (); 27 a.setKeepRunning ();
27#else 28#else
28 QApplication a( argc, argv ); 29 QApplication a( argc, argv );
29 QApplication::setStyle( new QPlatinumStyle ()); 30 QApplication::setStyle( new QPlatinumStyle ());
30 QString hdir = QDir::homeDirPath(); 31 QString hdir = QDir::homeDirPath();
31 // there is a bug when creating dirs for WIN 98 32 // there is a bug when creating dirs for WIN 98
32 // it is difficult to fix, because we have no WIN 98 runnung 33 // it is difficult to fix, because we have no WIN 98 runnung
33 // such that we try it to create the dirs at startup here 34 // such that we try it to create the dirs at startup here
34 if ( hdir == "C:\\" ) { // win 98 or ME 35 if ( hdir == "C:\\" ) { // win 98 or ME
35 QDir app_dir; 36 QDir app_dir;
36 if ( !app_dir.exists("C:\\kdepim") ) 37 if ( !app_dir.exists("C:\\kdepim") )
37 app_dir.mkdir ("C:\\kdepim"); 38 app_dir.mkdir ("C:\\kdepim");
38 if ( !app_dir.exists("C:\\kdepim\\apps") ) 39 if ( !app_dir.exists("C:\\kdepim\\apps") )
39 app_dir.mkdir ("C:\\kdepim\\apps"); 40 app_dir.mkdir ("C:\\kdepim\\apps");
40 if ( !app_dir.exists("C:\\kdepim\\config") ) 41 if ( !app_dir.exists("C:\\kdepim\\config") )
41 app_dir.mkdir ("C:\\kdepim\\config"); 42 app_dir.mkdir ("C:\\kdepim\\config");
42 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") ) 43 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") )
43 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer"); 44 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer");
44 } 45 }
45#endif 46#endif
46 bool exitHelp = false; 47 bool exitHelp = false;
47 if ( argc > 1 ) { 48 if ( argc > 1 ) {
48 QString command = argv[1]; 49 QString command = argv[1];
49 if ( command == "-help" ){ 50 if ( command == "-help" ){
50 printf("KO/Pi command line commands:\n"); 51 printf("KO/Pi command line commands:\n");
51 printf(" no command: Start KO/Pi in usual way\n"); 52 printf(" no command: Start KO/Pi in usual way\n");
52 printf(" -help: This output\n"); 53 printf(" -help: This output\n");
53 printf("Next Option: Open or Show after start:\n"); 54 printf("Next Option: Open or Show after start:\n");
54 printf(" -newTodo: New Todo dialog\n"); 55 printf(" -newTodo: New Todo dialog\n");
55 printf(" -newEvent: New Event dialog\n"); 56 printf(" -newEvent: New Event dialog\n");
56 printf(" -showList: List view\n"); 57 printf(" -showList: List view\n");
57 printf(" -showDay: Day view\n"); 58 printf(" -showDay: Day view\n");
58 printf(" -showWWeek: Work Week view\n"); 59 printf(" -showWWeek: Work Week view\n");
59 printf(" -showWeek: Week view\n"); 60 printf(" -showWeek: Week view\n");
60 printf(" -showTodo: Todo view\n"); 61 printf(" -showTodo: Todo view\n");
61 printf(" -showJournal: Journal view\n"); 62 printf(" -showJournal: Journal view\n");
62 printf(" -showKO: Next Days view\n"); 63 printf(" -showKO: Next Days view\n");
63 printf(" -showWNext: What's Next view\n"); 64 printf(" -showWNext: What's Next view\n");
64 printf(" -showNextXView: Next X View\n"); 65 printf(" -showNextXView: Next X View\n");
65 printf(" -new[Y] and -show[X] may be used togehther\n"); 66 printf(" -new[Y] and -show[X] may be used togehther\n");
66 printf(" KO/Pi is exiting now. Bye!\n"); 67 printf(" KO/Pi is exiting now. Bye!\n");
67 exitHelp = true; 68 exitHelp = true;
68 } 69 }
69 } 70 }
70 if ( ! exitHelp ) { 71 if ( ! exitHelp ) {
71 KGlobal::setAppName( "korganizer" ); 72 KGlobal::setAppName( "korganizer" );
72 QString fileName ; 73 QString fileName ;
73#ifndef DESKTOP_VERSION 74#ifndef DESKTOP_VERSION
74 fileName = getenv("QPEDIR"); 75 fileName = getenv("QPEDIR");
75 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 76 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
76#else 77#else
77 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 78 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
78 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 79 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
79#endif 80#endif
80 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); 81 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
81 MainWindow m; 82 MainWindow m;
82#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
83 84
84 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 85 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
85 a.showMainWidget(&m ); 86 a.showMainWidget(&m );
86#else 87#else
87 a.setMainWidget(&m ); 88 a.setMainWidget(&m );
88 m.show(); 89 m.show();
89 //m.resize( 800, 600 ); 90 //m.resize( 800, 600 );
90 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 91 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
91#endif 92#endif
92 if ( argc > 1 ) { 93 if ( argc > 1 ) {
93 QCString command = argv[1]; 94 QCString command = argv[1];
94 if ( argc > 2 ) 95 if ( argc > 2 )
95 command += argv[2]; 96 command += argv[2];
96 qApp->processEvents(); 97 qApp->processEvents();
97 m.recieve(command, QByteArray() ); 98 m.recieve(command, QByteArray() );
98 99
99 } 100 }
101
100 a.exec(); 102 a.exec();
101 103
102 } 104 }
103 qDebug("KO: Bye! "); 105 qDebug("KO: Bye! ");
104} 106}
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
index 8b6dfbc..8404c3e 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -1,201 +1,208 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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$Id$ 23$Id$
24*/ 24*/
25 25
26#include "getmasterpwwnd_emb.h" 26#include "getmasterpwwnd_emb.h"
27 27
28#include "klocale.h" 28#include "klocale.h"
29 29
30/* 30/*
31#include <qvariant.h> 31#include <qvariant.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlineedit.h> 34#include <qlineedit.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qtooltip.h> 36#include <qtooltip.h>
37#include <qwhatsthis.h> 37#include <qwhatsthis.h>
38*/ 38*/
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h>
45 46
46/* 47/*
47 * Constructs a getMasterPwWnd as a child of 'parent', with the 48 * Constructs a getMasterPwWnd as a child of 'parent', with the
48 * name 'name' 49 * name 'name'
49 */ 50 */
50getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name) 51getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
51 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ), 52 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
52 KDialogBase::Ok | KDialogBase::Cancel, 53 KDialogBase::Ok | KDialogBase::Cancel,
53 KDialogBase::Ok, parent, name, true ) 54 KDialogBase::Ok, parent, name, true )
54{ 55{
55 QWidget *page = plainPage(); 56 QWidget *page = plainPage();
56 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 57 QVBoxLayout *pageLayout = new QVBoxLayout( page );
57 58
58 pwLineEdit = new QLineEdit( page, "pwLineEdit" ); 59 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
59 pwLineEdit->setEchoMode( QLineEdit::Password ); 60 pwLineEdit->setEchoMode( QLineEdit::Password );
60 61
61 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" ); 62 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
62 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 63 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
63 pageLayout->addWidget(textLabel1); 64 pageLayout->addWidget(textLabel1);
64 pageLayout->addWidget(pwLineEdit); 65 pageLayout->addWidget(pwLineEdit);
65 66
66 QWidget* numberBox = new QWidget( page ); 67 QWidget* numberBox = new QWidget( page );
67#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
68 numberBox->setFixedHeight(150); 69 if ( QApplication::desktop()->width() > 320 ) {
69 numberBox->setFixedWidth(150); 70 numberBox->setFixedHeight(250);
71 numberBox->setFixedWidth(200);
72 }
73 else{
74 numberBox->setFixedHeight(150);
75 numberBox->setFixedWidth(150);
76 }
70#endif 77#endif
71 78
72 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 ); 79 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 );
73 numberLayout->setMargin( 0 ); 80 numberLayout->setMargin( 0 );
74 numberLayout->setSpacing( 0 ); 81 numberLayout->setSpacing( 0 );
75 82
76 QPushButton* p1 = new QPushButton( i18n("1"), numberBox ); 83 QPushButton* p1 = new QPushButton( i18n("1"), numberBox );
77 numberLayout->addWidget( p1, 0, 0 ); 84 numberLayout->addWidget( p1, 0, 0 );
78 QPushButton* p2 = new QPushButton( i18n("2"), numberBox ); 85 QPushButton* p2 = new QPushButton( i18n("2"), numberBox );
79 numberLayout->addWidget( p2, 0, 1 ); 86 numberLayout->addWidget( p2, 0, 1 );
80 QPushButton* p3 = new QPushButton( i18n("3"), numberBox ); 87 QPushButton* p3 = new QPushButton( i18n("3"), numberBox );
81 numberLayout->addWidget( p3, 0, 2 ); 88 numberLayout->addWidget( p3, 0, 2 );
82 QPushButton* p4 = new QPushButton( i18n("4"), numberBox ); 89 QPushButton* p4 = new QPushButton( i18n("4"), numberBox );
83 numberLayout->addWidget( p4, 1, 0 ); 90 numberLayout->addWidget( p4, 1, 0 );
84 QPushButton* p5 = new QPushButton( i18n("5"), numberBox ); 91 QPushButton* p5 = new QPushButton( i18n("5"), numberBox );
85 numberLayout->addWidget( p5, 1, 1 ); 92 numberLayout->addWidget( p5, 1, 1 );
86 QPushButton* p6 = new QPushButton( i18n("6"), numberBox ); 93 QPushButton* p6 = new QPushButton( i18n("6"), numberBox );
87 numberLayout->addWidget( p6, 1, 2 ); 94 numberLayout->addWidget( p6, 1, 2 );
88 QPushButton* p7 = new QPushButton( i18n("7"), numberBox ); 95 QPushButton* p7 = new QPushButton( i18n("7"), numberBox );
89 numberLayout->addWidget( p7, 2, 0 ); 96 numberLayout->addWidget( p7, 2, 0 );
90 QPushButton* p8 = new QPushButton( i18n("8"), numberBox ); 97 QPushButton* p8 = new QPushButton( i18n("8"), numberBox );
91 numberLayout->addWidget( p8, 2, 1 ); 98 numberLayout->addWidget( p8, 2, 1 );
92 QPushButton* p9 = new QPushButton( i18n("9"), numberBox ); 99 QPushButton* p9 = new QPushButton( i18n("9"), numberBox );
93 numberLayout->addWidget( p9, 2, 2 ); 100 numberLayout->addWidget( p9, 2, 2 );
94 QPushButton* clear = new QPushButton( i18n("x"), numberBox ); 101 QPushButton* clear = new QPushButton( i18n("x"), numberBox );
95 numberLayout->addWidget( clear, 3, 0 ); 102 numberLayout->addWidget( clear, 3, 0 );
96 QPushButton* p0 = new QPushButton( i18n("0"), numberBox ); 103 QPushButton* p0 = new QPushButton( i18n("0"), numberBox );
97 numberLayout->addWidget( p0, 3, 1 ); 104 numberLayout->addWidget( p0, 3, 1 );
98 QPushButton* backspace = new QPushButton( i18n("-"), numberBox ); 105 QPushButton* backspace = new QPushButton( i18n("-"), numberBox );
99 numberLayout->addWidget( backspace, 3, 2 ); 106 numberLayout->addWidget( backspace, 3, 2 );
100 107
101 108
102 pageLayout->addWidget(numberBox); 109 pageLayout->addWidget(numberBox);
103#ifdef DESKTOP_VERSION 110#ifdef DESKTOP_VERSION
104 resize( sizeHint() ); 111 resize( sizeHint() );
105#else 112#else
106 resize( 200,sizeHint().height() ); 113 resize( 200,sizeHint().height() );
107#endif 114#endif
108 115
109 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) ); 116 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) );
110 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) ); 117 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) );
111 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) ); 118 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) );
112 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) ); 119 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) );
113 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) ); 120 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) );
114 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) ); 121 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) );
115 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) ); 122 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) );
116 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) ); 123 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) );
117 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) ); 124 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) );
118 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) ); 125 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) );
119 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) ); 126 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) );
120 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 127 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
121 128
122 129
123 130
124} 131}
125 132
126/* 133/*
127 * Destroys the object and frees any allocated resources 134 * Destroys the object and frees any allocated resources
128 */ 135 */
129getMasterPwWnd::~getMasterPwWnd() 136getMasterPwWnd::~getMasterPwWnd()
130{ 137{
131 // no need to delete child widgets, Qt does it all for us 138 // no need to delete child widgets, Qt does it all for us
132} 139}
133 140
134void getMasterPwWnd::okButton_slot() 141void getMasterPwWnd::okButton_slot()
135{ 142{
136 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" ); 143 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
137} 144}
138 145
139void getMasterPwWnd::cancelButton_slot() 146void getMasterPwWnd::cancelButton_slot()
140{ 147{
141 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 148 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
142} 149}
143 150
144void getMasterPwWnd::add0() 151void getMasterPwWnd::add0()
145{ 152{
146 addCharacter("0"); 153 addCharacter("0");
147} 154}
148void getMasterPwWnd::add1() 155void getMasterPwWnd::add1()
149{ 156{
150 addCharacter("1"); 157 addCharacter("1");
151} 158}
152void getMasterPwWnd::add2() 159void getMasterPwWnd::add2()
153{ 160{
154 addCharacter("2"); 161 addCharacter("2");
155} 162}
156void getMasterPwWnd::add3() 163void getMasterPwWnd::add3()
157{ 164{
158 addCharacter("3"); 165 addCharacter("3");
159} 166}
160void getMasterPwWnd::add4() 167void getMasterPwWnd::add4()
161{ 168{
162 addCharacter("4"); 169 addCharacter("4");
163} 170}
164void getMasterPwWnd::add5() 171void getMasterPwWnd::add5()
165{ 172{
166 addCharacter("5"); 173 addCharacter("5");
167} 174}
168void getMasterPwWnd::add6() 175void getMasterPwWnd::add6()
169{ 176{
170 addCharacter("6"); 177 addCharacter("6");
171} 178}
172void getMasterPwWnd::add7() 179void getMasterPwWnd::add7()
173{ 180{
174 addCharacter("7"); 181 addCharacter("7");
175} 182}
176void getMasterPwWnd::add8() 183void getMasterPwWnd::add8()
177{ 184{
178 addCharacter("8"); 185 addCharacter("8");
179} 186}
180void getMasterPwWnd::add9() 187void getMasterPwWnd::add9()
181{ 188{
182 addCharacter("9"); 189 addCharacter("9");
183} 190}
184void getMasterPwWnd::backspace() 191void getMasterPwWnd::backspace()
185{ 192{
186 QString old = pwLineEdit->text(); 193 QString old = pwLineEdit->text();
187 old.truncate(old.length()-1); 194 old.truncate(old.length()-1);
188 pwLineEdit->setText(old); 195 pwLineEdit->setText(old);
189} 196}
190 197
191void getMasterPwWnd::clear() 198void getMasterPwWnd::clear()
192{ 199{
193 pwLineEdit->setText(""); 200 pwLineEdit->setText("");
194} 201}
195 202
196void getMasterPwWnd::addCharacter(const QString& s) 203void getMasterPwWnd::addCharacter(const QString& s)
197{ 204{
198 QString old = pwLineEdit->text(); 205 QString old = pwLineEdit->text();
199 pwLineEdit->setText(old + s); 206 pwLineEdit->setText(old + s);
200} 207}
201 208