summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -7,768 +7,770 @@
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( )
@@ -2498,406 +2500,408 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
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
@@ -114,467 +114,468 @@ void KOEventViewer::setSource(const QString& n)
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