summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-06 16:20:25 (UTC)
committer zautrix <zautrix>2004-10-06 16:20:25 (UTC)
commit656636acfb8c607901c97c4f55129e29e1df9913 (patch) (unidiff)
tree25efd61a6b691822a11f43719efcbf69ce7d5c25
parenta22de800110d8350a5200a994b041e47d51bf4c6 (diff)
downloadkdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.zip
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.gz
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp32
-rw-r--r--korganizer/mainwindow.cpp5
-rw-r--r--libkcal/libkcal.pro2
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/phoneformat.cpp117
-rw-r--r--libkcal/phoneformat.h1
6 files changed, 22 insertions, 137 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 185cf46..7bec90a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1763 +1,1759 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 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 <qlineedit.h> 38#include <qlineedit.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qprogressbar.h> 41#include <qprogressbar.h>
42#include <libkdepim/phoneaccess.h>
42 43
43#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
44#include <qclipboard.h> 45#include <qclipboard.h>
45#include <qdir.h> 46#include <qdir.h>
46#include <qfile.h> 47#include <qfile.h>
47#include <qapplicaton.h> 48#include <qapplicaton.h>
48#include <qprogressbar.h> 49#include <qprogressbar.h>
49#include <qlayout.h> 50#include <qlayout.h>
50#include <qregexp.h> 51#include <qregexp.h>
51#include <qvbox.h> 52#include <qvbox.h>
52#include <kabc/addresseelist.h> 53#include <kabc/addresseelist.h>
53#include <kabc/errorhandler.h> 54#include <kabc/errorhandler.h>
54#include <kabc/resource.h> 55#include <kabc/resource.h>
55#include <kabc/vcardconverter.h> 56#include <kabc/vcardconverter.h>
56#include <kapplication.h> 57#include <kapplication.h>
57#include <kactionclasses.h> 58#include <kactionclasses.h>
58#include <kcmultidialog.h> 59#include <kcmultidialog.h>
59#include <kdebug.h> 60#include <kdebug.h>
60#include <kdeversion.h> 61#include <kdeversion.h>
61#include <kkeydialog.h> 62#include <kkeydialog.h>
62#include <kmessagebox.h> 63#include <kmessagebox.h>
63#include <kprinter.h> 64#include <kprinter.h>
64#include <kprotocolinfo.h> 65#include <kprotocolinfo.h>
65#include <kresources/selectdialog.h> 66#include <kresources/selectdialog.h>
66#include <kstandarddirs.h> 67#include <kstandarddirs.h>
67#include <ktempfile.h> 68#include <ktempfile.h>
68#include <kxmlguiclient.h> 69#include <kxmlguiclient.h>
69#include <kaboutdata.h> 70#include <kaboutdata.h>
70#include <libkdepim/categoryselectdialog.h> 71#include <libkdepim/categoryselectdialog.h>
71 72
72#include "addresseeutil.h" 73#include "addresseeutil.h"
73#include "addresseeeditordialog.h" 74#include "addresseeeditordialog.h"
74#include "extensionmanager.h" 75#include "extensionmanager.h"
75#include "kstdaction.h" 76#include "kstdaction.h"
76#include "kaddressbookservice.h" 77#include "kaddressbookservice.h"
77#include "ldapsearchdialog.h" 78#include "ldapsearchdialog.h"
78#include "printing/printingwizard.h" 79#include "printing/printingwizard.h"
79#else // KAB_EMBEDDED 80#else // KAB_EMBEDDED
80 81
81#include <kapplication.h> 82#include <kapplication.h>
82#include "KDGanttMinimizeSplitter.h" 83#include "KDGanttMinimizeSplitter.h"
83#include "kaddressbookmain.h" 84#include "kaddressbookmain.h"
84#include "kactioncollection.h" 85#include "kactioncollection.h"
85#include "addresseedialog.h" 86#include "addresseedialog.h"
86//US 87//US
87#include <addresseeview.h> 88#include <addresseeview.h>
88 89
89#include <qapp.h> 90#include <qapp.h>
90#include <qmenubar.h> 91#include <qmenubar.h>
91//#include <qtoolbar.h> 92//#include <qtoolbar.h>
92#include <qmessagebox.h> 93#include <qmessagebox.h>
93#include <kdebug.h> 94#include <kdebug.h>
94#include <kiconloader.h> // needed for SmallIcon 95#include <kiconloader.h> // needed for SmallIcon
95#include <kresources/kcmkresources.h> 96#include <kresources/kcmkresources.h>
96#include <ktoolbar.h> 97#include <ktoolbar.h>
97 98
98 99
99//#include <qlabel.h> 100//#include <qlabel.h>
100 101
101 102
102#ifndef DESKTOP_VERSION 103#ifndef DESKTOP_VERSION
103#include <qpe/ir.h> 104#include <qpe/ir.h>
104#include <qpe/qpemenubar.h> 105#include <qpe/qpemenubar.h>
105#include <qtopia/qcopenvelope_qws.h> 106#include <qtopia/qcopenvelope_qws.h>
106#else 107#else
107 108
108#include <qmenubar.h> 109#include <qmenubar.h>
109#endif 110#endif
110 111
111#endif // KAB_EMBEDDED 112#endif // KAB_EMBEDDED
112#include "kcmconfigs/kcmkabconfig.h" 113#include "kcmconfigs/kcmkabconfig.h"
113#include "kcmconfigs/kcmkdepimconfig.h" 114#include "kcmconfigs/kcmkdepimconfig.h"
114#include "kpimglobalprefs.h" 115#include "kpimglobalprefs.h"
115#include "externalapphandler.h" 116#include "externalapphandler.h"
116 117
117 118
118#include <kresources/selectdialog.h> 119#include <kresources/selectdialog.h>
119#include <kmessagebox.h> 120#include <kmessagebox.h>
120 121
121#include <picture.h> 122#include <picture.h>
122#include <resource.h> 123#include <resource.h>
123 124
124//US#include <qsplitter.h> 125//US#include <qsplitter.h>
125#include <qmap.h> 126#include <qmap.h>
126#include <qdir.h> 127#include <qdir.h>
127#include <qfile.h> 128#include <qfile.h>
128#include <qvbox.h> 129#include <qvbox.h>
129#include <qlayout.h> 130#include <qlayout.h>
130#include <qclipboard.h> 131#include <qclipboard.h>
131#include <qtextstream.h> 132#include <qtextstream.h>
132 133
133#include <libkdepim/categoryselectdialog.h> 134#include <libkdepim/categoryselectdialog.h>
134#include <kabc/vcardconverter.h> 135#include <kabc/vcardconverter.h>
135 136
136 137
137#include "addresseeutil.h" 138#include "addresseeutil.h"
138#include "undocmds.h" 139#include "undocmds.h"
139#include "addresseeeditordialog.h" 140#include "addresseeeditordialog.h"
140#include "viewmanager.h" 141#include "viewmanager.h"
141#include "details/detailsviewcontainer.h" 142#include "details/detailsviewcontainer.h"
142#include "kabprefs.h" 143#include "kabprefs.h"
143#include "xxportmanager.h" 144#include "xxportmanager.h"
144#include "incsearchwidget.h" 145#include "incsearchwidget.h"
145#include "jumpbuttonbar.h" 146#include "jumpbuttonbar.h"
146#include "extensionmanager.h" 147#include "extensionmanager.h"
147#include "addresseeconfig.h" 148#include "addresseeconfig.h"
148#include <kcmultidialog.h> 149#include <kcmultidialog.h>
149 150
150#ifdef _WIN32_ 151#ifdef _WIN32_
151 152
152#include "kaimportoldialog.h" 153#include "kaimportoldialog.h"
153#else 154#else
154#include <unistd.h> 155#include <unistd.h>
155#endif 156#endif
156// sync includes 157// sync includes
157#include <libkdepim/ksyncprofile.h> 158#include <libkdepim/ksyncprofile.h>
158#include <libkdepim/ksyncprefsdialog.h> 159#include <libkdepim/ksyncprefsdialog.h>
159 160
160class KAex2phonePrefs : public QDialog 161class KAex2phonePrefs : public QDialog
161{ 162{
162 public: 163 public:
163 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 164 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
164 QDialog( parent, name, true ) 165 QDialog( parent, name, true )
165 { 166 {
166 setCaption( i18n("Export to phone options") ); 167 setCaption( i18n("Export to phone options") );
167 QVBoxLayout* lay = new QVBoxLayout( this ); 168 QVBoxLayout* lay = new QVBoxLayout( this );
168 lay->setSpacing( 3 ); 169 lay->setSpacing( 3 );
169 lay->setMargin( 3 ); 170 lay->setMargin( 3 );
170 QLabel *lab; 171 QLabel *lab;
171 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 172 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
172 lab->setAlignment (AlignHCenter ); 173 lab->setAlignment (AlignHCenter );
173 QHBox* temphb; 174 QHBox* temphb;
174 temphb = new QHBox( this ); 175 temphb = new QHBox( this );
175 new QLabel( i18n("I/O device: "), temphb ); 176 new QLabel( i18n("I/O device: "), temphb );
176 mPhoneDevice = new QLineEdit( temphb); 177 mPhoneDevice = new QLineEdit( temphb);
177 lay->addWidget( temphb ); 178 lay->addWidget( temphb );
178 temphb = new QHBox( this ); 179 temphb = new QHBox( this );
179 new QLabel( i18n("Connection: "), temphb ); 180 new QLabel( i18n("Connection: "), temphb );
180 mPhoneConnection = new QLineEdit( temphb); 181 mPhoneConnection = new QLineEdit( temphb);
181 lay->addWidget( temphb ); 182 lay->addWidget( temphb );
182 temphb = new QHBox( this ); 183 temphb = new QHBox( this );
183 new QLabel( i18n("Model(opt.): "), temphb ); 184 new QLabel( i18n("Model(opt.): "), temphb );
184 mPhoneModel = new QLineEdit( temphb); 185 mPhoneModel = new QLineEdit( temphb);
185 lay->addWidget( temphb ); 186 lay->addWidget( temphb );
186 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 187 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
187 lay->addWidget( mWriteToSim ); 188 lay->addWidget( mWriteToSim );
188 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 189 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
189 lab->setAlignment (AlignHCenter ); 190 lab->setAlignment (AlignHCenter );
190 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 191 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
191 lay->addWidget( ok ); 192 lay->addWidget( ok );
192 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 193 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
193 lay->addWidget( cancel ); 194 lay->addWidget( cancel );
194 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 195 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
195 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 196 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
196 resize( 220, 240 ); 197 resize( 220, 240 );
197 198
198 } 199 }
199 200
200public: 201public:
201 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 202 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
202 QCheckBox* mWriteToSim; 203 QCheckBox* mWriteToSim;
203}; 204};
204 205
205bool pasteWithNewUid = true; 206bool pasteWithNewUid = true;
206 207
207#ifdef KAB_EMBEDDED 208#ifdef KAB_EMBEDDED
208KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 209KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
209 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 210 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
210 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 211 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
211 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 212 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
212#else //KAB_EMBEDDED 213#else //KAB_EMBEDDED
213KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 214KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
214 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 215 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
215 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 216 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
216 mReadWrite( readWrite ), mModified( false ) 217 mReadWrite( readWrite ), mModified( false )
217#endif //KAB_EMBEDDED 218#endif //KAB_EMBEDDED
218{ 219{
219 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 220 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
220 // syncManager->setBlockSave(false); 221 // syncManager->setBlockSave(false);
221 mExtensionBarSplitter = 0; 222 mExtensionBarSplitter = 0;
222 mIsPart = !parent->inherits( "KAddressBookMain" ); 223 mIsPart = !parent->inherits( "KAddressBookMain" );
223 224
224 mAddressBook = KABC::StdAddressBook::self(); 225 mAddressBook = KABC::StdAddressBook::self();
225 KABC::StdAddressBook::setAutomaticSave( false ); 226 KABC::StdAddressBook::setAutomaticSave( false );
226 227
227#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
228 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 229 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
229#endif //KAB_EMBEDDED 230#endif //KAB_EMBEDDED
230 231
231 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 232 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
232 SLOT( addressBookChanged() ) ); 233 SLOT( addressBookChanged() ) );
233 234
234#if 0 235#if 0
235 // LP moved to addressbook init method 236 // LP moved to addressbook init method
236 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 237 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
237 "X-Department", "KADDRESSBOOK" ); 238 "X-Department", "KADDRESSBOOK" );
238 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 239 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
239 "X-Profession", "KADDRESSBOOK" ); 240 "X-Profession", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 241 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
241 "X-AssistantsName", "KADDRESSBOOK" ); 242 "X-AssistantsName", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 243 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
243 "X-ManagersName", "KADDRESSBOOK" ); 244 "X-ManagersName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 245 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
245 "X-SpousesName", "KADDRESSBOOK" ); 246 "X-SpousesName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 247 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
247 "X-Office", "KADDRESSBOOK" ); 248 "X-Office", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 249 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
249 "X-IMAddress", "KADDRESSBOOK" ); 250 "X-IMAddress", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 251 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
251 "X-Anniversary", "KADDRESSBOOK" ); 252 "X-Anniversary", "KADDRESSBOOK" );
252 253
253 //US added this field to become compatible with Opie/qtopia addressbook 254 //US added this field to become compatible with Opie/qtopia addressbook
254 // values can be "female" or "male" or "". An empty field represents undefined. 255 // values can be "female" or "male" or "". An empty field represents undefined.
255 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 256 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
256 "X-Gender", "KADDRESSBOOK" ); 257 "X-Gender", "KADDRESSBOOK" );
257 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 258 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
258 "X-Children", "KADDRESSBOOK" ); 259 "X-Children", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 260 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
260 "X-FreeBusyUrl", "KADDRESSBOOK" ); 261 "X-FreeBusyUrl", "KADDRESSBOOK" );
261#endif 262#endif
262 initGUI(); 263 initGUI();
263 264
264 mIncSearchWidget->setFocus(); 265 mIncSearchWidget->setFocus();
265 266
266 267
267 connect( mViewManager, SIGNAL( selected( const QString& ) ), 268 connect( mViewManager, SIGNAL( selected( const QString& ) ),
268 SLOT( setContactSelected( const QString& ) ) ); 269 SLOT( setContactSelected( const QString& ) ) );
269 connect( mViewManager, SIGNAL( executed( const QString& ) ), 270 connect( mViewManager, SIGNAL( executed( const QString& ) ),
270 SLOT( executeContact( const QString& ) ) ); 271 SLOT( executeContact( const QString& ) ) );
271 272
272 connect( mViewManager, SIGNAL( deleteRequest( ) ), 273 connect( mViewManager, SIGNAL( deleteRequest( ) ),
273 SLOT( deleteContacts( ) ) ); 274 SLOT( deleteContacts( ) ) );
274 connect( mViewManager, SIGNAL( modified() ), 275 connect( mViewManager, SIGNAL( modified() ),
275 SLOT( setModified() ) ); 276 SLOT( setModified() ) );
276 277
277 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 278 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
278 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 279 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
279 280
280 connect( mXXPortManager, SIGNAL( modified() ), 281 connect( mXXPortManager, SIGNAL( modified() ),
281 SLOT( setModified() ) ); 282 SLOT( setModified() ) );
282 283
283 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 284 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
284 SLOT( incrementalSearch( const QString& ) ) ); 285 SLOT( incrementalSearch( const QString& ) ) );
285 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 286 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
286 mJumpButtonBar, SLOT( recreateButtons() ) ); 287 mJumpButtonBar, SLOT( recreateButtons() ) );
287 288
288 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 289 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
289 SLOT( sendMail( const QString& ) ) ); 290 SLOT( sendMail( const QString& ) ) );
290 291
291 292
292 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 293 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
293 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&))); 294 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&)));
294 295
295 296
296#ifndef KAB_EMBEDDED 297#ifndef KAB_EMBEDDED
297 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 298 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
298 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 299 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
299 300
300 connect( mDetails, SIGNAL( browse( const QString& ) ), 301 connect( mDetails, SIGNAL( browse( const QString& ) ),
301 SLOT( browse( const QString& ) ) ); 302 SLOT( browse( const QString& ) ) );
302 303
303 304
304 mAddressBookService = new KAddressBookService( this ); 305 mAddressBookService = new KAddressBookService( this );
305 306
306#endif //KAB_EMBEDDED 307#endif //KAB_EMBEDDED
307 mEditorDialog = 0; 308 mEditorDialog = 0;
308 createAddresseeEditorDialog( this ); 309 createAddresseeEditorDialog( this );
309 setModified( false ); 310 setModified( false );
310} 311}
311 312
312KABCore::~KABCore() 313KABCore::~KABCore()
313{ 314{
314 // save(); 315 // save();
315 //saveSettings(); 316 //saveSettings();
316 //KABPrefs::instance()->writeConfig(); 317 //KABPrefs::instance()->writeConfig();
317 delete AddresseeConfig::instance(); 318 delete AddresseeConfig::instance();
318 mAddressBook = 0; 319 mAddressBook = 0;
319 KABC::StdAddressBook::close(); 320 KABC::StdAddressBook::close();
320 321
321 delete syncManager; 322 delete syncManager;
322} 323}
323 324
324void KABCore::restoreSettings() 325void KABCore::restoreSettings()
325{ 326{
326 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 327 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
327 328
328 bool state; 329 bool state;
329 330
330 if (mMultipleViewsAtOnce) 331 if (mMultipleViewsAtOnce)
331 state = KABPrefs::instance()->mDetailsPageVisible; 332 state = KABPrefs::instance()->mDetailsPageVisible;
332 else 333 else
333 state = false; 334 state = false;
334 335
335 mActionDetails->setChecked( state ); 336 mActionDetails->setChecked( state );
336 setDetailsVisible( state ); 337 setDetailsVisible( state );
337 338
338 state = KABPrefs::instance()->mJumpButtonBarVisible; 339 state = KABPrefs::instance()->mJumpButtonBarVisible;
339 340
340 mActionJumpBar->setChecked( state ); 341 mActionJumpBar->setChecked( state );
341 setJumpButtonBarVisible( state ); 342 setJumpButtonBarVisible( state );
342/*US 343/*US
343 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 344 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
344 if ( splitterSize.count() == 0 ) { 345 if ( splitterSize.count() == 0 ) {
345 splitterSize.append( width() / 2 ); 346 splitterSize.append( width() / 2 );
346 splitterSize.append( width() / 2 ); 347 splitterSize.append( width() / 2 );
347 } 348 }
348 mMiniSplitter->setSizes( splitterSize ); 349 mMiniSplitter->setSizes( splitterSize );
349 if ( mExtensionBarSplitter ) { 350 if ( mExtensionBarSplitter ) {
350 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 351 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
351 if ( splitterSize.count() == 0 ) { 352 if ( splitterSize.count() == 0 ) {
352 splitterSize.append( width() / 2 ); 353 splitterSize.append( width() / 2 );
353 splitterSize.append( width() / 2 ); 354 splitterSize.append( width() / 2 );
354 } 355 }
355 mExtensionBarSplitter->setSizes( splitterSize ); 356 mExtensionBarSplitter->setSizes( splitterSize );
356 357
357 } 358 }
358*/ 359*/
359 mViewManager->restoreSettings(); 360 mViewManager->restoreSettings();
360 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 361 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
361 mExtensionManager->restoreSettings(); 362 mExtensionManager->restoreSettings();
362#ifdef DESKTOP_VERSION 363#ifdef DESKTOP_VERSION
363 int wid = width(); 364 int wid = width();
364 if ( wid < 10 ) 365 if ( wid < 10 )
365 wid = 400; 366 wid = 400;
366#else 367#else
367 int wid = QApplication::desktop()->width(); 368 int wid = QApplication::desktop()->width();
368 if ( wid < 640 ) 369 if ( wid < 640 )
369 wid = QApplication::desktop()->height(); 370 wid = QApplication::desktop()->height();
370#endif 371#endif
371 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 372 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
372 if ( true /*splitterSize.count() == 0*/ ) { 373 if ( true /*splitterSize.count() == 0*/ ) {
373 splitterSize.append( wid / 2 ); 374 splitterSize.append( wid / 2 );
374 splitterSize.append( wid / 2 ); 375 splitterSize.append( wid / 2 );
375 } 376 }
376 mMiniSplitter->setSizes( splitterSize ); 377 mMiniSplitter->setSizes( splitterSize );
377 if ( mExtensionBarSplitter ) { 378 if ( mExtensionBarSplitter ) {
378 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 379 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
379 if ( true /*splitterSize.count() == 0*/ ) { 380 if ( true /*splitterSize.count() == 0*/ ) {
380 splitterSize.append( wid / 2 ); 381 splitterSize.append( wid / 2 );
381 splitterSize.append( wid / 2 ); 382 splitterSize.append( wid / 2 );
382 } 383 }
383 mExtensionBarSplitter->setSizes( splitterSize ); 384 mExtensionBarSplitter->setSizes( splitterSize );
384 385
385 } 386 }
386 387
387 388
388} 389}
389 390
390void KABCore::saveSettings() 391void KABCore::saveSettings()
391{ 392{
392 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 393 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
393 if ( mExtensionBarSplitter ) 394 if ( mExtensionBarSplitter )
394 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 395 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
395 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 396 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
396 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 397 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
397#ifndef KAB_EMBEDDED 398#ifndef KAB_EMBEDDED
398 399
399 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 400 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
400 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 401 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
401#endif //KAB_EMBEDDED 402#endif //KAB_EMBEDDED
402 mExtensionManager->saveSettings(); 403 mExtensionManager->saveSettings();
403 mViewManager->saveSettings(); 404 mViewManager->saveSettings();
404 405
405 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 406 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
406} 407}
407 408
408KABC::AddressBook *KABCore::addressBook() const 409KABC::AddressBook *KABCore::addressBook() const
409{ 410{
410 return mAddressBook; 411 return mAddressBook;
411} 412}
412 413
413KConfig *KABCore::config() 414KConfig *KABCore::config()
414{ 415{
415#ifndef KAB_EMBEDDED 416#ifndef KAB_EMBEDDED
416 return KABPrefs::instance()->config(); 417 return KABPrefs::instance()->config();
417#else //KAB_EMBEDDED 418#else //KAB_EMBEDDED
418 return KABPrefs::instance()->getConfig(); 419 return KABPrefs::instance()->getConfig();
419#endif //KAB_EMBEDDED 420#endif //KAB_EMBEDDED
420} 421}
421 422
422KActionCollection *KABCore::actionCollection() const 423KActionCollection *KABCore::actionCollection() const
423{ 424{
424 return mGUIClient->actionCollection(); 425 return mGUIClient->actionCollection();
425} 426}
426 427
427KABC::Field *KABCore::currentSearchField() const 428KABC::Field *KABCore::currentSearchField() const
428{ 429{
429 if (mIncSearchWidget) 430 if (mIncSearchWidget)
430 return mIncSearchWidget->currentField(); 431 return mIncSearchWidget->currentField();
431 else 432 else
432 return 0; 433 return 0;
433} 434}
434 435
435QStringList KABCore::selectedUIDs() const 436QStringList KABCore::selectedUIDs() const
436{ 437{
437 return mViewManager->selectedUids(); 438 return mViewManager->selectedUids();
438} 439}
439 440
440KABC::Resource *KABCore::requestResource( QWidget *parent ) 441KABC::Resource *KABCore::requestResource( QWidget *parent )
441{ 442{
442 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 443 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
443 444
444 QPtrList<KRES::Resource> kresResources; 445 QPtrList<KRES::Resource> kresResources;
445 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 446 QPtrListIterator<KABC::Resource> resIt( kabcResources );
446 KABC::Resource *resource; 447 KABC::Resource *resource;
447 while ( ( resource = resIt.current() ) != 0 ) { 448 while ( ( resource = resIt.current() ) != 0 ) {
448 ++resIt; 449 ++resIt;
449 if ( !resource->readOnly() ) { 450 if ( !resource->readOnly() ) {
450 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 451 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
451 if ( res ) 452 if ( res )
452 kresResources.append( res ); 453 kresResources.append( res );
453 } 454 }
454 } 455 }
455 456
456 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 457 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
457 return static_cast<KABC::Resource*>( res ); 458 return static_cast<KABC::Resource*>( res );
458} 459}
459 460
460#ifndef KAB_EMBEDDED 461#ifndef KAB_EMBEDDED
461KAboutData *KABCore::createAboutData() 462KAboutData *KABCore::createAboutData()
462#else //KAB_EMBEDDED 463#else //KAB_EMBEDDED
463void KABCore::createAboutData() 464void KABCore::createAboutData()
464#endif //KAB_EMBEDDED 465#endif //KAB_EMBEDDED
465{ 466{
466#ifndef KAB_EMBEDDED 467#ifndef KAB_EMBEDDED
467 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 468 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
468 "3.1", I18N_NOOP( "The KDE Address Book" ), 469 "3.1", I18N_NOOP( "The KDE Address Book" ),
469 KAboutData::License_GPL_V2, 470 KAboutData::License_GPL_V2,
470 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 471 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
471 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 472 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
472 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 473 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
473 about->addAuthor( "Cornelius Schumacher", 474 about->addAuthor( "Cornelius Schumacher",
474 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 475 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
475 "schumacher@kde.org" ); 476 "schumacher@kde.org" );
476 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 477 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
477 "mpilone@slac.com" ); 478 "mpilone@slac.com" );
478 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 479 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
479 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 480 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
480 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 481 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
481 "michel@klaralvdalens-datakonsult.se" ); 482 "michel@klaralvdalens-datakonsult.se" );
482 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 483 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
483 "hansen@kde.org" ); 484 "hansen@kde.org" );
484 485
485 return about; 486 return about;
486#endif //KAB_EMBEDDED 487#endif //KAB_EMBEDDED
487 488
488 QString version; 489 QString version;
489#include <../version> 490#include <../version>
490 QMessageBox::about( this, "About KAddressbook/Pi", 491 QMessageBox::about( this, "About KAddressbook/Pi",
491 "KAddressbook/Platform-independent\n" 492 "KAddressbook/Platform-independent\n"
492 "(KA/Pi) " +version + " - " + 493 "(KA/Pi) " +version + " - " +
493#ifdef DESKTOP_VERSION 494#ifdef DESKTOP_VERSION
494 "Desktop Edition\n" 495 "Desktop Edition\n"
495#else 496#else
496 "PDA-Edition\n" 497 "PDA-Edition\n"
497 "for: Zaurus 5500 / 7x0 / 8x0\n" 498 "for: Zaurus 5500 / 7x0 / 8x0\n"
498#endif 499#endif
499 500
500 "(c) 2004 Ulf Schenk\n" 501 "(c) 2004 Ulf Schenk\n"
501 "(c) 2004 Lutz Rogowski\n" 502 "(c) 2004 Lutz Rogowski\n"
502 "(c) 1997-2003, The KDE PIM Team\n" 503 "(c) 1997-2003, The KDE PIM Team\n"
503 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 504 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
504 "Don Sanders Original author\n" 505 "Don Sanders Original author\n"
505 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 506 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
506 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 507 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
507 "Greg Stern DCOP interface\n" 508 "Greg Stern DCOP interface\n"
508 "Mark Westcot Contact pinning\n" 509 "Mark Westcot Contact pinning\n"
509 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 510 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
510 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 511 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
511#ifdef _WIN32_ 512#ifdef _WIN32_
512 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 513 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
513#endif 514#endif
514 ); 515 );
515} 516}
516 517
517void KABCore::setContactSelected( const QString &uid ) 518void KABCore::setContactSelected( const QString &uid )
518{ 519{
519 KABC::Addressee addr = mAddressBook->findByUid( uid ); 520 KABC::Addressee addr = mAddressBook->findByUid( uid );
520 if ( !mDetails->isHidden() ) 521 if ( !mDetails->isHidden() )
521 mDetails->setAddressee( addr ); 522 mDetails->setAddressee( addr );
522 523
523 if ( !addr.isEmpty() ) { 524 if ( !addr.isEmpty() ) {
524 emit contactSelected( addr.formattedName() ); 525 emit contactSelected( addr.formattedName() );
525 KABC::Picture pic = addr.photo(); 526 KABC::Picture pic = addr.photo();
526 if ( pic.isIntern() ) { 527 if ( pic.isIntern() ) {
527//US emit contactSelected( pic.data() ); 528//US emit contactSelected( pic.data() );
528//US instead use: 529//US instead use:
529 QPixmap px; 530 QPixmap px;
530 if (pic.data().isNull() != true) 531 if (pic.data().isNull() != true)
531 { 532 {
532 px.convertFromImage(pic.data()); 533 px.convertFromImage(pic.data());
533 } 534 }
534 535
535 emit contactSelected( px ); 536 emit contactSelected( px );
536 } 537 }
537 } 538 }
538 539
539 540
540 mExtensionManager->setSelectionChanged(); 541 mExtensionManager->setSelectionChanged();
541 542
542 // update the actions 543 // update the actions
543 bool selected = !uid.isEmpty(); 544 bool selected = !uid.isEmpty();
544 545
545 if ( mReadWrite ) { 546 if ( mReadWrite ) {
546 mActionCut->setEnabled( selected ); 547 mActionCut->setEnabled( selected );
547 mActionPaste->setEnabled( selected ); 548 mActionPaste->setEnabled( selected );
548 } 549 }
549 550
550 mActionCopy->setEnabled( selected ); 551 mActionCopy->setEnabled( selected );
551 mActionDelete->setEnabled( selected ); 552 mActionDelete->setEnabled( selected );
552 mActionEditAddressee->setEnabled( selected ); 553 mActionEditAddressee->setEnabled( selected );
553 mActionMail->setEnabled( selected ); 554 mActionMail->setEnabled( selected );
554 mActionMailVCard->setEnabled( selected ); 555 mActionMailVCard->setEnabled( selected );
555 //if (mActionBeam) 556 //if (mActionBeam)
556 //mActionBeam->setEnabled( selected ); 557 //mActionBeam->setEnabled( selected );
557 558
558 if (mActionBeamVCard) 559 if (mActionBeamVCard)
559 mActionBeamVCard->setEnabled( selected ); 560 mActionBeamVCard->setEnabled( selected );
560 561
561 mActionExport2phone->setEnabled( selected ); 562 mActionExport2phone->setEnabled( selected );
562 mActionWhoAmI->setEnabled( selected ); 563 mActionWhoAmI->setEnabled( selected );
563 mActionCategories->setEnabled( selected ); 564 mActionCategories->setEnabled( selected );
564} 565}
565 566
566void KABCore::sendMail() 567void KABCore::sendMail()
567{ 568{
568 sendMail( mViewManager->selectedEmails().join( ", " ) ); 569 sendMail( mViewManager->selectedEmails().join( ", " ) );
569} 570}
570 571
571void KABCore::sendMail( const QString& emaillist ) 572void KABCore::sendMail( const QString& emaillist )
572{ 573{
573 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 574 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
574 if (emaillist.contains(",") > 0) 575 if (emaillist.contains(",") > 0)
575 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 576 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
576 else 577 else
577 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 578 ExternalAppHandler::instance()->mailToOneContact( emaillist );
578} 579}
579 580
580 581
581 582
582void KABCore::mailVCard() 583void KABCore::mailVCard()
583{ 584{
584 QStringList uids = mViewManager->selectedUids(); 585 QStringList uids = mViewManager->selectedUids();
585 if ( !uids.isEmpty() ) 586 if ( !uids.isEmpty() )
586 mailVCard( uids ); 587 mailVCard( uids );
587} 588}
588 589
589void KABCore::mailVCard( const QStringList& uids ) 590void KABCore::mailVCard( const QStringList& uids )
590{ 591{
591 QStringList urls; 592 QStringList urls;
592 593
593// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 594// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
594 595
595 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 596 QString dirName = "/tmp/" + KApplication::randomString( 8 );
596 597
597 598
598 599
599 QDir().mkdir( dirName, true ); 600 QDir().mkdir( dirName, true );
600 601
601 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 602 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
602 KABC::Addressee a = mAddressBook->findByUid( *it ); 603 KABC::Addressee a = mAddressBook->findByUid( *it );
603 604
604 if ( a.isEmpty() ) 605 if ( a.isEmpty() )
605 continue; 606 continue;
606 607
607 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 608 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
608 609
609 QString fileName = dirName + "/" + name; 610 QString fileName = dirName + "/" + name;
610 611
611 QFile outFile(fileName); 612 QFile outFile(fileName);
612 613
613 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 614 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
614 KABC::VCardConverter converter; 615 KABC::VCardConverter converter;
615 QString vcard; 616 QString vcard;
616 617
617 converter.addresseeToVCard( a, vcard ); 618 converter.addresseeToVCard( a, vcard );
618 619
619 QTextStream t( &outFile ); // use a text stream 620 QTextStream t( &outFile ); // use a text stream
620 t.setEncoding( QTextStream::UnicodeUTF8 ); 621 t.setEncoding( QTextStream::UnicodeUTF8 );
621 t << vcard; 622 t << vcard;
622 623
623 outFile.close(); 624 outFile.close();
624 625
625 urls.append( fileName ); 626 urls.append( fileName );
626 } 627 }
627 } 628 }
628 629
629 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 630 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
630 631
631 632
632/*US 633/*US
633 kapp->invokeMailer( QString::null, QString::null, QString::null, 634 kapp->invokeMailer( QString::null, QString::null, QString::null,
634 QString::null, // subject 635 QString::null, // subject
635 QString::null, // body 636 QString::null, // body
636 QString::null, 637 QString::null,
637 urls ); // attachments 638 urls ); // attachments
638*/ 639*/
639 640
640} 641}
641 642
642/** 643/**
643 Beams the "WhoAmI contact. 644 Beams the "WhoAmI contact.
644*/ 645*/
645void KABCore::beamMySelf() 646void KABCore::beamMySelf()
646{ 647{
647 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 648 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
648 if (!a.isEmpty()) 649 if (!a.isEmpty())
649 { 650 {
650 QStringList uids; 651 QStringList uids;
651 uids << a.uid(); 652 uids << a.uid();
652 653
653 beamVCard(uids); 654 beamVCard(uids);
654 } else { 655 } else {
655 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 656 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
656 657
657 658
658 } 659 }
659} 660}
660 661
661void KABCore::export2phone() 662void KABCore::export2phone()
662{ 663{
663 664
664 KAex2phonePrefs ex2phone; 665 KAex2phonePrefs ex2phone;
665 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 666 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
666 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 667 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
667 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 668 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
668 669
669 if ( !ex2phone.exec() ) { 670 if ( !ex2phone.exec() ) {
670 return; 671 return;
671 } 672 }
672 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 673 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
673 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 674 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
674 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 675 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
675 676
676#if 0 677
677 PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 678 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
678 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 679 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
679 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 680 KPimGlobalPrefs::instance()->mEx2PhoneModel );
680 681
682 QStringList uids = mViewManager->selectedUids();
683 if ( uids.isEmpty() )
684 return;
681 685
686#ifdef _WIN32_
687 QString fileName = locateLocal("tmp", "tempfile.vcf");
688#else
689 QString fileName = "/tmp/kdepimtemp.vcf";
690#endif
682 691
683
684
685 QString fileName = "/tmp/kapibeamfile.vcf";
686
687
688 //QDir().mkdir( dirName, true );
689
690
691 KABC::VCardConverter converter; 692 KABC::VCardConverter converter;
692 QString description; 693 QString description;
693 QString datastream; 694 QString datastream;
694 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 695 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
695 KABC::Addressee a = mAddressBook->findByUid( *it ); 696 KABC::Addressee a = mAddressBook->findByUid( *it );
696 697
697 if ( a.isEmpty() ) 698 if ( a.isEmpty() )
698 continue; 699 continue;
699 700
700 if (description.isEmpty()) 701 if (description.isEmpty())
701 description = a.formattedName(); 702 description = a.formattedName();
702 703
703 QString vcard; 704 QString vcard;
704 converter.addresseeToVCard( a, vcard ); 705 converter.addresseeToVCard( a, vcard );
705 int start = 0; 706 int start = 0;
706 int next; 707 int next;
707 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 708 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
708 int semi = vcard.find(";", next); 709 int semi = vcard.find(";", next);
709 int dopp = vcard.find(":", next); 710 int dopp = vcard.find(":", next);
710 int sep; 711 int sep;
711 if ( semi < dopp && semi >= 0 ) 712 if ( semi < dopp && semi >= 0 )
712 sep = semi ; 713 sep = semi ;
713 else 714 else
714 sep = dopp; 715 sep = dopp;
715 datastream +=vcard.mid( start, next - start); 716 datastream +=vcard.mid( start, next - start);
716 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 717 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
717 start = sep; 718 start = sep;
718 } 719 }
719 datastream += vcard.mid( start,vcard.length() ); 720 datastream += vcard.mid( start,vcard.length() );
720 } 721 }
721#ifndef DESKTOP_VERSION
722 QFile outFile(fileName); 722 QFile outFile(fileName);
723 if ( outFile.open(IO_WriteOnly) ) { 723 if ( outFile.open(IO_WriteOnly) ) {
724 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 724 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
725 QTextStream t( &outFile ); // use a text stream 725 QTextStream t( &outFile ); // use a text stream
726 t.setEncoding( QTextStream::UnicodeUTF8 ); 726 t.setEncoding( QTextStream::UnicodeUTF8 );
727 t <<datastream; 727 t <<datastream;
728 outFile.close(); 728 outFile.close();
729 Ir *ir = new Ir( this );
730 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
731 ir->send( fileName, description, "text/x-vCard" );
732 } else { 729 } else {
733 qDebug("Error open temp beam file "); 730 qDebug("Error open temp file ");
734 return; 731 return;
735 } 732 }
736#endif
737
738 733
739 734
735#if 0
740 736
741 setCaption( i18n("Writing to phone...")); 737 setCaption( i18n("Writing to phone..."));
742 if ( PhoneFormat::writeToPhone( cal ) ) 738 if ( PhoneFormat::writeToPhone( cal ) )
743 setCaption( i18n("Export to phone successful!")); 739 setCaption( i18n("Export to phone successful!"));
744 else 740 else
745 setCaption( i18n("Error exporting to phone!")); 741 setCaption( i18n("Error exporting to phone!"));
746#endif 742#endif
747 743
748 744
749} 745}
750void KABCore::beamVCard() 746void KABCore::beamVCard()
751{ 747{
752 QStringList uids = mViewManager->selectedUids(); 748 QStringList uids = mViewManager->selectedUids();
753 if ( !uids.isEmpty() ) 749 if ( !uids.isEmpty() )
754 beamVCard( uids ); 750 beamVCard( uids );
755} 751}
756 752
757 753
758void KABCore::beamVCard(const QStringList& uids) 754void KABCore::beamVCard(const QStringList& uids)
759{ 755{
760/*US 756/*US
761 QString beamFilename; 757 QString beamFilename;
762 Opie::OPimContact c; 758 Opie::OPimContact c;
763 if ( actionPersonal->isOn() ) { 759 if ( actionPersonal->isOn() ) {
764 beamFilename = addressbookPersonalVCardName(); 760 beamFilename = addressbookPersonalVCardName();
765 if ( !QFile::exists( beamFilename ) ) 761 if ( !QFile::exists( beamFilename ) )
766 return; // can't beam a non-existent file 762 return; // can't beam a non-existent file
767 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 763 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
768 beamFilename ); 764 beamFilename );
769 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 765 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
770 Opie::OPimContactAccess::List allList = access->allRecords(); 766 Opie::OPimContactAccess::List allList = access->allRecords();
771 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 767 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
772 c = *it; 768 c = *it;
773 769
774 delete access; 770 delete access;
775 } else { 771 } else {
776 unlink( beamfile ); // delete if exists 772 unlink( beamfile ); // delete if exists
777 mkdir("/tmp/obex/", 0755); 773 mkdir("/tmp/obex/", 0755);
778 c = m_abView -> currentEntry(); 774 c = m_abView -> currentEntry();
779 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 775 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
780 beamfile ); 776 beamfile );
781 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 777 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
782 access->add( c ); 778 access->add( c );
783 access->save(); 779 access->save();
784 delete access; 780 delete access;
785 781
786 beamFilename = beamfile; 782 beamFilename = beamfile;
787 } 783 }
788 784
789 owarn << "Beaming: " << beamFilename << oendl; 785 owarn << "Beaming: " << beamFilename << oendl;
790*/ 786*/
791 787
792#if 0 788#if 0
793 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 789 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
794 790
795 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 791 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
796 792
797 QString name = "contact.vcf"; 793 QString name = "contact.vcf";
798 794
799 QString fileName = dirName + "/" + name; 795 QString fileName = dirName + "/" + name;
800#endif 796#endif
801 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 797 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
802 // 798 //
803 QString fileName = "/tmp/kapibeamfile.vcf"; 799 QString fileName = "/tmp/kapibeamfile.vcf";
804 800
805 801
806 //QDir().mkdir( dirName, true ); 802 //QDir().mkdir( dirName, true );
807 803
808 804
809 KABC::VCardConverter converter; 805 KABC::VCardConverter converter;
810 QString description; 806 QString description;
811 QString datastream; 807 QString datastream;
812 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 808 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
813 KABC::Addressee a = mAddressBook->findByUid( *it ); 809 KABC::Addressee a = mAddressBook->findByUid( *it );
814 810
815 if ( a.isEmpty() ) 811 if ( a.isEmpty() )
816 continue; 812 continue;
817 813
818 if (description.isEmpty()) 814 if (description.isEmpty())
819 description = a.formattedName(); 815 description = a.formattedName();
820 816
821 QString vcard; 817 QString vcard;
822 converter.addresseeToVCard( a, vcard ); 818 converter.addresseeToVCard( a, vcard );
823 int start = 0; 819 int start = 0;
824 int next; 820 int next;
825 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 821 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
826 int semi = vcard.find(";", next); 822 int semi = vcard.find(";", next);
827 int dopp = vcard.find(":", next); 823 int dopp = vcard.find(":", next);
828 int sep; 824 int sep;
829 if ( semi < dopp && semi >= 0 ) 825 if ( semi < dopp && semi >= 0 )
830 sep = semi ; 826 sep = semi ;
831 else 827 else
832 sep = dopp; 828 sep = dopp;
833 datastream +=vcard.mid( start, next - start); 829 datastream +=vcard.mid( start, next - start);
834 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 830 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
835 start = sep; 831 start = sep;
836 } 832 }
837 datastream += vcard.mid( start,vcard.length() ); 833 datastream += vcard.mid( start,vcard.length() );
838 } 834 }
839#ifndef DESKTOP_VERSION 835#ifndef DESKTOP_VERSION
840 QFile outFile(fileName); 836 QFile outFile(fileName);
841 if ( outFile.open(IO_WriteOnly) ) { 837 if ( outFile.open(IO_WriteOnly) ) {
842 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 838 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
843 QTextStream t( &outFile ); // use a text stream 839 QTextStream t( &outFile ); // use a text stream
844 t.setEncoding( QTextStream::UnicodeUTF8 ); 840 t.setEncoding( QTextStream::UnicodeUTF8 );
845 t <<datastream; 841 t <<datastream;
846 outFile.close(); 842 outFile.close();
847 Ir *ir = new Ir( this ); 843 Ir *ir = new Ir( this );
848 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
849 ir->send( fileName, description, "text/x-vCard" ); 845 ir->send( fileName, description, "text/x-vCard" );
850 } else { 846 } else {
851 qDebug("Error open temp beam file "); 847 qDebug("Error open temp beam file ");
852 return; 848 return;
853 } 849 }
854#endif 850#endif
855 851
856} 852}
857 853
858void KABCore::beamDone( Ir *ir ) 854void KABCore::beamDone( Ir *ir )
859{ 855{
860#ifndef DESKTOP_VERSION 856#ifndef DESKTOP_VERSION
861 delete ir; 857 delete ir;
862#endif 858#endif
863} 859}
864 860
865 861
866void KABCore::browse( const QString& url ) 862void KABCore::browse( const QString& url )
867{ 863{
868#ifndef KAB_EMBEDDED 864#ifndef KAB_EMBEDDED
869 kapp->invokeBrowser( url ); 865 kapp->invokeBrowser( url );
870#else //KAB_EMBEDDED 866#else //KAB_EMBEDDED
871 qDebug("KABCore::browse must be fixed"); 867 qDebug("KABCore::browse must be fixed");
872#endif //KAB_EMBEDDED 868#endif //KAB_EMBEDDED
873} 869}
874 870
875void KABCore::selectAllContacts() 871void KABCore::selectAllContacts()
876{ 872{
877 mViewManager->setSelected( QString::null, true ); 873 mViewManager->setSelected( QString::null, true );
878} 874}
879 875
880void KABCore::deleteContacts() 876void KABCore::deleteContacts()
881{ 877{
882 QStringList uidList = mViewManager->selectedUids(); 878 QStringList uidList = mViewManager->selectedUids();
883 deleteContacts( uidList ); 879 deleteContacts( uidList );
884} 880}
885 881
886void KABCore::deleteContacts( const QStringList &uids ) 882void KABCore::deleteContacts( const QStringList &uids )
887{ 883{
888 if ( uids.count() > 0 ) { 884 if ( uids.count() > 0 ) {
889 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 885 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
890 UndoStack::instance()->push( command ); 886 UndoStack::instance()->push( command );
891 RedoStack::instance()->clear(); 887 RedoStack::instance()->clear();
892 888
893 // now if we deleted anything, refresh 889 // now if we deleted anything, refresh
894 setContactSelected( QString::null ); 890 setContactSelected( QString::null );
895 setModified( true ); 891 setModified( true );
896 } 892 }
897} 893}
898 894
899void KABCore::copyContacts() 895void KABCore::copyContacts()
900{ 896{
901 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 897 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
902 898
903 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 899 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
904 900
905 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 901 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
906 902
907 QClipboard *cb = QApplication::clipboard(); 903 QClipboard *cb = QApplication::clipboard();
908 cb->setText( clipText ); 904 cb->setText( clipText );
909} 905}
910 906
911void KABCore::cutContacts() 907void KABCore::cutContacts()
912{ 908{
913 QStringList uidList = mViewManager->selectedUids(); 909 QStringList uidList = mViewManager->selectedUids();
914 910
915//US if ( uidList.size() > 0 ) { 911//US if ( uidList.size() > 0 ) {
916 if ( uidList.count() > 0 ) { 912 if ( uidList.count() > 0 ) {
917 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 913 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
918 UndoStack::instance()->push( command ); 914 UndoStack::instance()->push( command );
919 RedoStack::instance()->clear(); 915 RedoStack::instance()->clear();
920 916
921 setModified( true ); 917 setModified( true );
922 } 918 }
923} 919}
924 920
925void KABCore::pasteContacts() 921void KABCore::pasteContacts()
926{ 922{
927 QClipboard *cb = QApplication::clipboard(); 923 QClipboard *cb = QApplication::clipboard();
928 924
929 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 925 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
930 926
931 pasteContacts( list ); 927 pasteContacts( list );
932} 928}
933 929
934void KABCore::pasteContacts( KABC::Addressee::List &list ) 930void KABCore::pasteContacts( KABC::Addressee::List &list )
935{ 931{
936 KABC::Resource *resource = requestResource( this ); 932 KABC::Resource *resource = requestResource( this );
937 KABC::Addressee::List::Iterator it; 933 KABC::Addressee::List::Iterator it;
938 for ( it = list.begin(); it != list.end(); ++it ) 934 for ( it = list.begin(); it != list.end(); ++it )
939 (*it).setResource( resource ); 935 (*it).setResource( resource );
940 936
941 PwPasteCommand *command = new PwPasteCommand( this, list ); 937 PwPasteCommand *command = new PwPasteCommand( this, list );
942 UndoStack::instance()->push( command ); 938 UndoStack::instance()->push( command );
943 RedoStack::instance()->clear(); 939 RedoStack::instance()->clear();
944 940
945 setModified( true ); 941 setModified( true );
946} 942}
947 943
948void KABCore::setWhoAmI() 944void KABCore::setWhoAmI()
949{ 945{
950 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 946 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
951 947
952 if ( addrList.count() > 1 ) { 948 if ( addrList.count() > 1 ) {
953 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 949 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
954 return; 950 return;
955 } 951 }
956 952
957 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 953 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
958 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 954 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
959 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 955 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
960} 956}
961 957
962void KABCore::setCategories() 958void KABCore::setCategories()
963{ 959{
964 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 960 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
965 if ( !dlg.exec() ) 961 if ( !dlg.exec() )
966 return; 962 return;
967 963
968 bool merge = false; 964 bool merge = false;
969 QString msg = i18n( "Merge with existing categories?" ); 965 QString msg = i18n( "Merge with existing categories?" );
970 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 966 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
971 merge = true; 967 merge = true;
972 968
973 QStringList categories = dlg.selectedCategories(); 969 QStringList categories = dlg.selectedCategories();
974 970
975 QStringList uids = mViewManager->selectedUids(); 971 QStringList uids = mViewManager->selectedUids();
976 QStringList::Iterator it; 972 QStringList::Iterator it;
977 for ( it = uids.begin(); it != uids.end(); ++it ) { 973 for ( it = uids.begin(); it != uids.end(); ++it ) {
978 KABC::Addressee addr = mAddressBook->findByUid( *it ); 974 KABC::Addressee addr = mAddressBook->findByUid( *it );
979 if ( !addr.isEmpty() ) { 975 if ( !addr.isEmpty() ) {
980 if ( !merge ) 976 if ( !merge )
981 addr.setCategories( categories ); 977 addr.setCategories( categories );
982 else { 978 else {
983 QStringList addrCategories = addr.categories(); 979 QStringList addrCategories = addr.categories();
984 QStringList::Iterator catIt; 980 QStringList::Iterator catIt;
985 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 981 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
986 if ( !addrCategories.contains( *catIt ) ) 982 if ( !addrCategories.contains( *catIt ) )
987 addrCategories.append( *catIt ); 983 addrCategories.append( *catIt );
988 } 984 }
989 addr.setCategories( addrCategories ); 985 addr.setCategories( addrCategories );
990 } 986 }
991 987
992 mAddressBook->insertAddressee( addr ); 988 mAddressBook->insertAddressee( addr );
993 } 989 }
994 } 990 }
995 991
996 if ( uids.count() > 0 ) 992 if ( uids.count() > 0 )
997 setModified( true ); 993 setModified( true );
998} 994}
999 995
1000void KABCore::setSearchFields( const KABC::Field::List &fields ) 996void KABCore::setSearchFields( const KABC::Field::List &fields )
1001{ 997{
1002 mIncSearchWidget->setFields( fields ); 998 mIncSearchWidget->setFields( fields );
1003} 999}
1004 1000
1005void KABCore::incrementalSearch( const QString& text ) 1001void KABCore::incrementalSearch( const QString& text )
1006{ 1002{
1007 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1003 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1008} 1004}
1009 1005
1010void KABCore::setModified() 1006void KABCore::setModified()
1011{ 1007{
1012 setModified( true ); 1008 setModified( true );
1013} 1009}
1014 1010
1015void KABCore::setModifiedWOrefresh() 1011void KABCore::setModifiedWOrefresh()
1016{ 1012{
1017 // qDebug("KABCore::setModifiedWOrefresh() "); 1013 // qDebug("KABCore::setModifiedWOrefresh() ");
1018 mModified = true; 1014 mModified = true;
1019 mActionSave->setEnabled( mModified ); 1015 mActionSave->setEnabled( mModified );
1020#ifdef DESKTOP_VERSION 1016#ifdef DESKTOP_VERSION
1021 mDetails->refreshView(); 1017 mDetails->refreshView();
1022#endif 1018#endif
1023 1019
1024} 1020}
1025void KABCore::setModified( bool modified ) 1021void KABCore::setModified( bool modified )
1026{ 1022{
1027 mModified = modified; 1023 mModified = modified;
1028 mActionSave->setEnabled( mModified ); 1024 mActionSave->setEnabled( mModified );
1029 1025
1030 if ( modified ) 1026 if ( modified )
1031 mJumpButtonBar->recreateButtons(); 1027 mJumpButtonBar->recreateButtons();
1032 1028
1033 mViewManager->refreshView(); 1029 mViewManager->refreshView();
1034 mDetails->refreshView(); 1030 mDetails->refreshView();
1035 1031
1036} 1032}
1037 1033
1038bool KABCore::modified() const 1034bool KABCore::modified() const
1039{ 1035{
1040 return mModified; 1036 return mModified;
1041} 1037}
1042 1038
1043void KABCore::contactModified( const KABC::Addressee &addr ) 1039void KABCore::contactModified( const KABC::Addressee &addr )
1044{ 1040{
1045 1041
1046 Command *command = 0; 1042 Command *command = 0;
1047 QString uid; 1043 QString uid;
1048 1044
1049 // check if it exists already 1045 // check if it exists already
1050 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1046 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1051 if ( origAddr.isEmpty() ) 1047 if ( origAddr.isEmpty() )
1052 command = new PwNewCommand( mAddressBook, addr ); 1048 command = new PwNewCommand( mAddressBook, addr );
1053 else { 1049 else {
1054 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1050 command = new PwEditCommand( mAddressBook, origAddr, addr );
1055 uid = addr.uid(); 1051 uid = addr.uid();
1056 } 1052 }
1057 1053
1058 UndoStack::instance()->push( command ); 1054 UndoStack::instance()->push( command );
1059 RedoStack::instance()->clear(); 1055 RedoStack::instance()->clear();
1060 1056
1061 setModified( true ); 1057 setModified( true );
1062} 1058}
1063 1059
1064void KABCore::newContact() 1060void KABCore::newContact()
1065{ 1061{
1066 1062
1067 1063
1068 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1064 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1069 1065
1070 QPtrList<KRES::Resource> kresResources; 1066 QPtrList<KRES::Resource> kresResources;
1071 QPtrListIterator<KABC::Resource> it( kabcResources ); 1067 QPtrListIterator<KABC::Resource> it( kabcResources );
1072 KABC::Resource *resource; 1068 KABC::Resource *resource;
1073 while ( ( resource = it.current() ) != 0 ) { 1069 while ( ( resource = it.current() ) != 0 ) {
1074 ++it; 1070 ++it;
1075 if ( !resource->readOnly() ) { 1071 if ( !resource->readOnly() ) {
1076 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1072 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1077 if ( res ) 1073 if ( res )
1078 kresResources.append( res ); 1074 kresResources.append( res );
1079 } 1075 }
1080 } 1076 }
1081 1077
1082 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1078 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1083 resource = static_cast<KABC::Resource*>( res ); 1079 resource = static_cast<KABC::Resource*>( res );
1084 1080
1085 if ( resource ) { 1081 if ( resource ) {
1086 KABC::Addressee addr; 1082 KABC::Addressee addr;
1087 addr.setResource( resource ); 1083 addr.setResource( resource );
1088 mEditorDialog->setAddressee( addr ); 1084 mEditorDialog->setAddressee( addr );
1089 KApplication::execDialog ( mEditorDialog ); 1085 KApplication::execDialog ( mEditorDialog );
1090 1086
1091 } else 1087 } else
1092 return; 1088 return;
1093 1089
1094 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1090 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1095 1091
1096 1092
1097} 1093}
1098 1094
1099void KABCore::addEmail( QString aStr ) 1095void KABCore::addEmail( QString aStr )
1100{ 1096{
1101#ifndef KAB_EMBEDDED 1097#ifndef KAB_EMBEDDED
1102 QString fullName, email; 1098 QString fullName, email;
1103 1099
1104 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1100 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1105 1101
1106 // Try to lookup the addressee matching the email address 1102 // Try to lookup the addressee matching the email address
1107 bool found = false; 1103 bool found = false;
1108 QStringList emailList; 1104 QStringList emailList;
1109 KABC::AddressBook::Iterator it; 1105 KABC::AddressBook::Iterator it;
1110 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1106 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1111 emailList = (*it).emails(); 1107 emailList = (*it).emails();
1112 if ( emailList.contains( email ) > 0 ) { 1108 if ( emailList.contains( email ) > 0 ) {
1113 found = true; 1109 found = true;
1114 (*it).setNameFromString( fullName ); 1110 (*it).setNameFromString( fullName );
1115 editContact( (*it).uid() ); 1111 editContact( (*it).uid() );
1116 } 1112 }
1117 } 1113 }
1118 1114
1119 if ( !found ) { 1115 if ( !found ) {
1120 KABC::Addressee addr; 1116 KABC::Addressee addr;
1121 addr.setNameFromString( fullName ); 1117 addr.setNameFromString( fullName );
1122 addr.insertEmail( email, true ); 1118 addr.insertEmail( email, true );
1123 1119
1124 mAddressBook->insertAddressee( addr ); 1120 mAddressBook->insertAddressee( addr );
1125 mViewManager->refreshView( addr.uid() ); 1121 mViewManager->refreshView( addr.uid() );
1126 editContact( addr.uid() ); 1122 editContact( addr.uid() );
1127 } 1123 }
1128#else //KAB_EMBEDDED 1124#else //KAB_EMBEDDED
1129 qDebug("KABCore::addEmail finsih method"); 1125 qDebug("KABCore::addEmail finsih method");
1130#endif //KAB_EMBEDDED 1126#endif //KAB_EMBEDDED
1131} 1127}
1132 1128
1133void KABCore::importVCard( const KURL &url, bool showPreview ) 1129void KABCore::importVCard( const KURL &url, bool showPreview )
1134{ 1130{
1135 mXXPortManager->importVCard( url, showPreview ); 1131 mXXPortManager->importVCard( url, showPreview );
1136} 1132}
1137void KABCore::importFromOL() 1133void KABCore::importFromOL()
1138{ 1134{
1139#ifdef _WIN32_ 1135#ifdef _WIN32_
1140 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1136 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1141 idgl->exec(); 1137 idgl->exec();
1142 KABC::Addressee::List list = idgl->getAddressList(); 1138 KABC::Addressee::List list = idgl->getAddressList();
1143 if ( list.count() > 0 ) { 1139 if ( list.count() > 0 ) {
1144 KABC::Addressee::List listNew; 1140 KABC::Addressee::List listNew;
1145 KABC::Addressee::List listExisting; 1141 KABC::Addressee::List listExisting;
1146 KABC::Addressee::List::Iterator it; 1142 KABC::Addressee::List::Iterator it;
1147 KABC::AddressBook::Iterator iter; 1143 KABC::AddressBook::Iterator iter;
1148 for ( it = list.begin(); it != list.end(); ++it ) { 1144 for ( it = list.begin(); it != list.end(); ++it ) {
1149 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1145 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1150 listNew.append( (*it) ); 1146 listNew.append( (*it) );
1151 else 1147 else
1152 listExisting.append( (*it) ); 1148 listExisting.append( (*it) );
1153 } 1149 }
1154 if ( listExisting.count() > 0 ) 1150 if ( listExisting.count() > 0 )
1155 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1151 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1156 if ( listNew.count() > 0 ) { 1152 if ( listNew.count() > 0 ) {
1157 pasteWithNewUid = false; 1153 pasteWithNewUid = false;
1158 pasteContacts( listNew ); 1154 pasteContacts( listNew );
1159 pasteWithNewUid = true; 1155 pasteWithNewUid = true;
1160 } 1156 }
1161 } 1157 }
1162 delete idgl; 1158 delete idgl;
1163#endif 1159#endif
1164} 1160}
1165 1161
1166void KABCore::importVCard( const QString &vCard, bool showPreview ) 1162void KABCore::importVCard( const QString &vCard, bool showPreview )
1167{ 1163{
1168 mXXPortManager->importVCard( vCard, showPreview ); 1164 mXXPortManager->importVCard( vCard, showPreview );
1169} 1165}
1170 1166
1171//US added a second method without defaultparameter 1167//US added a second method without defaultparameter
1172void KABCore::editContact2() { 1168void KABCore::editContact2() {
1173 editContact( QString::null ); 1169 editContact( QString::null );
1174} 1170}
1175 1171
1176void KABCore::editContact( const QString &uid ) 1172void KABCore::editContact( const QString &uid )
1177{ 1173{
1178 1174
1179 if ( mExtensionManager->isQuickEditVisible() ) 1175 if ( mExtensionManager->isQuickEditVisible() )
1180 return; 1176 return;
1181 1177
1182 // First, locate the contact entry 1178 // First, locate the contact entry
1183 QString localUID = uid; 1179 QString localUID = uid;
1184 if ( localUID.isNull() ) { 1180 if ( localUID.isNull() ) {
1185 QStringList uidList = mViewManager->selectedUids(); 1181 QStringList uidList = mViewManager->selectedUids();
1186 if ( uidList.count() > 0 ) 1182 if ( uidList.count() > 0 )
1187 localUID = *( uidList.at( 0 ) ); 1183 localUID = *( uidList.at( 0 ) );
1188 } 1184 }
1189 1185
1190 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1186 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1191 if ( !addr.isEmpty() ) { 1187 if ( !addr.isEmpty() ) {
1192 mEditorDialog->setAddressee( addr ); 1188 mEditorDialog->setAddressee( addr );
1193 KApplication::execDialog ( mEditorDialog ); 1189 KApplication::execDialog ( mEditorDialog );
1194 } 1190 }
1195} 1191}
1196 1192
1197/** 1193/**
1198 Shows or edits the detail view for the given uid. If the uid is QString::null, 1194 Shows or edits the detail view for the given uid. If the uid is QString::null,
1199 the method will try to find a selected addressee in the view. 1195 the method will try to find a selected addressee in the view.
1200 */ 1196 */
1201void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1197void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1202{ 1198{
1203 if ( mMultipleViewsAtOnce ) 1199 if ( mMultipleViewsAtOnce )
1204 { 1200 {
1205 editContact( uid ); 1201 editContact( uid );
1206 } 1202 }
1207 else 1203 else
1208 { 1204 {
1209 setDetailsVisible( true ); 1205 setDetailsVisible( true );
1210 mActionDetails->setChecked(true); 1206 mActionDetails->setChecked(true);
1211 } 1207 }
1212 1208
1213} 1209}
1214 1210
1215void KABCore::save() 1211void KABCore::save()
1216{ 1212{
1217 if (syncManager->blockSave()) 1213 if (syncManager->blockSave())
1218 return; 1214 return;
1219 if ( !mModified ) 1215 if ( !mModified )
1220 return; 1216 return;
1221 1217
1222 syncManager->setBlockSave(true); 1218 syncManager->setBlockSave(true);
1223 QString text = i18n( "There was an error while attempting to save\n the " 1219 QString text = i18n( "There was an error while attempting to save\n the "
1224 "address book. Please check that some \nother application is " 1220 "address book. Please check that some \nother application is "
1225 "not using it. " ); 1221 "not using it. " );
1226 statusMessage(i18n("Saving addressbook ... ")); 1222 statusMessage(i18n("Saving addressbook ... "));
1227#ifndef KAB_EMBEDDED 1223#ifndef KAB_EMBEDDED
1228 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1224 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1229 if ( !b || !b->save() ) { 1225 if ( !b || !b->save() ) {
1230 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1226 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1231 } 1227 }
1232#else //KAB_EMBEDDED 1228#else //KAB_EMBEDDED
1233 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1229 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1234 if ( !b || !b->save() ) { 1230 if ( !b || !b->save() ) {
1235 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1231 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1236 } 1232 }
1237#endif //KAB_EMBEDDED 1233#endif //KAB_EMBEDDED
1238 1234
1239 statusMessage(i18n("Addressbook saved!")); 1235 statusMessage(i18n("Addressbook saved!"));
1240 setModified( false ); 1236 setModified( false );
1241 syncManager->setBlockSave(false); 1237 syncManager->setBlockSave(false);
1242} 1238}
1243 1239
1244void KABCore::statusMessage(QString mess , int time ) 1240void KABCore::statusMessage(QString mess , int time )
1245{ 1241{
1246 //topLevelWidget()->setCaption( mess ); 1242 //topLevelWidget()->setCaption( mess );
1247 // pending setting timer to revome message 1243 // pending setting timer to revome message
1248} 1244}
1249void KABCore::undo() 1245void KABCore::undo()
1250{ 1246{
1251 UndoStack::instance()->undo(); 1247 UndoStack::instance()->undo();
1252 1248
1253 // Refresh the view 1249 // Refresh the view
1254 mViewManager->refreshView(); 1250 mViewManager->refreshView();
1255} 1251}
1256 1252
1257void KABCore::redo() 1253void KABCore::redo()
1258{ 1254{
1259 RedoStack::instance()->redo(); 1255 RedoStack::instance()->redo();
1260 1256
1261 // Refresh the view 1257 // Refresh the view
1262 mViewManager->refreshView(); 1258 mViewManager->refreshView();
1263} 1259}
1264 1260
1265void KABCore::setJumpButtonBarVisible( bool visible ) 1261void KABCore::setJumpButtonBarVisible( bool visible )
1266{ 1262{
1267 if (mMultipleViewsAtOnce) 1263 if (mMultipleViewsAtOnce)
1268 { 1264 {
1269 if ( visible ) 1265 if ( visible )
1270 mJumpButtonBar->show(); 1266 mJumpButtonBar->show();
1271 else 1267 else
1272 mJumpButtonBar->hide(); 1268 mJumpButtonBar->hide();
1273 } 1269 }
1274 else 1270 else
1275 { 1271 {
1276 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1272 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1277 if (mViewManager->isVisible()) 1273 if (mViewManager->isVisible())
1278 { 1274 {
1279 if ( visible ) 1275 if ( visible )
1280 mJumpButtonBar->show(); 1276 mJumpButtonBar->show();
1281 else 1277 else
1282 mJumpButtonBar->hide(); 1278 mJumpButtonBar->hide();
1283 } 1279 }
1284 else 1280 else
1285 { 1281 {
1286 mJumpButtonBar->hide(); 1282 mJumpButtonBar->hide();
1287 } 1283 }
1288 } 1284 }
1289} 1285}
1290 1286
1291 1287
1292void KABCore::setDetailsToState() 1288void KABCore::setDetailsToState()
1293{ 1289{
1294 setDetailsVisible( mActionDetails->isChecked() ); 1290 setDetailsVisible( mActionDetails->isChecked() );
1295} 1291}
1296 1292
1297 1293
1298 1294
1299void KABCore::setDetailsVisible( bool visible ) 1295void KABCore::setDetailsVisible( bool visible )
1300{ 1296{
1301 if (visible && mDetails->isHidden()) 1297 if (visible && mDetails->isHidden())
1302 { 1298 {
1303 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1299 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1304 if ( addrList.count() > 0 ) 1300 if ( addrList.count() > 0 )
1305 mDetails->setAddressee( addrList[ 0 ] ); 1301 mDetails->setAddressee( addrList[ 0 ] );
1306 } 1302 }
1307 1303
1308 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1304 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1309 // the listview and the detailview. We do that by changing the splitbar size. 1305 // the listview and the detailview. We do that by changing the splitbar size.
1310 if (mMultipleViewsAtOnce) 1306 if (mMultipleViewsAtOnce)
1311 { 1307 {
1312 if ( visible ) 1308 if ( visible )
1313 mDetails->show(); 1309 mDetails->show();
1314 else 1310 else
1315 mDetails->hide(); 1311 mDetails->hide();
1316 } 1312 }
1317 else 1313 else
1318 { 1314 {
1319 if ( visible ) { 1315 if ( visible ) {
1320 mViewManager->hide(); 1316 mViewManager->hide();
1321 mDetails->show(); 1317 mDetails->show();
1322 } 1318 }
1323 else { 1319 else {
1324 mViewManager->show(); 1320 mViewManager->show();
1325 mDetails->hide(); 1321 mDetails->hide();
1326 } 1322 }
1327 setJumpButtonBarVisible( !visible ); 1323 setJumpButtonBarVisible( !visible );
1328 } 1324 }
1329 1325
1330} 1326}
1331 1327
1332void KABCore::extensionChanged( int id ) 1328void KABCore::extensionChanged( int id )
1333{ 1329{
1334 //change the details view only for non desktop systems 1330 //change the details view only for non desktop systems
1335#ifndef DESKTOP_VERSION 1331#ifndef DESKTOP_VERSION
1336 1332
1337 if (id == 0) 1333 if (id == 0)
1338 { 1334 {
1339 //the user disabled the extension. 1335 //the user disabled the extension.
1340 1336
1341 if (mMultipleViewsAtOnce) 1337 if (mMultipleViewsAtOnce)
1342 { // enable detailsview again 1338 { // enable detailsview again
1343 setDetailsVisible( true ); 1339 setDetailsVisible( true );
1344 mActionDetails->setChecked( true ); 1340 mActionDetails->setChecked( true );
1345 } 1341 }
1346 else 1342 else
1347 { //go back to the listview 1343 { //go back to the listview
1348 setDetailsVisible( false ); 1344 setDetailsVisible( false );
1349 mActionDetails->setChecked( false ); 1345 mActionDetails->setChecked( false );
1350 mActionDetails->setEnabled(true); 1346 mActionDetails->setEnabled(true);
1351 } 1347 }
1352 1348
1353 } 1349 }
1354 else 1350 else
1355 { 1351 {
1356 //the user enabled the extension. 1352 //the user enabled the extension.
1357 setDetailsVisible( false ); 1353 setDetailsVisible( false );
1358 mActionDetails->setChecked( false ); 1354 mActionDetails->setChecked( false );
1359 1355
1360 if (!mMultipleViewsAtOnce) 1356 if (!mMultipleViewsAtOnce)
1361 { 1357 {
1362 mActionDetails->setEnabled(false); 1358 mActionDetails->setEnabled(false);
1363 } 1359 }
1364 1360
1365 mExtensionManager->setSelectionChanged(); 1361 mExtensionManager->setSelectionChanged();
1366 1362
1367 } 1363 }
1368 1364
1369#endif// DESKTOP_VERSION 1365#endif// DESKTOP_VERSION
1370 1366
1371} 1367}
1372 1368
1373 1369
1374void KABCore::extensionModified( const KABC::Addressee::List &list ) 1370void KABCore::extensionModified( const KABC::Addressee::List &list )
1375{ 1371{
1376 1372
1377 if ( list.count() != 0 ) { 1373 if ( list.count() != 0 ) {
1378 KABC::Addressee::List::ConstIterator it; 1374 KABC::Addressee::List::ConstIterator it;
1379 for ( it = list.begin(); it != list.end(); ++it ) 1375 for ( it = list.begin(); it != list.end(); ++it )
1380 mAddressBook->insertAddressee( *it ); 1376 mAddressBook->insertAddressee( *it );
1381 if ( list.count() > 1 ) 1377 if ( list.count() > 1 )
1382 setModified(); 1378 setModified();
1383 else 1379 else
1384 setModifiedWOrefresh(); 1380 setModifiedWOrefresh();
1385 } 1381 }
1386 if ( list.count() == 0 ) 1382 if ( list.count() == 0 )
1387 mViewManager->refreshView(); 1383 mViewManager->refreshView();
1388 else 1384 else
1389 mViewManager->refreshView( list[ 0 ].uid() ); 1385 mViewManager->refreshView( list[ 0 ].uid() );
1390 1386
1391 1387
1392 1388
1393} 1389}
1394 1390
1395QString KABCore::getNameByPhone( const QString &phone ) 1391QString KABCore::getNameByPhone( const QString &phone )
1396{ 1392{
1397#ifndef KAB_EMBEDDED 1393#ifndef KAB_EMBEDDED
1398 QRegExp r( "[/*/-/ ]" ); 1394 QRegExp r( "[/*/-/ ]" );
1399 QString localPhone( phone ); 1395 QString localPhone( phone );
1400 1396
1401 bool found = false; 1397 bool found = false;
1402 QString ownerName = ""; 1398 QString ownerName = "";
1403 KABC::AddressBook::Iterator iter; 1399 KABC::AddressBook::Iterator iter;
1404 KABC::PhoneNumber::List::Iterator phoneIter; 1400 KABC::PhoneNumber::List::Iterator phoneIter;
1405 KABC::PhoneNumber::List phoneList; 1401 KABC::PhoneNumber::List phoneList;
1406 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1402 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1407 phoneList = (*iter).phoneNumbers(); 1403 phoneList = (*iter).phoneNumbers();
1408 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1404 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1409 ++phoneIter) { 1405 ++phoneIter) {
1410 // Get rid of separator chars so just the numbers are compared. 1406 // Get rid of separator chars so just the numbers are compared.
1411 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1407 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1412 ownerName = (*iter).formattedName(); 1408 ownerName = (*iter).formattedName();
1413 found = true; 1409 found = true;
1414 } 1410 }
1415 } 1411 }
1416 } 1412 }
1417 1413
1418 return ownerName; 1414 return ownerName;
1419#else //KAB_EMBEDDED 1415#else //KAB_EMBEDDED
1420 qDebug("KABCore::getNameByPhone finsih method"); 1416 qDebug("KABCore::getNameByPhone finsih method");
1421 return ""; 1417 return "";
1422#endif //KAB_EMBEDDED 1418#endif //KAB_EMBEDDED
1423 1419
1424} 1420}
1425 1421
1426void KABCore::openConfigDialog() 1422void KABCore::openConfigDialog()
1427{ 1423{
1428 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1424 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1429 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1425 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1430 ConfigureDialog->addModule(kabcfg ); 1426 ConfigureDialog->addModule(kabcfg );
1431 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1427 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1432 ConfigureDialog->addModule(kdelibcfg ); 1428 ConfigureDialog->addModule(kdelibcfg );
1433 1429
1434 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1430 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1435 this, SLOT( configurationChanged() ) ); 1431 this, SLOT( configurationChanged() ) );
1436 connect( ConfigureDialog, SIGNAL( okClicked() ), 1432 connect( ConfigureDialog, SIGNAL( okClicked() ),
1437 this, SLOT( configurationChanged() ) ); 1433 this, SLOT( configurationChanged() ) );
1438 saveSettings(); 1434 saveSettings();
1439#ifndef DESKTOP_VERSION 1435#ifndef DESKTOP_VERSION
1440 ConfigureDialog->showMaximized(); 1436 ConfigureDialog->showMaximized();
1441#endif 1437#endif
1442 if ( ConfigureDialog->exec() ) 1438 if ( ConfigureDialog->exec() )
1443 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1439 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1444 delete ConfigureDialog; 1440 delete ConfigureDialog;
1445} 1441}
1446 1442
1447void KABCore::openLDAPDialog() 1443void KABCore::openLDAPDialog()
1448{ 1444{
1449#ifndef KAB_EMBEDDED 1445#ifndef KAB_EMBEDDED
1450 if ( !mLdapSearchDialog ) { 1446 if ( !mLdapSearchDialog ) {
1451 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1447 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1452 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1448 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1453 SLOT( refreshView() ) ); 1449 SLOT( refreshView() ) );
1454 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1450 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1455 SLOT( setModified() ) ); 1451 SLOT( setModified() ) );
1456 } else 1452 } else
1457 mLdapSearchDialog->restoreSettings(); 1453 mLdapSearchDialog->restoreSettings();
1458 1454
1459 if ( mLdapSearchDialog->isOK() ) 1455 if ( mLdapSearchDialog->isOK() )
1460 mLdapSearchDialog->exec(); 1456 mLdapSearchDialog->exec();
1461#else //KAB_EMBEDDED 1457#else //KAB_EMBEDDED
1462 qDebug("KABCore::openLDAPDialog() finsih method"); 1458 qDebug("KABCore::openLDAPDialog() finsih method");
1463#endif //KAB_EMBEDDED 1459#endif //KAB_EMBEDDED
1464} 1460}
1465 1461
1466void KABCore::print() 1462void KABCore::print()
1467{ 1463{
1468#ifndef KAB_EMBEDDED 1464#ifndef KAB_EMBEDDED
1469 KPrinter printer; 1465 KPrinter printer;
1470 if ( !printer.setup( this ) ) 1466 if ( !printer.setup( this ) )
1471 return; 1467 return;
1472 1468
1473 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1469 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1474 mViewManager->selectedUids(), this ); 1470 mViewManager->selectedUids(), this );
1475 1471
1476 wizard.exec(); 1472 wizard.exec();
1477#else //KAB_EMBEDDED 1473#else //KAB_EMBEDDED
1478 qDebug("KABCore::print() finsih method"); 1474 qDebug("KABCore::print() finsih method");
1479#endif //KAB_EMBEDDED 1475#endif //KAB_EMBEDDED
1480 1476
1481} 1477}
1482 1478
1483 1479
1484void KABCore::addGUIClient( KXMLGUIClient *client ) 1480void KABCore::addGUIClient( KXMLGUIClient *client )
1485{ 1481{
1486 if ( mGUIClient ) 1482 if ( mGUIClient )
1487 mGUIClient->insertChildClient( client ); 1483 mGUIClient->insertChildClient( client );
1488 else 1484 else
1489 KMessageBox::error( this, "no KXMLGUICLient"); 1485 KMessageBox::error( this, "no KXMLGUICLient");
1490} 1486}
1491 1487
1492 1488
1493void KABCore::configurationChanged() 1489void KABCore::configurationChanged()
1494{ 1490{
1495 mExtensionManager->reconfigure(); 1491 mExtensionManager->reconfigure();
1496} 1492}
1497 1493
1498void KABCore::addressBookChanged() 1494void KABCore::addressBookChanged()
1499{ 1495{
1500/*US 1496/*US
1501 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1497 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1502 while ( it.current() ) { 1498 while ( it.current() ) {
1503 if ( it.current()->dirty() ) { 1499 if ( it.current()->dirty() ) {
1504 QString text = i18n( "Data has been changed externally. Unsaved " 1500 QString text = i18n( "Data has been changed externally. Unsaved "
1505 "changes will be lost." ); 1501 "changes will be lost." );
1506 KMessageBox::information( this, text ); 1502 KMessageBox::information( this, text );
1507 } 1503 }
1508 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1504 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1509 ++it; 1505 ++it;
1510 } 1506 }
1511*/ 1507*/
1512 if (mEditorDialog) 1508 if (mEditorDialog)
1513 { 1509 {
1514 if (mEditorDialog->dirty()) 1510 if (mEditorDialog->dirty())
1515 { 1511 {
1516 QString text = i18n( "Data has been changed externally. Unsaved " 1512 QString text = i18n( "Data has been changed externally. Unsaved "
1517 "changes will be lost." ); 1513 "changes will be lost." );
1518 KMessageBox::information( this, text ); 1514 KMessageBox::information( this, text );
1519 } 1515 }
1520 QString currentuid = mEditorDialog->addressee().uid(); 1516 QString currentuid = mEditorDialog->addressee().uid();
1521 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1517 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1522 } 1518 }
1523 mViewManager->refreshView(); 1519 mViewManager->refreshView();
1524// mDetails->refreshView(); 1520// mDetails->refreshView();
1525 1521
1526 1522
1527} 1523}
1528 1524
1529AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1525AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1530 const char *name ) 1526 const char *name )
1531{ 1527{
1532 1528
1533 if ( mEditorDialog == 0 ) { 1529 if ( mEditorDialog == 0 ) {
1534 mEditorDialog = new AddresseeEditorDialog( this, parent, 1530 mEditorDialog = new AddresseeEditorDialog( this, parent,
1535 name ? name : "editorDialog" ); 1531 name ? name : "editorDialog" );
1536 1532
1537 1533
1538 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1534 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1539 SLOT( contactModified( const KABC::Addressee& ) ) ); 1535 SLOT( contactModified( const KABC::Addressee& ) ) );
1540 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1536 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1541 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1537 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1542 } 1538 }
1543 1539
1544 return mEditorDialog; 1540 return mEditorDialog;
1545} 1541}
1546 1542
1547void KABCore::slotEditorDestroyed( const QString &uid ) 1543void KABCore::slotEditorDestroyed( const QString &uid )
1548{ 1544{
1549 //mEditorDict.remove( uid ); 1545 //mEditorDict.remove( uid );
1550} 1546}
1551 1547
1552void KABCore::initGUI() 1548void KABCore::initGUI()
1553{ 1549{
1554#ifndef KAB_EMBEDDED 1550#ifndef KAB_EMBEDDED
1555 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1551 QHBoxLayout *topLayout = new QHBoxLayout( this );
1556 topLayout->setSpacing( KDialogBase::spacingHint() ); 1552 topLayout->setSpacing( KDialogBase::spacingHint() );
1557 1553
1558 mExtensionBarSplitter = new QSplitter( this ); 1554 mExtensionBarSplitter = new QSplitter( this );
1559 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1555 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1560 1556
1561 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1557 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1562 1558
1563 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1559 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1564 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1560 mIncSearchWidget = new IncSearchWidget( viewSpace );
1565 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1561 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1566 SLOT( incrementalSearch( const QString& ) ) ); 1562 SLOT( incrementalSearch( const QString& ) ) );
1567 1563
1568 mViewManager = new ViewManager( this, viewSpace ); 1564 mViewManager = new ViewManager( this, viewSpace );
1569 viewSpace->setStretchFactor( mViewManager, 1 ); 1565 viewSpace->setStretchFactor( mViewManager, 1 );
1570 1566
1571 mDetails = new ViewContainer( mDetailsSplitter ); 1567 mDetails = new ViewContainer( mDetailsSplitter );
1572 1568
1573 mJumpButtonBar = new JumpButtonBar( this, this ); 1569 mJumpButtonBar = new JumpButtonBar( this, this );
1574 1570
1575 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1571 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1576 1572
1577 topLayout->addWidget( mExtensionBarSplitter ); 1573 topLayout->addWidget( mExtensionBarSplitter );
1578 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1574 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1579 topLayout->addWidget( mJumpButtonBar ); 1575 topLayout->addWidget( mJumpButtonBar );
1580 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1576 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1581 1577
1582 mXXPortManager = new XXPortManager( this, this ); 1578 mXXPortManager = new XXPortManager( this, this );
1583 1579
1584#else //KAB_EMBEDDED 1580#else //KAB_EMBEDDED
1585 //US initialize viewMenu before settingup viewmanager. 1581 //US initialize viewMenu before settingup viewmanager.
1586 // Viewmanager needs this menu to plugin submenues. 1582 // Viewmanager needs this menu to plugin submenues.
1587 viewMenu = new QPopupMenu( this ); 1583 viewMenu = new QPopupMenu( this );
1588 settingsMenu = new QPopupMenu( this ); 1584 settingsMenu = new QPopupMenu( this );
1589 //filterMenu = new QPopupMenu( this ); 1585 //filterMenu = new QPopupMenu( this );
1590 ImportMenu = new QPopupMenu( this ); 1586 ImportMenu = new QPopupMenu( this );
1591 ExportMenu = new QPopupMenu( this ); 1587 ExportMenu = new QPopupMenu( this );
1592 syncMenu = new QPopupMenu( this ); 1588 syncMenu = new QPopupMenu( this );
1593 changeMenu= new QPopupMenu( this ); 1589 changeMenu= new QPopupMenu( this );
1594 1590
1595//US since we have no splitter for the embedded system, setup 1591//US since we have no splitter for the embedded system, setup
1596// a layout with two frames. One left and one right. 1592// a layout with two frames. One left and one right.
1597 1593
1598 QBoxLayout *topLayout; 1594 QBoxLayout *topLayout;
1599 1595
1600 // = new QHBoxLayout( this ); 1596 // = new QHBoxLayout( this );
1601// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1597// QBoxLayout *topLayout = (QBoxLayout*)layout();
1602 1598
1603// QWidget *mainBox = new QWidget( this ); 1599// QWidget *mainBox = new QWidget( this );
1604// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1600// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1605 1601
1606#ifdef DESKTOP_VERSION 1602#ifdef DESKTOP_VERSION
1607 topLayout = new QHBoxLayout( this ); 1603 topLayout = new QHBoxLayout( this );
1608 1604
1609 1605
1610 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1606 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1611 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1607 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1612 1608
1613 topLayout->addWidget(mMiniSplitter ); 1609 topLayout->addWidget(mMiniSplitter );
1614 1610
1615 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1611 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1616 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1612 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1617 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1613 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1618 mDetails = new ViewContainer( mMiniSplitter ); 1614 mDetails = new ViewContainer( mMiniSplitter );
1619 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1615 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1620#else 1616#else
1621 if ( QApplication::desktop()->width() > 480 ) { 1617 if ( QApplication::desktop()->width() > 480 ) {
1622 topLayout = new QHBoxLayout( this ); 1618 topLayout = new QHBoxLayout( this );
1623 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1619 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1624 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1620 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1625 } else { 1621 } else {
1626 1622
1627 topLayout = new QHBoxLayout( this ); 1623 topLayout = new QHBoxLayout( this );
1628 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1624 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1629 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1625 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1630 } 1626 }
1631 1627
1632 topLayout->addWidget(mMiniSplitter ); 1628 topLayout->addWidget(mMiniSplitter );
1633 mViewManager = new ViewManager( this, mMiniSplitter ); 1629 mViewManager = new ViewManager( this, mMiniSplitter );
1634 mDetails = new ViewContainer( mMiniSplitter ); 1630 mDetails = new ViewContainer( mMiniSplitter );
1635 1631
1636 1632
1637 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1633 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1638#endif 1634#endif
1639 //eh->hide(); 1635 //eh->hide();
1640 // topLayout->addWidget(mExtensionManager ); 1636 // topLayout->addWidget(mExtensionManager );
1641 1637
1642 1638
1643/*US 1639/*US
1644#ifndef KAB_NOSPLITTER 1640#ifndef KAB_NOSPLITTER
1645 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1641 QHBoxLayout *topLayout = new QHBoxLayout( this );
1646//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1642//US topLayout->setSpacing( KDialogBase::spacingHint() );
1647 topLayout->setSpacing( 10 ); 1643 topLayout->setSpacing( 10 );
1648 1644
1649 mDetailsSplitter = new QSplitter( this ); 1645 mDetailsSplitter = new QSplitter( this );
1650 1646
1651 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1647 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1652 1648
1653 mViewManager = new ViewManager( this, viewSpace ); 1649 mViewManager = new ViewManager( this, viewSpace );
1654 viewSpace->setStretchFactor( mViewManager, 1 ); 1650 viewSpace->setStretchFactor( mViewManager, 1 );
1655 1651
1656 mDetails = new ViewContainer( mDetailsSplitter ); 1652 mDetails = new ViewContainer( mDetailsSplitter );
1657 1653
1658 topLayout->addWidget( mDetailsSplitter ); 1654 topLayout->addWidget( mDetailsSplitter );
1659 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1655 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1660#else //KAB_NOSPLITTER 1656#else //KAB_NOSPLITTER
1661 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1657 QHBoxLayout *topLayout = new QHBoxLayout( this );
1662//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1658//US topLayout->setSpacing( KDialogBase::spacingHint() );
1663 topLayout->setSpacing( 10 ); 1659 topLayout->setSpacing( 10 );
1664 1660
1665// mDetailsSplitter = new QSplitter( this ); 1661// mDetailsSplitter = new QSplitter( this );
1666 1662
1667 QVBox *viewSpace = new QVBox( this ); 1663 QVBox *viewSpace = new QVBox( this );
1668 1664
1669 mViewManager = new ViewManager( this, viewSpace ); 1665 mViewManager = new ViewManager( this, viewSpace );
1670 viewSpace->setStretchFactor( mViewManager, 1 ); 1666 viewSpace->setStretchFactor( mViewManager, 1 );
1671 1667
1672 mDetails = new ViewContainer( this ); 1668 mDetails = new ViewContainer( this );
1673 1669
1674 topLayout->addWidget( viewSpace ); 1670 topLayout->addWidget( viewSpace );
1675// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1671// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1676 topLayout->addWidget( mDetails ); 1672 topLayout->addWidget( mDetails );
1677#endif //KAB_NOSPLITTER 1673#endif //KAB_NOSPLITTER
1678*/ 1674*/
1679 1675
1680 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1676 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1681 syncManager->setBlockSave(false); 1677 syncManager->setBlockSave(false);
1682 1678
1683 1679
1684#endif //KAB_EMBEDDED 1680#endif //KAB_EMBEDDED
1685 initActions(); 1681 initActions();
1686 1682
1687#ifdef KAB_EMBEDDED 1683#ifdef KAB_EMBEDDED
1688 addActionsManually(); 1684 addActionsManually();
1689 //US make sure the export and import menues are initialized before creating the xxPortManager. 1685 //US make sure the export and import menues are initialized before creating the xxPortManager.
1690 mXXPortManager = new XXPortManager( this, this ); 1686 mXXPortManager = new XXPortManager( this, this );
1691 1687
1692 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1688 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1693 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1689 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1694 // mActionQuit->plug ( mMainWindow->toolBar()); 1690 // mActionQuit->plug ( mMainWindow->toolBar());
1695 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1691 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1696 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1692 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1697 // mIncSearchWidget->hide(); 1693 // mIncSearchWidget->hide();
1698 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1694 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1699 SLOT( incrementalSearch( const QString& ) ) ); 1695 SLOT( incrementalSearch( const QString& ) ) );
1700 1696
1701 1697
1702 mJumpButtonBar = new JumpButtonBar( this, this ); 1698 mJumpButtonBar = new JumpButtonBar( this, this );
1703 1699
1704 topLayout->addWidget( mJumpButtonBar ); 1700 topLayout->addWidget( mJumpButtonBar );
1705//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1701//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1706 1702
1707// mMainWindow->getIconToolBar()->raise(); 1703// mMainWindow->getIconToolBar()->raise();
1708 1704
1709#endif //KAB_EMBEDDED 1705#endif //KAB_EMBEDDED
1710 1706
1711} 1707}
1712void KABCore::initActions() 1708void KABCore::initActions()
1713{ 1709{
1714//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1710//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1715 1711
1716#ifndef KAB_EMBEDDED 1712#ifndef KAB_EMBEDDED
1717 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1713 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1718 SLOT( clipboardDataChanged() ) ); 1714 SLOT( clipboardDataChanged() ) );
1719#endif //KAB_EMBEDDED 1715#endif //KAB_EMBEDDED
1720 1716
1721 // file menu 1717 // file menu
1722 if ( mIsPart ) { 1718 if ( mIsPart ) {
1723 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1719 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1724 SLOT( sendMail() ), actionCollection(), 1720 SLOT( sendMail() ), actionCollection(),
1725 "kaddressbook_mail" ); 1721 "kaddressbook_mail" );
1726 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1722 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1727 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1723 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1728 1724
1729 } else { 1725 } else {
1730 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1726 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1731 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1727 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1732 } 1728 }
1733 1729
1734 1730
1735 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1731 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1736 SLOT( save() ), actionCollection(), "file_sync" ); 1732 SLOT( save() ), actionCollection(), "file_sync" );
1737 1733
1738 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1734 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1739 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1735 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1740 1736
1741 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1737 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1742 this, SLOT( mailVCard() ), 1738 this, SLOT( mailVCard() ),
1743 actionCollection(), "file_mail_vcard"); 1739 actionCollection(), "file_mail_vcard");
1744 1740
1745 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1741 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1746 SLOT( export2phone() ), actionCollection(), 1742 SLOT( export2phone() ), actionCollection(),
1747 "kaddressbook_ex2phone" ); 1743 "kaddressbook_ex2phone" );
1748 1744
1749 mActionBeamVCard = 0; 1745 mActionBeamVCard = 0;
1750 mActionBeam = 0; 1746 mActionBeam = 0;
1751 1747
1752#ifndef DESKTOP_VERSION 1748#ifndef DESKTOP_VERSION
1753 if ( Ir::supported() ) { 1749 if ( Ir::supported() ) {
1754 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1750 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1755 SLOT( beamVCard() ), actionCollection(), 1751 SLOT( beamVCard() ), actionCollection(),
1756 "kaddressbook_beam_vcard" ); 1752 "kaddressbook_beam_vcard" );
1757 1753
1758 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1754 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1759 SLOT( beamMySelf() ), actionCollection(), 1755 SLOT( beamMySelf() ), actionCollection(),
1760 "kaddressbook_beam_myself" ); 1756 "kaddressbook_beam_myself" );
1761 } 1757 }
1762#endif 1758#endif
1763 1759
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2f286e0..ec69b11 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2260 +1,2261 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h>
42#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
43#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
44 45
45#include "calendarview.h" 46#include "calendarview.h"
46#include "koviewmanager.h" 47#include "koviewmanager.h"
47#include "datenavigator.h" 48#include "datenavigator.h"
48#include "koagendaview.h" 49#include "koagendaview.h"
49#include "koagenda.h" 50#include "koagenda.h"
50#include "kodialogmanager.h" 51#include "kodialogmanager.h"
51#include "kdialogbase.h" 52#include "kdialogbase.h"
52#include "kapplication.h" 53#include "kapplication.h"
53#include "kofilterview.h" 54#include "kofilterview.h"
54#include "kstandarddirs.h" 55#include "kstandarddirs.h"
55#include "koprefs.h" 56#include "koprefs.h"
56#include "kfiledialog.h" 57#include "kfiledialog.h"
57#include "koglobals.h" 58#include "koglobals.h"
58#include "kglobal.h" 59#include "kglobal.h"
59#include "klocale.h" 60#include "klocale.h"
60#include "kconfig.h" 61#include "kconfig.h"
61#include "simplealarmclient.h" 62#include "simplealarmclient.h"
62#include "externalapphandler.h" 63#include "externalapphandler.h"
63 64
64using namespace KCal; 65using namespace KCal;
65#ifndef _WIN32_ 66#ifndef _WIN32_
66#include <unistd.h> 67#include <unistd.h>
67#else 68#else
68#include "koimportoldialog.h" 69#include "koimportoldialog.h"
69#endif 70#endif
70#include "mainwindow.h" 71#include "mainwindow.h"
71 72
72class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
73{ 74{
74 public: 75 public:
75 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
76 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
77 { 78 {
78 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
79 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
80 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
81 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
82 QLabel *lab; 83 QLabel *lab;
83 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
84 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
85 QHBox* temphb; 86 QHBox* temphb;
86 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
87 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
88 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
89 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
90 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
91 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
92 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
95 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
96 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
98 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
99 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
100 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
101 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
102 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
103 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
104 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
105 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
106 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
107 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
108 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
109 lay->addWidget( ok ); 110 lay->addWidget( ok );
110 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
111 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
112 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
113 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
114 resize( 220, 240 ); 115 resize( 220, 240 );
115 116
116 } 117 }
117 118
118public: 119public:
119 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
120 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
121 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
122}; 123};
123 124
124int globalFlagBlockStartup; 125int globalFlagBlockStartup;
125MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
126 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
127{ 128{
128 mPassWordPiSync = "abc"; 129 mPassWordPiSync = "abc";
129#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
130 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
131#endif 132#endif
132 mSyncActionDialog = 0; 133 mSyncActionDialog = 0;
133 mServerSocket = 0; 134 mServerSocket = 0;
134 mClosed = false; 135 mClosed = false;
135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 136 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
136 QString confFile = locateLocal("config","korganizerrc"); 137 QString confFile = locateLocal("config","korganizerrc");
137 QFileInfo finf ( confFile ); 138 QFileInfo finf ( confFile );
138 bool showWarning = !finf.exists(); 139 bool showWarning = !finf.exists();
139 setIcon(SmallIcon( "ko24" ) ); 140 setIcon(SmallIcon( "ko24" ) );
140 mBlockAtStartup = true; 141 mBlockAtStartup = true;
141 mFlagKeyPressed = false; 142 mFlagKeyPressed = false;
142 setCaption("KOrganizer/Pi"); 143 setCaption("KOrganizer/Pi");
143 KOPrefs *p = KOPrefs::instance(); 144 KOPrefs *p = KOPrefs::instance();
144 KPimGlobalPrefs::instance()->setGlobalConfig(); 145 KPimGlobalPrefs::instance()->setGlobalConfig();
145 // if ( QApplication::desktop()->height() > 480 ) { 146 // if ( QApplication::desktop()->height() > 480 ) {
146// if ( p->mHourSize == 4 ) 147// if ( p->mHourSize == 4 )
147// p->mHourSize = 6; 148// p->mHourSize = 6;
148// } 149// }
149 if ( p->mHourSize > 18 ) 150 if ( p->mHourSize > 18 )
150 p->mHourSize = 18; 151 p->mHourSize = 18;
151 QMainWindow::ToolBarDock tbd; 152 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 153 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
154 tbd = Bottom; 155 tbd = Bottom;
155 else 156 else
156 tbd = Top; 157 tbd = Top;
157 } 158 }
158 else { 159 else {
159 if ( p->mToolBarUp ) 160 if ( p->mToolBarUp )
160 tbd = Right; 161 tbd = Right;
161 else 162 else
162 tbd = Left; 163 tbd = Left;
163 } 164 }
164 if ( KOPrefs::instance()->mUseAppColors ) 165 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 166 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 167 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 168 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 169 addToolBar (iconToolBar , tbd );
169 mBlockSaveFlag = false; 170 mBlockSaveFlag = false;
170 mCalendarModifiedFlag = false; 171 mCalendarModifiedFlag = false;
171 172
172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 173 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
173 splash->setAlignment ( AlignCenter ); 174 splash->setAlignment ( AlignCenter );
174 setCentralWidget( splash ); 175 setCentralWidget( splash );
175#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
176 showMaximized(); 177 showMaximized();
177#endif 178#endif
178 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 179 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
179 setDefaultPreferences(); 180 setDefaultPreferences();
180 mCalendar = new CalendarLocal(); 181 mCalendar = new CalendarLocal();
181 mView = new CalendarView( mCalendar, this,"mCalendar " ); 182 mView = new CalendarView( mCalendar, this,"mCalendar " );
182 mView->hide(); 183 mView->hide();
183 //mView->resize(splash->size() ); 184 //mView->resize(splash->size() );
184 initActions(); 185 initActions();
185#ifndef DESKTOP_VERSION 186#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 187 iconToolBar->show();
187 qApp->processEvents(); 188 qApp->processEvents();
188#endif 189#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 190 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 191 int vh = height() ;
191 int vw = width(); 192 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 193 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 194 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 195 vh -= iconToolBar->height();
195 } else { 196 } else {
196 vw -= iconToolBar->height(); 197 vw -= iconToolBar->height();
197 } 198 }
198 //mView->setMaximumSize( splash->size() ); 199 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 200 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 202 mView->readSettings();
202 bool newFile = false; 203 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 204 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 205 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 206 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 207 qDebug("oldfile %s ", oldFile.latin1());
207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 208 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
208 finfo.setFile( oldFile ); 209 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 210 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 211 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 212 mView->openCalendar( oldFile );
212 qApp->processEvents(); 213 qApp->processEvents();
213 } else { 214 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 215 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 216 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 217 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 218 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 219 mView->openCalendar( oldFile );
219 qApp->processEvents(); 220 qApp->processEvents();
220 } 221 }
221 } 222 }
222 mView->saveCalendar( defaultFileName() ); 223 mView->saveCalendar( defaultFileName() );
223 newFile = true; 224 newFile = true;
224 } 225 }
225 226
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 227 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 228 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 229 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 230 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 231
231 if ( KOPrefs::instance()->mLanguageChanged ) { 232 if ( KOPrefs::instance()->mLanguageChanged ) {
232 KOPrefs::instance()->setCategoryDefaults(); 233 KOPrefs::instance()->setCategoryDefaults();
233 int count = mView->addCategories(); 234 int count = mView->addCategories();
234 KOPrefs::instance()->mLanguageChanged = false; 235 KOPrefs::instance()->mLanguageChanged = false;
235 } 236 }
236 processIncidenceSelection( 0 ); 237 processIncidenceSelection( 0 );
237 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
238 SLOT( processIncidenceSelection( Incidence * ) ) ); 239 SLOT( processIncidenceSelection( Incidence * ) ) );
239 connect( mView, SIGNAL( modifiedChanged( bool ) ), 240 connect( mView, SIGNAL( modifiedChanged( bool ) ),
240 SLOT( slotModifiedChanged( bool ) ) ); 241 SLOT( slotModifiedChanged( bool ) ) );
241 242
242 243
243 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
244 mView->setModified( false ); 245 mView->setModified( false );
245 mBlockAtStartup = false; 246 mBlockAtStartup = false;
246 mView->setModified( false ); 247 mView->setModified( false );
247 setCentralWidget( mView ); 248 setCentralWidget( mView );
248 globalFlagBlockStartup = 0; 249 globalFlagBlockStartup = 0;
249 mView->show(); 250 mView->show();
250 delete splash; 251 delete splash;
251 if ( newFile ) 252 if ( newFile )
252 mView->updateConfig(); 253 mView->updateConfig();
253 // qApp->processEvents(); 254 // qApp->processEvents();
254 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
255 fillSyncMenu(); 256 fillSyncMenu();
256 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 257 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
257 if ( showWarning ) { 258 if ( showWarning ) {
258 KMessageBox::information( this, 259 KMessageBox::information( this,
259 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 260 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
260 qApp->processEvents(); 261 qApp->processEvents();
261 mView->dialogManager()->showSyncOptions(); 262 mView->dialogManager()->showSyncOptions();
262 } 263 }
263 264
264 //US listen for result adressed from Ka/Pi 265 //US listen for result adressed from Ka/Pi
265#ifndef DESKTOP_VERSION 266#ifndef DESKTOP_VERSION
266 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 267 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
267#endif 268#endif
268} 269}
269MainWindow::~MainWindow() 270MainWindow::~MainWindow()
270{ 271{
271 //qDebug("MainWindow::~MainWindow() "); 272 //qDebug("MainWindow::~MainWindow() ");
272 //save toolbar location 273 //save toolbar location
273 delete mServerSocket; 274 delete mServerSocket;
274 delete mCalendar; 275 delete mCalendar;
275 delete KOPrefs::instance(); 276 delete KOPrefs::instance();
276 delete KIncidenceFormatter::instance(); 277 delete KIncidenceFormatter::instance();
277 278
278 279
279} 280}
280void MainWindow::showMaximized () 281void MainWindow::showMaximized ()
281{ 282{
282#ifndef DESKTOP_VERSION 283#ifndef DESKTOP_VERSION
283 if ( ! globalFlagBlockStartup ) 284 if ( ! globalFlagBlockStartup )
284 if ( mClosed ) 285 if ( mClosed )
285 mView->goToday(); 286 mView->goToday();
286#endif 287#endif
287 QWidget::showMaximized () ; 288 QWidget::showMaximized () ;
288 mClosed = false; 289 mClosed = false;
289} 290}
290void MainWindow::closeEvent( QCloseEvent* ce ) 291void MainWindow::closeEvent( QCloseEvent* ce )
291{ 292{
292 293
293 294
294 295
295 if ( ! KOPrefs::instance()->mAskForQuit ) { 296 if ( ! KOPrefs::instance()->mAskForQuit ) {
296 saveOnClose(); 297 saveOnClose();
297 mClosed = true; 298 mClosed = true;
298 ce->accept(); 299 ce->accept();
299 return; 300 return;
300 301
301 } 302 }
302 303
303 switch( QMessageBox::information( this, "KO/Pi", 304 switch( QMessageBox::information( this, "KO/Pi",
304 i18n("Do you really want\nto close KO/Pi?"), 305 i18n("Do you really want\nto close KO/Pi?"),
305 i18n("Close"), i18n("No"), 306 i18n("Close"), i18n("No"),
306 0, 0 ) ) { 307 0, 0 ) ) {
307 case 0: 308 case 0:
308 saveOnClose(); 309 saveOnClose();
309 mClosed = true; 310 mClosed = true;
310 ce->accept(); 311 ce->accept();
311 break; 312 break;
312 case 1: 313 case 1:
313 ce->ignore(); 314 ce->ignore();
314 break; 315 break;
315 case 2: 316 case 2:
316 317
317 default: 318 default:
318 break; 319 break;
319 } 320 }
320 321
321 322
322} 323}
323 324
324void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 325void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
325{ 326{
326 QDataStream stream( data, IO_ReadOnly ); 327 QDataStream stream( data, IO_ReadOnly );
327 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 328 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
328 //QString datamess; 329 //QString datamess;
329 //qDebug("message "); 330 //qDebug("message ");
330 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 331 qDebug("KO: QCOP message received: %s ", cmsg.data() );
331 332
332 if ( cmsg == "-writeFile" ) { 333 if ( cmsg == "-writeFile" ) {
333 // I made from the "-writeFile" an "-writeAlarm" 334 // I made from the "-writeFile" an "-writeAlarm"
334 mView->viewManager()->showWhatsNextView(); 335 mView->viewManager()->showWhatsNextView();
335 mCalendar->checkAlarmForIncidence( 0, true); 336 mCalendar->checkAlarmForIncidence( 0, true);
336 showMaximized(); 337 showMaximized();
337 raise(); 338 raise();
338 return; 339 return;
339 } 340 }
340 341
341 if ( cmsg == "-writeFile" ) { 342 if ( cmsg == "-writeFile" ) {
342 // I made from the "-writeFile" an "-writeAlarm" 343 // I made from the "-writeFile" an "-writeAlarm"
343 mView->viewManager()->showWhatsNextView(); 344 mView->viewManager()->showWhatsNextView();
344 mCalendar->checkAlarmForIncidence( 0, true); 345 mCalendar->checkAlarmForIncidence( 0, true);
345 showMaximized(); 346 showMaximized();
346 raise(); 347 raise();
347 return; 348 return;
348 349
349 } 350 }
350 if ( cmsg == "-writeFileSilent" ) { 351 if ( cmsg == "-writeFileSilent" ) {
351 // I made from the "-writeFile" an "-writeAlarm" 352 // I made from the "-writeFile" an "-writeAlarm"
352 // mView->viewManager()->showWhatsNextView(); 353 // mView->viewManager()->showWhatsNextView();
353 mCalendar->checkAlarmForIncidence( 0, true); 354 mCalendar->checkAlarmForIncidence( 0, true);
354 //showMaximized(); 355 //showMaximized();
355 //raise(); 356 //raise();
356 hide(); 357 hide();
357 return; 358 return;
358 } 359 }
359 if ( cmsg == "-newCountdown" ) { 360 if ( cmsg == "-newCountdown" ) {
360 qDebug("newCountdown "); 361 qDebug("newCountdown ");
361 362
362 } 363 }
363 QString msg ; 364 QString msg ;
364 QString allmsg = cmsg; 365 QString allmsg = cmsg;
365 while ( allmsg.length() > 0 ) { 366 while ( allmsg.length() > 0 ) {
366 int nextC = allmsg.find( "-", 1 ); 367 int nextC = allmsg.find( "-", 1 );
367 if ( nextC == -1 ) { 368 if ( nextC == -1 ) {
368 msg = allmsg; 369 msg = allmsg;
369 allmsg = ""; 370 allmsg = "";
370 } else{ 371 } else{
371 msg = allmsg.left( nextC ); 372 msg = allmsg.left( nextC );
372 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 373 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
373 } 374 }
374 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 375 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
375 if ( msg == "-newEvent" ) { 376 if ( msg == "-newEvent" ) {
376 mView->newEvent(); 377 mView->newEvent();
377 } 378 }
378 if ( msg == "-newTodo" ) { 379 if ( msg == "-newTodo" ) {
379 mView->newTodo(); 380 mView->newTodo();
380 381
381 } 382 }
382 if ( msg == "-showWN" ) { 383 if ( msg == "-showWN" ) {
383 mView->viewManager()->showWhatsNextView(); 384 mView->viewManager()->showWhatsNextView();
384 } 385 }
385 if ( msg == "-showTodo" ) { 386 if ( msg == "-showTodo" ) {
386 mView->viewManager()->showTodoView(); 387 mView->viewManager()->showTodoView();
387 } 388 }
388 if ( msg == "-showList" ) { 389 if ( msg == "-showList" ) {
389 mView->viewManager()->showListView(); 390 mView->viewManager()->showListView();
390 } 391 }
391 else if ( msg == "-showDay" ) { 392 else if ( msg == "-showDay" ) {
392 mView->viewManager()->showDayView(); 393 mView->viewManager()->showDayView();
393 } 394 }
394 else if ( msg == "-showWWeek" ) { 395 else if ( msg == "-showWWeek" ) {
395 mView->viewManager()->showWorkWeekView(); 396 mView->viewManager()->showWorkWeekView();
396 } 397 }
397 else if ( msg == "-ringSync" ) { 398 else if ( msg == "-ringSync" ) {
398 multiSync( false ); 399 multiSync( false );
399 } 400 }
400 else if ( msg == "-showWeek" ) { 401 else if ( msg == "-showWeek" ) {
401 mView->viewManager()->showWeekView(); 402 mView->viewManager()->showWeekView();
402 } 403 }
403 else if ( msg == "-showTodo" ) { 404 else if ( msg == "-showTodo" ) {
404 mView->viewManager()->showTodoView(); 405 mView->viewManager()->showTodoView();
405 } 406 }
406 else if ( msg == "-showJournal" ) { 407 else if ( msg == "-showJournal" ) {
407 mView->dateNavigator()->selectDates( 1 ); 408 mView->dateNavigator()->selectDates( 1 );
408 mView->dateNavigator()->selectToday(); 409 mView->dateNavigator()->selectToday();
409 mView->viewManager()->showJournalView(); 410 mView->viewManager()->showJournalView();
410 } 411 }
411 else if ( msg == "-showKO" ) { 412 else if ( msg == "-showKO" ) {
412 mView->viewManager()->showNextXView(); 413 mView->viewManager()->showNextXView();
413 } 414 }
414 else if ( msg == "-showWNext" || msg == "nextView()" ) { 415 else if ( msg == "-showWNext" || msg == "nextView()" ) {
415 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
416 } 417 }
417 else if ( msg == "-showNextXView" ) { 418 else if ( msg == "-showNextXView" ) {
418 mView->viewManager()->showNextXView(); 419 mView->viewManager()->showNextXView();
419 } 420 }
420 421
421 422
422 } 423 }
423 424
424 showMaximized(); 425 showMaximized();
425 raise(); 426 raise();
426} 427}
427 428
428QPixmap MainWindow::loadPixmap( QString name ) 429QPixmap MainWindow::loadPixmap( QString name )
429{ 430{
430 return SmallIcon( name ); 431 return SmallIcon( name );
431 432
432} 433}
433void MainWindow::initActions() 434void MainWindow::initActions()
434{ 435{
435 //KOPrefs::instance()->mShowFullMenu 436 //KOPrefs::instance()->mShowFullMenu
436 iconToolBar->clear(); 437 iconToolBar->clear();
437 KOPrefs *p = KOPrefs::instance(); 438 KOPrefs *p = KOPrefs::instance();
438 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 439 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
439 440
440 QPopupMenu *viewMenu = new QPopupMenu( this ); 441 QPopupMenu *viewMenu = new QPopupMenu( this );
441 QPopupMenu *actionMenu = new QPopupMenu( this ); 442 QPopupMenu *actionMenu = new QPopupMenu( this );
442 QPopupMenu *importMenu = new QPopupMenu( this ); 443 QPopupMenu *importMenu = new QPopupMenu( this );
443 selectFilterMenu = new QPopupMenu( this ); 444 selectFilterMenu = new QPopupMenu( this );
444 selectFilterMenu->setCheckable( true ); 445 selectFilterMenu->setCheckable( true );
445 syncMenu = new QPopupMenu( this ); 446 syncMenu = new QPopupMenu( this );
446 configureAgendaMenu = new QPopupMenu( this ); 447 configureAgendaMenu = new QPopupMenu( this );
447 configureToolBarMenu = new QPopupMenu( this ); 448 configureToolBarMenu = new QPopupMenu( this );
448 QPopupMenu *helpMenu = new QPopupMenu( this ); 449 QPopupMenu *helpMenu = new QPopupMenu( this );
449 if ( KOPrefs::instance()->mShowFullMenu ) { 450 if ( KOPrefs::instance()->mShowFullMenu ) {
450 QMenuBar *menuBar1; 451 QMenuBar *menuBar1;
451 menuBar1 = menuBar(); 452 menuBar1 = menuBar();
452 menuBar1->insertItem( i18n("File"), importMenu ); 453 menuBar1->insertItem( i18n("File"), importMenu );
453 menuBar1->insertItem( i18n("View"), viewMenu ); 454 menuBar1->insertItem( i18n("View"), viewMenu );
454 menuBar1->insertItem( i18n("Actions"), actionMenu ); 455 menuBar1->insertItem( i18n("Actions"), actionMenu );
455 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 456 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
456 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 457 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
457 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 458 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
458 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 459 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
459 menuBar1->insertItem( i18n("Help"), helpMenu ); 460 menuBar1->insertItem( i18n("Help"), helpMenu );
460 } else { 461 } else {
461 QPEMenuBar *menuBar1; 462 QPEMenuBar *menuBar1;
462 menuBar1 = new QPEMenuBar( iconToolBar ); 463 menuBar1 = new QPEMenuBar( iconToolBar );
463 QPopupMenu *menuBar = new QPopupMenu( this ); 464 QPopupMenu *menuBar = new QPopupMenu( this );
464 menuBar1->insertItem( i18n("ME"), menuBar); 465 menuBar1->insertItem( i18n("ME"), menuBar);
465 menuBar->insertItem( i18n("File"), importMenu ); 466 menuBar->insertItem( i18n("File"), importMenu );
466 menuBar->insertItem( i18n("View"), viewMenu ); 467 menuBar->insertItem( i18n("View"), viewMenu );
467 menuBar->insertItem( i18n("Actions"), actionMenu ); 468 menuBar->insertItem( i18n("Actions"), actionMenu );
468 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 469 menuBar->insertItem( i18n("Synchronize"), syncMenu );
469 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 470 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
470 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 471 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
471 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 472 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
472 menuBar->insertItem( i18n("Help"), helpMenu ); 473 menuBar->insertItem( i18n("Help"), helpMenu );
473 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 474 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
474 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 475 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
475 } 476 }
476 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 477 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
477 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 478 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
478 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 479 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
479 480
480 // ****************** 481 // ******************
481 QAction *action; 482 QAction *action;
482 QIconSet icon; 483 QIconSet icon;
483 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 484 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
484 configureToolBarMenu->setCheckable( true ); 485 configureToolBarMenu->setCheckable( true );
485 486
486 QString pathString = ""; 487 QString pathString = "";
487 if ( !p->mToolBarMiniIcons ) { 488 if ( !p->mToolBarMiniIcons ) {
488 if ( QApplication::desktop()->width() < 480 ) 489 if ( QApplication::desktop()->width() < 480 )
489 pathString += "icons16/"; 490 pathString += "icons16/";
490 } else 491 } else
491 pathString += "iconsmini/"; 492 pathString += "iconsmini/";
492 configureAgendaMenu->setCheckable( true ); 493 configureAgendaMenu->setCheckable( true );
493 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 494 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
494 configureAgendaMenu->insertSeparator(); 495 configureAgendaMenu->insertSeparator();
495 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 496 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
496 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 497 configureAgendaMenu->insertItem(i18n("Small"), 6 );
497 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 498 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
498 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 499 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
499 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 500 configureAgendaMenu->insertItem(i18n("Large"), 12 );
500 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 501 configureAgendaMenu->insertItem(i18n("Big"), 14 );
501 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 502 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
502 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 503 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
503 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 504 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
504 505
505 icon = loadPixmap( pathString + "configure" ); 506 icon = loadPixmap( pathString + "configure" );
506 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 507 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
507 action->addTo( actionMenu ); 508 action->addTo( actionMenu );
508 connect( action, SIGNAL( activated() ), 509 connect( action, SIGNAL( activated() ),
509 mView, SLOT( edit_options() ) ); 510 mView, SLOT( edit_options() ) );
510 actionMenu->insertSeparator(); 511 actionMenu->insertSeparator();
511 icon = loadPixmap( pathString + "newevent" ); 512 icon = loadPixmap( pathString + "newevent" );
512 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 513 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
513 configureToolBarMenu->insertSeparator(); 514 configureToolBarMenu->insertSeparator();
514 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 515 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
515 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 516 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
516 ne_action->addTo( actionMenu ); 517 ne_action->addTo( actionMenu );
517 connect( ne_action, SIGNAL( activated() ), 518 connect( ne_action, SIGNAL( activated() ),
518 mView, SLOT( newEvent() ) ); 519 mView, SLOT( newEvent() ) );
519 icon = loadPixmap( pathString + "newtodo" ); 520 icon = loadPixmap( pathString + "newtodo" );
520 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 521 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
521 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 522 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
522 nt_action->addTo( actionMenu ); 523 nt_action->addTo( actionMenu );
523 connect( nt_action, SIGNAL( activated() ), 524 connect( nt_action, SIGNAL( activated() ),
524 mView, SLOT( newTodo() ) ); 525 mView, SLOT( newTodo() ) );
525 icon = loadPixmap( pathString + "navi" ); 526 icon = loadPixmap( pathString + "navi" );
526 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 527 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
527 action->addTo( viewMenu ); 528 action->addTo( viewMenu );
528 connect( action, SIGNAL( activated() ), 529 connect( action, SIGNAL( activated() ),
529 mView, SLOT( toggleDateNavigatorWidget() ) ); 530 mView, SLOT( toggleDateNavigatorWidget() ) );
530 icon = loadPixmap( pathString + "filter" ); 531 icon = loadPixmap( pathString + "filter" );
531 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 532 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
532 action->addTo( viewMenu ); 533 action->addTo( viewMenu );
533 connect( action, SIGNAL( activated() ), 534 connect( action, SIGNAL( activated() ),
534 mView, SLOT( toggleFilter() ) ); 535 mView, SLOT( toggleFilter() ) );
535 536
536 537
537 viewMenu->insertSeparator(); 538 viewMenu->insertSeparator();
538 icon = loadPixmap( pathString + "picker" ); 539 icon = loadPixmap( pathString + "picker" );
539 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 540 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
540 action->addTo( viewMenu ); 541 action->addTo( viewMenu );
541 connect( action, SIGNAL( activated() ), 542 connect( action, SIGNAL( activated() ),
542 mView, SLOT( showDatePicker() ) ); 543 mView, SLOT( showDatePicker() ) );
543 action->addTo( iconToolBar ); 544 action->addTo( iconToolBar );
544 viewMenu->insertSeparator(); 545 viewMenu->insertSeparator();
545 icon = loadPixmap( pathString + "list" ); 546 icon = loadPixmap( pathString + "list" );
546 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 547 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
547 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 548 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
548 showlist_action->addTo( viewMenu ); 549 showlist_action->addTo( viewMenu );
549 connect( showlist_action, SIGNAL( activated() ), 550 connect( showlist_action, SIGNAL( activated() ),
550 mView->viewManager(), SLOT( showListView() ) ); 551 mView->viewManager(), SLOT( showListView() ) );
551 552
552 553
553 icon = loadPixmap( pathString + "day" ); 554 icon = loadPixmap( pathString + "day" );
554 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 555 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
555 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 556 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
556 day1_action->addTo( viewMenu ); 557 day1_action->addTo( viewMenu );
557 // action->addTo( toolBar ); 558 // action->addTo( toolBar );
558 connect( day1_action, SIGNAL( activated() ), 559 connect( day1_action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showDayView() ) ); 560 mView->viewManager(), SLOT( showDayView() ) );
560 561
561 icon = loadPixmap( pathString + "workweek" ); 562 icon = loadPixmap( pathString + "workweek" );
562 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 563 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
563 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 564 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
564 day5_action->addTo( viewMenu ); 565 day5_action->addTo( viewMenu );
565 connect( day5_action, SIGNAL( activated() ), 566 connect( day5_action, SIGNAL( activated() ),
566 mView->viewManager(), SLOT( showWorkWeekView() ) ); 567 mView->viewManager(), SLOT( showWorkWeekView() ) );
567 568
568 icon = loadPixmap( pathString + "week" ); 569 icon = loadPixmap( pathString + "week" );
569 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 570 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
570 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 571 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
571 day7_action->addTo( viewMenu ); 572 day7_action->addTo( viewMenu );
572 connect( day7_action, SIGNAL( activated() ), 573 connect( day7_action, SIGNAL( activated() ),
573 mView->viewManager(), SLOT( showWeekView() ) ); 574 mView->viewManager(), SLOT( showWeekView() ) );
574 575
575 icon = loadPixmap( pathString + "month" ); 576 icon = loadPixmap( pathString + "month" );
576 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 577 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
577 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 578 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
578 month_action->addTo( viewMenu ); 579 month_action->addTo( viewMenu );
579 connect( month_action, SIGNAL( activated() ), 580 connect( month_action, SIGNAL( activated() ),
580 mView->viewManager(), SLOT( showMonthView() ) ); 581 mView->viewManager(), SLOT( showMonthView() ) );
581 582
582 icon = loadPixmap( pathString + "todo" ); 583 icon = loadPixmap( pathString + "todo" );
583 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 584 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
584 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 585 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
585 todoview_action->addTo( viewMenu ); 586 todoview_action->addTo( viewMenu );
586 connect( todoview_action, SIGNAL( activated() ), 587 connect( todoview_action, SIGNAL( activated() ),
587 mView->viewManager(), SLOT( showTodoView() ) ); 588 mView->viewManager(), SLOT( showTodoView() ) );
588 589
589 icon = loadPixmap( pathString + "journal" ); 590 icon = loadPixmap( pathString + "journal" );
590 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 591 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
591 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 592 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
592 viewjournal_action->addTo( viewMenu ); 593 viewjournal_action->addTo( viewMenu );
593 connect( viewjournal_action, SIGNAL( activated() ), 594 connect( viewjournal_action, SIGNAL( activated() ),
594 mView->viewManager(), SLOT( showJournalView() ) ); 595 mView->viewManager(), SLOT( showJournalView() ) );
595 596
596 icon = loadPixmap( pathString + "xdays" ); 597 icon = loadPixmap( pathString + "xdays" );
597 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 598 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
598 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 599 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
599 xdays_action->addTo( viewMenu ); 600 xdays_action->addTo( viewMenu );
600 connect( xdays_action, SIGNAL( activated() ), 601 connect( xdays_action, SIGNAL( activated() ),
601 mView->viewManager(), SLOT( showNextXView() ) ); 602 mView->viewManager(), SLOT( showNextXView() ) );
602 603
603 icon = loadPixmap( pathString + "whatsnext" ); 604 icon = loadPixmap( pathString + "whatsnext" );
604 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 605 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
605 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 606 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
606 whatsnext_action->addTo( viewMenu ); 607 whatsnext_action->addTo( viewMenu );
607 connect( whatsnext_action, SIGNAL( activated() ), 608 connect( whatsnext_action, SIGNAL( activated() ),
608 mView->viewManager(), SLOT( showWhatsNextView() ) ); 609 mView->viewManager(), SLOT( showWhatsNextView() ) );
609 610
610#if 0 611#if 0
611 action = new QAction( "view_timespan", "Time Span", 0, this ); 612 action = new QAction( "view_timespan", "Time Span", 0, this );
612 action->addTo( viewMenu ); 613 action->addTo( viewMenu );
613 connect( action, SIGNAL( activated() ), 614 connect( action, SIGNAL( activated() ),
614 mView->viewManager(), SLOT( showTimeSpanView() ) ); 615 mView->viewManager(), SLOT( showTimeSpanView() ) );
615#endif 616#endif
616 617
617 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 618 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
618 this ); 619 this );
619 mNewSubTodoAction->addTo( actionMenu ); 620 mNewSubTodoAction->addTo( actionMenu );
620 connect( mNewSubTodoAction, SIGNAL( activated() ), 621 connect( mNewSubTodoAction, SIGNAL( activated() ),
621 mView, SLOT( newSubTodo() ) ); 622 mView, SLOT( newSubTodo() ) );
622 623
623 actionMenu->insertSeparator(); 624 actionMenu->insertSeparator();
624 625
625 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 626 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
626 mShowAction->addTo( actionMenu ); 627 mShowAction->addTo( actionMenu );
627 connect( mShowAction, SIGNAL( activated() ), 628 connect( mShowAction, SIGNAL( activated() ),
628 mView, SLOT( showIncidence() ) ); 629 mView, SLOT( showIncidence() ) );
629 630
630 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 631 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
631 mEditAction->addTo( actionMenu ); 632 mEditAction->addTo( actionMenu );
632 connect( mEditAction, SIGNAL( activated() ), 633 connect( mEditAction, SIGNAL( activated() ),
633 mView, SLOT( editIncidence() ) ); 634 mView, SLOT( editIncidence() ) );
634 635
635 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 636 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
636 mDeleteAction->addTo( actionMenu ); 637 mDeleteAction->addTo( actionMenu );
637 connect( mDeleteAction, SIGNAL( activated() ), 638 connect( mDeleteAction, SIGNAL( activated() ),
638 mView, SLOT( deleteIncidence() ) ); 639 mView, SLOT( deleteIncidence() ) );
639 640
640 641
641 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 642 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
642 mCloneAction->addTo( actionMenu ); 643 mCloneAction->addTo( actionMenu );
643 connect( mCloneAction, SIGNAL( activated() ), 644 connect( mCloneAction, SIGNAL( activated() ),
644 mView, SLOT( cloneIncidence() ) ); 645 mView, SLOT( cloneIncidence() ) );
645 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 646 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
646 mMoveAction->addTo( actionMenu ); 647 mMoveAction->addTo( actionMenu );
647 connect( mMoveAction, SIGNAL( activated() ), 648 connect( mMoveAction, SIGNAL( activated() ),
648 mView, SLOT( moveIncidence() ) ); 649 mView, SLOT( moveIncidence() ) );
649 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 650 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
650 mBeamAction->addTo( actionMenu ); 651 mBeamAction->addTo( actionMenu );
651 connect( mBeamAction, SIGNAL( activated() ), 652 connect( mBeamAction, SIGNAL( activated() ),
652 mView, SLOT( beamIncidence() ) ); 653 mView, SLOT( beamIncidence() ) );
653 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 654 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
654 mCancelAction->addTo( actionMenu ); 655 mCancelAction->addTo( actionMenu );
655 connect( mCancelAction, SIGNAL( activated() ), 656 connect( mCancelAction, SIGNAL( activated() ),
656 mView, SLOT( toggleCancelIncidence() ) ); 657 mView, SLOT( toggleCancelIncidence() ) );
657 658
658 actionMenu->insertSeparator(); 659 actionMenu->insertSeparator();
659 660
660 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 661 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
661 this ); 662 this );
662 action->addTo( actionMenu ); 663 action->addTo( actionMenu );
663 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 664 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
664 665
665 icon = loadPixmap( pathString + "search" ); 666 icon = loadPixmap( pathString + "search" );
666 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 667 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
667 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 668 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
668 search_action->addTo( actionMenu ); 669 search_action->addTo( actionMenu );
669 connect( search_action, SIGNAL( activated() ), 670 connect( search_action, SIGNAL( activated() ),
670 mView->dialogManager(), SLOT( showSearchDialog() ) ); 671 mView->dialogManager(), SLOT( showSearchDialog() ) );
671 672
672 icon = loadPixmap( pathString + "today" ); 673 icon = loadPixmap( pathString + "today" );
673 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 674 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
674 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 675 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
675 today_action->addTo( actionMenu ); 676 today_action->addTo( actionMenu );
676 connect( today_action, SIGNAL( activated() ), 677 connect( today_action, SIGNAL( activated() ),
677 mView, SLOT( goToday() ) ); 678 mView, SLOT( goToday() ) );
678 679
679 if ( KOPrefs::instance()->mShowFullMenu ) { 680 if ( KOPrefs::instance()->mShowFullMenu ) {
680 actionMenu->insertSeparator(); 681 actionMenu->insertSeparator();
681 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 682 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
682 683
683 } 684 }
684 // actionMenu->insertSeparator(); 685 // actionMenu->insertSeparator();
685 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 686 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
686 this ); 687 this );
687 action->addTo( importMenu ); 688 action->addTo( importMenu );
688 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 689 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
689 action = new QAction( "import_quick", i18n("Import last file"), 0, 690 action = new QAction( "import_quick", i18n("Import last file"), 0,
690 this ); 691 this );
691 action->addTo( importMenu ); 692 action->addTo( importMenu );
692 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 693 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
693 importMenu->insertSeparator(); 694 importMenu->insertSeparator();
694 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 695 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
695 this ); 696 this );
696 action->addTo( importMenu ); 697 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 698 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
698#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
699 importMenu->insertSeparator(); 700 importMenu->insertSeparator();
700 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 701 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
701 this ); 702 this );
702 action->addTo( importMenu ); 703 action->addTo( importMenu );
703 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 704 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
704#else 705#else
705#ifdef _WIN32_ 706#ifdef _WIN32_
706 importMenu->insertSeparator(); 707 importMenu->insertSeparator();
707 action = new QAction( "import_ol", i18n("Import from OL"), 0, 708 action = new QAction( "import_ol", i18n("Import from OL"), 0,
708 this ); 709 this );
709 action->addTo( importMenu ); 710 action->addTo( importMenu );
710 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 711 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
711#endif 712#endif
712#endif 713#endif
713 714
714 importMenu->insertSeparator(); 715 importMenu->insertSeparator();
715 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 716 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
716 this ); 717 this );
717 action->addTo( importMenu ); 718 action->addTo( importMenu );
718 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 719 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
719 720
720 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 721 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
721 this ); 722 this );
722 action->addTo( importMenu ); 723 action->addTo( importMenu );
723 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 724 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
724 725
725 importMenu->insertSeparator(); 726 importMenu->insertSeparator();
726 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 727 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
727 this ); 728 this );
728 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 729 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
729 730
730 731
731 //LR 732 //LR
732 QPopupMenu *ex2phone = new QPopupMenu( this ); 733 QPopupMenu *ex2phone = new QPopupMenu( this );
733 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 734 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
734 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 735 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
735 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 736 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
736 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 737 importMenu->insertItem( i18n("Export to phone"), ex2phone );
737 738
738 importMenu->insertSeparator(); 739 importMenu->insertSeparator();
739 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 740 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
740 this ); 741 this );
741 action->addTo( importMenu ); 742 action->addTo( importMenu );
742 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 743 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
743#ifndef DESKTOP_VERSION 744#ifndef DESKTOP_VERSION
744 importMenu->insertSeparator(); 745 importMenu->insertSeparator();
745 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 746 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
746 this ); 747 this );
747 action->addTo( importMenu ); 748 action->addTo( importMenu );
748 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 749 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
749 750
750 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 751 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
751 this ); 752 this );
752 action->addTo( importMenu ); 753 action->addTo( importMenu );
753 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 754 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
754#else 755#else
755 importMenu->insertSeparator(); 756 importMenu->insertSeparator();
756 icon = loadPixmap( pathString + "print" ); 757 icon = loadPixmap( pathString + "print" );
757 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 758 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
758 action->addTo( importMenu ); 759 action->addTo( importMenu );
759 connect( action, SIGNAL( activated() ), 760 connect( action, SIGNAL( activated() ),
760 this, SLOT( printCal() ) ); 761 this, SLOT( printCal() ) );
761 762
762 icon = loadPixmap( pathString + "print" ); 763 icon = loadPixmap( pathString + "print" );
763 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 764 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
764 action->addTo( importMenu ); 765 action->addTo( importMenu );
765 connect( action, SIGNAL( activated() ), 766 connect( action, SIGNAL( activated() ),
766 this, SLOT( printSel() ) ); 767 this, SLOT( printSel() ) );
767#endif 768#endif
768 importMenu->insertSeparator(); 769 importMenu->insertSeparator();
769 action = new QAction( "beam all", i18n("Save"), 0, 770 action = new QAction( "beam all", i18n("Save"), 0,
770 this ); 771 this );
771 action->addTo( importMenu ); 772 action->addTo( importMenu );
772 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 773 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
773 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 774 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
774 this ); 775 this );
775 action->addTo( importMenu ); 776 action->addTo( importMenu );
776 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 777 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
777 778
778 //menuBar->insertItem( "Configure",configureMenu ); 779 //menuBar->insertItem( "Configure",configureMenu );
779 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 780 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
780 icon = loadPixmap( "korganizer/korganizer" ); 781 icon = loadPixmap( "korganizer/korganizer" );
781 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 782 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
782 action->addTo( helpMenu ); 783 action->addTo( helpMenu );
783 connect( action, SIGNAL( activated() ), 784 connect( action, SIGNAL( activated() ),
784 SLOT( keyBindings() ) ); 785 SLOT( keyBindings() ) );
785 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 786 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
786 action->addTo( helpMenu ); 787 action->addTo( helpMenu );
787 connect( action, SIGNAL( activated() ), 788 connect( action, SIGNAL( activated() ),
788 SLOT( features() ) ); 789 SLOT( features() ) );
789 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 790 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
790 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
791 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
792 SLOT( aboutAutoSaving() ) ); 793 SLOT( aboutAutoSaving() ) );
793 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 794 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
794 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
795 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
796 SLOT( aboutKnownBugs() ) ); 797 SLOT( aboutKnownBugs() ) );
797 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 798 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
798 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
799 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
800 SLOT( usertrans() ) ); 801 SLOT( usertrans() ) );
801 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 802 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
802 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
803 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
804 SLOT( synchowto() ) ); 805 SLOT( synchowto() ) );
805 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 806 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
806 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
807 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
808 SLOT( whatsNew() ) ); 809 SLOT( whatsNew() ) );
809 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 810 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
810 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
811 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
812 SLOT( faq() ) ); 813 SLOT( faq() ) );
813 814
814 815
815 action = new QAction( "about", i18n("About..."), 0, this ); 816 action = new QAction( "about", i18n("About..."), 0, this );
816 action->addTo( helpMenu ); 817 action->addTo( helpMenu );
817 connect( action, SIGNAL( activated() ), 818 connect( action, SIGNAL( activated() ),
818 SLOT( about() ) ); 819 SLOT( about() ) );
819 action = new QAction( "licence", i18n("Licence..."), 0, this ); 820 action = new QAction( "licence", i18n("Licence..."), 0, this );
820 action->addTo( helpMenu ); 821 action->addTo( helpMenu );
821 connect( action, SIGNAL( activated() ), 822 connect( action, SIGNAL( activated() ),
822 SLOT( licence() ) ); 823 SLOT( licence() ) );
823 //menuBar->insertSeparator(); 824 //menuBar->insertSeparator();
824 825
825 // ****************************************************** 826 // ******************************************************
826 // menubar icons 827 // menubar icons
827 828
828 829
829 iconToolBar->setHorizontalStretchable (true ); 830 iconToolBar->setHorizontalStretchable (true );
830 //menuBar->insertItem( iconToolBar ); 831 //menuBar->insertItem( iconToolBar );
831 //xdays_action 832 //xdays_action
832 if (p-> mShowIconNewEvent) 833 if (p-> mShowIconNewEvent)
833 ne_action->addTo( iconToolBar ); 834 ne_action->addTo( iconToolBar );
834 if (p->mShowIconNewTodo ) 835 if (p->mShowIconNewTodo )
835 nt_action->addTo( iconToolBar ); 836 nt_action->addTo( iconToolBar );
836 if (p-> mShowIconSearch) 837 if (p-> mShowIconSearch)
837 search_action->addTo( iconToolBar ); 838 search_action->addTo( iconToolBar );
838 if (p-> mShowIconNext) 839 if (p-> mShowIconNext)
839 whatsnext_action->addTo( iconToolBar ); 840 whatsnext_action->addTo( iconToolBar );
840 if (p-> mShowIconNextDays) 841 if (p-> mShowIconNextDays)
841 xdays_action->addTo( iconToolBar ); 842 xdays_action->addTo( iconToolBar );
842 if (p-> mShowIconList) 843 if (p-> mShowIconList)
843 showlist_action->addTo( iconToolBar ); 844 showlist_action->addTo( iconToolBar );
844 if (p-> mShowIconDay1) 845 if (p-> mShowIconDay1)
845 day1_action->addTo( iconToolBar ); 846 day1_action->addTo( iconToolBar );
846 if (p-> mShowIconDay5) 847 if (p-> mShowIconDay5)
847 day5_action->addTo( iconToolBar ); 848 day5_action->addTo( iconToolBar );
848 if (p-> mShowIconDay7) 849 if (p-> mShowIconDay7)
849 day7_action->addTo( iconToolBar ); 850 day7_action->addTo( iconToolBar );
850 if (p-> mShowIconMonth) 851 if (p-> mShowIconMonth)
851 month_action->addTo( iconToolBar ); 852 month_action->addTo( iconToolBar );
852 if (p-> mShowIconTodoview) 853 if (p-> mShowIconTodoview)
853 todoview_action->addTo( iconToolBar ); 854 todoview_action->addTo( iconToolBar );
854 if (p-> mShowIconJournal) 855 if (p-> mShowIconJournal)
855 viewjournal_action->addTo( iconToolBar ); 856 viewjournal_action->addTo( iconToolBar );
856 icon = loadPixmap( pathString + "2leftarrowB" ); 857 icon = loadPixmap( pathString + "2leftarrowB" );
857 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 858 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
858 if (p-> mShowIconBackFast) { 859 if (p-> mShowIconBackFast) {
859 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 860 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
860 connect( action, SIGNAL( activated() ), 861 connect( action, SIGNAL( activated() ),
861 mView, SLOT( goPreviousMonth() ) ); 862 mView, SLOT( goPreviousMonth() ) );
862 action->addTo( iconToolBar ); 863 action->addTo( iconToolBar );
863 } 864 }
864 icon = loadPixmap( pathString + "1leftarrowB" ); 865 icon = loadPixmap( pathString + "1leftarrowB" );
865 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 866 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
866 if (p-> mShowIconBack) { 867 if (p-> mShowIconBack) {
867 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 868 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
868 connect( action, SIGNAL( activated() ), 869 connect( action, SIGNAL( activated() ),
869 mView, SLOT( goPrevious() ) ); 870 mView, SLOT( goPrevious() ) );
870 action->addTo( iconToolBar ); 871 action->addTo( iconToolBar );
871 } 872 }
872 if (p-> mShowIconToday) 873 if (p-> mShowIconToday)
873 today_action->addTo( iconToolBar ); 874 today_action->addTo( iconToolBar );
874 icon = loadPixmap( pathString + "1rightarrowB" ); 875 icon = loadPixmap( pathString + "1rightarrowB" );
875 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 876 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
876 if (p-> mShowIconForward) { 877 if (p-> mShowIconForward) {
877 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 878 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
878 connect( action, SIGNAL( activated() ), 879 connect( action, SIGNAL( activated() ),
879 mView, SLOT( goNext() ) ); 880 mView, SLOT( goNext() ) );
880 action->addTo( iconToolBar ); 881 action->addTo( iconToolBar );
881 } 882 }
882 icon = loadPixmap( pathString + "2rightarrowB" ); 883 icon = loadPixmap( pathString + "2rightarrowB" );
883 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 884 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
884 if (p-> mShowIconForwardFast) { 885 if (p-> mShowIconForwardFast) {
885 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 886 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
886 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
887 mView, SLOT( goNextMonth() ) ); 888 mView, SLOT( goNextMonth() ) );
888 action->addTo( iconToolBar ); 889 action->addTo( iconToolBar );
889 } 890 }
890 891
891 892
892 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 893 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
893 894
894 if (p-> mShowIconNewEvent) 895 if (p-> mShowIconNewEvent)
895 configureToolBarMenu->setItemChecked( 10, true ); 896 configureToolBarMenu->setItemChecked( 10, true );
896 if (p->mShowIconNewTodo ) 897 if (p->mShowIconNewTodo )
897 configureToolBarMenu->setItemChecked( 20, true ); 898 configureToolBarMenu->setItemChecked( 20, true );
898 if (p-> mShowIconSearch) 899 if (p-> mShowIconSearch)
899 configureToolBarMenu->setItemChecked( 120, true ); 900 configureToolBarMenu->setItemChecked( 120, true );
900 if (p-> mShowIconList) 901 if (p-> mShowIconList)
901 configureToolBarMenu->setItemChecked( 30, true ); 902 configureToolBarMenu->setItemChecked( 30, true );
902 if (p-> mShowIconDay1) 903 if (p-> mShowIconDay1)
903 configureToolBarMenu->setItemChecked( 40, true ); 904 configureToolBarMenu->setItemChecked( 40, true );
904 if (p-> mShowIconDay5) 905 if (p-> mShowIconDay5)
905 configureToolBarMenu->setItemChecked( 50, true ); 906 configureToolBarMenu->setItemChecked( 50, true );
906 if (p-> mShowIconDay7) 907 if (p-> mShowIconDay7)
907 configureToolBarMenu->setItemChecked( 60, true ); 908 configureToolBarMenu->setItemChecked( 60, true );
908 if (p-> mShowIconMonth) 909 if (p-> mShowIconMonth)
909 configureToolBarMenu->setItemChecked( 70, true ); 910 configureToolBarMenu->setItemChecked( 70, true );
910 if (p-> mShowIconTodoview) 911 if (p-> mShowIconTodoview)
911 configureToolBarMenu->setItemChecked( 80, true ); 912 configureToolBarMenu->setItemChecked( 80, true );
912 if (p-> mShowIconBackFast) 913 if (p-> mShowIconBackFast)
913 configureToolBarMenu->setItemChecked( 200, true ); 914 configureToolBarMenu->setItemChecked( 200, true );
914 if (p-> mShowIconBack) 915 if (p-> mShowIconBack)
915 configureToolBarMenu->setItemChecked( 210, true ); 916 configureToolBarMenu->setItemChecked( 210, true );
916 if (p-> mShowIconToday) 917 if (p-> mShowIconToday)
917 configureToolBarMenu->setItemChecked( 130, true ); 918 configureToolBarMenu->setItemChecked( 130, true );
918 if (p-> mShowIconForward) 919 if (p-> mShowIconForward)
919 configureToolBarMenu->setItemChecked( 220, true ); 920 configureToolBarMenu->setItemChecked( 220, true );
920 if (p-> mShowIconForwardFast) 921 if (p-> mShowIconForwardFast)
921 configureToolBarMenu->setItemChecked( 230, true ); 922 configureToolBarMenu->setItemChecked( 230, true );
922 if (p-> mShowIconNextDays) 923 if (p-> mShowIconNextDays)
923 configureToolBarMenu->setItemChecked( 100, true ); 924 configureToolBarMenu->setItemChecked( 100, true );
924 if (p-> mShowIconNext) 925 if (p-> mShowIconNext)
925 configureToolBarMenu->setItemChecked( 110, true ); 926 configureToolBarMenu->setItemChecked( 110, true );
926 if (p-> mShowIconJournal) 927 if (p-> mShowIconJournal)
927 configureToolBarMenu->setItemChecked( 90, true ); 928 configureToolBarMenu->setItemChecked( 90, true );
928 if (p-> mShowIconWhatsThis) 929 if (p-> mShowIconWhatsThis)
929 configureToolBarMenu->setItemChecked( 300, true ); 930 configureToolBarMenu->setItemChecked( 300, true );
930 931
931 QLabel* dummy = new QLabel( iconToolBar ); 932 QLabel* dummy = new QLabel( iconToolBar );
932 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 933 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
933 if (!p-> mShowIconStretch) 934 if (!p-> mShowIconStretch)
934 iconToolBar->setStretchableWidget ( dummy ) ; 935 iconToolBar->setStretchableWidget ( dummy ) ;
935 else 936 else
936 configureToolBarMenu->setItemChecked( 5, true ); 937 configureToolBarMenu->setItemChecked( 5, true );
937 if (p-> mShowIconWhatsThis) 938 if (p-> mShowIconWhatsThis)
938 QWhatsThis::whatsThisButton ( iconToolBar ); 939 QWhatsThis::whatsThisButton ( iconToolBar );
939 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 940 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
940 configureAgenda( p->mHourSize ); 941 configureAgenda( p->mHourSize );
941 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 942 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
942} 943}
943void MainWindow::fillSyncMenu() 944void MainWindow::fillSyncMenu()
944{ 945{
945 if ( syncMenu->count() ) 946 if ( syncMenu->count() )
946 syncMenu->clear(); 947 syncMenu->clear();
947 syncMenu->insertItem( i18n("Configure..."), 0 ); 948 syncMenu->insertItem( i18n("Configure..."), 0 );
948 syncMenu->insertSeparator(); 949 syncMenu->insertSeparator();
949 if ( mServerSocket == 0 ) { 950 if ( mServerSocket == 0 ) {
950 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 951 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
951 } else { 952 } else {
952 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 953 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
953 } 954 }
954 syncMenu->insertSeparator(); 955 syncMenu->insertSeparator();
955 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 956 syncMenu->insertItem( i18n("Multiple sync"), 1 );
956 syncMenu->insertSeparator(); 957 syncMenu->insertSeparator();
957 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 958 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
958 config.setGroup("General"); 959 config.setGroup("General");
959 QStringList prof = config.readListEntry("SyncProfileNames"); 960 QStringList prof = config.readListEntry("SyncProfileNames");
960 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 961 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
961 if ( prof.count() < 3 ) { 962 if ( prof.count() < 3 ) {
962 prof.clear(); 963 prof.clear();
963 prof << i18n("Sharp_DTM"); 964 prof << i18n("Sharp_DTM");
964 prof << i18n("Local_file"); 965 prof << i18n("Local_file");
965 prof << i18n("Last_file"); 966 prof << i18n("Last_file");
966 KSyncProfile* temp = new KSyncProfile (); 967 KSyncProfile* temp = new KSyncProfile ();
967 temp->setName( prof[0] ); 968 temp->setName( prof[0] );
968 temp->writeConfig(&config); 969 temp->writeConfig(&config);
969 temp->setName( prof[1] ); 970 temp->setName( prof[1] );
970 temp->writeConfig(&config); 971 temp->writeConfig(&config);
971 temp->setName( prof[2] ); 972 temp->setName( prof[2] );
972 temp->writeConfig(&config); 973 temp->writeConfig(&config);
973 config.setGroup("General"); 974 config.setGroup("General");
974 config.writeEntry("SyncProfileNames",prof); 975 config.writeEntry("SyncProfileNames",prof);
975 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 976 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
976 config.sync(); 977 config.sync();
977 delete temp; 978 delete temp;
978 } 979 }
979 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 980 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
980 KOPrefs::instance()->mSyncProfileNames = prof; 981 KOPrefs::instance()->mSyncProfileNames = prof;
981 int i; 982 int i;
982 for ( i = 0; i < prof.count(); ++i ) { 983 for ( i = 0; i < prof.count(); ++i ) {
983 984
984 syncMenu->insertItem( prof[i], 1000+i ); 985 syncMenu->insertItem( prof[i], 1000+i );
985 if ( i == 2 ) 986 if ( i == 2 )
986 syncMenu->insertSeparator(); 987 syncMenu->insertSeparator();
987 } 988 }
988 QDir app_dir; 989 QDir app_dir;
989 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 990 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
990 syncMenu->setItemEnabled( false , 1000 ); 991 syncMenu->setItemEnabled( false , 1000 );
991 } 992 }
992 mView->setupExternSyncProfiles(); 993 mView->setupExternSyncProfiles();
993} 994}
994 995
995int MainWindow::ringSync() 996int MainWindow::ringSync()
996{ 997{
997 int syncedProfiles = 0; 998 int syncedProfiles = 0;
998 int i; 999 int i;
999 QTime timer; 1000 QTime timer;
1000 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1001 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1001 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 1002 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
1002 KSyncProfile* temp = new KSyncProfile (); 1003 KSyncProfile* temp = new KSyncProfile ();
1003 KOPrefs::instance()->mAskForPreferences = false; 1004 KOPrefs::instance()->mAskForPreferences = false;
1004 for ( i = 0; i < syncProfileNames.count(); ++i ) { 1005 for ( i = 0; i < syncProfileNames.count(); ++i ) {
1005 mCurrentSyncProfile = i; 1006 mCurrentSyncProfile = i;
1006 temp->setName(syncProfileNames[mCurrentSyncProfile]); 1007 temp->setName(syncProfileNames[mCurrentSyncProfile]);
1007 temp->readConfig(&config); 1008 temp->readConfig(&config);
1008 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 1009 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
1009 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 1010 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
1010 ++syncedProfiles; 1011 ++syncedProfiles;
1011 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1012 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1012 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1013 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1013 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1014 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1014 KOPrefs::instance()->mWriteBackInFuture = 0; 1015 KOPrefs::instance()->mWriteBackInFuture = 0;
1015 if ( temp->getWriteBackFuture() ) 1016 if ( temp->getWriteBackFuture() )
1016 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1017 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1017 KOPrefs::instance()->mShowSyncSummary = false; 1018 KOPrefs::instance()->mShowSyncSummary = false;
1018 mView->setSyncDevice(syncProfileNames[i] ); 1019 mView->setSyncDevice(syncProfileNames[i] );
1019 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1020 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1020 if ( i == 0 ) { 1021 if ( i == 0 ) {
1021 syncSharp(); 1022 syncSharp();
1022 } else { 1023 } else {
1023 if ( temp->getIsLocalFileSync() ) { 1024 if ( temp->getIsLocalFileSync() ) {
1024 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 1025 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
1025 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1026 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1026 } else { 1027 } else {
1027 if ( temp->getIsPhoneSync() ) { 1028 if ( temp->getIsPhoneSync() ) {
1028 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1029 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1029 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1030 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1030 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1031 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1031 syncPhone(); 1032 syncPhone();
1032 } else if ( temp->getIsPiSync() ) { 1033 } else if ( temp->getIsPiSync() ) {
1033 mPassWordPiSync = temp->getRemotePw(); 1034 mPassWordPiSync = temp->getRemotePw();
1034 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1035 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1035 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1036 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1036 syncPi(); 1037 syncPi();
1037 } else 1038 } else
1038 syncRemote( temp, false ); 1039 syncRemote( temp, false );
1039 1040
1040 } 1041 }
1041 } 1042 }
1042 timer.start(); 1043 timer.start();
1043 setCaption(i18n("Multiple sync in progress ... please wait!") ); 1044 setCaption(i18n("Multiple sync in progress ... please wait!") );
1044 while ( timer.elapsed () < 2000 ) { 1045 while ( timer.elapsed () < 2000 ) {
1045 qApp->processEvents(); 1046 qApp->processEvents();
1046#ifndef _WIN32_ 1047#ifndef _WIN32_
1047 sleep (1); 1048 sleep (1);
1048#endif 1049#endif
1049 } 1050 }
1050 1051
1051 } 1052 }
1052 1053
1053 } 1054 }
1054 delete temp; 1055 delete temp;
1055 return syncedProfiles; 1056 return syncedProfiles;
1056} 1057}
1057 1058
1058void MainWindow::multiSync( bool askforPrefs ) 1059void MainWindow::multiSync( bool askforPrefs )
1059{ 1060{
1060 if (mBlockSaveFlag) 1061 if (mBlockSaveFlag)
1061 return; 1062 return;
1062 mBlockSaveFlag = true; 1063 mBlockSaveFlag = true;
1063 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 1064 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
1064 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1065 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1065 question, 1066 question,
1066 i18n("Yes"), i18n("No"), 1067 i18n("Yes"), i18n("No"),
1067 0, 0 ) != 0 ) { 1068 0, 0 ) != 0 ) {
1068 mBlockSaveFlag = false; 1069 mBlockSaveFlag = false;
1069 setCaption(i18n("Aborted! Nothing synced!")); 1070 setCaption(i18n("Aborted! Nothing synced!"));
1070 return; 1071 return;
1071 } 1072 }
1072 mView->setSyncDevice(i18n("Multiple profiles") ); 1073 mView->setSyncDevice(i18n("Multiple profiles") );
1073 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 1074 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
1074 if ( askforPrefs ) { 1075 if ( askforPrefs ) {
1075 mView->edit_sync_options(); 1076 mView->edit_sync_options();
1076 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 1077 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
1077 } 1078 }
1078 setCaption(i18n("Multiple sync started.") ); 1079 setCaption(i18n("Multiple sync started.") );
1079 qApp->processEvents(); 1080 qApp->processEvents();
1080 int num = ringSync() ; 1081 int num = ringSync() ;
1081 if ( num > 1 ) 1082 if ( num > 1 )
1082 ringSync(); 1083 ringSync();
1083 mBlockSaveFlag = false; 1084 mBlockSaveFlag = false;
1084 if ( num ) 1085 if ( num )
1085 save(); 1086 save();
1086 if ( num ) 1087 if ( num )
1087 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1088 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1088 else 1089 else
1089 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1090 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1090 return; 1091 return;
1091} 1092}
1092void MainWindow::slotSyncMenu( int action ) 1093void MainWindow::slotSyncMenu( int action )
1093{ 1094{
1094 qDebug("syncaction %d ", action); 1095 qDebug("syncaction %d ", action);
1095 if ( action == 0 ) { 1096 if ( action == 0 ) {
1096 1097
1097 // seems to be a Qt2 event handling bug 1098 // seems to be a Qt2 event handling bug
1098 // syncmenu.clear causes a segfault at first time 1099 // syncmenu.clear causes a segfault at first time
1099 // when we call it after the main event loop, it is ok 1100 // when we call it after the main event loop, it is ok
1100 // same behaviour when calling OM/Pi via QCOP for the first time 1101 // same behaviour when calling OM/Pi via QCOP for the first time
1101 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1102 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1102 //confSync(); 1103 //confSync();
1103 1104
1104 return; 1105 return;
1105 } 1106 }
1106 if ( action == 1 ) { 1107 if ( action == 1 ) {
1107 multiSync( true ); 1108 multiSync( true );
1108 return; 1109 return;
1109 } 1110 }
1110 if ( action == 2 ) { 1111 if ( action == 2 ) {
1111 enableQuick(); 1112 enableQuick();
1112 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1113 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1113 return; 1114 return;
1114 } 1115 }
1115 if ( action == 3 ) { 1116 if ( action == 3 ) {
1116 delete mServerSocket; 1117 delete mServerSocket;
1117 mServerSocket = 0; 1118 mServerSocket = 0;
1118 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1119 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1119 return; 1120 return;
1120 } 1121 }
1121 1122
1122 if (mBlockSaveFlag) 1123 if (mBlockSaveFlag)
1123 return; 1124 return;
1124 mBlockSaveFlag = true; 1125 mBlockSaveFlag = true;
1125 mCurrentSyncProfile = action - 1000 ; 1126 mCurrentSyncProfile = action - 1000 ;
1126 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1127 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1127 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1128 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1128 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1129 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1129 KSyncProfile* temp = new KSyncProfile (); 1130 KSyncProfile* temp = new KSyncProfile ();
1130 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1131 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1131 temp->readConfig(&config); 1132 temp->readConfig(&config);
1132 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1133 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1133 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1134 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1134 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1135 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1135 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1136 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1136 KOPrefs::instance()->mWriteBackInFuture = 0; 1137 KOPrefs::instance()->mWriteBackInFuture = 0;
1137 if ( temp->getWriteBackFuture() ) 1138 if ( temp->getWriteBackFuture() )
1138 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1139 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1139 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1140 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1140 if ( action == 1000 ) { 1141 if ( action == 1000 ) {
1141 syncSharp(); 1142 syncSharp();
1142 1143
1143 } else if ( action == 1001 ) { 1144 } else if ( action == 1001 ) {
1144 syncLocalFile(); 1145 syncLocalFile();
1145 1146
1146 } else if ( action == 1002 ) { 1147 } else if ( action == 1002 ) {
1147 quickSyncLocalFile(); 1148 quickSyncLocalFile();
1148 1149
1149 } else if ( action >= 1003 ) { 1150 } else if ( action >= 1003 ) {
1150 if ( temp->getIsLocalFileSync() ) { 1151 if ( temp->getIsLocalFileSync() ) {
1151 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1152 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1152 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1153 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1153 } else { 1154 } else {
1154 if ( temp->getIsPhoneSync() ) { 1155 if ( temp->getIsPhoneSync() ) {
1155 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1156 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1156 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1157 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1157 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1158 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1158 syncPhone(); 1159 syncPhone();
1159 } else if ( temp->getIsPiSync() ) { 1160 } else if ( temp->getIsPiSync() ) {
1160 mPassWordPiSync = temp->getRemotePw(); 1161 mPassWordPiSync = temp->getRemotePw();
1161 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1162 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1162 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1163 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1163 syncPi(); 1164 syncPi();
1164 } else 1165 } else
1165 syncRemote( temp ); 1166 syncRemote( temp );
1166 1167
1167 } 1168 }
1168 } 1169 }
1169 delete temp; 1170 delete temp;
1170 mBlockSaveFlag = false; 1171 mBlockSaveFlag = false;
1171} 1172}
1172void MainWindow::exportToPhone( int mode ) 1173void MainWindow::exportToPhone( int mode )
1173{ 1174{
1174 1175
1175 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1176 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1176 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1177 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1177 KOex2phonePrefs ex2phone; 1178 KOex2phonePrefs ex2phone;
1178 1179
1179 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1180 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1180 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1181 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1181 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1182 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1182 if ( mode == 1 ) 1183 if ( mode == 1 )
1183 ex2phone.setCaption(i18n("Export complete calendar")); 1184 ex2phone.setCaption(i18n("Export complete calendar"));
1184 if ( mode == 2 ) 1185 if ( mode == 2 )
1185 ex2phone.setCaption(i18n("Export filtered calendar")); 1186 ex2phone.setCaption(i18n("Export filtered calendar"));
1186 1187
1187 if ( !ex2phone.exec() ) { 1188 if ( !ex2phone.exec() ) {
1188 return; 1189 return;
1189 } 1190 }
1190 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1191 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1191 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1192 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1192 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1193 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1193 1194
1194 int inFuture = 0; 1195 int inFuture = 0;
1195 if ( ex2phone.mWriteBackFuture->isChecked() ) 1196 if ( ex2phone.mWriteBackFuture->isChecked() )
1196 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1197 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1197 QPtrList<Incidence> delSel; 1198 QPtrList<Incidence> delSel;
1198 if ( mode == 1 ) 1199 if ( mode == 1 )
1199 delSel = mCalendar->rawIncidences(); 1200 delSel = mCalendar->rawIncidences();
1200 if ( mode == 2 ) 1201 if ( mode == 2 )
1201 delSel = mCalendar->incidences(); 1202 delSel = mCalendar->incidences();
1202 CalendarLocal* cal = new CalendarLocal(); 1203 CalendarLocal* cal = new CalendarLocal();
1203 cal->setLocalTime(); 1204 cal->setLocalTime();
1204 Incidence *incidence = delSel.first(); 1205 Incidence *incidence = delSel.first();
1205 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1206 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1206 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1207 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1207 while ( incidence ) { 1208 while ( incidence ) {
1208 if ( incidence->type() != "Journal" ) { 1209 if ( incidence->type() != "Journal" ) {
1209 bool add = true; 1210 bool add = true;
1210 if ( inFuture ) { 1211 if ( inFuture ) {
1211 QDateTime dt; 1212 QDateTime dt;
1212 if ( incidence->type() == "Todo" ) { 1213 if ( incidence->type() == "Todo" ) {
1213 Todo * t = (Todo*)incidence; 1214 Todo * t = (Todo*)incidence;
1214 if ( t->hasDueDate() ) 1215 if ( t->hasDueDate() )
1215 dt = t->dtDue(); 1216 dt = t->dtDue();
1216 else 1217 else
1217 dt = cur.addSecs( 62 ); 1218 dt = cur.addSecs( 62 );
1218 } 1219 }
1219 else { 1220 else {
1220 bool ok; 1221 bool ok;
1221 dt = incidence->getNextOccurence( cur, &ok ); 1222 dt = incidence->getNextOccurence( cur, &ok );
1222 if ( !ok ) 1223 if ( !ok )
1223 dt = cur.addSecs( -62 ); 1224 dt = cur.addSecs( -62 );
1224 } 1225 }
1225 if ( dt < cur || dt > end ) { 1226 if ( dt < cur || dt > end ) {
1226 add = false; 1227 add = false;
1227 } 1228 }
1228 } 1229 }
1229 if ( add ) { 1230 if ( add ) {
1230 Incidence *in = incidence->clone(); 1231 Incidence *in = incidence->clone();
1231 cal->addIncidence( in ); 1232 cal->addIncidence( in );
1232 } 1233 }
1233 } 1234 }
1234 incidence = delSel.next(); 1235 incidence = delSel.next();
1235 } 1236 }
1236 PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1237 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1237 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1238 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1238 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1239 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1239 1240
1240 setCaption( i18n("Writing to phone...")); 1241 setCaption( i18n("Writing to phone..."));
1241 if ( PhoneFormat::writeToPhone( cal ) ) 1242 if ( PhoneFormat::writeToPhone( cal ) )
1242 setCaption( i18n("Export to phone successful!")); 1243 setCaption( i18n("Export to phone successful!"));
1243 else 1244 else
1244 setCaption( i18n("Error exporting to phone!")); 1245 setCaption( i18n("Error exporting to phone!"));
1245 delete cal; 1246 delete cal;
1246} 1247}
1247 1248
1248 1249
1249void MainWindow::setDefaultPreferences() 1250void MainWindow::setDefaultPreferences()
1250{ 1251{
1251 KOPrefs *p = KOPrefs::instance(); 1252 KOPrefs *p = KOPrefs::instance();
1252 1253
1253 p->mCompactDialogs = true; 1254 p->mCompactDialogs = true;
1254 p->mConfirm = true; 1255 p->mConfirm = true;
1255 // p->mEnableQuickTodo = false; 1256 // p->mEnableQuickTodo = false;
1256 1257
1257} 1258}
1258 1259
1259QString MainWindow::resourcePath() 1260QString MainWindow::resourcePath()
1260{ 1261{
1261 return KGlobal::iconLoader()->iconPath(); 1262 return KGlobal::iconLoader()->iconPath();
1262} 1263}
1263 1264
1264void MainWindow::displayText( QString text ,QString cap ) 1265void MainWindow::displayText( QString text ,QString cap )
1265{ 1266{
1266 QDialog dia( this, "name", true ); ; 1267 QDialog dia( this, "name", true ); ;
1267 dia.setCaption( cap ); 1268 dia.setCaption( cap );
1268 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1269 QVBoxLayout* lay = new QVBoxLayout( &dia );
1269 lay->setSpacing( 3 ); 1270 lay->setSpacing( 3 );
1270 lay->setMargin( 3 ); 1271 lay->setMargin( 3 );
1271 QTextBrowser tb ( &dia ); 1272 QTextBrowser tb ( &dia );
1272 lay->addWidget( &tb ); 1273 lay->addWidget( &tb );
1273 tb.setText( text ); 1274 tb.setText( text );
1274#ifdef DESKTOP_VERSION 1275#ifdef DESKTOP_VERSION
1275 dia.resize( 640, 480); 1276 dia.resize( 640, 480);
1276#else 1277#else
1277 dia.showMaximized(); 1278 dia.showMaximized();
1278#endif 1279#endif
1279 dia.exec(); 1280 dia.exec();
1280} 1281}
1281void MainWindow::displayFile( QString fn, QString cap ) 1282void MainWindow::displayFile( QString fn, QString cap )
1282{ 1283{
1283 QString fileName = resourcePath() + fn; 1284 QString fileName = resourcePath() + fn;
1284 QString text; 1285 QString text;
1285 QFile file( fileName ); 1286 QFile file( fileName );
1286 if (!file.open( IO_ReadOnly ) ) { 1287 if (!file.open( IO_ReadOnly ) ) {
1287 return ; 1288 return ;
1288 1289
1289 } 1290 }
1290 QTextStream ts( &file ); 1291 QTextStream ts( &file );
1291 text = ts.read(); 1292 text = ts.read();
1292 file.close(); 1293 file.close();
1293 displayText( text, cap); 1294 displayText( text, cap);
1294} 1295}
1295void MainWindow::features() 1296void MainWindow::features()
1296{ 1297{
1297 1298
1298 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1299 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1299} 1300}
1300 1301
1301void MainWindow::usertrans() 1302void MainWindow::usertrans()
1302{ 1303{
1303 1304
1304 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1305 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1305} 1306}
1306 1307
1307void MainWindow::synchowto() 1308void MainWindow::synchowto()
1308{ 1309{
1309#if 0 1310#if 0
1310 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1311 QPtrList<Incidence> er = mCalendar->rawIncidences();
1311 Incidence* inR = er.first(); 1312 Incidence* inR = er.first();
1312 VCalFormat vf; 1313 VCalFormat vf;
1313 QString strout; 1314 QString strout;
1314 while ( inR ) { 1315 while ( inR ) {
1315 if ( inR->type() == "Todo" ) 1316 if ( inR->type() == "Todo" )
1316 strout = vf.todoToString( (Todo *) inR ); 1317 strout = vf.todoToString( (Todo *) inR );
1317 if ( inR->type() == "Event" ) 1318 if ( inR->type() == "Event" )
1318 strout = vf.eventToString( (Event *) inR ); 1319 strout = vf.eventToString( (Event *) inR );
1319 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1320 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1320 inR = er.next(); 1321 inR = er.next();
1321 } 1322 }
1322#endif 1323#endif
1323 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1324 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1324} 1325}
1325void MainWindow::faq() 1326void MainWindow::faq()
1326{ 1327{
1327 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1328 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1328 1329
1329} 1330}
1330void MainWindow::whatsNew() 1331void MainWindow::whatsNew()
1331{ 1332{
1332 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1333 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1333 1334
1334} 1335}
1335void MainWindow::licence() 1336void MainWindow::licence()
1336{ 1337{
1337 KApplication::showLicence(); 1338 KApplication::showLicence();
1338 1339
1339} 1340}
1340void MainWindow::about() 1341void MainWindow::about()
1341{ 1342{
1342 QString version; 1343 QString version;
1343#include <../version> 1344#include <../version>
1344 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1345 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1345 i18n("KOrganizer/Platform-independent\n") + 1346 i18n("KOrganizer/Platform-independent\n") +
1346 "(KO/Pi) " + version + " - " + 1347 "(KO/Pi) " + version + " - " +
1347 1348
1348#ifdef DESKTOP_VERSION 1349#ifdef DESKTOP_VERSION
1349 i18n("Desktop Edition\n") + 1350 i18n("Desktop Edition\n") +
1350#else 1351#else
1351 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1352 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1352#endif 1353#endif
1353 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1354 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1354} 1355}
1355void MainWindow::keyBindings() 1356void MainWindow::keyBindings()
1356{ 1357{
1357 QString cap = i18n("Key bindings KOrganizer/Pi"); 1358 QString cap = i18n("Key bindings KOrganizer/Pi");
1358 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1359 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1359 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1360 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1360 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1361 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1361 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1362 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1362 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1363 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1363 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1364 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1364 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1365 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1365 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1366 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1366 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1367 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1367 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1368 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1368 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1369 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1369 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1370 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1370 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1371 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1371 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1372 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1372 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1373 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1373 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1374 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1374 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1375 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1375 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1376 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1376 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1377 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1377 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1378 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1378 i18n("<p><h3>In agenda view:</h3></p>\n") + 1379 i18n("<p><h3>In agenda view:</h3></p>\n") +
1379 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1380 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1380 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1381 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1381 i18n("<p><h3>In todo view:</h3></p>\n") + 1382 i18n("<p><h3>In todo view:</h3></p>\n") +
1382 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1383 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1383 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1384 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1384 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1385 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1385 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1386 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1386 i18n("<p><h3>In list view:</h3></p>\n") + 1387 i18n("<p><h3>In list view:</h3></p>\n") +
1387 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1388 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1388 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1389 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1389 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1390 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1390 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1391 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1391 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1392 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1392 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1393 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1393 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1394 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1394 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1395 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1395 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1396 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1396 i18n("<p><b>E</b>: Edit item</p>\n") + 1397 i18n("<p><b>E</b>: Edit item</p>\n") +
1397 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1398 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1398 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1399 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1399 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1400 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1400 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1401 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1401 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1402 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1402 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1403 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1403 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1404 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1404 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1405 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1405 i18n("<p><b>White</b>: Item readonly</p>\n"); 1406 i18n("<p><b>White</b>: Item readonly</p>\n");
1406 displayText( text, cap); 1407 displayText( text, cap);
1407 1408
1408} 1409}
1409void MainWindow::aboutAutoSaving() 1410void MainWindow::aboutAutoSaving()
1410{ 1411{
1411 QMessageBox* msg; 1412 QMessageBox* msg;
1412 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1413 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1413 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1414 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1414 QMessageBox::Ok, 1415 QMessageBox::Ok,
1415 QMessageBox::NoButton, 1416 QMessageBox::NoButton,
1416 QMessageBox::NoButton); 1417 QMessageBox::NoButton);
1417 msg->exec(); 1418 msg->exec();
1418 delete msg; 1419 delete msg;
1419 1420
1420 1421
1421} 1422}
1422void MainWindow::aboutKnownBugs() 1423void MainWindow::aboutKnownBugs()
1423{ 1424{
1424 QMessageBox* msg; 1425 QMessageBox* msg;
1425 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1426 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1426 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1427 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1427 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1428 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1428 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1429 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1429 i18n("\nor report them in the bugtracker on\n") + 1430 i18n("\nor report them in the bugtracker on\n") +
1430 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1431 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1431 QMessageBox::NoIcon, 1432 QMessageBox::NoIcon,
1432 QMessageBox::Ok, 1433 QMessageBox::Ok,
1433 QMessageBox::NoButton, 1434 QMessageBox::NoButton,
1434 QMessageBox::NoButton); 1435 QMessageBox::NoButton);
1435 msg->exec(); 1436 msg->exec();
1436 delete msg; 1437 delete msg;
1437 1438
1438} 1439}
1439 1440
1440QString MainWindow::defaultFileName() 1441QString MainWindow::defaultFileName()
1441{ 1442{
1442 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1443 return locateLocal( "data", "korganizer/mycalendar.ics" );
1443} 1444}
1444QString MainWindow::syncFileName() 1445QString MainWindow::syncFileName()
1445{ 1446{
1446#ifdef _WIN32_ 1447#ifdef _WIN32_
1447 return locateLocal( "tmp", "synccalendar.ics" ); 1448 return locateLocal( "tmp", "synccalendar.ics" );
1448#else 1449#else
1449 return QString( "/tmp/kopitempfile.ics" ); 1450 return QString( "/tmp/kopitempfile.ics" );
1450#endif 1451#endif
1451} 1452}
1452 1453
1453void MainWindow::processIncidenceSelection( Incidence *incidence ) 1454void MainWindow::processIncidenceSelection( Incidence *incidence )
1454{ 1455{
1455 if ( !incidence ) { 1456 if ( !incidence ) {
1456 enableIncidenceActions( false ); 1457 enableIncidenceActions( false );
1457 1458
1458 mNewSubTodoAction->setEnabled( false ); 1459 mNewSubTodoAction->setEnabled( false );
1459 setCaptionToDates(); 1460 setCaptionToDates();
1460 return; 1461 return;
1461 1462
1462 } 1463 }
1463 1464
1464 //KGlobal::locale()->formatDateTime(nextA, true); 1465 //KGlobal::locale()->formatDateTime(nextA, true);
1465 QString startString = ""; 1466 QString startString = "";
1466 if ( incidence->type() != "Todo" ) { 1467 if ( incidence->type() != "Todo" ) {
1467 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1468 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1468 if ( incidence->doesFloat() ) { 1469 if ( incidence->doesFloat() ) {
1469 startString += ": "+incidence->dtStartDateStr( true ); 1470 startString += ": "+incidence->dtStartDateStr( true );
1470 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1471 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1471 1472
1472 } else { 1473 } else {
1473 startString = ": "+incidence->dtStartStr(true); 1474 startString = ": "+incidence->dtStartStr(true);
1474 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1475 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1475 1476
1476 } 1477 }
1477 1478
1478 } else { 1479 } else {
1479 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1480 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1480 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1481 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1481 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1482 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1482 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1483 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1483 } 1484 }
1484 1485
1485 } 1486 }
1486 else 1487 else
1487 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1488 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1488 if ( !incidence->location().isEmpty() ) 1489 if ( !incidence->location().isEmpty() )
1489 startString += " (" +incidence->location()+")"; 1490 startString += " (" +incidence->location()+")";
1490 setCaption( incidence->summary()+startString); 1491 setCaption( incidence->summary()+startString);
1491 1492
1492 enableIncidenceActions( true ); 1493 enableIncidenceActions( true );
1493 1494
1494 if ( incidence->type() == "Event" ) { 1495 if ( incidence->type() == "Event" ) {
1495 mShowAction->setText( i18n("Show Event...") ); 1496 mShowAction->setText( i18n("Show Event...") );
1496 mEditAction->setText( i18n("Edit Event...") ); 1497 mEditAction->setText( i18n("Edit Event...") );
1497 mDeleteAction->setText( i18n("Delete Event...") ); 1498 mDeleteAction->setText( i18n("Delete Event...") );
1498 1499
1499 mNewSubTodoAction->setEnabled( false ); 1500 mNewSubTodoAction->setEnabled( false );
1500 } else if ( incidence->type() == "Todo" ) { 1501 } else if ( incidence->type() == "Todo" ) {
1501 mShowAction->setText( i18n("Show Todo...") ); 1502 mShowAction->setText( i18n("Show Todo...") );
1502 mEditAction->setText( i18n("Edit Todo...") ); 1503 mEditAction->setText( i18n("Edit Todo...") );
1503 mDeleteAction->setText( i18n("Delete Todo...") ); 1504 mDeleteAction->setText( i18n("Delete Todo...") );
1504 1505
1505 mNewSubTodoAction->setEnabled( true ); 1506 mNewSubTodoAction->setEnabled( true );
1506 } else { 1507 } else {
1507 mShowAction->setText( i18n("Show...") ); 1508 mShowAction->setText( i18n("Show...") );
1508 mShowAction->setText( i18n("Edit...") ); 1509 mShowAction->setText( i18n("Edit...") );
1509 mShowAction->setText( i18n("Delete...") ); 1510 mShowAction->setText( i18n("Delete...") );
1510 1511
1511 mNewSubTodoAction->setEnabled( false ); 1512 mNewSubTodoAction->setEnabled( false );
1512 } 1513 }
1513} 1514}
1514 1515
1515void MainWindow::enableIncidenceActions( bool enabled ) 1516void MainWindow::enableIncidenceActions( bool enabled )
1516{ 1517{
1517 mShowAction->setEnabled( enabled ); 1518 mShowAction->setEnabled( enabled );
1518 mEditAction->setEnabled( enabled ); 1519 mEditAction->setEnabled( enabled );
1519 mDeleteAction->setEnabled( enabled ); 1520 mDeleteAction->setEnabled( enabled );
1520 1521
1521 mCloneAction->setEnabled( enabled ); 1522 mCloneAction->setEnabled( enabled );
1522 mMoveAction->setEnabled( enabled ); 1523 mMoveAction->setEnabled( enabled );
1523 mBeamAction->setEnabled( enabled ); 1524 mBeamAction->setEnabled( enabled );
1524 mCancelAction->setEnabled( enabled ); 1525 mCancelAction->setEnabled( enabled );
1525} 1526}
1526 1527
1527void MainWindow::importOL() 1528void MainWindow::importOL()
1528{ 1529{
1529#ifdef _WIN32_ 1530#ifdef _WIN32_
1530 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1531 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1531 id->exec(); 1532 id->exec();
1532 delete id; 1533 delete id;
1533 mView->updateView(); 1534 mView->updateView();
1534#endif 1535#endif
1535} 1536}
1536void MainWindow::importBday() 1537void MainWindow::importBday()
1537{ 1538{
1538 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1539 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1539 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1540 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1540 i18n("Import!"), i18n("Cancel"), 0, 1541 i18n("Import!"), i18n("Cancel"), 0,
1541 0, 1 ); 1542 0, 1 );
1542 if ( result == 0 ) { 1543 if ( result == 0 ) {
1543 mView->importBday(); 1544 mView->importBday();
1544 1545
1545 } 1546 }
1546 1547
1547 1548
1548} 1549}
1549void MainWindow::importQtopia() 1550void MainWindow::importQtopia()
1550{ 1551{
1551#ifndef DESKTOP_VERSION 1552#ifndef DESKTOP_VERSION
1552 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1553 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1553 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1554 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1554 i18n("Import!"), i18n("Cancel"), 0, 1555 i18n("Import!"), i18n("Cancel"), 0,
1555 0, 1 ); 1556 0, 1 );
1556 if ( result == 0 ) { 1557 if ( result == 0 ) {
1557 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1558 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1558 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1559 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1559 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1560 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1560 mView->importQtopia( categories, datebook, todolist ); 1561 mView->importQtopia( categories, datebook, todolist );
1561 } 1562 }
1562#else 1563#else
1563 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1564 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1564 i18n("Not supported \non desktop!\n"), 1565 i18n("Not supported \non desktop!\n"),
1565 i18n("Ok"), i18n("Cancel"), 0, 1566 i18n("Ok"), i18n("Cancel"), 0,
1566 0, 1 ); 1567 0, 1 );
1567 1568
1568#endif 1569#endif
1569} 1570}
1570 1571
1571void MainWindow::saveOnClose() 1572void MainWindow::saveOnClose()
1572{ 1573{
1573 KOPrefs *p = KOPrefs::instance(); 1574 KOPrefs *p = KOPrefs::instance();
1574 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1575 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1575 p->mToolBarUp = iconToolBar->x() > width()/2 || 1576 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1576 iconToolBar->y() > height()/2; 1577 iconToolBar->y() > height()/2;
1577 mView->writeSettings(); 1578 mView->writeSettings();
1578 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1579 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1579 save(); 1580 save();
1580} 1581}
1581void MainWindow::slotModifiedChanged( bool changed ) 1582void MainWindow::slotModifiedChanged( bool changed )
1582{ 1583{
1583 if ( mBlockAtStartup ) 1584 if ( mBlockAtStartup )
1584 return; 1585 return;
1585 int msec; 1586 int msec;
1586 // we store the changes after 1 minute, 1587 // we store the changes after 1 minute,
1587 // and for safety reasons after 10 minutes again 1588 // and for safety reasons after 10 minutes again
1588 if ( !mBlockSaveFlag ) 1589 if ( !mBlockSaveFlag )
1589 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1590 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1590 else 1591 else
1591 msec = 1000 * 600; 1592 msec = 1000 * 600;
1592 mSaveTimer.start( msec, true ); // 1 minute 1593 mSaveTimer.start( msec, true ); // 1 minute
1593 qDebug("KO: Saving File in %d secs!", msec/1000); 1594 qDebug("KO: Saving File in %d secs!", msec/1000);
1594 mCalendarModifiedFlag = true; 1595 mCalendarModifiedFlag = true;
1595} 1596}
1596void MainWindow::save() 1597void MainWindow::save()
1597{ 1598{
1598 if ( mBlockSaveFlag ) 1599 if ( mBlockSaveFlag )
1599 return; 1600 return;
1600 bool store = mBlockSaveFlag; 1601 bool store = mBlockSaveFlag;
1601 mBlockSaveFlag = true; 1602 mBlockSaveFlag = true;
1602 if ( mView->checkFileVersion( defaultFileName()) ) { 1603 if ( mView->checkFileVersion( defaultFileName()) ) {
1603 1604
1604 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1605 QTime neededSaveTime = QDateTime::currentDateTime().time();
1605 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1606 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1606 qDebug("KO: Start saving data to file!"); 1607 qDebug("KO: Start saving data to file!");
1607 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1608 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1608 mView->saveCalendar( defaultFileName() ); 1609 mView->saveCalendar( defaultFileName() );
1609 1610
1610 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1611 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1611 mView->watchSavedFile(); 1612 mView->watchSavedFile();
1612 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1613 qDebug("KO: Needed %d ms for saving.",msNeeded );
1613 QString savemes; 1614 QString savemes;
1614 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1615 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1615 setCaption(savemes); 1616 setCaption(savemes);
1616 } else 1617 } else
1617 setCaption(i18n("Saving cancelled!")); 1618 setCaption(i18n("Saving cancelled!"));
1618 mCalendarModifiedFlag = false; 1619 mCalendarModifiedFlag = false;
1619 mBlockSaveFlag = store; 1620 mBlockSaveFlag = store;
1620} 1621}
1621 1622
1622void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1623void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1623{ 1624{
1624 if ( !e->isAutoRepeat() ) { 1625 if ( !e->isAutoRepeat() ) {
1625 mFlagKeyPressed = false; 1626 mFlagKeyPressed = false;
1626 } 1627 }
1627} 1628}
1628void MainWindow::keyPressEvent ( QKeyEvent * e ) 1629void MainWindow::keyPressEvent ( QKeyEvent * e )
1629{ 1630{
1630 qApp->processEvents(); 1631 qApp->processEvents();
1631 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1632 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1632 e->ignore(); 1633 e->ignore();
1633 // qDebug(" ignore %d",e->isAutoRepeat() ); 1634 // qDebug(" ignore %d",e->isAutoRepeat() );
1634 return; 1635 return;
1635 } 1636 }
1636 if (! e->isAutoRepeat() ) 1637 if (! e->isAutoRepeat() )
1637 mFlagKeyPressed = true; 1638 mFlagKeyPressed = true;
1638 KOPrefs *p = KOPrefs::instance(); 1639 KOPrefs *p = KOPrefs::instance();
1639 bool showSelectedDates = false; 1640 bool showSelectedDates = false;
1640 int size; 1641 int size;
1641 int pro = 0; 1642 int pro = 0;
1642 //qDebug("MainWindow::keyPressEvent "); 1643 //qDebug("MainWindow::keyPressEvent ");
1643 switch ( e->key() ) { 1644 switch ( e->key() ) {
1644 case Qt::Key_Right: 1645 case Qt::Key_Right:
1645 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1646 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1646 mView->goNextMonth(); 1647 mView->goNextMonth();
1647 else 1648 else
1648 mView->goNext(); 1649 mView->goNext();
1649 showSelectedDates = true; 1650 showSelectedDates = true;
1650 break; 1651 break;
1651 case Qt::Key_Left: 1652 case Qt::Key_Left:
1652 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1653 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1653 mView->goPreviousMonth(); 1654 mView->goPreviousMonth();
1654 else 1655 else
1655 mView->goPrevious(); 1656 mView->goPrevious();
1656 showSelectedDates = true; 1657 showSelectedDates = true;
1657 break; 1658 break;
1658 case Qt::Key_Down: 1659 case Qt::Key_Down:
1659 mView->viewManager()->agendaView()->scrollOneHourDown(); 1660 mView->viewManager()->agendaView()->scrollOneHourDown();
1660 break; 1661 break;
1661 case Qt::Key_Up: 1662 case Qt::Key_Up:
1662 mView->viewManager()->agendaView()->scrollOneHourUp(); 1663 mView->viewManager()->agendaView()->scrollOneHourUp();
1663 break; 1664 break;
1664 case Qt::Key_I: 1665 case Qt::Key_I:
1665 mView->showIncidence(); 1666 mView->showIncidence();
1666 break; 1667 break;
1667 case Qt::Key_Delete: 1668 case Qt::Key_Delete:
1668 case Qt::Key_Backspace: 1669 case Qt::Key_Backspace:
1669 mView->deleteIncidence(); 1670 mView->deleteIncidence();
1670 break; 1671 break;
1671 case Qt::Key_D: 1672 case Qt::Key_D:
1672 mView->viewManager()->showDayView(); 1673 mView->viewManager()->showDayView();
1673 showSelectedDates = true; 1674 showSelectedDates = true;
1674 break; 1675 break;
1675 case Qt::Key_O: 1676 case Qt::Key_O:
1676 mView->toggleFilerEnabled( ); 1677 mView->toggleFilerEnabled( );
1677 break; 1678 break;
1678 case Qt::Key_0: 1679 case Qt::Key_0:
1679 case Qt::Key_1: 1680 case Qt::Key_1:
1680 case Qt::Key_2: 1681 case Qt::Key_2:
1681 case Qt::Key_3: 1682 case Qt::Key_3:
1682 case Qt::Key_4: 1683 case Qt::Key_4:
1683 case Qt::Key_5: 1684 case Qt::Key_5:
1684 case Qt::Key_6: 1685 case Qt::Key_6:
1685 case Qt::Key_7: 1686 case Qt::Key_7:
1686 case Qt::Key_8: 1687 case Qt::Key_8:
1687 case Qt::Key_9: 1688 case Qt::Key_9:
1688 pro = e->key()-48; 1689 pro = e->key()-48;
1689 if ( pro == 0 ) 1690 if ( pro == 0 )
1690 pro = 10; 1691 pro = 10;
1691 if ( e->state() == Qt::ControlButton) 1692 if ( e->state() == Qt::ControlButton)
1692 pro += 10; 1693 pro += 10;
1693 break; 1694 break;
1694 case Qt::Key_M: 1695 case Qt::Key_M:
1695 mView->viewManager()->showMonthView(); 1696 mView->viewManager()->showMonthView();
1696 showSelectedDates = true; 1697 showSelectedDates = true;
1697 break; 1698 break;
1698 case Qt::Key_Insert: 1699 case Qt::Key_Insert:
1699 mView->newEvent(); 1700 mView->newEvent();
1700 break; 1701 break;
1701 case Qt::Key_S : 1702 case Qt::Key_S :
1702 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1703 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1703 mView->newSubTodo(); 1704 mView->newSubTodo();
1704 else 1705 else
1705 mView->dialogManager()->showSearchDialog(); 1706 mView->dialogManager()->showSearchDialog();
1706 break; 1707 break;
1707 case Qt::Key_Y : 1708 case Qt::Key_Y :
1708 case Qt::Key_Z : 1709 case Qt::Key_Z :
1709 mView->viewManager()->showWorkWeekView(); 1710 mView->viewManager()->showWorkWeekView();
1710 showSelectedDates = true; 1711 showSelectedDates = true;
1711 break; 1712 break;
1712 case Qt::Key_U : 1713 case Qt::Key_U :
1713 mView->viewManager()->showWeekView(); 1714 mView->viewManager()->showWeekView();
1714 showSelectedDates = true; 1715 showSelectedDates = true;
1715 break; 1716 break;
1716 case Qt::Key_H : 1717 case Qt::Key_H :
1717 keyBindings(); 1718 keyBindings();
1718 break; 1719 break;
1719 case Qt::Key_W: 1720 case Qt::Key_W:
1720 mView->viewManager()->showWhatsNextView(); 1721 mView->viewManager()->showWhatsNextView();
1721 break; 1722 break;
1722 case Qt::Key_L: 1723 case Qt::Key_L:
1723 mView->viewManager()->showListView(); 1724 mView->viewManager()->showListView();
1724 break; 1725 break;
1725 case Qt::Key_N: 1726 case Qt::Key_N:
1726 mView->viewManager()->showNextXView(); 1727 mView->viewManager()->showNextXView();
1727 showSelectedDates = true; 1728 showSelectedDates = true;
1728 break; 1729 break;
1729 case Qt::Key_V: 1730 case Qt::Key_V:
1730 mView->viewManager()->showTodoView(); 1731 mView->viewManager()->showTodoView();
1731 break; 1732 break;
1732 case Qt::Key_C: 1733 case Qt::Key_C:
1733 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1734 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1734 break; 1735 break;
1735 case Qt::Key_P: 1736 case Qt::Key_P:
1736 mView->showDatePicker( ); 1737 mView->showDatePicker( );
1737 break; 1738 break;
1738 case Qt::Key_F: 1739 case Qt::Key_F:
1739 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1740 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1740 mView->editFilters(); 1741 mView->editFilters();
1741 else 1742 else
1742 mView->toggleFilter(); 1743 mView->toggleFilter();
1743 break; 1744 break;
1744 case Qt::Key_X: 1745 case Qt::Key_X:
1745 mView->toggleDateNavigatorWidget(); 1746 mView->toggleDateNavigatorWidget();
1746 break; 1747 break;
1747 case Qt::Key_Space: 1748 case Qt::Key_Space:
1748 mView->toggleExpand(); 1749 mView->toggleExpand();
1749 break; 1750 break;
1750 case Qt::Key_A: 1751 case Qt::Key_A:
1751 mView->toggleAllDaySize(); 1752 mView->toggleAllDaySize();
1752 break; 1753 break;
1753 case Qt::Key_T: 1754 case Qt::Key_T:
1754 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1755 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1755 mView->newTodo(); 1756 mView->newTodo();
1756 else { 1757 else {
1757 mView->goToday(); 1758 mView->goToday();
1758 showSelectedDates = true; 1759 showSelectedDates = true;
1759 } 1760 }
1760 break; 1761 break;
1761 case Qt::Key_J: 1762 case Qt::Key_J:
1762 mView->viewManager()->showJournalView(); 1763 mView->viewManager()->showJournalView();
1763 break; 1764 break;
1764 case Qt::Key_B: 1765 case Qt::Key_B:
1765 mView->editIncidenceDescription();; 1766 mView->editIncidenceDescription();;
1766 break; 1767 break;
1767 // case Qt::Key_Return: 1768 // case Qt::Key_Return:
1768 case Qt::Key_E: 1769 case Qt::Key_E:
1769 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1770 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1770 mView->newEvent(); 1771 mView->newEvent();
1771 else 1772 else
1772 mView->editIncidence(); 1773 mView->editIncidence();
1773 break; 1774 break;
1774 case Qt::Key_Plus: 1775 case Qt::Key_Plus:
1775 size = p->mHourSize +2; 1776 size = p->mHourSize +2;
1776 if ( size <= 18 ) 1777 if ( size <= 18 )
1777 configureAgenda( size ); 1778 configureAgenda( size );
1778 break; 1779 break;
1779 case Qt::Key_Minus: 1780 case Qt::Key_Minus:
1780 size = p->mHourSize - 2; 1781 size = p->mHourSize - 2;
1781 if ( size >= 4 ) 1782 if ( size >= 4 )
1782 configureAgenda( size ); 1783 configureAgenda( size );
1783 break; 1784 break;
1784 1785
1785 1786
1786 default: 1787 default:
1787 e->ignore(); 1788 e->ignore();
1788 } 1789 }
1789 if ( pro > 0 ) { 1790 if ( pro > 0 ) {
1790 mView->selectFilter( pro-1 ); 1791 mView->selectFilter( pro-1 );
1791 } 1792 }
1792 if ( showSelectedDates ) { 1793 if ( showSelectedDates ) {
1793 ;// setCaptionToDates(); 1794 ;// setCaptionToDates();
1794 } 1795 }
1795 1796
1796} 1797}
1797 1798
1798void MainWindow::fillFilterMenu() 1799void MainWindow::fillFilterMenu()
1799{ 1800{
1800 selectFilterMenu->clear(); 1801 selectFilterMenu->clear();
1801 bool disable = false; 1802 bool disable = false;
1802 if ( mView->filterView()->filtersEnabled() ) { 1803 if ( mView->filterView()->filtersEnabled() ) {
1803 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1804 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1804 } 1805 }
1805 else { 1806 else {
1806 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1807 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1807 disable = true; 1808 disable = true;
1808 } 1809 }
1809 selectFilterMenu->insertSeparator(); 1810 selectFilterMenu->insertSeparator();
1810 QPtrList<CalFilter> fili = mView->filters(); 1811 QPtrList<CalFilter> fili = mView->filters();
1811 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1812 CalFilter *curfilter = mView->filterView()->selectedFilter();
1812 CalFilter *filter = fili.first(); 1813 CalFilter *filter = fili.first();
1813 int iii = 1; 1814 int iii = 1;
1814 while(filter) { 1815 while(filter) {
1815 selectFilterMenu->insertItem( filter->name(), iii ); 1816 selectFilterMenu->insertItem( filter->name(), iii );
1816 if ( filter == curfilter) 1817 if ( filter == curfilter)
1817 selectFilterMenu->setItemChecked( iii, true ); 1818 selectFilterMenu->setItemChecked( iii, true );
1818 if ( disable ) 1819 if ( disable )
1819 selectFilterMenu->setItemEnabled( iii, false ); 1820 selectFilterMenu->setItemEnabled( iii, false );
1820 filter = fili.next(); 1821 filter = fili.next();
1821 ++iii; 1822 ++iii;
1822 } 1823 }
1823} 1824}
1824void MainWindow::selectFilter( int fil ) 1825void MainWindow::selectFilter( int fil )
1825{ 1826{
1826 if ( fil == 0 ) { 1827 if ( fil == 0 ) {
1827 mView->toggleFilerEnabled( ); 1828 mView->toggleFilerEnabled( );
1828 } else { 1829 } else {
1829 mView->selectFilter( fil-1 ); 1830 mView->selectFilter( fil-1 );
1830 } 1831 }
1831} 1832}
1832void MainWindow::configureToolBar( int item ) 1833void MainWindow::configureToolBar( int item )
1833{ 1834{
1834 1835
1835 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1836 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1836 KOPrefs *p = KOPrefs::instance(); 1837 KOPrefs *p = KOPrefs::instance();
1837 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1838 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1838 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1839 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1839 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1840 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1840 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1841 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1841 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1842 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1842 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1843 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1843 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1844 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1844 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1845 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1845 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1846 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1846 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1847 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1847 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1848 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1848 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1849 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1849 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1850 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1850 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1851 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1851 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1852 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1852 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1853 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1853 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1854 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1854 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1855 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1855 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1856 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1856 // initActions(); 1857 // initActions();
1857} 1858}
1858 1859
1859void MainWindow::setCaptionToDates() 1860void MainWindow::setCaptionToDates()
1860{ 1861{
1861 QString selDates; 1862 QString selDates;
1862 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1863 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1863 if (mView->startDate() < mView->endDate() ) 1864 if (mView->startDate() < mView->endDate() )
1864 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1865 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1865 setCaption( i18n("Dates: ") + selDates ); 1866 setCaption( i18n("Dates: ") + selDates );
1866 1867
1867} 1868}
1868// parameter item == 0: reinit 1869// parameter item == 0: reinit
1869void MainWindow::configureAgenda( int item ) 1870void MainWindow::configureAgenda( int item )
1870{ 1871{
1871 1872
1872 KOPrefs *p = KOPrefs::instance(); 1873 KOPrefs *p = KOPrefs::instance();
1873 1874
1874 int i; 1875 int i;
1875 if ( item == 1 ) { 1876 if ( item == 1 ) {
1876 mView->toggleAllDaySize(); 1877 mView->toggleAllDaySize();
1877 return; 1878 return;
1878 } 1879 }
1879 // do not allow 4 for widgets higher than 480 1880 // do not allow 4 for widgets higher than 480
1880 // if ( QApplication::desktop()->height() > 480 ) { 1881 // if ( QApplication::desktop()->height() > 480 ) {
1881// if ( item == 4 ) 1882// if ( item == 4 )
1882// item = 6; 1883// item = 6;
1883// } 1884// }
1884 for ( i = 4; i <= 18; i= i+2 ) 1885 for ( i = 4; i <= 18; i= i+2 )
1885 configureAgendaMenu->setItemChecked( i, false ); 1886 configureAgendaMenu->setItemChecked( i, false );
1886 configureAgendaMenu->setItemChecked( item, true ); 1887 configureAgendaMenu->setItemChecked( item, true );
1887 if ( p->mHourSize == item ) 1888 if ( p->mHourSize == item )
1888 return; 1889 return;
1889 p->mHourSize=item; 1890 p->mHourSize=item;
1890 mView->viewManager()->agendaView()->updateConfig(); 1891 mView->viewManager()->agendaView()->updateConfig();
1891} 1892}
1892 1893
1893void MainWindow::saveCalendar() 1894void MainWindow::saveCalendar()
1894{ 1895{
1895 QString fn = KOPrefs::instance()->mLastSaveFile; 1896 QString fn = KOPrefs::instance()->mLastSaveFile;
1896 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1897 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1897 1898
1898 if ( fn == "" ) 1899 if ( fn == "" )
1899 return; 1900 return;
1900 QFileInfo info; 1901 QFileInfo info;
1901 info.setFile( fn ); 1902 info.setFile( fn );
1902 QString mes; 1903 QString mes;
1903 bool createbup = true; 1904 bool createbup = true;
1904 if ( info. exists() ) { 1905 if ( info. exists() ) {
1905 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1906 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1906 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1907 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1907 i18n("Overwrite!"), i18n("Cancel"), 0, 1908 i18n("Overwrite!"), i18n("Cancel"), 0,
1908 0, 1 ); 1909 0, 1 );
1909 if ( result != 0 ) { 1910 if ( result != 0 ) {
1910 createbup = false; 1911 createbup = false;
1911 } 1912 }
1912 } 1913 }
1913 if ( createbup ) { 1914 if ( createbup ) {
1914 mView->saveCalendar( fn ); 1915 mView->saveCalendar( fn );
1915 mes = i18n("KO/Pi:Saved %1").arg(fn); 1916 mes = i18n("KO/Pi:Saved %1").arg(fn);
1916 KOPrefs::instance()->mLastSaveFile = fn; 1917 KOPrefs::instance()->mLastSaveFile = fn;
1917 setCaption(mes); 1918 setCaption(mes);
1918 } 1919 }
1919} 1920}
1920void MainWindow::loadCalendar() 1921void MainWindow::loadCalendar()
1921{ 1922{
1922 1923
1923 QString fn = KOPrefs::instance()->mLastLoadFile; 1924 QString fn = KOPrefs::instance()->mLastLoadFile;
1924 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1925 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1925 1926
1926 if ( fn == "" ) 1927 if ( fn == "" )
1927 return; 1928 return;
1928 QFileInfo info; 1929 QFileInfo info;
1929 info.setFile( fn ); 1930 info.setFile( fn );
1930 QString mess; 1931 QString mess;
1931 bool loadbup = true; 1932 bool loadbup = true;
1932 if ( info. exists() ) { 1933 if ( info. exists() ) {
1933 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1934 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1934 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1935 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1935 mess, 1936 mess,
1936 i18n("Load!"), i18n("Cancel"), 0, 1937 i18n("Load!"), i18n("Cancel"), 0,
1937 0, 1 ); 1938 0, 1 );
1938 if ( result != 0 ) { 1939 if ( result != 0 ) {
1939 loadbup = false; 1940 loadbup = false;
1940 } 1941 }
1941 } else { 1942 } else {
1942 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1943 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1943 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1944 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1944 0, 1 ); 1945 0, 1 );
1945 1946
1946 return; 1947 return;
1947 } 1948 }
1948 if ( loadbup ) { 1949 if ( loadbup ) {
1949 mView->openCalendar( fn ); 1950 mView->openCalendar( fn );
1950 KOPrefs::instance()->mLastLoadFile = fn; 1951 KOPrefs::instance()->mLastLoadFile = fn;
1951 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1952 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1952 setCaption(mess); 1953 setCaption(mess);
1953 } 1954 }
1954 1955
1955} 1956}
1956void MainWindow::quickImportIcal() 1957void MainWindow::quickImportIcal()
1957{ 1958{
1958 importFile( KOPrefs::instance()->mLastImportFile, false ); 1959 importFile( KOPrefs::instance()->mLastImportFile, false );
1959} 1960}
1960void MainWindow::importFile( QString fn, bool quick ) 1961void MainWindow::importFile( QString fn, bool quick )
1961{ 1962{
1962 QFileInfo info; 1963 QFileInfo info;
1963 info.setFile( fn ); 1964 info.setFile( fn );
1964 QString mess; 1965 QString mess;
1965 bool loadbup = true; 1966 bool loadbup = true;
1966 if ( !info. exists() ) { 1967 if ( !info. exists() ) {
1967 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1968 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1968 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1969 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1969 mess ); 1970 mess );
1970 return; 1971 return;
1971 } 1972 }
1972 int result = 0; 1973 int result = 0;
1973 if ( !quick ) { 1974 if ( !quick ) {
1974 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1975 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1975 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1976 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1976 mess, 1977 mess,
1977 "Import", "Cancel", 0, 1978 "Import", "Cancel", 0,
1978 0, 1 ); 1979 0, 1 );
1979 } 1980 }
1980 if ( result == 0 ) { 1981 if ( result == 0 ) {
1981 if ( mView->openCalendar( fn, true )) { 1982 if ( mView->openCalendar( fn, true )) {
1982 KOPrefs::instance()->mLastImportFile = fn; 1983 KOPrefs::instance()->mLastImportFile = fn;
1983 setCaption(i18n("Imported file successfully")); 1984 setCaption(i18n("Imported file successfully"));
1984 } else { 1985 } else {
1985 setCaption(i18n("Error importing file")); 1986 setCaption(i18n("Error importing file"));
1986 } 1987 }
1987 } 1988 }
1988} 1989}
1989 1990
1990void MainWindow::importIcal() 1991void MainWindow::importIcal()
1991{ 1992{
1992 1993
1993 QString fn =KOPrefs::instance()->mLastImportFile; 1994 QString fn =KOPrefs::instance()->mLastImportFile;
1994 1995
1995 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1996 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1996 if ( fn == "" ) 1997 if ( fn == "" )
1997 return; 1998 return;
1998 importFile( fn, true ); 1999 importFile( fn, true );
1999 2000
2000} 2001}
2001 2002
2002void MainWindow::exportVCalendar() 2003void MainWindow::exportVCalendar()
2003{ 2004{
2004 QString fn = KOPrefs::instance()->mLastVcalFile; 2005 QString fn = KOPrefs::instance()->mLastVcalFile;
2005 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2006 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2006 if ( fn == "" ) 2007 if ( fn == "" )
2007 return; 2008 return;
2008 QFileInfo info; 2009 QFileInfo info;
2009 info.setFile( fn ); 2010 info.setFile( fn );
2010 QString mes; 2011 QString mes;
2011 bool createbup = true; 2012 bool createbup = true;
2012 if ( info. exists() ) { 2013 if ( info. exists() ) {
2013 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2014 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2014 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2015 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2015 i18n("Overwrite!"), i18n("Cancel"), 0, 2016 i18n("Overwrite!"), i18n("Cancel"), 0,
2016 0, 1 ); 2017 0, 1 );
2017 if ( result != 0 ) { 2018 if ( result != 0 ) {
2018 createbup = false; 2019 createbup = false;
2019 } 2020 }
2020 } 2021 }
2021 if ( createbup ) { 2022 if ( createbup ) {
2022 if ( mView->exportVCalendar( fn ) ) { 2023 if ( mView->exportVCalendar( fn ) ) {
2023 KOPrefs::instance()->mLastVcalFile = fn; 2024 KOPrefs::instance()->mLastVcalFile = fn;
2024 if ( fn.length() > 20 ) 2025 if ( fn.length() > 20 )
2025 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2026 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2026 else 2027 else
2027 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2028 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2028 setCaption(mes); 2029 setCaption(mes);
2029 } 2030 }
2030 } 2031 }
2031 2032
2032} 2033}
2033QString MainWindow::getPassword( ) 2034QString MainWindow::getPassword( )
2034{ 2035{
2035 QString retfile = ""; 2036 QString retfile = "";
2036 QDialog dia ( this, "input-dialog", true ); 2037 QDialog dia ( this, "input-dialog", true );
2037 QLineEdit lab ( &dia ); 2038 QLineEdit lab ( &dia );
2038 lab.setEchoMode( QLineEdit::Password ); 2039 lab.setEchoMode( QLineEdit::Password );
2039 QVBoxLayout lay( &dia ); 2040 QVBoxLayout lay( &dia );
2040 lay.setMargin(7); 2041 lay.setMargin(7);
2041 lay.setSpacing(7); 2042 lay.setSpacing(7);
2042 lay.addWidget( &lab); 2043 lay.addWidget( &lab);
2043 dia.setFixedSize( 230,50 ); 2044 dia.setFixedSize( 230,50 );
2044 dia.setCaption( i18n("Enter password") ); 2045 dia.setCaption( i18n("Enter password") );
2045 QPushButton pb ( "OK", &dia); 2046 QPushButton pb ( "OK", &dia);
2046 lay.addWidget( &pb ); 2047 lay.addWidget( &pb );
2047 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2048 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2048 dia.show(); 2049 dia.show();
2049 int res = dia.exec(); 2050 int res = dia.exec();
2050 if ( res ) 2051 if ( res )
2051 retfile = lab.text(); 2052 retfile = lab.text();
2052 dia.hide(); 2053 dia.hide();
2053 qApp->processEvents(); 2054 qApp->processEvents();
2054 return retfile; 2055 return retfile;
2055 2056
2056} 2057}
2057 2058
2058void MainWindow::enableQuick() 2059void MainWindow::enableQuick()
2059{ 2060{
2060 QDialog dia ( this, "input-dialog", true ); 2061 QDialog dia ( this, "input-dialog", true );
2061 QLineEdit lab ( &dia ); 2062 QLineEdit lab ( &dia );
2062 QVBoxLayout lay( &dia ); 2063 QVBoxLayout lay( &dia );
2063 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 2064 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
2064 lay.setMargin(7); 2065 lay.setMargin(7);
2065 lay.setSpacing(7); 2066 lay.setSpacing(7);
2066 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 2067 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
2067 lay.addWidget( &label); 2068 lay.addWidget( &label);
2068 lay.addWidget( &lab); 2069 lay.addWidget( &lab);
2069 2070
2070 QLineEdit lepw ( &dia ); 2071 QLineEdit lepw ( &dia );
2071 lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); 2072 lepw.setText( KOPrefs::instance()->mPassiveSyncPw );
2072 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 2073 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
2073 lay.addWidget( &label2); 2074 lay.addWidget( &label2);
2074 lay.addWidget( &lepw); 2075 lay.addWidget( &lepw);
2075 dia.setFixedSize( 230,80 ); 2076 dia.setFixedSize( 230,80 );
2076 dia.setCaption( i18n("Enter port for Pi-Sync") ); 2077 dia.setCaption( i18n("Enter port for Pi-Sync") );
2077 QPushButton pb ( "OK", &dia); 2078 QPushButton pb ( "OK", &dia);
2078 lay.addWidget( &pb ); 2079 lay.addWidget( &pb );
2079 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2080 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2080 dia.show(); 2081 dia.show();
2081 if ( ! dia.exec() ) 2082 if ( ! dia.exec() )
2082 return; 2083 return;
2083 dia.hide(); 2084 dia.hide();
2084 qApp->processEvents(); 2085 qApp->processEvents();
2085 KOPrefs::instance()->mPassiveSyncPw = lepw.text(); 2086 KOPrefs::instance()->mPassiveSyncPw = lepw.text();
2086 KOPrefs::instance()->mPassiveSyncPort = lab.text(); 2087 KOPrefs::instance()->mPassiveSyncPort = lab.text();
2087 bool ok; 2088 bool ok;
2088 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); 2089 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok);
2089 if ( ! ok ) { 2090 if ( ! ok ) {
2090 KMessageBox::information( this, i18n("No valid port")); 2091 KMessageBox::information( this, i18n("No valid port"));
2091 return; 2092 return;
2092 } 2093 }
2093 //qDebug("port %d ", port); 2094 //qDebug("port %d ", port);
2094 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); 2095 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 );
2095 mServerSocket->setFileName( defaultFileName() ); 2096 mServerSocket->setFileName( defaultFileName() );
2096 //qDebug("connected "); 2097 //qDebug("connected ");
2097 if ( !mServerSocket->ok() ) { 2098 if ( !mServerSocket->ok() ) {
2098 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); 2099 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!"));
2099 delete mServerSocket; 2100 delete mServerSocket;
2100 mServerSocket = 0; 2101 mServerSocket = 0;
2101 return; 2102 return;
2102 } 2103 }
2103 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); 2104 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
2104 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); 2105 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
2105} 2106}
2106 2107
2107void MainWindow::getFile( bool success ) 2108void MainWindow::getFile( bool success )
2108{ 2109{
2109 if ( ! success ) { 2110 if ( ! success ) {
2110 setCaption( i18n("Error receiving file. Nothing changed!") ); 2111 setCaption( i18n("Error receiving file. Nothing changed!") );
2111 return; 2112 return;
2112 } 2113 }
2113 mView->watchSavedFile(); 2114 mView->watchSavedFile();
2114 mView->openCalendar( defaultFileName() ); 2115 mView->openCalendar( defaultFileName() );
2115 setCaption( i18n("Pi-Sync successful!") ); 2116 setCaption( i18n("Pi-Sync successful!") );
2116 2117
2117} 2118}
2118 2119
2119 2120
2120void MainWindow::syncPi() 2121void MainWindow::syncPi()
2121{ 2122{
2122 qApp->processEvents(); 2123 qApp->processEvents();
2123 bool ok; 2124 bool ok;
2124 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2125 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2125 if ( ! ok ) { 2126 if ( ! ok ) {
2126 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2127 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2127 return; 2128 return;
2128 } 2129 }
2129 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); 2130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
2130 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 2131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
2131 setCaption( i18n("Sending request for remote file ...") ); 2132 setCaption( i18n("Sending request for remote file ...") );
2132 commandSocket->readFile( syncFileName() ); 2133 commandSocket->readFile( syncFileName() );
2133} 2134}
2134 2135
2135void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) 2136void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
2136{ 2137{
2137 qDebug("MainWindow::deleteCommandSocket %d", state); 2138 qDebug("MainWindow::deleteCommandSocket %d", state);
2138 2139
2139 //enum { success, errorW, errorR, quiet }; 2140 //enum { success, errorW, errorR, quiet };
2140 if ( state == KCommandSocket::errorR ) { 2141 if ( state == KCommandSocket::errorR ) {
2141 setCaption( i18n("ERROR: Receiving remote file failed.") ); 2142 setCaption( i18n("ERROR: Receiving remote file failed.") );
2142 delete s; 2143 delete s;
2143 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2144 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2144 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2145 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2145 commandSocket->sendStop(); 2146 commandSocket->sendStop();
2146 return; 2147 return;
2147 2148
2148 } else if ( state == KCommandSocket::errorW ) { 2149 } else if ( state == KCommandSocket::errorW ) {
2149 setCaption( i18n("ERROR:Writing back file failed.") ); 2150 setCaption( i18n("ERROR:Writing back file failed.") );
2150 2151
2151 } else if ( state == KCommandSocket::successR ) { 2152 } else if ( state == KCommandSocket::successR ) {
2152 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 2153 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
2153 2154
2154 } else if ( state == KCommandSocket::successW ) { 2155 } else if ( state == KCommandSocket::successW ) {
2155 setCaption( i18n("Pi-Sync succesful!") ); 2156 setCaption( i18n("Pi-Sync succesful!") );
2156 } 2157 }
2157 2158
2158 delete s; 2159 delete s;
2159} 2160}
2160 2161
2161void MainWindow::readFileFromSocket() 2162void MainWindow::readFileFromSocket()
2162{ 2163{
2163 QString fileName = syncFileName(); 2164 QString fileName = syncFileName();
2164 setCaption( i18n("Remote file saved to temp file.") ); 2165 setCaption( i18n("Remote file saved to temp file.") );
2165 if ( ! syncWithFile( fileName , true ) ) { 2166 if ( ! syncWithFile( fileName , true ) ) {
2166 setCaption( i18n("Syncing failed.") ); 2167 setCaption( i18n("Syncing failed.") );
2167 qDebug("Syncing failed "); 2168 qDebug("Syncing failed ");
2168 return; 2169 return;
2169 } 2170 }
2170 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2171 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2171 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2172 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2172 if ( KOPrefs::instance()->mWriteBackFile ) 2173 if ( KOPrefs::instance()->mWriteBackFile )
2173 commandSocket->writeFile( fileName ); 2174 commandSocket->writeFile( fileName );
2174 else { 2175 else {
2175 commandSocket->sendStop(); 2176 commandSocket->sendStop();
2176 setCaption( i18n("Pi-Sync succesful!") ); 2177 setCaption( i18n("Pi-Sync succesful!") );
2177 } 2178 }
2178} 2179}
2179 2180
2180void MainWindow::syncLocalFile() 2181void MainWindow::syncLocalFile()
2181{ 2182{
2182 2183
2183 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2184 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2184 2185
2185 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2186 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2186 if ( fn == "" ) 2187 if ( fn == "" )
2187 return; 2188 return;
2188 //mView->setSyncDevice("local-file" ); 2189 //mView->setSyncDevice("local-file" );
2189 if ( syncWithFile( fn, false ) ) { 2190 if ( syncWithFile( fn, false ) ) {
2190 // Event* e = mView->getLastSyncEvent(); 2191 // Event* e = mView->getLastSyncEvent();
2191// e->setReadOnly( false ); 2192// e->setReadOnly( false );
2192// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2193// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2193// e->setReadOnly( true ); 2194// e->setReadOnly( true );
2194 } 2195 }
2195 2196
2196} 2197}
2197 2198
2198bool MainWindow::syncWithFile( QString fn , bool quick ) 2199bool MainWindow::syncWithFile( QString fn , bool quick )
2199{ 2200{
2200 bool ret = false; 2201 bool ret = false;
2201 QFileInfo info; 2202 QFileInfo info;
2202 info.setFile( fn ); 2203 info.setFile( fn );
2203 QString mess; 2204 QString mess;
2204 bool loadbup = true; 2205 bool loadbup = true;
2205 if ( !info. exists() ) { 2206 if ( !info. exists() ) {
2206 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2207 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2207 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2208 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2208 mess ); 2209 mess );
2209 return ret; 2210 return ret;
2210 } 2211 }
2211 int result = 0; 2212 int result = 0;
2212 if ( !quick ) { 2213 if ( !quick ) {
2213 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2214 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2214 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2215 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2215 mess, 2216 mess,
2216 i18n("Sync"), i18n("Cancel"), 0, 2217 i18n("Sync"), i18n("Cancel"), 0,
2217 0, 1 ); 2218 0, 1 );
2218 if ( result ) 2219 if ( result )
2219 return false; 2220 return false;
2220 } 2221 }
2221 if ( KOPrefs::instance()->mAskForPreferences ) 2222 if ( KOPrefs::instance()->mAskForPreferences )
2222 mView->edit_sync_options(); 2223 mView->edit_sync_options();
2223 if ( result == 0 ) { 2224 if ( result == 0 ) {
2224 //qDebug("Now sycing ... "); 2225 //qDebug("Now sycing ... ");
2225 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2226 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2226 setCaption( i18n("Synchronization successful") ); 2227 setCaption( i18n("Synchronization successful") );
2227 else 2228 else
2228 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2229 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2229 if ( ! quick ) 2230 if ( ! quick )
2230 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2231 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2231 slotModifiedChanged( true ); 2232 slotModifiedChanged( true );
2232 } 2233 }
2233 return ret; 2234 return ret;
2234} 2235}
2235void MainWindow::quickSyncLocalFile() 2236void MainWindow::quickSyncLocalFile()
2236{ 2237{
2237 //mView->setSyncDevice("local-file" ); 2238 //mView->setSyncDevice("local-file" );
2238 //qDebug("quickSyncLocalFile() "); 2239 //qDebug("quickSyncLocalFile() ");
2239 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2240 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2240 // Event* e = mView->getLastSyncEvent(); 2241 // Event* e = mView->getLastSyncEvent();
2241// e->setReadOnly( false ); 2242// e->setReadOnly( false );
2242// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2243// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2243// e->setReadOnly( true ); 2244// e->setReadOnly( true );
2244 2245
2245 } 2246 }
2246} 2247}
2247 2248
2248void MainWindow::confSync() 2249void MainWindow::confSync()
2249{ 2250{
2250 mView->confSync(); 2251 mView->confSync();
2251 fillSyncMenu(); 2252 fillSyncMenu();
2252} 2253}
2253void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2254void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2254{ 2255{
2255 QString question; 2256 QString question;
2256 if ( ask ) { 2257 if ( ask ) {
2257 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2258 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2258 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2259 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2259 question, 2260 question,
2260 i18n("Yes"), i18n("No"), 2261 i18n("Yes"), i18n("No"),
diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro
index 7a0bd22..171c726 100644
--- a/libkcal/libkcal.pro
+++ b/libkcal/libkcal.pro
@@ -1,106 +1,106 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = microkcal
4 4
5include( ../variables.pri ) 5include( ../variables.pri )
6 6
7INCLUDEPATH += ../microkde versit ../microkde/kdecore 7INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore
8#../qtcompat 8#../qtcompat
9INCLUDEPATH += ../libical/src/libical 9INCLUDEPATH += ../libical/src/libical
10INCLUDEPATH += ../libical/src/libicalss 10INCLUDEPATH += ../libical/src/libicalss
11DESTDIR = ../bin 11DESTDIR = ../bin
12DEFINES += DESKTOP_VERSION 12DEFINES += DESKTOP_VERSION
13unix: { 13unix: {
14LIBS += ../libical/lib/libical.a 14LIBS += ../libical/lib/libical.a
15LIBS += ../libical/lib/libicalss.a 15LIBS += ../libical/lib/libicalss.a
16OBJECTS_DIR = obj/unix 16OBJECTS_DIR = obj/unix
17MOC_DIR = moc/unix 17MOC_DIR = moc/unix
18} 18}
19win32: { 19win32: {
20DEFINES += _WIN32_ 20DEFINES += _WIN32_
21 21
22LIBS += ../libical/lib/ical.lib 22LIBS += ../libical/lib/ical.lib
23LIBS += ../libical/lib/icalss.lib 23LIBS += ../libical/lib/icalss.lib
24OBJECTS_DIR = obj/win 24OBJECTS_DIR = obj/win
25MOC_DIR = moc/win 25MOC_DIR = moc/win
26 26
27} 27}
28 28
29INTERFACES = \ 29INTERFACES = \
30 30
31HEADERS = \ 31HEADERS = \
32 alarm.h \ 32 alarm.h \
33 attachment.h \ 33 attachment.h \
34 attendee.h \ 34 attendee.h \
35 calendar.h \ 35 calendar.h \
36 calendarlocal.h \ 36 calendarlocal.h \
37 calfilter.h \ 37 calfilter.h \
38 calformat.h \ 38 calformat.h \
39 calstorage.h \ 39 calstorage.h \
40 compat.h \ 40 compat.h \
41 customproperties.h \ 41 customproperties.h \
42 dummyscheduler.h \ 42 dummyscheduler.h \
43kincidenceformatter.h \ 43kincidenceformatter.h \
44 duration.h \ 44 duration.h \
45 event.h \ 45 event.h \
46 exceptions.h \ 46 exceptions.h \
47 filestorage.h \ 47 filestorage.h \
48 freebusy.h \ 48 freebusy.h \
49 icaldrag.h \ 49 icaldrag.h \
50 icalformat.h \ 50 icalformat.h \
51 icalformatimpl.h \ 51 icalformatimpl.h \
52 imipscheduler.h \ 52 imipscheduler.h \
53 incidence.h \ 53 incidence.h \
54 incidencebase.h \ 54 incidencebase.h \
55 journal.h \ 55 journal.h \
56 period.h \ 56 period.h \
57 person.h \ 57 person.h \
58 qtopiaformat.h \ 58 qtopiaformat.h \
59 recurrence.h \ 59 recurrence.h \
60 scheduler.h \ 60 scheduler.h \
61 todo.h \ 61 todo.h \
62 vcaldrag.h \ 62 vcaldrag.h \
63 vcalformat.h \ 63 vcalformat.h \
64 versit/port.h \ 64 versit/port.h \
65 versit/vcc.h \ 65 versit/vcc.h \
66 versit/vobject.h \ 66 versit/vobject.h \
67 phoneformat.h \ 67 phoneformat.h \
68 68
69 69
70 70
71SOURCES = \ 71SOURCES = \
72 alarm.cpp \ 72 alarm.cpp \
73 attachment.cpp \ 73 attachment.cpp \
74 attendee.cpp \ 74 attendee.cpp \
75 calendar.cpp \ 75 calendar.cpp \
76 calendarlocal.cpp \ 76 calendarlocal.cpp \
77 calfilter.cpp \ 77 calfilter.cpp \
78 calformat.cpp \ 78 calformat.cpp \
79 compat.cpp \ 79 compat.cpp \
80 customproperties.cpp \ 80 customproperties.cpp \
81 dummyscheduler.cpp \ 81 dummyscheduler.cpp \
82 kincidenceformatter.cpp \ 82 kincidenceformatter.cpp \
83 duration.cpp \ 83 duration.cpp \
84 event.cpp \ 84 event.cpp \
85 exceptions.cpp \ 85 exceptions.cpp \
86 filestorage.cpp \ 86 filestorage.cpp \
87 freebusy.cpp \ 87 freebusy.cpp \
88 icaldrag.cpp \ 88 icaldrag.cpp \
89 icalformat.cpp \ 89 icalformat.cpp \
90 icalformatimpl.cpp \ 90 icalformatimpl.cpp \
91 imipscheduler.cpp \ 91 imipscheduler.cpp \
92 incidence.cpp \ 92 incidence.cpp \
93 incidencebase.cpp \ 93 incidencebase.cpp \
94 journal.cpp \ 94 journal.cpp \
95 period.cpp \ 95 period.cpp \
96 person.cpp \ 96 person.cpp \
97 qtopiaformat.cpp \ 97 qtopiaformat.cpp \
98 recurrence.cpp \ 98 recurrence.cpp \
99 scheduler.cpp \ 99 scheduler.cpp \
100 todo.cpp \ 100 todo.cpp \
101 vcaldrag.cpp \ 101 vcaldrag.cpp \
102 vcalformat.cpp \ 102 vcalformat.cpp \
103 versit/vcc.c \ 103 versit/vcc.c \
104 versit/vobject.c \ 104 versit/vobject.c \
105 phoneformat.cpp \ 105 phoneformat.cpp \
106 106
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index e379b95..e42dc9c 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,91 +1,91 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = komicrokcal 3 TARGET = komicrokcal
4 4
5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include 5INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include
6INCLUDEPATH += ../libical/src/libical 6INCLUDEPATH += ../libical/src/libical
7INCLUDEPATH += ../libical/src/libicalss 7INCLUDEPATH += ../libical/src/libicalss
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += ../libical/lib/$(PLATFORM)/libical.a 11LIBS += ../libical/lib/$(PLATFORM)/libical.a
12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a 12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a
13 13
14INTERFACES = \ 14INTERFACES = \
15 15
16HEADERS = \ 16HEADERS = \
17 alarm.h \ 17 alarm.h \
18 attachment.h \ 18 attachment.h \
19 attendee.h \ 19 attendee.h \
20 calendar.h \ 20 calendar.h \
21 calendarlocal.h \ 21 calendarlocal.h \
22 calfilter.h \ 22 calfilter.h \
23 calformat.h \ 23 calformat.h \
24 calstorage.h \ 24 calstorage.h \
25 compat.h \ 25 compat.h \
26 customproperties.h \ 26 customproperties.h \
27 dummyscheduler.h \ 27 dummyscheduler.h \
28 duration.h \ 28 duration.h \
29 event.h \ 29 event.h \
30 exceptions.h \ 30 exceptions.h \
31 filestorage.h \ 31 filestorage.h \
32 freebusy.h \ 32 freebusy.h \
33 icaldrag.h \ 33 icaldrag.h \
34 icalformat.h \ 34 icalformat.h \
35 icalformatimpl.h \ 35 icalformatimpl.h \
36 imipscheduler.h \ 36 imipscheduler.h \
37 incidence.h \ 37 incidence.h \
38 incidencebase.h \ 38 incidencebase.h \
39kincidenceformatter.h \ 39kincidenceformatter.h \
40 journal.h \ 40 journal.h \
41 period.h \ 41 period.h \
42 person.h \ 42 person.h \
43 qtopiaformat.h \ 43 qtopiaformat.h \
44 sharpformat.h \ 44 sharpformat.h \
45 phoneformat.h \ 45 phoneformat.h \
46 recurrence.h \ 46 recurrence.h \
47 scheduler.h \ 47 scheduler.h \
48 todo.h \ 48 todo.h \
49 vcaldrag.h \ 49 vcaldrag.h \
50 vcalformat.h \ 50 vcalformat.h \
51 versit/port.h \ 51 versit/port.h \
52 versit/vcc.h \ 52 versit/vcc.h \
53 versit/vobject.h \ 53 versit/vobject.h \
54 54
55SOURCES = \ 55SOURCES = \
56 alarm.cpp \ 56 alarm.cpp \
57 attachment.cpp \ 57 attachment.cpp \
58 attendee.cpp \ 58 attendee.cpp \
59 calendar.cpp \ 59 calendar.cpp \
60 calendarlocal.cpp \ 60 calendarlocal.cpp \
61 calfilter.cpp \ 61 calfilter.cpp \
62 calformat.cpp \ 62 calformat.cpp \
63 compat.cpp \ 63 compat.cpp \
64 customproperties.cpp \ 64 customproperties.cpp \
65 dummyscheduler.cpp \ 65 dummyscheduler.cpp \
66 duration.cpp \ 66 duration.cpp \
67 event.cpp \ 67 event.cpp \
68 exceptions.cpp \ 68 exceptions.cpp \
69 filestorage.cpp \ 69 filestorage.cpp \
70 freebusy.cpp \ 70 freebusy.cpp \
71 icaldrag.cpp \ 71 icaldrag.cpp \
72 icalformat.cpp \ 72 icalformat.cpp \
73 icalformatimpl.cpp \ 73 icalformatimpl.cpp \
74 imipscheduler.cpp \ 74 imipscheduler.cpp \
75 incidence.cpp \ 75 incidence.cpp \
76 incidencebase.cpp \ 76 incidencebase.cpp \
77 kincidenceformatter.cpp \ 77 kincidenceformatter.cpp \
78 journal.cpp \ 78 journal.cpp \
79 period.cpp \ 79 period.cpp \
80 person.cpp \ 80 person.cpp \
81 qtopiaformat.cpp \ 81 qtopiaformat.cpp \
82 sharpformat.cpp \ 82 sharpformat.cpp \
83 phoneformat.cpp \ 83 phoneformat.cpp \
84 recurrence.cpp \ 84 recurrence.cpp \
85 scheduler.cpp \ 85 scheduler.cpp \
86 todo.cpp \ 86 todo.cpp \
87 vcaldrag.cpp \ 87 vcaldrag.cpp \
88 vcalformat.cpp \ 88 vcalformat.cpp \
89 versit/vcc.c \ 89 versit/vcc.c \
90 versit/vobject.c \ 90 versit/vobject.c \
91 91
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index b2a62b1..c39413e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,748 +1,637 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library 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 GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <phoneaccess.h>
39 40
40#include "calendar.h" 41#include "calendar.h"
41#include "alarm.h" 42#include "alarm.h"
42#include "recurrence.h" 43#include "recurrence.h"
43#include "calendarlocal.h" 44#include "calendarlocal.h"
44 45
45#include "phoneformat.h" 46#include "phoneformat.h"
46#include "syncdefines.h" 47#include "syncdefines.h"
47 48
48using namespace KCal; 49using namespace KCal;
49class PhoneParser : public QObject 50class PhoneParser : public QObject
50{ 51{
51public: 52public:
52 PhoneParser( ) { 53 PhoneParser( ) {
53 ; 54 ;
54 } 55 }
55 56
56 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 57 static QString dtToString( const QDateTime& dti, bool useTZ = false )
57 { 58 {
58 QString datestr; 59 QString datestr;
59 QString timestr; 60 QString timestr;
60 int offset = KGlobal::locale()->localTimeOffset( dti ); 61 int offset = KGlobal::locale()->localTimeOffset( dti );
61 QDateTime dt; 62 QDateTime dt;
62 if (useTZ) 63 if (useTZ)
63 dt = dti.addSecs ( -(offset*60)); 64 dt = dti.addSecs ( -(offset*60));
64 else 65 else
65 dt = dti; 66 dt = dti;
66 if(dt.date().isValid()){ 67 if(dt.date().isValid()){
67 const QDate& date = dt.date(); 68 const QDate& date = dt.date();
68 datestr.sprintf("%04d%02d%02d", 69 datestr.sprintf("%04d%02d%02d",
69 date.year(), date.month(), date.day()); 70 date.year(), date.month(), date.day());
70 } 71 }
71 if(dt.time().isValid()){ 72 if(dt.time().isValid()){
72 const QTime& time = dt.time(); 73 const QTime& time = dt.time();
73 timestr.sprintf("T%02d%02d%02d", 74 timestr.sprintf("T%02d%02d%02d",
74 time.hour(), time.minute(), time.second()); 75 time.hour(), time.minute(), time.second());
75 } 76 }
76 return datestr + timestr; 77 return datestr + timestr;
77 } 78 }
78 79
79 80
80}; 81};
81 82
82 83
83 84
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 85PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 86{
86 mProfileName = profileName; 87 mProfileName = profileName;
87 writeConfig( device, connection, model ); 88 PhoneAccess::writeConfig( device, connection, model );
88} 89}
89 90
90PhoneFormat::~PhoneFormat() 91PhoneFormat::~PhoneFormat()
91{ 92{
92} 93}
93void PhoneFormat::writeConfig( QString device, QString connection, QString model )
94{
95#ifdef _WIN32_
96 QString fileName = qApp->applicationDirPath () +"\\gammurc";
97#else
98 QString fileName = QDir::homeDirPath() +"/.gammurc";
99#endif
100 //qDebug("save %d ", load );
101 QString content;
102 bool write = false;
103 bool addPort = true, addConnection = true, addModel = true;
104 QFile file( fileName );
105 if ( QFile::exists( fileName) ) {
106 if (!file.open( IO_ReadOnly ) ) {
107 qDebug("Error: cannot open %s ", fileName.latin1() );
108 return;
109 }
110 QString line;
111 while ( file.readLine( line, 1024 ) > 0 ) {
112 //qDebug("*%s* ", line.latin1() );
113 if ( line.left(7 ) == "[gammu]" ) {
114 ;
115 } else
116 if ( line.left(4 ) == "port" ) {
117 if ( line == "port = " + device+"\n" ) {
118 content += line ;
119 addPort = false;
120 //qDebug("port found" );
121 }
122
123 } else if ( line.left(5 ) == "model" ) {
124 if ( line == "model = " + model +"\n") {
125 content += line ;
126 addModel = false;
127 //qDebug("model found" );
128 }
129
130 } else if ( line.left( 10 ) == "connection" ) {
131 if ( line == "connection = " + connection +"\n") {
132 addConnection = false;
133 content += line ;
134 //qDebug("con found" );
135 }
136
137 } else {
138 content += line ;
139 }
140 }
141 file.close();
142 } else {
143 if ( ! connection.isEmpty() ) {
144 addConnection = true;
145 }
146 if ( ! device.isEmpty() ) {
147 addPort = true;
148 94
149 }
150 if ( ! model.isEmpty() ) {
151 addModel = true;
152 }
153 }
154
155 if ( addConnection ) {
156 if ( ! write )
157 content += "[gammu]\n";
158 write = true;
159 content += "connection = ";
160 content += connection;
161 content += "\n";
162 }
163 if ( addPort ) {
164 if ( ! write )
165 content += "[gammu]\n";
166 write = true;
167 content += "port = ";
168 content += device;
169 content += "\n";
170
171 }
172 if ( addModel ) {
173 if ( ! write )
174 content += "[gammu]\n";
175 write = true;
176 content += "model = ";
177 content += model;
178 content += "\n";
179 }
180 if ( write ) {
181 if (!file.open( IO_WriteOnly ) ) {
182 qDebug("Error: cannot write file %s ", fileName.latin1() );
183 return;
184 }
185 qDebug("Writing file %s ", fileName.latin1() );
186 QTextStream ts( &file );
187 ts << content ;
188 file.close();
189 }
190
191}
192#if 0 95#if 0
193int PhoneFormat::initDevice(GSM_StateMachine *s) 96int PhoneFormat::initDevice(GSM_StateMachine *s)
194{ 97{
195 GSM_ReadConfig(NULL, &s->Config[0], 0); 98 GSM_ReadConfig(NULL, &s->Config[0], 0);
196 s->ConfigNum = 1; 99 s->ConfigNum = 1;
197 GSM_Config *cfg = &s->Config[0]; 100 GSM_Config *cfg = &s->Config[0];
198 if ( ! mConnection.isEmpty() ) { 101 if ( ! mConnection.isEmpty() ) {
199 cfg->Connection = strdup(mConnection.latin1()); 102 cfg->Connection = strdup(mConnection.latin1());
200 cfg->DefaultConnection = false; 103 cfg->DefaultConnection = false;
201 qDebug("Connection set %s ", cfg->Connection ); 104 qDebug("Connection set %s ", cfg->Connection );
202 105
203 } 106 }
204 if ( ! mDevice.isEmpty() ) { 107 if ( ! mDevice.isEmpty() ) {
205 cfg->Device = strdup(mDevice.latin1()); 108 cfg->Device = strdup(mDevice.latin1());
206 cfg->DefaultDevice = false; 109 cfg->DefaultDevice = false;
207 qDebug("Device set %s ", cfg->Device); 110 qDebug("Device set %s ", cfg->Device);
208 111
209 } 112 }
210 if ( ! mModel.isEmpty() ) { 113 if ( ! mModel.isEmpty() ) {
211 strcpy(cfg->Model,mModel.latin1() ); 114 strcpy(cfg->Model,mModel.latin1() );
212 cfg->DefaultModel = false; 115 cfg->DefaultModel = false;
213 qDebug("Model set %s ",cfg->Model ); 116 qDebug("Model set %s ",cfg->Model );
214 } 117 }
215 int error=GSM_InitConnection(s,3); 118 int error=GSM_InitConnection(s,3);
216 return error; 119 return error;
217} 120}
218#endif 121#endif
219ulong PhoneFormat::getCsumTodo( Todo* todo ) 122ulong PhoneFormat::getCsumTodo( Todo* todo )
220{ 123{
221 QStringList attList; 124 QStringList attList;
222 if ( todo->hasDueDate() ) 125 if ( todo->hasDueDate() )
223 attList << PhoneParser::dtToString ( todo->dtDue() ); 126 attList << PhoneParser::dtToString ( todo->dtDue() );
224 attList << todo->summary(); 127 attList << todo->summary();
225 QString completedString = "no"; 128 QString completedString = "no";
226 if ( todo->isCompleted() ) 129 if ( todo->isCompleted() )
227 completedString = "yes"; 130 completedString = "yes";
228 attList << completedString; 131 attList << completedString;
229 int prio = todo->priority(); 132 int prio = todo->priority();
230 if( prio == 2 ) prio = 1; 133 if( prio == 2 ) prio = 1;
231 if (prio == 4 ) prio = 5 ; 134 if (prio == 4 ) prio = 5 ;
232 attList << QString::number( prio ); 135 attList << QString::number( prio );
233 QString alarmString = "na"; 136 QString alarmString = "na";
234 Alarm *alarm; 137 Alarm *alarm;
235 if ( todo->alarms().count() > 0 ) { 138 if ( todo->alarms().count() > 0 ) {
236 alarm = todo->alarms().first(); 139 alarm = todo->alarms().first();
237 if ( alarm->enabled() ) { 140 if ( alarm->enabled() ) {
238 alarmString = QString::number(alarm->offset() ); 141 alarmString = QString::number(alarm->offset() );
239 } 142 }
240 } 143 }
241 attList << alarmString; 144 attList << alarmString;
242 attList << todo->categoriesStr(); 145 attList << todo->categoriesStr();
243 attList << todo->secrecyStr(); 146 attList << todo->secrecyStr();
244 return PhoneFormat::getCsum(attList ); 147 return PhoneFormat::getCsum(attList );
245 148
246} 149}
247ulong PhoneFormat::getCsumEvent( Event* event ) 150ulong PhoneFormat::getCsumEvent( Event* event )
248{ 151{
249 QStringList attList; 152 QStringList attList;
250 attList << PhoneParser::dtToString ( event->dtStart() ); 153 attList << PhoneParser::dtToString ( event->dtStart() );
251 attList << PhoneParser::dtToString ( event->dtEnd() ); 154 attList << PhoneParser::dtToString ( event->dtEnd() );
252 attList << event->summary(); 155 attList << event->summary();
253 attList << event->location(); 156 attList << event->location();
254 QString alarmString = "na"; 157 QString alarmString = "na";
255 Alarm *alarm; 158 Alarm *alarm;
256 if ( event->alarms().count() > 0 ) { 159 if ( event->alarms().count() > 0 ) {
257 alarm = event->alarms().first(); 160 alarm = event->alarms().first();
258 if ( alarm->enabled() ) { 161 if ( alarm->enabled() ) {
259 alarmString = QString::number( alarm->offset() ); 162 alarmString = QString::number( alarm->offset() );
260 } 163 }
261 } 164 }
262 attList << alarmString; 165 attList << alarmString;
263 Recurrence* rec = event->recurrence(); 166 Recurrence* rec = event->recurrence();
264 QStringList list; 167 QStringList list;
265 bool writeEndDate = false; 168 bool writeEndDate = false;
266 switch ( rec->doesRecur() ) 169 switch ( rec->doesRecur() )
267 { 170 {
268 case Recurrence::rDaily: // 0 171 case Recurrence::rDaily: // 0
269 list.append( "0" ); 172 list.append( "0" );
270 list.append( QString::number( rec->frequency() ));//12 173 list.append( QString::number( rec->frequency() ));//12
271 list.append( "0" ); 174 list.append( "0" );
272 list.append( "0" ); 175 list.append( "0" );
273 writeEndDate = true; 176 writeEndDate = true;
274 break; 177 break;
275 case Recurrence::rWeekly:// 1 178 case Recurrence::rWeekly:// 1
276 list.append( "1" ); 179 list.append( "1" );
277 list.append( QString::number( rec->frequency()) );//12 180 list.append( QString::number( rec->frequency()) );//12
278 list.append( "0" ); 181 list.append( "0" );
279 { 182 {
280 int days = 0; 183 int days = 0;
281 QBitArray weekDays = rec->days(); 184 QBitArray weekDays = rec->days();
282 int i; 185 int i;
283 for( i = 1; i <= 7; ++i ) { 186 for( i = 1; i <= 7; ++i ) {
284 if ( weekDays[i-1] ) { 187 if ( weekDays[i-1] ) {
285 days += 1 << (i-1); 188 days += 1 << (i-1);
286 } 189 }
287 } 190 }
288 list.append( QString::number( days ) ); 191 list.append( QString::number( days ) );
289 } 192 }
290 //pending weekdays 193 //pending weekdays
291 writeEndDate = true; 194 writeEndDate = true;
292 195
293 break; 196 break;
294 case Recurrence::rMonthlyPos:// 2 197 case Recurrence::rMonthlyPos:// 2
295 list.append( "2" ); 198 list.append( "2" );
296 list.append( QString::number( rec->frequency()) );//12 199 list.append( QString::number( rec->frequency()) );//12
297 200
298 writeEndDate = true; 201 writeEndDate = true;
299 { 202 {
300 int count = 1; 203 int count = 1;
301 QPtrList<Recurrence::rMonthPos> rmp; 204 QPtrList<Recurrence::rMonthPos> rmp;
302 rmp = rec->monthPositions(); 205 rmp = rec->monthPositions();
303 if ( rmp.first()->negative ) 206 if ( rmp.first()->negative )
304 count = 5 - rmp.first()->rPos - 1; 207 count = 5 - rmp.first()->rPos - 1;
305 else 208 else
306 count = rmp.first()->rPos - 1; 209 count = rmp.first()->rPos - 1;
307 list.append( QString::number( count ) ); 210 list.append( QString::number( count ) );
308 211
309 } 212 }
310 213
311 list.append( "0" ); 214 list.append( "0" );
312 break; 215 break;
313 case Recurrence::rMonthlyDay:// 3 216 case Recurrence::rMonthlyDay:// 3
314 list.append( "3" ); 217 list.append( "3" );
315 list.append( QString::number( rec->frequency()) );//12 218 list.append( QString::number( rec->frequency()) );//12
316 list.append( "0" ); 219 list.append( "0" );
317 list.append( "0" ); 220 list.append( "0" );
318 writeEndDate = true; 221 writeEndDate = true;
319 break; 222 break;
320 case Recurrence::rYearlyMonth://4 223 case Recurrence::rYearlyMonth://4
321 list.append( "4" ); 224 list.append( "4" );
322 list.append( QString::number( rec->frequency()) );//12 225 list.append( QString::number( rec->frequency()) );//12
323 list.append( "0" ); 226 list.append( "0" );
324 list.append( "0" ); 227 list.append( "0" );
325 writeEndDate = true; 228 writeEndDate = true;
326 break; 229 break;
327 230
328 default: 231 default:
329 list.append( "255" ); 232 list.append( "255" );
330 list.append( QString() ); 233 list.append( QString() );
331 list.append( "0" ); 234 list.append( "0" );
332 list.append( QString() ); 235 list.append( QString() );
333 list.append( "0" ); 236 list.append( "0" );
334 list.append( "20991231T000000" ); 237 list.append( "20991231T000000" );
335 break; 238 break;
336 } 239 }
337 if ( writeEndDate ) { 240 if ( writeEndDate ) {
338 241
339 if ( rec->endDate().isValid() ) { // 15 + 16 242 if ( rec->endDate().isValid() ) { // 15 + 16
340 list.append( "1" ); 243 list.append( "1" );
341 list.append( PhoneParser::dtToString( rec->endDate()) ); 244 list.append( PhoneParser::dtToString( rec->endDate()) );
342 } else { 245 } else {
343 list.append( "0" ); 246 list.append( "0" );
344 list.append( "20991231T000000" ); 247 list.append( "20991231T000000" );
345 } 248 }
346 249
347 } 250 }
348 attList << list.join(""); 251 attList << list.join("");
349 attList << event->categoriesStr(); 252 attList << event->categoriesStr();
350 //qDebug("csum cat %s", event->categoriesStr().latin1()); 253 //qDebug("csum cat %s", event->categoriesStr().latin1());
351 254
352 attList << event->secrecyStr(); 255 attList << event->secrecyStr();
353 return PhoneFormat::getCsum(attList ); 256 return PhoneFormat::getCsum(attList );
354} 257}
355ulong PhoneFormat::getCsum( const QStringList & attList) 258ulong PhoneFormat::getCsum( const QStringList & attList)
356{ 259{
357 int max = attList.count(); 260 int max = attList.count();
358 ulong cSum = 0; 261 ulong cSum = 0;
359 int j,k,i; 262 int j,k,i;
360 int add; 263 int add;
361 for ( i = 0; i < max ; ++i ) { 264 for ( i = 0; i < max ; ++i ) {
362 QString s = attList[i]; 265 QString s = attList[i];
363 if ( ! s.isEmpty() ){ 266 if ( ! s.isEmpty() ){
364 j = s.length(); 267 j = s.length();
365 for ( k = 0; k < j; ++k ) { 268 for ( k = 0; k < j; ++k ) {
366 int mul = k +1; 269 int mul = k +1;
367 add = s[k].unicode (); 270 add = s[k].unicode ();
368 if ( k < 16 ) 271 if ( k < 16 )
369 mul = mul * mul; 272 mul = mul * mul;
370 int ii = i+1; 273 int ii = i+1;
371 add = add * mul *ii*ii*ii; 274 add = add * mul *ii*ii*ii;
372 cSum += add; 275 cSum += add;
373 } 276 }
374 } 277 }
375 278
376 } 279 }
377 //QString dump = attList.join(","); 280 //QString dump = attList.join(",");
378 //qDebug("csum: %d %s", cSum,dump.latin1()); 281 //qDebug("csum: %d %s", cSum,dump.latin1());
379 282
380 return cSum; 283 return cSum;
381 284
382} 285}
383//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
384#include <stdlib.h> 287#include <stdlib.h>
385#define DEBUGMODE false 288#define DEBUGMODE false
386bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 289bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
387{ 290{
388 291
389 QString fileName; 292 QString fileName;
390#ifdef _WIN32_ 293#ifdef _WIN32_
391 fileName = locateLocal("tmp", "tempfile.vcs"); 294 fileName = locateLocal("tmp", "tempfile.vcs");
392#else 295#else
393 fileName = "/tmp/kdepimtemp.vcs"; 296 fileName = "/tmp/kdepimtemp.vcs";
394#endif 297#endif
395#ifdef DESKTOP_VERSION 298#ifdef DESKTOP_VERSION
396 QString command ="./kammu --backup " + fileName + " -yes" ; 299 QString command ="./kammu --backup " + fileName + " -yes" ;
397#else 300#else
398 QString command ="kammu --backup " + fileName + " -yes" ; 301 QString command ="kammu --backup " + fileName + " -yes" ;
399#endif 302#endif
400 int ret = system ( command.latin1() ); 303 int ret = system ( command.latin1() );
401 if ( ret != 0 ) { 304 if ( ret != 0 ) {
402 qDebug("Error::command returned %d", ret); 305 qDebug("Error::command returned %d", ret);
403 return false; 306 return false;
404 } 307 }
405 VCalFormat vfload; 308 VCalFormat vfload;
406 vfload.setLocalTime ( true ); 309 vfload.setLocalTime ( true );
407 qDebug("loading file ..."); 310 qDebug("loading file ...");
408 311
409 if ( ! vfload.load( calendar, fileName ) ) 312 if ( ! vfload.load( calendar, fileName ) )
410 return false; 313 return false;
411 QPtrList<Event> er = calendar->rawEvents(); 314 QPtrList<Event> er = calendar->rawEvents();
412 Event* ev = er.first(); 315 Event* ev = er.first();
413 qDebug("reading events... "); 316 qDebug("reading events... ");
414 while ( ev ) { 317 while ( ev ) {
415 QStringList cat = ev->categories(); 318 QStringList cat = ev->categories();
416 if ( cat.contains( "MeetingDEF" )) { 319 if ( cat.contains( "MeetingDEF" )) {
417 ev->setCategories( QStringList() ); 320 ev->setCategories( QStringList() );
418 } 321 }
419 int id = ev->pilotId(); 322 int id = ev->pilotId();
420 Event *event; 323 Event *event;
421 event = existingCal->event( mProfileName ,QString::number( id ) ); 324 event = existingCal->event( mProfileName ,QString::number( id ) );
422 if ( event ) { 325 if ( event ) {
423 event = (Event*)event->clone(); 326 event = (Event*)event->clone();
424 copyEvent( event, ev ); 327 copyEvent( event, ev );
425 calendar->deleteEvent( ev ); 328 calendar->deleteEvent( ev );
426 calendar->addEvent( event); 329 calendar->addEvent( event);
427 } 330 }
428 else 331 else
429 event = ev; 332 event = ev;
430 uint cSum; 333 uint cSum;
431 cSum = PhoneFormat::getCsumEvent( event ); 334 cSum = PhoneFormat::getCsumEvent( event );
432 event->setCsum( mProfileName, QString::number( cSum )); 335 event->setCsum( mProfileName, QString::number( cSum ));
433 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 336 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
434 event->setID( mProfileName,QString::number( id ) ); 337 event->setID( mProfileName,QString::number( id ) );
435 ev = er.next(); 338 ev = er.next();
436 } 339 }
437 { 340 {
438 qDebug("reading todos... "); 341 qDebug("reading todos... ");
439 QPtrList<Todo> tr = calendar->rawTodos(); 342 QPtrList<Todo> tr = calendar->rawTodos();
440 Todo* ev = tr.first(); 343 Todo* ev = tr.first();
441 while ( ev ) { 344 while ( ev ) {
442 345
443 QStringList cat = ev->categories(); 346 QStringList cat = ev->categories();
444 if ( cat.contains( "MeetingDEF" )) { 347 if ( cat.contains( "MeetingDEF" )) {
445 ev->setCategories( QStringList() ); 348 ev->setCategories( QStringList() );
446 } 349 }
447 int id = ev->pilotId(); 350 int id = ev->pilotId();
448 Todo *event; 351 Todo *event;
449 event = existingCal->todo( mProfileName ,QString::number( id ) ); 352 event = existingCal->todo( mProfileName ,QString::number( id ) );
450 if ( event ) { 353 if ( event ) {
451 //qDebug("copy todo %s ", event->summary().latin1()); 354 //qDebug("copy todo %s ", event->summary().latin1());
452 355
453 event = (Todo*)event->clone(); 356 event = (Todo*)event->clone();
454 copyTodo( event, ev ); 357 copyTodo( event, ev );
455 calendar->deleteTodo( ev ); 358 calendar->deleteTodo( ev );
456 calendar->addTodo( event); 359 calendar->addTodo( event);
457 } 360 }
458 else 361 else
459 event = ev; 362 event = ev;
460 uint cSum; 363 uint cSum;
461 cSum = PhoneFormat::getCsumTodo( event ); 364 cSum = PhoneFormat::getCsumTodo( event );
462 event->setCsum( mProfileName, QString::number( cSum )); 365 event->setCsum( mProfileName, QString::number( cSum ));
463 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 366 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
464 event->setID( mProfileName,QString::number( id ) ); 367 event->setID( mProfileName,QString::number( id ) );
465 ev = tr.next(); 368 ev = tr.next();
466 } 369 }
467 } 370 }
468 return true; 371 return true;
469} 372}
470void PhoneFormat::copyEvent( Event* to, Event* from ) 373void PhoneFormat::copyEvent( Event* to, Event* from )
471{ 374{
472 if ( from->dtStart().isValid() ) 375 if ( from->dtStart().isValid() )
473 to->setDtStart( from->dtStart() ); 376 to->setDtStart( from->dtStart() );
474 if ( from->dtEnd().isValid() ) 377 if ( from->dtEnd().isValid() )
475 to->setDtEnd( from->dtEnd() ); 378 to->setDtEnd( from->dtEnd() );
476 if ( !from->location().isEmpty() ) 379 if ( !from->location().isEmpty() )
477 to->setLocation( from->location() ); 380 to->setLocation( from->location() );
478 if ( !from->description().isEmpty() ) 381 if ( !from->description().isEmpty() )
479 to->setDescription( from->description() ); 382 to->setDescription( from->description() );
480 if ( !from->summary().isEmpty() ) 383 if ( !from->summary().isEmpty() )
481 to->setSummary( from->summary() ); 384 to->setSummary( from->summary() );
482 385
483 if ( from->alarms().count() ) { 386 if ( from->alarms().count() ) {
484 to->clearAlarms(); 387 to->clearAlarms();
485 Alarm *a = from->alarms().first(); 388 Alarm *a = from->alarms().first();
486 Alarm *b = to->newAlarm( ); 389 Alarm *b = to->newAlarm( );
487 b->setEnabled( a->enabled() ); 390 b->setEnabled( a->enabled() );
488 if ( a->hasStartOffset() ) { 391 if ( a->hasStartOffset() ) {
489 b->setStartOffset( a->startOffset() ); 392 b->setStartOffset( a->startOffset() );
490 } 393 }
491 if ( a->hasTime() ) 394 if ( a->hasTime() )
492 b->setTime( a->time() ); 395 b->setTime( a->time() );
493 396
494 } 397 }
495 QStringList cat = to->categories(); 398 QStringList cat = to->categories();
496 QStringList catFrom = from->categories(); 399 QStringList catFrom = from->categories();
497 QString nCat; 400 QString nCat;
498 int iii; 401 int iii;
499 for ( iii = 0; iii < catFrom.count();++iii ) { 402 for ( iii = 0; iii < catFrom.count();++iii ) {
500 nCat = catFrom[iii]; 403 nCat = catFrom[iii];
501 if ( !nCat.isEmpty() ) 404 if ( !nCat.isEmpty() )
502 if ( !cat.contains( nCat )) { 405 if ( !cat.contains( nCat )) {
503 cat << nCat; 406 cat << nCat;
504 } 407 }
505 } 408 }
506 to->setCategories( cat ); 409 to->setCategories( cat );
507 Recurrence * r = new Recurrence( *from->recurrence(),to); 410 Recurrence * r = new Recurrence( *from->recurrence(),to);
508 to->setRecurrence( r ) ; 411 to->setRecurrence( r ) ;
509 412
510 413
511} 414}
512void PhoneFormat::copyTodo( Todo* to, Todo* from ) 415void PhoneFormat::copyTodo( Todo* to, Todo* from )
513{ 416{
514 if ( from->dtStart().isValid() ) 417 if ( from->dtStart().isValid() )
515 to->setDtStart( from->dtStart() ); 418 to->setDtStart( from->dtStart() );
516 if ( from->dtDue().isValid() ) 419 if ( from->dtDue().isValid() )
517 to->setDtDue( from->dtDue() ); 420 to->setDtDue( from->dtDue() );
518 if ( !from->location().isEmpty() ) 421 if ( !from->location().isEmpty() )
519 to->setLocation( from->location() ); 422 to->setLocation( from->location() );
520 if ( !from->description().isEmpty() ) 423 if ( !from->description().isEmpty() )
521 to->setDescription( from->description() ); 424 to->setDescription( from->description() );
522 if ( !from->summary().isEmpty() ) 425 if ( !from->summary().isEmpty() )
523 to->setSummary( from->summary() ); 426 to->setSummary( from->summary() );
524 427
525 if ( from->alarms().count() ) { 428 if ( from->alarms().count() ) {
526 to->clearAlarms(); 429 to->clearAlarms();
527 Alarm *a = from->alarms().first(); 430 Alarm *a = from->alarms().first();
528 Alarm *b = to->newAlarm( ); 431 Alarm *b = to->newAlarm( );
529 b->setEnabled( a->enabled() ); 432 b->setEnabled( a->enabled() );
530 if ( a->hasStartOffset() ) 433 if ( a->hasStartOffset() )
531 b->setStartOffset( a->startOffset() ); 434 b->setStartOffset( a->startOffset() );
532 if ( a->hasTime() ) 435 if ( a->hasTime() )
533 b->setTime( a->time() ); 436 b->setTime( a->time() );
534 } 437 }
535 438
536 QStringList cat = to->categories(); 439 QStringList cat = to->categories();
537 QStringList catFrom = from->categories(); 440 QStringList catFrom = from->categories();
538 QString nCat; 441 QString nCat;
539 int iii; 442 int iii;
540 for ( iii = 0; iii < catFrom.count();++iii ) { 443 for ( iii = 0; iii < catFrom.count();++iii ) {
541 nCat = catFrom[iii]; 444 nCat = catFrom[iii];
542 if ( !nCat.isEmpty() ) 445 if ( !nCat.isEmpty() )
543 if ( !cat.contains( nCat )) { 446 if ( !cat.contains( nCat )) {
544 cat << nCat; 447 cat << nCat;
545 } 448 }
546 } 449 }
547 to->setCategories( cat ); 450 to->setCategories( cat );
548 if ( from->isCompleted() ) { 451 if ( from->isCompleted() ) {
549 to->setCompleted( true ); 452 to->setCompleted( true );
550 if( from->completed().isValid() ) 453 if( from->completed().isValid() )
551 to->setCompleted( from->completed() ); 454 to->setCompleted( from->completed() );
552 } else { 455 } else {
553 // set percentcomplete only, if to->isCompleted() 456 // set percentcomplete only, if to->isCompleted()
554 if ( to->isCompleted() ) 457 if ( to->isCompleted() )
555 to->setPercentComplete(from->percentComplete()); 458 to->setPercentComplete(from->percentComplete());
556 } 459 }
557 if( to->priority() == 2 && from->priority() == 1 ) 460 if( to->priority() == 2 && from->priority() == 1 )
558 ; //skip 461 ; //skip
559 else if (to->priority() == 4 && from->priority() == 5 ) 462 else if (to->priority() == 4 && from->priority() == 5 )
560 ; 463 ;
561 else 464 else
562 to->setPriority(from->priority()); 465 to->setPriority(from->priority());
563 466
564} 467}
565#include <qcstring.h> 468#include <qcstring.h>
566 469
567void PhoneFormat::afterSave( Incidence* inc) 470void PhoneFormat::afterSave( Incidence* inc)
568{ 471{
569 uint csum; 472 uint csum;
570 inc->removeID( mProfileName ); 473 inc->removeID( mProfileName );
571 if ( inc->type() == "Event") 474 if ( inc->type() == "Event")
572 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 475 csum = PhoneFormat::getCsumEvent( (Event*) inc );
573 else 476 else
574 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 477 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
575 inc->setCsum( mProfileName, QString::number( csum )); 478 inc->setCsum( mProfileName, QString::number( csum ));
576 479
577 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 480 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
578 481
579} 482}
580 483
581bool PhoneFormat::writeToPhone( Calendar * calendar) 484bool PhoneFormat::writeToPhone( Calendar * calendar)
582{ 485{
583#ifdef _WIN32_ 486#ifdef _WIN32_
584 QString fileName = locateLocal("tmp", "tempfile.vcs"); 487 QString fileName = locateLocal("tmp", "tempfile.vcs");
585#else 488#else
586 QString fileName = "/tmp/kdepimtemp.vcs"; 489 QString fileName = "/tmp/kdepimtemp.vcs";
587#endif 490#endif
588 491
589 VCalFormat vfsave; 492 VCalFormat vfsave;
590 vfsave.setLocalTime ( true ); 493 vfsave.setLocalTime ( true );
591 if ( ! vfsave.save( calendar, fileName ) ) 494 if ( ! vfsave.save( calendar, fileName ) )
592 return false; 495 return false;
593 // 4 call kammu 496 return PhoneAccess::writeToPhone( fileName );
594#ifdef DESKTOP_VERSION
595 QString command ="./kammu --restore " + fileName ;
596#else
597 QString command ="kammu --restore " + fileName ;
598#endif
599 int ret;
600 while ( (ret = system ( command.latin1())) != 0 ) {
601 qDebug("Error S::command returned %d. asking users", ret);
602 int retval = KMessageBox::warningContinueCancel(0,
603 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
604 if ( retval != KMessageBox::Continue )
605 return false;
606 }
607 return true;
608} 497}
609bool PhoneFormat::save( Calendar *calendar) 498bool PhoneFormat::save( Calendar *calendar)
610{ 499{
611 QLabel status ( i18n(" Opening device ..."), 0 ); 500 QLabel status ( i18n(" Opening device ..."), 0 );
612 int w = status.sizeHint().width()+20 ; 501 int w = status.sizeHint().width()+20 ;
613 if ( w < 200 ) w = 230; 502 if ( w < 200 ) w = 230;
614 int h = status.sizeHint().height()+20 ; 503 int h = status.sizeHint().height()+20 ;
615 int dw = QApplication::desktop()->width(); 504 int dw = QApplication::desktop()->width();
616 int dh = QApplication::desktop()->height(); 505 int dh = QApplication::desktop()->height();
617 status.setCaption(i18n("Writing to phone...") ); 506 status.setCaption(i18n("Writing to phone...") );
618 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 507 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
619 status.show(); 508 status.show();
620 status.raise(); 509 status.raise();
621 qApp->processEvents(); 510 qApp->processEvents();
622 QString message; 511 QString message;
623 512
624 // 1 remove events which should be deleted 513 // 1 remove events which should be deleted
625 QPtrList<Event> er = calendar->rawEvents(); 514 QPtrList<Event> er = calendar->rawEvents();
626 Event* ev = er.first(); 515 Event* ev = er.first();
627 while ( ev ) { 516 while ( ev ) {
628 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 517 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
629 calendar->deleteEvent( ev ); 518 calendar->deleteEvent( ev );
630 } else { 519 } else {
631 520
632 } 521 }
633 ev = er.next(); 522 ev = er.next();
634 } 523 }
635 // 2 remove todos which should be deleted 524 // 2 remove todos which should be deleted
636 QPtrList<Todo> tl = calendar->rawTodos(); 525 QPtrList<Todo> tl = calendar->rawTodos();
637 Todo* to = tl.first(); 526 Todo* to = tl.first();
638 while ( to ) { 527 while ( to ) {
639 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 528 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
640 calendar->deleteTodo( to ); 529 calendar->deleteTodo( to );
641 } else { 530 } else {
642 if ( to->isCompleted()) { 531 if ( to->isCompleted()) {
643 calendar->deleteTodo( to ); 532 calendar->deleteTodo( to );
644 } 533 }
645 } 534 }
646 to = tl.next(); 535 to = tl.next();
647 } 536 }
648 // 3 save file 537 // 3 save file
649 if ( !writeToPhone( calendar ) ) 538 if ( !writeToPhone( calendar ) )
650 return false; 539 return false;
651 540
652 // 5 reread data 541 // 5 reread data
653 message = i18n(" Rereading all data ... "); 542 message = i18n(" Rereading all data ... ");
654 status.setText ( message ); 543 status.setText ( message );
655 qApp->processEvents(); 544 qApp->processEvents();
656 CalendarLocal* calendarTemp = new CalendarLocal(); 545 CalendarLocal* calendarTemp = new CalendarLocal();
657 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 546 calendarTemp->setTimeZoneId( calendar->timeZoneId());
658 if ( ! load( calendarTemp,calendar) ){ 547 if ( ! load( calendarTemp,calendar) ){
659 qDebug("error reloading calendar "); 548 qDebug("error reloading calendar ");
660 delete calendarTemp; 549 delete calendarTemp;
661 return false; 550 return false;
662 } 551 }
663 // 6 compare data 552 // 6 compare data
664 553
665//algo 6 compare event 554//algo 6 compare event
666 er = calendar->rawEvents(); 555 er = calendar->rawEvents();
667 ev = er.first(); 556 ev = er.first();
668 message = i18n(" Comparing event # "); 557 message = i18n(" Comparing event # ");
669 QPtrList<Event> er1 = calendarTemp->rawEvents(); 558 QPtrList<Event> er1 = calendarTemp->rawEvents();
670 Event* ev1; 559 Event* ev1;
671 int procCount = 0; 560 int procCount = 0;
672 while ( ev ) { 561 while ( ev ) {
673 //qDebug("event new ID %s",ev->summary().latin1()); 562 //qDebug("event new ID %s",ev->summary().latin1());
674 status.setText ( message + QString::number ( ++procCount ) ); 563 status.setText ( message + QString::number ( ++procCount ) );
675 qApp->processEvents(); 564 qApp->processEvents();
676 uint csum; 565 uint csum;
677 csum = PhoneFormat::getCsumEvent( ev ); 566 csum = PhoneFormat::getCsumEvent( ev );
678 QString cSum = QString::number( csum ); 567 QString cSum = QString::number( csum );
679 //ev->setCsum( mProfileName, cSum ); 568 //ev->setCsum( mProfileName, cSum );
680 //qDebug("Event cSum %s ", cSum.latin1()); 569 //qDebug("Event cSum %s ", cSum.latin1());
681 ev1 = er1.first(); 570 ev1 = er1.first();
682 while ( ev1 ) { 571 while ( ev1 ) {
683 if ( ev1->getCsum( mProfileName ) == cSum ) { 572 if ( ev1->getCsum( mProfileName ) == cSum ) {
684 er1.remove( ev1 ); 573 er1.remove( ev1 );
685 afterSave( ev ); 574 afterSave( ev );
686 ev->setID(mProfileName, ev1->getID(mProfileName) ); 575 ev->setID(mProfileName, ev1->getID(mProfileName) );
687 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 576 //qDebug("Event found on phone for %s ", ev->summary().latin1());
688 577
689 break; 578 break;
690 } 579 }
691 ev1 = er1.next(); 580 ev1 = er1.next();
692 } 581 }
693 if ( ! ev1 ) { 582 if ( ! ev1 ) {
694 // ev->removeID(mProfileName); 583 // ev->removeID(mProfileName);
695 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 584 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
696 } 585 }
697 586
698 587
699 ev = er.next(); 588 ev = er.next();
700 } 589 }
701 //algo 6 compare todo 590 //algo 6 compare todo
702 tl = calendar->rawTodos(); 591 tl = calendar->rawTodos();
703 to = tl.first(); 592 to = tl.first();
704 procCount = 0; 593 procCount = 0;
705 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 594 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
706 Todo* to1 ; 595 Todo* to1 ;
707 message = i18n(" Comparing todo # "); 596 message = i18n(" Comparing todo # ");
708 while ( to ) { 597 while ( to ) {
709 status.setText ( message + QString::number ( ++procCount ) ); 598 status.setText ( message + QString::number ( ++procCount ) );
710 qApp->processEvents(); 599 qApp->processEvents();
711 uint csum; 600 uint csum;
712 csum = PhoneFormat::getCsumTodo( to ); 601 csum = PhoneFormat::getCsumTodo( to );
713 QString cSum = QString::number( csum ); 602 QString cSum = QString::number( csum );
714 //to->setCsum( mProfileName, cSum ); 603 //to->setCsum( mProfileName, cSum );
715 //qDebug("Todo cSum %s ", cSum.latin1()); 604 //qDebug("Todo cSum %s ", cSum.latin1());
716 Todo* to1 = tl1.first(); 605 Todo* to1 = tl1.first();
717 while ( to1 ) { 606 while ( to1 ) {
718 if ( to1->getCsum( mProfileName ) == cSum ) { 607 if ( to1->getCsum( mProfileName ) == cSum ) {
719 tl1.remove( to1 ); 608 tl1.remove( to1 );
720 afterSave( to ); 609 afterSave( to );
721 to->setID(mProfileName, to1->getID(mProfileName) ); 610 to->setID(mProfileName, to1->getID(mProfileName) );
722 break; 611 break;
723 } 612 }
724 to1 = tl1.next(); 613 to1 = tl1.next();
725 } 614 }
726 if ( ! to1 ) { 615 if ( ! to1 ) {
727 //to->removeID(mProfileName); 616 //to->removeID(mProfileName);
728 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 617 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
729 } 618 }
730 619
731 to = tl.next(); 620 to = tl.next();
732 } 621 }
733 delete calendarTemp; 622 delete calendarTemp;
734 return true; 623 return true;
735 624
736 625
737 626
738} 627}
739 628
740 629
741QString PhoneFormat::toString( Calendar * ) 630QString PhoneFormat::toString( Calendar * )
742{ 631{
743 return QString::null; 632 return QString::null;
744} 633}
745bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 634bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
746{ 635{
747 return false; 636 return false;
748} 637}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 61e8160..001fd81 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,63 +1,62 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library 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 GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
35*/ 35*/
36 class Event; 36 class Event;
37 class Todo; 37 class Todo;
38class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
39 public: 39 public:
40 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
41 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
42 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
43 43
44 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
45 bool save( Calendar * ); 45 bool save( Calendar * );
46 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
47 QString toString( Calendar * ); 47 QString toString( Calendar * );
48 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
49 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
50 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
51 static void writeConfig( QString device,QString connection, QString model );
52 static bool writeToPhone( Calendar * ); 51 static bool writeToPhone( Calendar * );
53 private: 52 private:
54 void copyEvent( Event* to, Event* from ); 53 void copyEvent( Event* to, Event* from );
55 void copyTodo( Todo* to, Todo* from ); 54 void copyTodo( Todo* to, Todo* from );
56 //int initDevice(GSM_StateMachine *s); 55 //int initDevice(GSM_StateMachine *s);
57 QString mProfileName; 56 QString mProfileName;
58 void afterSave( Incidence* ); 57 void afterSave( Incidence* );
59}; 58};
60 59
61} 60}
62 61
63#endif 62#endif