summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp38
-rw-r--r--korganizer/kodaymatrix.cpp2
-rw-r--r--korganizer/mainwindow.cpp8
3 files changed, 42 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9c40142..a4f3579 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3403 +1,3437 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h" 154#include "nameeditdialog.h"
155#include <kcmultidialog.h> 155#include <kcmultidialog.h>
156 156
157#ifdef _WIN32_ 157#ifdef _WIN32_
158#ifdef _OL_IMPORT_ 158#ifdef _OL_IMPORT_
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#endif 160#endif
161#else 161#else
162#include <unistd.h> 162#include <unistd.h>
163#endif 163#endif
164// sync includes 164// sync includes
165#include <libkdepim/ksyncprofile.h> 165#include <libkdepim/ksyncprofile.h>
166#include <libkdepim/ksyncprefsdialog.h> 166#include <libkdepim/ksyncprefsdialog.h>
167 167
168 168
169class KABCatPrefs : public QDialog 169class KABCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from addressees"), format ); 185 new QRadioButton(i18n("Remove from addressees"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201class KABFormatPrefs : public QDialog 201class KABFormatPrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Set formatted name") ); 207 setCaption( i18n("Set formatted name") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
212 lay->addWidget( lab ); 212 lay->addWidget( lab );
213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
214 lay->addWidget( format ); 214 lay->addWidget( format );
215 format->setExclusive ( true ) ; 215 format->setExclusive ( true ) ;
216 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 216 simple = new QRadioButton(i18n("Simple: James Bond"), format );
217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
219 company = new QRadioButton(i18n("Organization: MI6"), format ); 219 company = new QRadioButton(i18n("Organization: MI6"), format );
220 simple->setChecked( true ); 220 simple->setChecked( true );
221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
222 lay->addWidget( setCompany ); 222 lay->addWidget( setCompany );
223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
224 lay->addWidget( ok ); 224 lay->addWidget( ok );
225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
226 lay->addWidget( cancel ); 226 lay->addWidget( cancel );
227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
229 //resize( 200, 200 ); 229 //resize( 200, 200 );
230 230
231 } 231 }
232public: 232public:
233 QRadioButton* simple, *full, *reverse, *company; 233 QRadioButton* simple, *full, *reverse, *company;
234 QCheckBox* setCompany; 234 QCheckBox* setCompany;
235}; 235};
236 236
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mIncSearchWidget = 0; 301 mIncSearchWidget = 0;
302 mMiniSplitter = 0; 302 mMiniSplitter = 0;
303 mExtensionBarSplitter = 0; 303 mExtensionBarSplitter = 0;
304 mIsPart = !parent->inherits( "KAddressBookMain" ); 304 mIsPart = !parent->inherits( "KAddressBookMain" );
305 mAddressBook = KABC::StdAddressBook::self(); 305 mAddressBook = KABC::StdAddressBook::self();
306 KABC::StdAddressBook::setAutomaticSave( false ); 306 KABC::StdAddressBook::setAutomaticSave( false );
307 307
308#ifndef KAB_EMBEDDED 308#ifndef KAB_EMBEDDED
309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
313 SLOT( addressBookChanged() ) ); 313 SLOT( addressBookChanged() ) );
314 314
315#if 0 315#if 0
316 // LR moved to addressbook init method 316 // LR moved to addressbook init method
317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
318 "X-Department", "KADDRESSBOOK" ); 318 "X-Department", "KADDRESSBOOK" );
319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
320 "X-Profession", "KADDRESSBOOK" ); 320 "X-Profession", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
322 "X-AssistantsName", "KADDRESSBOOK" ); 322 "X-AssistantsName", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
324 "X-ManagersName", "KADDRESSBOOK" ); 324 "X-ManagersName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
326 "X-SpousesName", "KADDRESSBOOK" ); 326 "X-SpousesName", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
328 "X-Office", "KADDRESSBOOK" ); 328 "X-Office", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
330 "X-IMAddress", "KADDRESSBOOK" ); 330 "X-IMAddress", "KADDRESSBOOK" );
331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
332 "X-Anniversary", "KADDRESSBOOK" ); 332 "X-Anniversary", "KADDRESSBOOK" );
333 333
334 //US added this field to become compatible with Opie/qtopia addressbook 334 //US added this field to become compatible with Opie/qtopia addressbook
335 // values can be "female" or "male" or "". An empty field represents undefined. 335 // values can be "female" or "male" or "". An empty field represents undefined.
336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
337 "X-Gender", "KADDRESSBOOK" ); 337 "X-Gender", "KADDRESSBOOK" );
338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
339 "X-Children", "KADDRESSBOOK" ); 339 "X-Children", "KADDRESSBOOK" );
340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
341 "X-FreeBusyUrl", "KADDRESSBOOK" ); 341 "X-FreeBusyUrl", "KADDRESSBOOK" );
342#endif 342#endif
343 initGUI(); 343 initGUI();
344 344
345 mIncSearchWidget->setFocus(); 345 mIncSearchWidget->setFocus();
346 346
347 347
348 connect( mViewManager, SIGNAL( selected( const QString& ) ), 348 connect( mViewManager, SIGNAL( selected( const QString& ) ),
349 SLOT( setContactSelected( const QString& ) ) ); 349 SLOT( setContactSelected( const QString& ) ) );
350 connect( mViewManager, SIGNAL( executed( const QString& ) ), 350 connect( mViewManager, SIGNAL( executed( const QString& ) ),
351 SLOT( executeContact( const QString& ) ) ); 351 SLOT( executeContact( const QString& ) ) );
352 352
353 connect( mViewManager, SIGNAL( deleteRequest( ) ), 353 connect( mViewManager, SIGNAL( deleteRequest( ) ),
354 SLOT( deleteContacts( ) ) ); 354 SLOT( deleteContacts( ) ) );
355 connect( mViewManager, SIGNAL( modified() ), 355 connect( mViewManager, SIGNAL( modified() ),
356 SLOT( setModified() ) ); 356 SLOT( setModified() ) );
357 357
358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
360 360
361 connect( mXXPortManager, SIGNAL( modified() ), 361 connect( mXXPortManager, SIGNAL( modified() ),
362 SLOT( setModified() ) ); 362 SLOT( setModified() ) );
363 363
364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
365 SLOT( incrementalSearchJump( const QString& ) ) ); 365 SLOT( incrementalSearchJump( const QString& ) ) );
366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
367 mJumpButtonBar, SLOT( recreateButtons() ) ); 367 mJumpButtonBar, SLOT( recreateButtons() ) );
368 368
369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
370 SLOT( sendMail( const QString& ) ) ); 370 SLOT( sendMail( const QString& ) ) );
371 371
372 372
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
378 378
379 379
380#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
382 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 382 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
383 383
384 connect( mDetails, SIGNAL( browse( const QString& ) ), 384 connect( mDetails, SIGNAL( browse( const QString& ) ),
385 SLOT( browse( const QString& ) ) ); 385 SLOT( browse( const QString& ) ) );
386 386
387 387
388 mAddressBookService = new KAddressBookService( this ); 388 mAddressBookService = new KAddressBookService( this );
389 389
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 mMessageTimer = new QTimer( this ); 392 mMessageTimer = new QTimer( this );
393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
394 mEditorDialog = 0; 394 mEditorDialog = 0;
395 createAddresseeEditorDialog( this ); 395 createAddresseeEditorDialog( this );
396 setModified( false ); 396 setModified( false );
397 mBRdisabled = false; 397 mBRdisabled = false;
398#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
399 infrared = 0; 399 infrared = 0;
400#endif 400#endif
401 //toggleBeamReceive( ); 401 //toggleBeamReceive( );
402 mMainWindow->toolBar()->show(); 402 mMainWindow->toolBar()->show();
403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
404 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 404 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
405} 405}
406 406
407void KABCore::updateToolBar() 407void KABCore::updateToolBar()
408{ 408{
409 static int iii = 0; 409 static int iii = 0;
410 ++iii; 410 ++iii;
411 mMainWindow->toolBar()->repaintMe(); 411 mMainWindow->toolBar()->repaintMe();
412 if ( iii < 4 ) 412 if ( iii < 4 )
413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
414} 414}
415KABCore::~KABCore() 415KABCore::~KABCore()
416{ 416{
417 // save(); 417 // save();
418 //saveSettings(); 418 //saveSettings();
419 //KABPrefs::instance()->writeConfig(); 419 //KABPrefs::instance()->writeConfig();
420 delete AddresseeConfig::instance(); 420 delete AddresseeConfig::instance();
421 mAddressBook = 0; 421 mAddressBook = 0;
422 KABC::StdAddressBook::close(); 422 KABC::StdAddressBook::close();
423 423
424 delete syncManager; 424 delete syncManager;
425#ifndef DESKTOP_VERSION 425#ifndef DESKTOP_VERSION
426 if ( infrared ) 426 if ( infrared )
427 delete infrared; 427 delete infrared;
428#endif 428#endif
429} 429}
430void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 430void KABCore::receive( const QCString& cmsg, const QByteArray& data )
431{ 431{
432 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 432 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
433 if ( cmsg == "setDocument(QString)" ) { 433 if ( cmsg == "setDocument(QString)" ) {
434 QDataStream stream( data, IO_ReadOnly ); 434 QDataStream stream( data, IO_ReadOnly );
435 QString fileName; 435 QString fileName;
436 stream >> fileName; 436 stream >> fileName;
437 recieve( fileName ); 437 recieve( fileName );
438 return; 438 return;
439 } 439 }
440} 440}
441void KABCore::toggleBeamReceive( ) 441void KABCore::toggleBeamReceive( )
442{ 442{
443 if ( mBRdisabled ) 443 if ( mBRdisabled )
444 return; 444 return;
445#ifndef DESKTOP_VERSION 445#ifndef DESKTOP_VERSION
446 if ( infrared ) { 446 if ( infrared ) {
447 qDebug("KA: AB disable BeamReceive "); 447 qDebug("KA: AB disable BeamReceive ");
448 delete infrared; 448 delete infrared;
449 infrared = 0; 449 infrared = 0;
450 mActionBR->setChecked(false); 450 mActionBR->setChecked(false);
451 return; 451 return;
452 } 452 }
453 qDebug("KA: AB enable BeamReceive "); 453 qDebug("KA: AB enable BeamReceive ");
454 mActionBR->setChecked(true); 454 mActionBR->setChecked(true);
455 455
456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
458#endif 458#endif
459} 459}
460 460
461 461
462void KABCore::disableBR(bool b) 462void KABCore::disableBR(bool b)
463{ 463{
464#ifndef DESKTOP_VERSION 464#ifndef DESKTOP_VERSION
465 if ( b ) { 465 if ( b ) {
466 if ( infrared ) { 466 if ( infrared ) {
467 toggleBeamReceive( ); 467 toggleBeamReceive( );
468 } 468 }
469 mBRdisabled = true; 469 mBRdisabled = true;
470 } else { 470 } else {
471 if ( mBRdisabled ) { 471 if ( mBRdisabled ) {
472 mBRdisabled = false; 472 mBRdisabled = false;
473 //toggleBeamReceive( ); 473 //toggleBeamReceive( );
474 } 474 }
475 } 475 }
476#endif 476#endif
477 477
478} 478}
479void KABCore::recieve( QString fn ) 479void KABCore::recieve( QString fn )
480{ 480{
481 //qDebug("KABCore::recieve "); 481 //qDebug("KABCore::recieve ");
482 int count = mAddressBook->importFromFile( fn, true ); 482 int count = mAddressBook->importFromFile( fn, true );
483 if ( count ) 483 if ( count )
484 setModified( true ); 484 setModified( true );
485 mViewManager->refreshView(); 485 mViewManager->refreshView();
486 message(i18n("%1 contact(s) received!").arg( count )); 486 message(i18n("%1 contact(s) received!").arg( count ));
487 topLevelWidget()->showMaximized(); 487 topLevelWidget()->showMaximized();
488 topLevelWidget()->raise(); 488 topLevelWidget()->raise();
489} 489}
490void KABCore::restoreSettings() 490void KABCore::restoreSettings()
491{ 491{
492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
493 493
494 bool state; 494 bool state;
495 495
496 if (mMultipleViewsAtOnce) 496 if (mMultipleViewsAtOnce)
497 state = KABPrefs::instance()->mDetailsPageVisible; 497 state = KABPrefs::instance()->mDetailsPageVisible;
498 else 498 else
499 state = false; 499 state = false;
500 500
501 mActionDetails->setChecked( state ); 501 mActionDetails->setChecked( state );
502 setDetailsVisible( state ); 502 setDetailsVisible( state );
503 503
504 state = KABPrefs::instance()->mJumpButtonBarVisible; 504 state = KABPrefs::instance()->mJumpButtonBarVisible;
505 505
506 mActionJumpBar->setChecked( state ); 506 mActionJumpBar->setChecked( state );
507 setJumpButtonBarVisible( state ); 507 setJumpButtonBarVisible( state );
508/*US 508/*US
509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
510 if ( splitterSize.count() == 0 ) { 510 if ( splitterSize.count() == 0 ) {
511 splitterSize.append( width() / 2 ); 511 splitterSize.append( width() / 2 );
512 splitterSize.append( width() / 2 ); 512 splitterSize.append( width() / 2 );
513 } 513 }
514 mMiniSplitter->setSizes( splitterSize ); 514 mMiniSplitter->setSizes( splitterSize );
515 if ( mExtensionBarSplitter ) { 515 if ( mExtensionBarSplitter ) {
516 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 516 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
517 if ( splitterSize.count() == 0 ) { 517 if ( splitterSize.count() == 0 ) {
518 splitterSize.append( width() / 2 ); 518 splitterSize.append( width() / 2 );
519 splitterSize.append( width() / 2 ); 519 splitterSize.append( width() / 2 );
520 } 520 }
521 mExtensionBarSplitter->setSizes( splitterSize ); 521 mExtensionBarSplitter->setSizes( splitterSize );
522 522
523 } 523 }
524*/ 524*/
525 mViewManager->restoreSettings(); 525 mViewManager->restoreSettings();
526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
527 mExtensionManager->restoreSettings(); 527 mExtensionManager->restoreSettings();
528#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
529 int wid = width(); 529 int wid = width();
530 if ( wid < 10 ) 530 if ( wid < 10 )
531 wid = 400; 531 wid = 400;
532#else 532#else
533 int wid = QApplication::desktop()->width(); 533 int wid = QApplication::desktop()->width();
534 if ( wid < 640 ) 534 if ( wid < 640 )
535 wid = QApplication::desktop()->height(); 535 wid = QApplication::desktop()->height();
536#endif 536#endif
537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
538 if ( true /*splitterSize.count() == 0*/ ) { 538 if ( true /*splitterSize.count() == 0*/ ) {
539 splitterSize.append( wid / 2 ); 539 splitterSize.append( wid / 2 );
540 splitterSize.append( wid / 2 ); 540 splitterSize.append( wid / 2 );
541 } 541 }
542 mMiniSplitter->setSizes( splitterSize ); 542 mMiniSplitter->setSizes( splitterSize );
543 if ( mExtensionBarSplitter ) { 543 if ( mExtensionBarSplitter ) {
544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
545 if ( true /*splitterSize.count() == 0*/ ) { 545 if ( true /*splitterSize.count() == 0*/ ) {
546 splitterSize.append( wid / 2 ); 546 splitterSize.append( wid / 2 );
547 splitterSize.append( wid / 2 ); 547 splitterSize.append( wid / 2 );
548 } 548 }
549 mExtensionBarSplitter->setSizes( splitterSize ); 549 mExtensionBarSplitter->setSizes( splitterSize );
550 550
551 } 551 }
552 552#ifdef DESKTOP_VERSION
553 553 KConfig *config = KABPrefs::instance()->getConfig();
554 config->setGroup("WidgetLayout");
555 QStringList list;
556 list = config->readListEntry("MainLayout");
557 int x,y,w,h;
558 if ( ! list.isEmpty() ) {
559 x = list[0].toInt();
560 y = list[1].toInt();
561 w = list[2].toInt();
562 h = list[3].toInt();
563 KApplication::testCoords( &x,&y,&w,&h );
564 topLevelWidget()->setGeometry(x,y,w,h);
565
566 } else {
567 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
568 }
569#endif
554} 570}
555 571
556void KABCore::saveSettings() 572void KABCore::saveSettings()
557{ 573{
558 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 574 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
559 if ( mExtensionBarSplitter ) 575 if ( mExtensionBarSplitter )
560 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 576 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
561 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 577 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
562 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 578 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
563#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
564 580
565 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 581 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
566 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 582 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
567#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
568 mExtensionManager->saveSettings(); 584 mExtensionManager->saveSettings();
569 mViewManager->saveSettings(); 585 mViewManager->saveSettings();
570 586
571 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 587 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
588#ifdef DESKTOP_VERSION
589 KConfig *config = KABPrefs::instance()->getConfig();
590 config->setGroup("WidgetLayout");
591 QStringList list ;//= config->readListEntry("MainLayout");
592 int x,y,w,h;
593 QWidget* wid;
594 wid = topLevelWidget();
595 x = wid->geometry().x();
596 y = wid->geometry().y();
597 w = wid->width();
598 h = wid->height();
599 list.clear();
600 list << QString::number( x );
601 list << QString::number( y );
602 list << QString::number( w );
603 list << QString::number( h );
604 config->writeEntry("MainLayout",list );
605#endif
572 KABPrefs::instance()->writeConfig(); 606 KABPrefs::instance()->writeConfig();
573 qDebug("KA: KABCore::saveSettings() "); 607 qDebug("KA: KABCore::saveSettings() ");
574} 608}
575 609
576KABC::AddressBook *KABCore::addressBook() const 610KABC::AddressBook *KABCore::addressBook() const
577{ 611{
578 return mAddressBook; 612 return mAddressBook;
579} 613}
580 614
581KConfig *KABCore::config() 615KConfig *KABCore::config()
582{ 616{
583#ifndef KAB_EMBEDDED 617#ifndef KAB_EMBEDDED
584 return KABPrefs::instance()->config(); 618 return KABPrefs::instance()->config();
585#else //KAB_EMBEDDED 619#else //KAB_EMBEDDED
586 return KABPrefs::instance()->getConfig(); 620 return KABPrefs::instance()->getConfig();
587#endif //KAB_EMBEDDED 621#endif //KAB_EMBEDDED
588} 622}
589 623
590KActionCollection *KABCore::actionCollection() const 624KActionCollection *KABCore::actionCollection() const
591{ 625{
592 return mGUIClient->actionCollection(); 626 return mGUIClient->actionCollection();
593} 627}
594 628
595KABC::Field *KABCore::currentSearchField() const 629KABC::Field *KABCore::currentSearchField() const
596{ 630{
597 if (mIncSearchWidget) 631 if (mIncSearchWidget)
598 return mIncSearchWidget->currentField(); 632 return mIncSearchWidget->currentField();
599 else 633 else
600 return 0; 634 return 0;
601} 635}
602 636
603QStringList KABCore::selectedUIDs() const 637QStringList KABCore::selectedUIDs() const
604{ 638{
605 return mViewManager->selectedUids(); 639 return mViewManager->selectedUids();
606} 640}
607 641
608KABC::Resource *KABCore::requestResource( QWidget *parent ) 642KABC::Resource *KABCore::requestResource( QWidget *parent )
609{ 643{
610 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 644 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
611 645
612 QPtrList<KRES::Resource> kresResources; 646 QPtrList<KRES::Resource> kresResources;
613 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 647 QPtrListIterator<KABC::Resource> resIt( kabcResources );
614 KABC::Resource *resource; 648 KABC::Resource *resource;
615 while ( ( resource = resIt.current() ) != 0 ) { 649 while ( ( resource = resIt.current() ) != 0 ) {
616 ++resIt; 650 ++resIt;
617 if ( !resource->readOnly() ) { 651 if ( !resource->readOnly() ) {
618 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 652 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
619 if ( res ) 653 if ( res )
620 kresResources.append( res ); 654 kresResources.append( res );
621 } 655 }
622 } 656 }
623 657
624 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 658 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
625 return static_cast<KABC::Resource*>( res ); 659 return static_cast<KABC::Resource*>( res );
626} 660}
627 661
628#ifndef KAB_EMBEDDED 662#ifndef KAB_EMBEDDED
629KAboutData *KABCore::createAboutData() 663KAboutData *KABCore::createAboutData()
630#else //KAB_EMBEDDED 664#else //KAB_EMBEDDED
631void KABCore::createAboutData() 665void KABCore::createAboutData()
632#endif //KAB_EMBEDDED 666#endif //KAB_EMBEDDED
633{ 667{
634 668
635 669
636 QString version; 670 QString version;
637#include <../version> 671#include <../version>
638 QMessageBox::about( this, "About KAddressbook/Pi", 672 QMessageBox::about( this, "About KAddressbook/Pi",
639 "KAddressbook/Platform-independent\n" 673 "KAddressbook/Platform-independent\n"
640 "(KA/Pi) " +version + " - " + 674 "(KA/Pi) " +version + " - " +
641#ifdef DESKTOP_VERSION 675#ifdef DESKTOP_VERSION
642 "Desktop Edition\n" 676 "Desktop Edition\n"
643#else 677#else
644 "PDA-Edition\n" 678 "PDA-Edition\n"
645 "for: Zaurus 5500 / 7x0 / 8x0\n" 679 "for: Zaurus 5500 / 7x0 / 8x0\n"
646#endif 680#endif
647 681
648 "(c) 2004 Ulf Schenk\n" 682 "(c) 2004 Ulf Schenk\n"
649 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 683 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
650 "(c) 1997-2003, The KDE PIM Team\n" 684 "(c) 1997-2003, The KDE PIM Team\n"
651 "Tobias Koenig Maintainer\n" 685 "Tobias Koenig Maintainer\n"
652 "Don Sanders Original author\n" 686 "Don Sanders Original author\n"
653 "Cornelius Schumacher Co-maintainer\n" 687 "Cornelius Schumacher Co-maintainer\n"
654 "Mike Pilone GUI and framework redesign\n" 688 "Mike Pilone GUI and framework redesign\n"
655 "Greg Stern DCOP interface\n" 689 "Greg Stern DCOP interface\n"
656 "Mark Westcot Contact pinning\n" 690 "Mark Westcot Contact pinning\n"
657 "Michel Boyer de la Giroday LDAP Lookup\n" 691 "Michel Boyer de la Giroday LDAP Lookup\n"
658 "Steffen Hansen LDAP Lookup" 692 "Steffen Hansen LDAP Lookup"
659#ifdef _WIN32_ 693#ifdef _WIN32_
660 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 694 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
661#endif 695#endif
662 ); 696 );
663} 697}
664 698
665void KABCore::setContactSelected( const QString &uid ) 699void KABCore::setContactSelected( const QString &uid )
666{ 700{
667 KABC::Addressee addr = mAddressBook->findByUid( uid ); 701 KABC::Addressee addr = mAddressBook->findByUid( uid );
668 if ( !mDetails->isHidden() ) 702 if ( !mDetails->isHidden() )
669 mDetails->setAddressee( addr ); 703 mDetails->setAddressee( addr );
670 704
671 if ( !addr.isEmpty() ) { 705 if ( !addr.isEmpty() ) {
672 emit contactSelected( addr.formattedName() ); 706 emit contactSelected( addr.formattedName() );
673 KABC::Picture pic = addr.photo(); 707 KABC::Picture pic = addr.photo();
674 if ( pic.isIntern() ) { 708 if ( pic.isIntern() ) {
675//US emit contactSelected( pic.data() ); 709//US emit contactSelected( pic.data() );
676//US instead use: 710//US instead use:
677 QPixmap px; 711 QPixmap px;
678 if (pic.data().isNull() != true) 712 if (pic.data().isNull() != true)
679 { 713 {
680 px.convertFromImage(pic.data()); 714 px.convertFromImage(pic.data());
681 } 715 }
682 716
683 emit contactSelected( px ); 717 emit contactSelected( px );
684 } 718 }
685 } 719 }
686 720
687 721
688 mExtensionManager->setSelectionChanged(); 722 mExtensionManager->setSelectionChanged();
689 723
690 // update the actions 724 // update the actions
691 bool selected = !uid.isEmpty(); 725 bool selected = !uid.isEmpty();
692 726
693 if ( mReadWrite ) { 727 if ( mReadWrite ) {
694 mActionCut->setEnabled( selected ); 728 mActionCut->setEnabled( selected );
695 mActionPaste->setEnabled( selected ); 729 mActionPaste->setEnabled( selected );
696 } 730 }
697 731
698 mActionCopy->setEnabled( selected ); 732 mActionCopy->setEnabled( selected );
699 mActionDelete->setEnabled( selected ); 733 mActionDelete->setEnabled( selected );
700 mActionEditAddressee->setEnabled( selected ); 734 mActionEditAddressee->setEnabled( selected );
701 mActionMail->setEnabled( selected ); 735 mActionMail->setEnabled( selected );
702 mActionMailVCard->setEnabled( selected ); 736 mActionMailVCard->setEnabled( selected );
703 //if (mActionBeam) 737 //if (mActionBeam)
704 //mActionBeam->setEnabled( selected ); 738 //mActionBeam->setEnabled( selected );
705 mActionWhoAmI->setEnabled( selected ); 739 mActionWhoAmI->setEnabled( selected );
706} 740}
707 741
708void KABCore::sendMail() 742void KABCore::sendMail()
709{ 743{
710 sendMail( mViewManager->selectedEmails().join( ", " ) ); 744 sendMail( mViewManager->selectedEmails().join( ", " ) );
711} 745}
712 746
713void KABCore::sendMail( const QString& emaillist ) 747void KABCore::sendMail( const QString& emaillist )
714{ 748{
715 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 749 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
716 if (emaillist.contains(",") > 0) 750 if (emaillist.contains(",") > 0)
717 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 751 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
718 else 752 else
719 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 753 ExternalAppHandler::instance()->mailToOneContact( emaillist );
720} 754}
721 755
722 756
723 757
724void KABCore::mailVCard() 758void KABCore::mailVCard()
725{ 759{
726 QStringList uids = mViewManager->selectedUids(); 760 QStringList uids = mViewManager->selectedUids();
727 if ( !uids.isEmpty() ) 761 if ( !uids.isEmpty() )
728 mailVCard( uids ); 762 mailVCard( uids );
729} 763}
730 764
731void KABCore::mailVCard( const QStringList& uids ) 765void KABCore::mailVCard( const QStringList& uids )
732{ 766{
733 QStringList urls; 767 QStringList urls;
734 768
735// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 769// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
736 770
737 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 771 QString dirName = "/tmp/" + KApplication::randomString( 8 );
738 772
739 773
740 774
741 QDir().mkdir( dirName, true ); 775 QDir().mkdir( dirName, true );
742 776
743 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 777 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
744 KABC::Addressee a = mAddressBook->findByUid( *it ); 778 KABC::Addressee a = mAddressBook->findByUid( *it );
745 779
746 if ( a.isEmpty() ) 780 if ( a.isEmpty() )
747 continue; 781 continue;
748 782
749 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 783 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
750 784
751 QString fileName = dirName + "/" + name; 785 QString fileName = dirName + "/" + name;
752 786
753 QFile outFile(fileName); 787 QFile outFile(fileName);
754 788
755 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 789 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
756 KABC::VCardConverter converter; 790 KABC::VCardConverter converter;
757 QString vcard; 791 QString vcard;
758 792
759 converter.addresseeToVCard( a, vcard ); 793 converter.addresseeToVCard( a, vcard );
760 794
761 QTextStream t( &outFile ); // use a text stream 795 QTextStream t( &outFile ); // use a text stream
762 t.setEncoding( QTextStream::UnicodeUTF8 ); 796 t.setEncoding( QTextStream::UnicodeUTF8 );
763 t << vcard; 797 t << vcard;
764 798
765 outFile.close(); 799 outFile.close();
766 800
767 urls.append( fileName ); 801 urls.append( fileName );
768 } 802 }
769 } 803 }
770 804
771 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 805 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
772 806
773 807
774/*US 808/*US
775 kapp->invokeMailer( QString::null, QString::null, QString::null, 809 kapp->invokeMailer( QString::null, QString::null, QString::null,
776 QString::null, // subject 810 QString::null, // subject
777 QString::null, // body 811 QString::null, // body
778 QString::null, 812 QString::null,
779 urls ); // attachments 813 urls ); // attachments
780*/ 814*/
781 815
782} 816}
783 817
784/** 818/**
785 Beams the "WhoAmI contact. 819 Beams the "WhoAmI contact.
786*/ 820*/
787void KABCore::beamMySelf() 821void KABCore::beamMySelf()
788{ 822{
789 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 823 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
790 if (!a.isEmpty()) 824 if (!a.isEmpty())
791 { 825 {
792 QStringList uids; 826 QStringList uids;
793 uids << a.uid(); 827 uids << a.uid();
794 828
795 beamVCard(uids); 829 beamVCard(uids);
796 } else { 830 } else {
797 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 831 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
798 832
799 833
800 } 834 }
801} 835}
802void KABCore::updateMainWindow() 836void KABCore::updateMainWindow()
803{ 837{
804 mMainWindow->showMaximized(); 838 mMainWindow->showMaximized();
805 mMainWindow->update(); 839 mMainWindow->update();
806} 840}
807void KABCore::resizeEvent(QResizeEvent* e ) 841void KABCore::resizeEvent(QResizeEvent* e )
808{ 842{
809 if ( !mMiniSplitter ) 843 if ( !mMiniSplitter )
810 return; 844 return;
811 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 845 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
812 if ( QApplication::desktop()->width() >= 480 ) { 846 if ( QApplication::desktop()->width() >= 480 ) {
813 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 847 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
814 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 848 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
815 mMiniSplitter->setOrientation( Qt::Horizontal); 849 mMiniSplitter->setOrientation( Qt::Horizontal);
816 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 850 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
817 } 851 }
818 if ( QApplication::desktop()->width() <= 640 ) { 852 if ( QApplication::desktop()->width() <= 640 ) {
819 mMainWindow->showMinimized(); 853 mMainWindow->showMinimized();
820 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 854 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
821 mViewManager->getFilterAction()->setComboWidth( 150 ); 855 mViewManager->getFilterAction()->setComboWidth( 150 );
822 if ( mIncSearchWidget ) 856 if ( mIncSearchWidget )
823 mIncSearchWidget->setSize(); 857 mIncSearchWidget->setSize();
824 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 858 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
825 } 859 }
826 860
827 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 861 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
828 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 862 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
829 mMiniSplitter->setOrientation( Qt::Vertical ); 863 mMiniSplitter->setOrientation( Qt::Vertical );
830 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 864 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
831 } 865 }
832 if ( QApplication::desktop()->width() <= 640 ) { 866 if ( QApplication::desktop()->width() <= 640 ) {
833 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 867 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
834 mMainWindow->showMinimized(); 868 mMainWindow->showMinimized();
835 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 869 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
836 if ( mIncSearchWidget ) { 870 if ( mIncSearchWidget ) {
837 mIncSearchWidget->setSize(); 871 mIncSearchWidget->setSize();
838 } 872 }
839 } else { 873 } else {
840 mViewManager->getFilterAction()->setComboWidth( 0 ); 874 mViewManager->getFilterAction()->setComboWidth( 0 );
841 } 875 }
842 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 876 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
843 } 877 }
844 } 878 }
845 } 879 }
846 QWidget::resizeEvent( e ); 880 QWidget::resizeEvent( e );
847 881
848} 882}
849void KABCore::export2phone() 883void KABCore::export2phone()
850{ 884{
851 885
852 QStringList uids; 886 QStringList uids;
853 XXPortSelectDialog dlg( this, false, this ); 887 XXPortSelectDialog dlg( this, false, this );
854 if ( dlg.exec() ) 888 if ( dlg.exec() )
855 uids = dlg.uids(); 889 uids = dlg.uids();
856 else 890 else
857 return; 891 return;
858 if ( uids.isEmpty() ) 892 if ( uids.isEmpty() )
859 return; 893 return;
860 // qDebug("count %d ", uids.count()); 894 // qDebug("count %d ", uids.count());
861 895
862 KAex2phonePrefs ex2phone; 896 KAex2phonePrefs ex2phone;
863 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 897 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
864 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 898 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
865 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 899 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
866 900
867 if ( !ex2phone.exec() ) { 901 if ( !ex2phone.exec() ) {
868 return; 902 return;
869 } 903 }
870 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 904 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
871 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 905 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
872 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 906 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
873 907
874 908
875 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 909 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
876 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 910 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
877 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 911 KPimGlobalPrefs::instance()->mEx2PhoneModel );
878 912
879 QString fileName = getPhoneFile(); 913 QString fileName = getPhoneFile();
880 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 914 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
881 return; 915 return;
882 916
883 message(i18n("Exporting to phone...")); 917 message(i18n("Exporting to phone..."));
884 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 918 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
885 919
886} 920}
887QString KABCore::getPhoneFile() 921QString KABCore::getPhoneFile()
888{ 922{
889#ifdef DESKTOP_VERSION 923#ifdef DESKTOP_VERSION
890 return locateLocal("tmp", "phonefile.vcf"); 924 return locateLocal("tmp", "phonefile.vcf");
891#else 925#else
892 return "/tmp/phonefile.vcf"; 926 return "/tmp/phonefile.vcf";
893#endif 927#endif
894 928
895} 929}
896void KABCore::writeToPhone( ) 930void KABCore::writeToPhone( )
897{ 931{
898 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 932 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
899 message(i18n("Export to phone finished!")); 933 message(i18n("Export to phone finished!"));
900 else 934 else
901 qDebug(i18n("KA: Error exporting to phone")); 935 qDebug(i18n("KA: Error exporting to phone"));
902} 936}
903void KABCore::beamVCard() 937void KABCore::beamVCard()
904{ 938{
905 QStringList uids; 939 QStringList uids;
906 XXPortSelectDialog dlg( this, false, this ); 940 XXPortSelectDialog dlg( this, false, this );
907 if ( dlg.exec() ) 941 if ( dlg.exec() )
908 uids = dlg.uids(); 942 uids = dlg.uids();
909 else 943 else
910 return; 944 return;
911 if ( uids.isEmpty() ) 945 if ( uids.isEmpty() )
912 return; 946 return;
913 beamVCard( uids ); 947 beamVCard( uids );
914} 948}
915 949
916 950
917void KABCore::beamVCard(const QStringList& uids) 951void KABCore::beamVCard(const QStringList& uids)
918{ 952{
919 953
920 // LR: we should use the /tmp dir on the Zaurus, 954 // LR: we should use the /tmp dir on the Zaurus,
921 // because: /tmp = RAM, (HOME)/kdepim = flash memory 955 // because: /tmp = RAM, (HOME)/kdepim = flash memory
922 956
923#ifdef DESKTOP_VERSION 957#ifdef DESKTOP_VERSION
924 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 958 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
925#else 959#else
926 QString fileName = "/tmp/kapibeamfile.vcf"; 960 QString fileName = "/tmp/kapibeamfile.vcf";
927#endif 961#endif
928 962
929 KABC::VCardConverter converter; 963 KABC::VCardConverter converter;
930 QString description; 964 QString description;
931 QString datastream; 965 QString datastream;
932 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 966 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
933 KABC::Addressee a = mAddressBook->findByUid( *it ); 967 KABC::Addressee a = mAddressBook->findByUid( *it );
934 968
935 if ( a.isEmpty() ) 969 if ( a.isEmpty() )
936 continue; 970 continue;
937 971
938 if (description.isEmpty()) 972 if (description.isEmpty())
939 description = a.formattedName(); 973 description = a.formattedName();
940 974
941 QString vcard; 975 QString vcard;
942 converter.addresseeToVCard( a, vcard ); 976 converter.addresseeToVCard( a, vcard );
943 int start = 0; 977 int start = 0;
944 int next; 978 int next;
945 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 979 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
946 int semi = vcard.find(";", next); 980 int semi = vcard.find(";", next);
947 int dopp = vcard.find(":", next); 981 int dopp = vcard.find(":", next);
948 int sep; 982 int sep;
949 if ( semi < dopp && semi >= 0 ) 983 if ( semi < dopp && semi >= 0 )
950 sep = semi ; 984 sep = semi ;
951 else 985 else
952 sep = dopp; 986 sep = dopp;
953 datastream +=vcard.mid( start, next - start); 987 datastream +=vcard.mid( start, next - start);
954 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 988 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
955 start = sep; 989 start = sep;
956 } 990 }
957 datastream += vcard.mid( start,vcard.length() ); 991 datastream += vcard.mid( start,vcard.length() );
958 } 992 }
959#ifndef DESKTOP_VERSION 993#ifndef DESKTOP_VERSION
960 QFile outFile(fileName); 994 QFile outFile(fileName);
961 if ( outFile.open(IO_WriteOnly) ) { 995 if ( outFile.open(IO_WriteOnly) ) {
962 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 996 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
963 QTextStream t( &outFile ); // use a text stream 997 QTextStream t( &outFile ); // use a text stream
964 //t.setEncoding( QTextStream::UnicodeUTF8 ); 998 //t.setEncoding( QTextStream::UnicodeUTF8 );
965 t.setEncoding( QTextStream::Latin1 ); 999 t.setEncoding( QTextStream::Latin1 );
966 t <<datastream.latin1(); 1000 t <<datastream.latin1();
967 outFile.close(); 1001 outFile.close();
968 Ir *ir = new Ir( this ); 1002 Ir *ir = new Ir( this );
969 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1003 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
970 ir->send( fileName, description, "text/x-vCard" ); 1004 ir->send( fileName, description, "text/x-vCard" );
971 } else { 1005 } else {
972 qDebug("KA: Error open temp beam file "); 1006 qDebug("KA: Error open temp beam file ");
973 return; 1007 return;
974 } 1008 }
975#endif 1009#endif
976 1010
977} 1011}
978 1012
979void KABCore::beamDone( Ir *ir ) 1013void KABCore::beamDone( Ir *ir )
980{ 1014{
981#ifndef DESKTOP_VERSION 1015#ifndef DESKTOP_VERSION
982 delete ir; 1016 delete ir;
983#endif 1017#endif
984 topLevelWidget()->raise(); 1018 topLevelWidget()->raise();
985 message( i18n("Beaming finished!") ); 1019 message( i18n("Beaming finished!") );
986} 1020}
987 1021
988 1022
989void KABCore::browse( const QString& url ) 1023void KABCore::browse( const QString& url )
990{ 1024{
991#ifndef KAB_EMBEDDED 1025#ifndef KAB_EMBEDDED
992 kapp->invokeBrowser( url ); 1026 kapp->invokeBrowser( url );
993#else //KAB_EMBEDDED 1027#else //KAB_EMBEDDED
994 qDebug("KABCore::browse must be fixed"); 1028 qDebug("KABCore::browse must be fixed");
995#endif //KAB_EMBEDDED 1029#endif //KAB_EMBEDDED
996} 1030}
997 1031
998void KABCore::selectAllContacts() 1032void KABCore::selectAllContacts()
999{ 1033{
1000 mViewManager->setSelected( QString::null, true ); 1034 mViewManager->setSelected( QString::null, true );
1001} 1035}
1002 1036
1003void KABCore::deleteContacts() 1037void KABCore::deleteContacts()
1004{ 1038{
1005 QStringList uidList = mViewManager->selectedUids(); 1039 QStringList uidList = mViewManager->selectedUids();
1006 deleteContacts( uidList ); 1040 deleteContacts( uidList );
1007} 1041}
1008 1042
1009void KABCore::deleteContacts( const QStringList &uids ) 1043void KABCore::deleteContacts( const QStringList &uids )
1010{ 1044{
1011 if ( uids.count() > 0 ) { 1045 if ( uids.count() > 0 ) {
1012 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1046 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1013 UndoStack::instance()->push( command ); 1047 UndoStack::instance()->push( command );
1014 RedoStack::instance()->clear(); 1048 RedoStack::instance()->clear();
1015 1049
1016 // now if we deleted anything, refresh 1050 // now if we deleted anything, refresh
1017 setContactSelected( QString::null ); 1051 setContactSelected( QString::null );
1018 setModified( true ); 1052 setModified( true );
1019 } 1053 }
1020} 1054}
1021 1055
1022void KABCore::copyContacts() 1056void KABCore::copyContacts()
1023{ 1057{
1024 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1058 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1025 1059
1026 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1060 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1027 1061
1028 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1062 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1029 1063
1030 QClipboard *cb = QApplication::clipboard(); 1064 QClipboard *cb = QApplication::clipboard();
1031 cb->setText( clipText ); 1065 cb->setText( clipText );
1032} 1066}
1033 1067
1034void KABCore::cutContacts() 1068void KABCore::cutContacts()
1035{ 1069{
1036 QStringList uidList = mViewManager->selectedUids(); 1070 QStringList uidList = mViewManager->selectedUids();
1037 1071
1038//US if ( uidList.size() > 0 ) { 1072//US if ( uidList.size() > 0 ) {
1039 if ( uidList.count() > 0 ) { 1073 if ( uidList.count() > 0 ) {
1040 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1074 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1041 UndoStack::instance()->push( command ); 1075 UndoStack::instance()->push( command );
1042 RedoStack::instance()->clear(); 1076 RedoStack::instance()->clear();
1043 1077
1044 setModified( true ); 1078 setModified( true );
1045 } 1079 }
1046} 1080}
1047 1081
1048void KABCore::pasteContacts() 1082void KABCore::pasteContacts()
1049{ 1083{
1050 QClipboard *cb = QApplication::clipboard(); 1084 QClipboard *cb = QApplication::clipboard();
1051 1085
1052 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1086 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1053 1087
1054 pasteContacts( list ); 1088 pasteContacts( list );
1055} 1089}
1056 1090
1057void KABCore::pasteContacts( KABC::Addressee::List &list ) 1091void KABCore::pasteContacts( KABC::Addressee::List &list )
1058{ 1092{
1059 KABC::Resource *resource = requestResource( this ); 1093 KABC::Resource *resource = requestResource( this );
1060 KABC::Addressee::List::Iterator it; 1094 KABC::Addressee::List::Iterator it;
1061 for ( it = list.begin(); it != list.end(); ++it ) 1095 for ( it = list.begin(); it != list.end(); ++it )
1062 (*it).setResource( resource ); 1096 (*it).setResource( resource );
1063 1097
1064 PwPasteCommand *command = new PwPasteCommand( this, list ); 1098 PwPasteCommand *command = new PwPasteCommand( this, list );
1065 UndoStack::instance()->push( command ); 1099 UndoStack::instance()->push( command );
1066 RedoStack::instance()->clear(); 1100 RedoStack::instance()->clear();
1067 1101
1068 setModified( true ); 1102 setModified( true );
1069} 1103}
1070 1104
1071void KABCore::setWhoAmI() 1105void KABCore::setWhoAmI()
1072{ 1106{
1073 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1107 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1074 1108
1075 if ( addrList.count() > 1 ) { 1109 if ( addrList.count() > 1 ) {
1076 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1110 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1077 return; 1111 return;
1078 } 1112 }
1079 1113
1080 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1114 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1081 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1115 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1082 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1116 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1083} 1117}
1084void KABCore::editCategories() 1118void KABCore::editCategories()
1085{ 1119{
1086 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1120 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1087 dlg.exec(); 1121 dlg.exec();
1088} 1122}
1089void KABCore::setCategories() 1123void KABCore::setCategories()
1090{ 1124{
1091 1125
1092 QStringList uids; 1126 QStringList uids;
1093 XXPortSelectDialog dlgx( this, false, this ); 1127 XXPortSelectDialog dlgx( this, false, this );
1094 if ( dlgx.exec() ) 1128 if ( dlgx.exec() )
1095 uids = dlgx.uids(); 1129 uids = dlgx.uids();
1096 else 1130 else
1097 return; 1131 return;
1098 if ( uids.isEmpty() ) 1132 if ( uids.isEmpty() )
1099 return; 1133 return;
1100 // qDebug("count %d ", uids.count()); 1134 // qDebug("count %d ", uids.count());
1101 1135
1102 1136
1103 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1137 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1104 if ( !dlg.exec() ) { 1138 if ( !dlg.exec() ) {
1105 message( i18n("Setting categories cancelled") ); 1139 message( i18n("Setting categories cancelled") );
1106 return; 1140 return;
1107 } 1141 }
1108 bool merge = false; 1142 bool merge = false;
1109 QString msg = i18n( "Merge with existing categories?" ); 1143 QString msg = i18n( "Merge with existing categories?" );
1110 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1144 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1111 merge = true; 1145 merge = true;
1112 1146
1113 message( i18n("Setting categories ... please wait!") ); 1147 message( i18n("Setting categories ... please wait!") );
1114 QStringList categories = dlg.selectedCategories(); 1148 QStringList categories = dlg.selectedCategories();
1115 1149
1116 //QStringList uids = mViewManager->selectedUids(); 1150 //QStringList uids = mViewManager->selectedUids();
1117 QStringList::Iterator it; 1151 QStringList::Iterator it;
1118 for ( it = uids.begin(); it != uids.end(); ++it ) { 1152 for ( it = uids.begin(); it != uids.end(); ++it ) {
1119 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1153 KABC::Addressee addr = mAddressBook->findByUid( *it );
1120 if ( !addr.isEmpty() ) { 1154 if ( !addr.isEmpty() ) {
1121 if ( !merge ) 1155 if ( !merge )
1122 addr.setCategories( categories ); 1156 addr.setCategories( categories );
1123 else { 1157 else {
1124 QStringList addrCategories = addr.categories(); 1158 QStringList addrCategories = addr.categories();
1125 QStringList::Iterator catIt; 1159 QStringList::Iterator catIt;
1126 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1160 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1127 if ( !addrCategories.contains( *catIt ) ) 1161 if ( !addrCategories.contains( *catIt ) )
1128 addrCategories.append( *catIt ); 1162 addrCategories.append( *catIt );
1129 } 1163 }
1130 addr.setCategories( addrCategories ); 1164 addr.setCategories( addrCategories );
1131 } 1165 }
1132 mAddressBook->insertAddressee( addr ); 1166 mAddressBook->insertAddressee( addr );
1133 } 1167 }
1134 } 1168 }
1135 1169
1136 if ( uids.count() > 0 ) 1170 if ( uids.count() > 0 )
1137 setModified( true ); 1171 setModified( true );
1138 message( i18n("Setting categories completed!") ); 1172 message( i18n("Setting categories completed!") );
1139} 1173}
1140 1174
1141void KABCore::setSearchFields( const KABC::Field::List &fields ) 1175void KABCore::setSearchFields( const KABC::Field::List &fields )
1142{ 1176{
1143 mIncSearchWidget->setFields( fields ); 1177 mIncSearchWidget->setFields( fields );
1144} 1178}
1145 1179
1146void KABCore::incrementalSearch( const QString& text ) 1180void KABCore::incrementalSearch( const QString& text )
1147{ 1181{
1148 QString stext; 1182 QString stext;
1149 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1183 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1150 stext = "*" + text; 1184 stext = "*" + text;
1151 } else { 1185 } else {
1152 stext = text; 1186 stext = text;
1153 } 1187 }
1154 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1188 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1155} 1189}
1156void KABCore::incrementalSearchJump( const QString& text ) 1190void KABCore::incrementalSearchJump( const QString& text )
1157{ 1191{
1158 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1192 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1159} 1193}
1160 1194
1161void KABCore::setModified() 1195void KABCore::setModified()
1162{ 1196{
1163 setModified( true ); 1197 setModified( true );
1164} 1198}
1165 1199
1166void KABCore::setModifiedWOrefresh() 1200void KABCore::setModifiedWOrefresh()
1167{ 1201{
1168 // qDebug("KABCore::setModifiedWOrefresh() "); 1202 // qDebug("KABCore::setModifiedWOrefresh() ");
1169 mModified = true; 1203 mModified = true;
1170 mActionSave->setEnabled( mModified ); 1204 mActionSave->setEnabled( mModified );
1171 1205
1172 1206
1173} 1207}
1174void KABCore::setModified( bool modified ) 1208void KABCore::setModified( bool modified )
1175{ 1209{
1176 mModified = modified; 1210 mModified = modified;
1177 mActionSave->setEnabled( mModified ); 1211 mActionSave->setEnabled( mModified );
1178 1212
1179 if ( modified ) 1213 if ( modified )
1180 mJumpButtonBar->recreateButtons(); 1214 mJumpButtonBar->recreateButtons();
1181 1215
1182 mViewManager->refreshView(); 1216 mViewManager->refreshView();
1183 1217
1184} 1218}
1185 1219
1186bool KABCore::modified() const 1220bool KABCore::modified() const
1187{ 1221{
1188 return mModified; 1222 return mModified;
1189} 1223}
1190 1224
1191void KABCore::contactModified( const KABC::Addressee &addr ) 1225void KABCore::contactModified( const KABC::Addressee &addr )
1192{ 1226{
1193 addrModified( addr ); 1227 addrModified( addr );
1194#if 0 // debug only 1228#if 0 // debug only
1195 KABC::Addressee ad = addr; 1229 KABC::Addressee ad = addr;
1196 ad.computeCsum( "123"); 1230 ad.computeCsum( "123");
1197#endif 1231#endif
1198} 1232}
1199 1233
1200void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1234void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1201{ 1235{
1202 1236
1203 Command *command = 0; 1237 Command *command = 0;
1204 QString uid; 1238 QString uid;
1205 1239
1206 // check if it exists already 1240 // check if it exists already
1207 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1241 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1208 if ( origAddr.isEmpty() ) 1242 if ( origAddr.isEmpty() )
1209 command = new PwNewCommand( mAddressBook, addr ); 1243 command = new PwNewCommand( mAddressBook, addr );
1210 else { 1244 else {
1211 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1245 command = new PwEditCommand( mAddressBook, origAddr, addr );
1212 uid = addr.uid(); 1246 uid = addr.uid();
1213 } 1247 }
1214 1248
1215 UndoStack::instance()->push( command ); 1249 UndoStack::instance()->push( command );
1216 RedoStack::instance()->clear(); 1250 RedoStack::instance()->clear();
1217 if ( updateDetails ) 1251 if ( updateDetails )
1218 mDetails->setAddressee( addr ); 1252 mDetails->setAddressee( addr );
1219 setModified( true ); 1253 setModified( true );
1220} 1254}
1221 1255
1222void KABCore::newContact() 1256void KABCore::newContact()
1223{ 1257{
1224 1258
1225 1259
1226 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1260 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1227 1261
1228 QPtrList<KRES::Resource> kresResources; 1262 QPtrList<KRES::Resource> kresResources;
1229 QPtrListIterator<KABC::Resource> it( kabcResources ); 1263 QPtrListIterator<KABC::Resource> it( kabcResources );
1230 KABC::Resource *resource; 1264 KABC::Resource *resource;
1231 while ( ( resource = it.current() ) != 0 ) { 1265 while ( ( resource = it.current() ) != 0 ) {
1232 ++it; 1266 ++it;
1233 if ( !resource->readOnly() ) { 1267 if ( !resource->readOnly() ) {
1234 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1268 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1235 if ( res ) 1269 if ( res )
1236 kresResources.append( res ); 1270 kresResources.append( res );
1237 } 1271 }
1238 } 1272 }
1239 1273
1240 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1274 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1241 resource = static_cast<KABC::Resource*>( res ); 1275 resource = static_cast<KABC::Resource*>( res );
1242 1276
1243 if ( resource ) { 1277 if ( resource ) {
1244 KABC::Addressee addr; 1278 KABC::Addressee addr;
1245 addr.setResource( resource ); 1279 addr.setResource( resource );
1246 mEditorDialog->setAddressee( addr ); 1280 mEditorDialog->setAddressee( addr );
1247 mEditorDialog->setCaption( i18n("Edit new contact")); 1281 mEditorDialog->setCaption( i18n("Edit new contact"));
1248 KApplication::execDialog ( mEditorDialog ); 1282 KApplication::execDialog ( mEditorDialog );
1249 1283
1250 } else 1284 } else
1251 return; 1285 return;
1252 1286
1253 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1287 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1254 1288
1255 1289
1256} 1290}
1257 1291
1258void KABCore::addEmail( QString aStr ) 1292void KABCore::addEmail( QString aStr )
1259{ 1293{
1260#ifndef KAB_EMBEDDED 1294#ifndef KAB_EMBEDDED
1261 QString fullName, email; 1295 QString fullName, email;
1262 1296
1263 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1297 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1264 1298
1265 // Try to lookup the addressee matching the email address 1299 // Try to lookup the addressee matching the email address
1266 bool found = false; 1300 bool found = false;
1267 QStringList emailList; 1301 QStringList emailList;
1268 KABC::AddressBook::Iterator it; 1302 KABC::AddressBook::Iterator it;
1269 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1303 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1270 emailList = (*it).emails(); 1304 emailList = (*it).emails();
1271 if ( emailList.contains( email ) > 0 ) { 1305 if ( emailList.contains( email ) > 0 ) {
1272 found = true; 1306 found = true;
1273 (*it).setNameFromString( fullName ); 1307 (*it).setNameFromString( fullName );
1274 editContact( (*it).uid() ); 1308 editContact( (*it).uid() );
1275 } 1309 }
1276 } 1310 }
1277 1311
1278 if ( !found ) { 1312 if ( !found ) {
1279 KABC::Addressee addr; 1313 KABC::Addressee addr;
1280 addr.setNameFromString( fullName ); 1314 addr.setNameFromString( fullName );
1281 addr.insertEmail( email, true ); 1315 addr.insertEmail( email, true );
1282 1316
1283 mAddressBook->insertAddressee( addr ); 1317 mAddressBook->insertAddressee( addr );
1284 mViewManager->refreshView( addr.uid() ); 1318 mViewManager->refreshView( addr.uid() );
1285 editContact( addr.uid() ); 1319 editContact( addr.uid() );
1286 } 1320 }
1287#else //KAB_EMBEDDED 1321#else //KAB_EMBEDDED
1288 qDebug("KABCore::addEmail finsih method"); 1322 qDebug("KABCore::addEmail finsih method");
1289#endif //KAB_EMBEDDED 1323#endif //KAB_EMBEDDED
1290} 1324}
1291 1325
1292void KABCore::importVCard( const KURL &url, bool showPreview ) 1326void KABCore::importVCard( const KURL &url, bool showPreview )
1293{ 1327{
1294 mXXPortManager->importVCard( url, showPreview ); 1328 mXXPortManager->importVCard( url, showPreview );
1295} 1329}
1296void KABCore::importFromOL() 1330void KABCore::importFromOL()
1297{ 1331{
1298#ifdef _OL_IMPORT_ 1332#ifdef _OL_IMPORT_
1299 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1333 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1300 idgl->exec(); 1334 idgl->exec();
1301 KABC::Addressee::List list = idgl->getAddressList(); 1335 KABC::Addressee::List list = idgl->getAddressList();
1302 if ( list.count() > 0 ) { 1336 if ( list.count() > 0 ) {
1303 KABC::Addressee::List listNew; 1337 KABC::Addressee::List listNew;
1304 KABC::Addressee::List listExisting; 1338 KABC::Addressee::List listExisting;
1305 KABC::Addressee::List::Iterator it; 1339 KABC::Addressee::List::Iterator it;
1306 KABC::AddressBook::Iterator iter; 1340 KABC::AddressBook::Iterator iter;
1307 for ( it = list.begin(); it != list.end(); ++it ) { 1341 for ( it = list.begin(); it != list.end(); ++it ) {
1308 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1342 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1309 listNew.append( (*it) ); 1343 listNew.append( (*it) );
1310 else 1344 else
1311 listExisting.append( (*it) ); 1345 listExisting.append( (*it) );
1312 } 1346 }
1313 if ( listExisting.count() > 0 ) 1347 if ( listExisting.count() > 0 )
1314 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1348 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1315 if ( listNew.count() > 0 ) { 1349 if ( listNew.count() > 0 ) {
1316 pasteWithNewUid = false; 1350 pasteWithNewUid = false;
1317 pasteContacts( listNew ); 1351 pasteContacts( listNew );
1318 pasteWithNewUid = true; 1352 pasteWithNewUid = true;
1319 } 1353 }
1320 } 1354 }
1321 delete idgl; 1355 delete idgl;
1322#endif 1356#endif
1323} 1357}
1324 1358
1325void KABCore::importVCard( const QString &vCard, bool showPreview ) 1359void KABCore::importVCard( const QString &vCard, bool showPreview )
1326{ 1360{
1327 mXXPortManager->importVCard( vCard, showPreview ); 1361 mXXPortManager->importVCard( vCard, showPreview );
1328} 1362}
1329 1363
1330//US added a second method without defaultparameter 1364//US added a second method without defaultparameter
1331void KABCore::editContact2() { 1365void KABCore::editContact2() {
1332 editContact( QString::null ); 1366 editContact( QString::null );
1333} 1367}
1334 1368
1335void KABCore::editContact( const QString &uid ) 1369void KABCore::editContact( const QString &uid )
1336{ 1370{
1337 1371
1338 if ( mExtensionManager->isQuickEditVisible() ) 1372 if ( mExtensionManager->isQuickEditVisible() )
1339 return; 1373 return;
1340 1374
1341 // First, locate the contact entry 1375 // First, locate the contact entry
1342 QString localUID = uid; 1376 QString localUID = uid;
1343 if ( localUID.isNull() ) { 1377 if ( localUID.isNull() ) {
1344 QStringList uidList = mViewManager->selectedUids(); 1378 QStringList uidList = mViewManager->selectedUids();
1345 if ( uidList.count() > 0 ) 1379 if ( uidList.count() > 0 )
1346 localUID = *( uidList.at( 0 ) ); 1380 localUID = *( uidList.at( 0 ) );
1347 } 1381 }
1348 1382
1349 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1383 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1350 if ( !addr.isEmpty() ) { 1384 if ( !addr.isEmpty() ) {
1351 mEditorDialog->setAddressee( addr ); 1385 mEditorDialog->setAddressee( addr );
1352 KApplication::execDialog ( mEditorDialog ); 1386 KApplication::execDialog ( mEditorDialog );
1353 } 1387 }
1354} 1388}
1355 1389
1356/** 1390/**
1357 Shows or edits the detail view for the given uid. If the uid is QString::null, 1391 Shows or edits the detail view for the given uid. If the uid is QString::null,
1358 the method will try to find a selected addressee in the view. 1392 the method will try to find a selected addressee in the view.
1359 */ 1393 */
1360void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1394void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1361{ 1395{
1362 if ( mMultipleViewsAtOnce ) 1396 if ( mMultipleViewsAtOnce )
1363 { 1397 {
1364 editContact( uid ); 1398 editContact( uid );
1365 } 1399 }
1366 else 1400 else
1367 { 1401 {
1368 setDetailsVisible( true ); 1402 setDetailsVisible( true );
1369 mActionDetails->setChecked(true); 1403 mActionDetails->setChecked(true);
1370 } 1404 }
1371 1405
1372} 1406}
1373 1407
1374void KABCore::save() 1408void KABCore::save()
1375{ 1409{
1376 if (syncManager->blockSave()) 1410 if (syncManager->blockSave())
1377 return; 1411 return;
1378 if ( !mModified ) 1412 if ( !mModified )
1379 return; 1413 return;
1380 1414
1381 syncManager->setBlockSave(true); 1415 syncManager->setBlockSave(true);
1382 QString text = i18n( "There was an error while attempting to save\n the " 1416 QString text = i18n( "There was an error while attempting to save\n the "
1383 "address book. Please check that some \nother application is " 1417 "address book. Please check that some \nother application is "
1384 "not using it. " ); 1418 "not using it. " );
1385 message(i18n("Saving ... please wait! "), false); 1419 message(i18n("Saving ... please wait! "), false);
1386 //qApp->processEvents(); 1420 //qApp->processEvents();
1387#ifndef KAB_EMBEDDED 1421#ifndef KAB_EMBEDDED
1388 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1422 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1389 if ( !b || !b->save() ) { 1423 if ( !b || !b->save() ) {
1390 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1424 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1391 } 1425 }
1392#else //KAB_EMBEDDED 1426#else //KAB_EMBEDDED
1393 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1427 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1394 if ( !b || !b->save() ) { 1428 if ( !b || !b->save() ) {
1395 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1429 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1396 } 1430 }
1397#endif //KAB_EMBEDDED 1431#endif //KAB_EMBEDDED
1398 1432
1399 message(i18n("Addressbook saved!")); 1433 message(i18n("Addressbook saved!"));
1400 setModified( false ); 1434 setModified( false );
1401 syncManager->setBlockSave(false); 1435 syncManager->setBlockSave(false);
1402} 1436}
1403 1437
1404 1438
1405void KABCore::undo() 1439void KABCore::undo()
1406{ 1440{
1407 UndoStack::instance()->undo(); 1441 UndoStack::instance()->undo();
1408 1442
1409 // Refresh the view 1443 // Refresh the view
1410 mViewManager->refreshView(); 1444 mViewManager->refreshView();
1411} 1445}
1412 1446
1413void KABCore::redo() 1447void KABCore::redo()
1414{ 1448{
1415 RedoStack::instance()->redo(); 1449 RedoStack::instance()->redo();
1416 1450
1417 // Refresh the view 1451 // Refresh the view
1418 mViewManager->refreshView(); 1452 mViewManager->refreshView();
1419} 1453}
1420void KABCore::setJumpButtonBar( bool visible ) 1454void KABCore::setJumpButtonBar( bool visible )
1421{ 1455{
1422 setJumpButtonBarVisible(visible ); 1456 setJumpButtonBarVisible(visible );
1423 saveSettings(); 1457 saveSettings();
1424} 1458}
1425void KABCore::setJumpButtonBarVisible( bool visible ) 1459void KABCore::setJumpButtonBarVisible( bool visible )
1426{ 1460{
1427 if (mMultipleViewsAtOnce) 1461 if (mMultipleViewsAtOnce)
1428 { 1462 {
1429 if ( visible ) 1463 if ( visible )
1430 mJumpButtonBar->show(); 1464 mJumpButtonBar->show();
1431 else 1465 else
1432 mJumpButtonBar->hide(); 1466 mJumpButtonBar->hide();
1433 } 1467 }
1434 else 1468 else
1435 { 1469 {
1436 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1470 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1437 if (mViewManager->isVisible()) 1471 if (mViewManager->isVisible())
1438 { 1472 {
1439 if ( visible ) 1473 if ( visible )
1440 mJumpButtonBar->show(); 1474 mJumpButtonBar->show();
1441 else 1475 else
1442 mJumpButtonBar->hide(); 1476 mJumpButtonBar->hide();
1443 } 1477 }
1444 else 1478 else
1445 { 1479 {
1446 mJumpButtonBar->hide(); 1480 mJumpButtonBar->hide();
1447 } 1481 }
1448 } 1482 }
1449 if ( visible ) { 1483 if ( visible ) {
1450 if ( mIncSearchWidget->currentItem() == 0 ) { 1484 if ( mIncSearchWidget->currentItem() == 0 ) {
1451 message( i18n("Change search field enable jump bar") ); 1485 message( i18n("Change search field enable jump bar") );
1452 } 1486 }
1453 } 1487 }
1454} 1488}
1455 1489
1456 1490
1457void KABCore::setDetailsToState() 1491void KABCore::setDetailsToState()
1458{ 1492{
1459 setDetailsVisible( mActionDetails->isChecked() ); 1493 setDetailsVisible( mActionDetails->isChecked() );
1460} 1494}
1461void KABCore::setDetailsToggle() 1495void KABCore::setDetailsToggle()
1462{ 1496{
1463 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1497 mActionDetails->setChecked( !mActionDetails->isChecked() );
1464 setDetailsToState(); 1498 setDetailsToState();
1465} 1499}
1466 1500
1467 1501
1468 1502
1469void KABCore::setDetailsVisible( bool visible ) 1503void KABCore::setDetailsVisible( bool visible )
1470{ 1504{
1471 if (visible && mDetails->isHidden()) 1505 if (visible && mDetails->isHidden())
1472 { 1506 {
1473 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1507 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1474 if ( addrList.count() > 0 ) 1508 if ( addrList.count() > 0 )
1475 mDetails->setAddressee( addrList[ 0 ] ); 1509 mDetails->setAddressee( addrList[ 0 ] );
1476 } 1510 }
1477 1511
1478 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1512 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1479 // the listview and the detailview. We do that by changing the splitbar size. 1513 // the listview and the detailview. We do that by changing the splitbar size.
1480 if (mMultipleViewsAtOnce) 1514 if (mMultipleViewsAtOnce)
1481 { 1515 {
1482 if ( visible ) 1516 if ( visible )
1483 mDetails->show(); 1517 mDetails->show();
1484 else 1518 else
1485 mDetails->hide(); 1519 mDetails->hide();
1486 } 1520 }
1487 else 1521 else
1488 { 1522 {
1489 if ( visible ) { 1523 if ( visible ) {
1490 mViewManager->hide(); 1524 mViewManager->hide();
1491 mDetails->show(); 1525 mDetails->show();
1492 mIncSearchWidget->setFocus(); 1526 mIncSearchWidget->setFocus();
1493 } 1527 }
1494 else { 1528 else {
1495 mViewManager->show(); 1529 mViewManager->show();
1496 mDetails->hide(); 1530 mDetails->hide();
1497 mViewManager->setFocusAV(); 1531 mViewManager->setFocusAV();
1498 } 1532 }
1499 setJumpButtonBarVisible( !visible ); 1533 setJumpButtonBarVisible( !visible );
1500 } 1534 }
1501 1535
1502} 1536}
1503 1537
1504void KABCore::extensionChanged( int id ) 1538void KABCore::extensionChanged( int id )
1505{ 1539{
1506 //change the details view only for non desktop systems 1540 //change the details view only for non desktop systems
1507#ifndef DESKTOP_VERSION 1541#ifndef DESKTOP_VERSION
1508 1542
1509 if (id == 0) 1543 if (id == 0)
1510 { 1544 {
1511 //the user disabled the extension. 1545 //the user disabled the extension.
1512 1546
1513 if (mMultipleViewsAtOnce) 1547 if (mMultipleViewsAtOnce)
1514 { // enable detailsview again 1548 { // enable detailsview again
1515 setDetailsVisible( true ); 1549 setDetailsVisible( true );
1516 mActionDetails->setChecked( true ); 1550 mActionDetails->setChecked( true );
1517 } 1551 }
1518 else 1552 else
1519 { //go back to the listview 1553 { //go back to the listview
1520 setDetailsVisible( false ); 1554 setDetailsVisible( false );
1521 mActionDetails->setChecked( false ); 1555 mActionDetails->setChecked( false );
1522 mActionDetails->setEnabled(true); 1556 mActionDetails->setEnabled(true);
1523 } 1557 }
1524 1558
1525 } 1559 }
1526 else 1560 else
1527 { 1561 {
1528 //the user enabled the extension. 1562 //the user enabled the extension.
1529 setDetailsVisible( false ); 1563 setDetailsVisible( false );
1530 mActionDetails->setChecked( false ); 1564 mActionDetails->setChecked( false );
1531 1565
1532 if (!mMultipleViewsAtOnce) 1566 if (!mMultipleViewsAtOnce)
1533 { 1567 {
1534 mActionDetails->setEnabled(false); 1568 mActionDetails->setEnabled(false);
1535 } 1569 }
1536 1570
1537 mExtensionManager->setSelectionChanged(); 1571 mExtensionManager->setSelectionChanged();
1538 1572
1539 } 1573 }
1540 1574
1541#endif// DESKTOP_VERSION 1575#endif// DESKTOP_VERSION
1542 1576
1543} 1577}
1544 1578
1545 1579
1546void KABCore::extensionModified( const KABC::Addressee::List &list ) 1580void KABCore::extensionModified( const KABC::Addressee::List &list )
1547{ 1581{
1548 1582
1549 if ( list.count() != 0 ) { 1583 if ( list.count() != 0 ) {
1550 KABC::Addressee::List::ConstIterator it; 1584 KABC::Addressee::List::ConstIterator it;
1551 for ( it = list.begin(); it != list.end(); ++it ) 1585 for ( it = list.begin(); it != list.end(); ++it )
1552 mAddressBook->insertAddressee( *it ); 1586 mAddressBook->insertAddressee( *it );
1553 if ( list.count() > 1 ) 1587 if ( list.count() > 1 )
1554 setModified(); 1588 setModified();
1555 else 1589 else
1556 setModifiedWOrefresh(); 1590 setModifiedWOrefresh();
1557 } 1591 }
1558 if ( list.count() == 0 ) 1592 if ( list.count() == 0 )
1559 mViewManager->refreshView(); 1593 mViewManager->refreshView();
1560 else 1594 else
1561 mViewManager->refreshView( list[ 0 ].uid() ); 1595 mViewManager->refreshView( list[ 0 ].uid() );
1562 1596
1563 1597
1564 1598
1565} 1599}
1566 1600
1567QString KABCore::getNameByPhone( const QString &phone ) 1601QString KABCore::getNameByPhone( const QString &phone )
1568{ 1602{
1569#ifndef KAB_EMBEDDED 1603#ifndef KAB_EMBEDDED
1570 QRegExp r( "[/*/-/ ]" ); 1604 QRegExp r( "[/*/-/ ]" );
1571 QString localPhone( phone ); 1605 QString localPhone( phone );
1572 1606
1573 bool found = false; 1607 bool found = false;
1574 QString ownerName = ""; 1608 QString ownerName = "";
1575 KABC::AddressBook::Iterator iter; 1609 KABC::AddressBook::Iterator iter;
1576 KABC::PhoneNumber::List::Iterator phoneIter; 1610 KABC::PhoneNumber::List::Iterator phoneIter;
1577 KABC::PhoneNumber::List phoneList; 1611 KABC::PhoneNumber::List phoneList;
1578 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1612 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1579 phoneList = (*iter).phoneNumbers(); 1613 phoneList = (*iter).phoneNumbers();
1580 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1614 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1581 ++phoneIter) { 1615 ++phoneIter) {
1582 // Get rid of separator chars so just the numbers are compared. 1616 // Get rid of separator chars so just the numbers are compared.
1583 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1617 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1584 ownerName = (*iter).formattedName(); 1618 ownerName = (*iter).formattedName();
1585 found = true; 1619 found = true;
1586 } 1620 }
1587 } 1621 }
1588 } 1622 }
1589 1623
1590 return ownerName; 1624 return ownerName;
1591#else //KAB_EMBEDDED 1625#else //KAB_EMBEDDED
1592 qDebug("KABCore::getNameByPhone finsih method"); 1626 qDebug("KABCore::getNameByPhone finsih method");
1593 return ""; 1627 return "";
1594#endif //KAB_EMBEDDED 1628#endif //KAB_EMBEDDED
1595 1629
1596} 1630}
1597 1631
1598void KABCore::openConfigDialog() 1632void KABCore::openConfigDialog()
1599{ 1633{
1600 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1634 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1601 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1635 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1602 ConfigureDialog->addModule(kabcfg ); 1636 ConfigureDialog->addModule(kabcfg );
1603 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1637 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1604 ConfigureDialog->addModule(kdelibcfg ); 1638 ConfigureDialog->addModule(kdelibcfg );
1605 1639
1606 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1640 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1607 this, SLOT( configurationChanged() ) ); 1641 this, SLOT( configurationChanged() ) );
1608 connect( ConfigureDialog, SIGNAL( okClicked() ), 1642 connect( ConfigureDialog, SIGNAL( okClicked() ),
1609 this, SLOT( configurationChanged() ) ); 1643 this, SLOT( configurationChanged() ) );
1610 saveSettings(); 1644 saveSettings();
1611#ifndef DESKTOP_VERSION 1645#ifndef DESKTOP_VERSION
1612 ConfigureDialog->showMaximized(); 1646 ConfigureDialog->showMaximized();
1613#endif 1647#endif
1614 if ( ConfigureDialog->exec() ) 1648 if ( ConfigureDialog->exec() )
1615 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1649 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1616 delete ConfigureDialog; 1650 delete ConfigureDialog;
1617} 1651}
1618 1652
1619void KABCore::openLDAPDialog() 1653void KABCore::openLDAPDialog()
1620{ 1654{
1621#ifndef KAB_EMBEDDED 1655#ifndef KAB_EMBEDDED
1622 if ( !mLdapSearchDialog ) { 1656 if ( !mLdapSearchDialog ) {
1623 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1657 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1624 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1658 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1625 SLOT( refreshView() ) ); 1659 SLOT( refreshView() ) );
1626 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1660 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1627 SLOT( setModified() ) ); 1661 SLOT( setModified() ) );
1628 } else 1662 } else
1629 mLdapSearchDialog->restoreSettings(); 1663 mLdapSearchDialog->restoreSettings();
1630 1664
1631 if ( mLdapSearchDialog->isOK() ) 1665 if ( mLdapSearchDialog->isOK() )
1632 mLdapSearchDialog->exec(); 1666 mLdapSearchDialog->exec();
1633#else //KAB_EMBEDDED 1667#else //KAB_EMBEDDED
1634 qDebug("KABCore::openLDAPDialog() finsih method"); 1668 qDebug("KABCore::openLDAPDialog() finsih method");
1635#endif //KAB_EMBEDDED 1669#endif //KAB_EMBEDDED
1636} 1670}
1637 1671
1638void KABCore::print() 1672void KABCore::print()
1639{ 1673{
1640#ifndef KAB_EMBEDDED 1674#ifndef KAB_EMBEDDED
1641 KPrinter printer; 1675 KPrinter printer;
1642 if ( !printer.setup( this ) ) 1676 if ( !printer.setup( this ) )
1643 return; 1677 return;
1644 1678
1645 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1679 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1646 mViewManager->selectedUids(), this ); 1680 mViewManager->selectedUids(), this );
1647 1681
1648 wizard.exec(); 1682 wizard.exec();
1649#else //KAB_EMBEDDED 1683#else //KAB_EMBEDDED
1650 qDebug("KABCore::print() finsih method"); 1684 qDebug("KABCore::print() finsih method");
1651#endif //KAB_EMBEDDED 1685#endif //KAB_EMBEDDED
1652 1686
1653} 1687}
1654 1688
1655 1689
1656void KABCore::addGUIClient( KXMLGUIClient *client ) 1690void KABCore::addGUIClient( KXMLGUIClient *client )
1657{ 1691{
1658 if ( mGUIClient ) 1692 if ( mGUIClient )
1659 mGUIClient->insertChildClient( client ); 1693 mGUIClient->insertChildClient( client );
1660 else 1694 else
1661 KMessageBox::error( this, "no KXMLGUICLient"); 1695 KMessageBox::error( this, "no KXMLGUICLient");
1662} 1696}
1663 1697
1664 1698
1665void KABCore::configurationChanged() 1699void KABCore::configurationChanged()
1666{ 1700{
1667 mExtensionManager->reconfigure(); 1701 mExtensionManager->reconfigure();
1668} 1702}
1669 1703
1670void KABCore::addressBookChanged() 1704void KABCore::addressBookChanged()
1671{ 1705{
1672/*US 1706/*US
1673 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1707 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1674 while ( it.current() ) { 1708 while ( it.current() ) {
1675 if ( it.current()->dirty() ) { 1709 if ( it.current()->dirty() ) {
1676 QString text = i18n( "Data has been changed externally. Unsaved " 1710 QString text = i18n( "Data has been changed externally. Unsaved "
1677 "changes will be lost." ); 1711 "changes will be lost." );
1678 KMessageBox::information( this, text ); 1712 KMessageBox::information( this, text );
1679 } 1713 }
1680 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1714 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1681 ++it; 1715 ++it;
1682 } 1716 }
1683*/ 1717*/
1684 if (mEditorDialog) 1718 if (mEditorDialog)
1685 { 1719 {
1686 if (mEditorDialog->dirty()) 1720 if (mEditorDialog->dirty())
1687 { 1721 {
1688 QString text = i18n( "Data has been changed externally. Unsaved " 1722 QString text = i18n( "Data has been changed externally. Unsaved "
1689 "changes will be lost." ); 1723 "changes will be lost." );
1690 KMessageBox::information( this, text ); 1724 KMessageBox::information( this, text );
1691 } 1725 }
1692 QString currentuid = mEditorDialog->addressee().uid(); 1726 QString currentuid = mEditorDialog->addressee().uid();
1693 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1727 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1694 } 1728 }
1695 mViewManager->refreshView(); 1729 mViewManager->refreshView();
1696 1730
1697 1731
1698} 1732}
1699 1733
1700AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1734AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1701 const char *name ) 1735 const char *name )
1702{ 1736{
1703 1737
1704 if ( mEditorDialog == 0 ) { 1738 if ( mEditorDialog == 0 ) {
1705 mEditorDialog = new AddresseeEditorDialog( this, parent, 1739 mEditorDialog = new AddresseeEditorDialog( this, parent,
1706 name ? name : "editorDialog" ); 1740 name ? name : "editorDialog" );
1707 1741
1708 1742
1709 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1743 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1710 SLOT( contactModified( const KABC::Addressee& ) ) ); 1744 SLOT( contactModified( const KABC::Addressee& ) ) );
1711 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1745 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1712 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1746 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1713 } 1747 }
1714 1748
1715 return mEditorDialog; 1749 return mEditorDialog;
1716} 1750}
1717 1751
1718void KABCore::slotEditorDestroyed( const QString &uid ) 1752void KABCore::slotEditorDestroyed( const QString &uid )
1719{ 1753{
1720 //mEditorDict.remove( uid ); 1754 //mEditorDict.remove( uid );
1721} 1755}
1722 1756
1723void KABCore::initGUI() 1757void KABCore::initGUI()
1724{ 1758{
1725#ifndef KAB_EMBEDDED 1759#ifndef KAB_EMBEDDED
1726 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1760 QHBoxLayout *topLayout = new QHBoxLayout( this );
1727 topLayout->setSpacing( KDialogBase::spacingHint() ); 1761 topLayout->setSpacing( KDialogBase::spacingHint() );
1728 1762
1729 mExtensionBarSplitter = new QSplitter( this ); 1763 mExtensionBarSplitter = new QSplitter( this );
1730 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1764 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1731 1765
1732 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1766 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1733 1767
1734 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1768 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1735 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1769 mIncSearchWidget = new IncSearchWidget( viewSpace );
1736 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1770 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1737 SLOT( incrementalSearch( const QString& ) ) ); 1771 SLOT( incrementalSearch( const QString& ) ) );
1738 1772
1739 mViewManager = new ViewManager( this, viewSpace ); 1773 mViewManager = new ViewManager( this, viewSpace );
1740 viewSpace->setStretchFactor( mViewManager, 1 ); 1774 viewSpace->setStretchFactor( mViewManager, 1 );
1741 1775
1742 mDetails = new ViewContainer( mDetailsSplitter ); 1776 mDetails = new ViewContainer( mDetailsSplitter );
1743 1777
1744 mJumpButtonBar = new JumpButtonBar( this, this ); 1778 mJumpButtonBar = new JumpButtonBar( this, this );
1745 1779
1746 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1780 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1747 1781
1748 topLayout->addWidget( mExtensionBarSplitter ); 1782 topLayout->addWidget( mExtensionBarSplitter );
1749 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1783 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1750 topLayout->addWidget( mJumpButtonBar ); 1784 topLayout->addWidget( mJumpButtonBar );
1751 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1785 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1752 1786
1753 mXXPortManager = new XXPortManager( this, this ); 1787 mXXPortManager = new XXPortManager( this, this );
1754 1788
1755#else //KAB_EMBEDDED 1789#else //KAB_EMBEDDED
1756 //US initialize viewMenu before settingup viewmanager. 1790 //US initialize viewMenu before settingup viewmanager.
1757 // Viewmanager needs this menu to plugin submenues. 1791 // Viewmanager needs this menu to plugin submenues.
1758 viewMenu = new QPopupMenu( this ); 1792 viewMenu = new QPopupMenu( this );
1759 settingsMenu = new QPopupMenu( this ); 1793 settingsMenu = new QPopupMenu( this );
1760 //filterMenu = new QPopupMenu( this ); 1794 //filterMenu = new QPopupMenu( this );
1761 ImportMenu = new QPopupMenu( this ); 1795 ImportMenu = new QPopupMenu( this );
1762 ExportMenu = new QPopupMenu( this ); 1796 ExportMenu = new QPopupMenu( this );
1763 syncMenu = new QPopupMenu( this ); 1797 syncMenu = new QPopupMenu( this );
1764 changeMenu= new QPopupMenu( this ); 1798 changeMenu= new QPopupMenu( this );
1765 beamMenu= new QPopupMenu( this ); 1799 beamMenu= new QPopupMenu( this );
1766 1800
1767//US since we have no splitter for the embedded system, setup 1801//US since we have no splitter for the embedded system, setup
1768// a layout with two frames. One left and one right. 1802// a layout with two frames. One left and one right.
1769 1803
1770 QBoxLayout *topLayout; 1804 QBoxLayout *topLayout;
1771 1805
1772 // = new QHBoxLayout( this ); 1806 // = new QHBoxLayout( this );
1773// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1807// QBoxLayout *topLayout = (QBoxLayout*)layout();
1774 1808
1775// QWidget *mainBox = new QWidget( this ); 1809// QWidget *mainBox = new QWidget( this );
1776// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1810// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1777 1811
1778#ifdef DESKTOP_VERSION 1812#ifdef DESKTOP_VERSION
1779 topLayout = new QHBoxLayout( this ); 1813 topLayout = new QHBoxLayout( this );
1780 1814
1781 1815
1782 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1816 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1783 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1817 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1784 1818
1785 topLayout->addWidget(mMiniSplitter ); 1819 topLayout->addWidget(mMiniSplitter );
1786 1820
1787 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1821 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1788 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1822 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1789 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1823 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1790 mDetails = new ViewContainer( mMiniSplitter ); 1824 mDetails = new ViewContainer( mMiniSplitter );
1791 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1825 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1792#else 1826#else
1793 if ( QApplication::desktop()->width() > 480 ) { 1827 if ( QApplication::desktop()->width() > 480 ) {
1794 topLayout = new QHBoxLayout( this ); 1828 topLayout = new QHBoxLayout( this );
1795 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1829 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1796 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1830 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1797 } else { 1831 } else {
1798 1832
1799 topLayout = new QHBoxLayout( this ); 1833 topLayout = new QHBoxLayout( this );
1800 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1834 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1801 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1802 } 1836 }
1803 1837
1804 topLayout->addWidget(mMiniSplitter ); 1838 topLayout->addWidget(mMiniSplitter );
1805 mViewManager = new ViewManager( this, mMiniSplitter ); 1839 mViewManager = new ViewManager( this, mMiniSplitter );
1806 mDetails = new ViewContainer( mMiniSplitter ); 1840 mDetails = new ViewContainer( mMiniSplitter );
1807 1841
1808 1842
1809 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1843 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1810#endif 1844#endif
1811 //eh->hide(); 1845 //eh->hide();
1812 // topLayout->addWidget(mExtensionManager ); 1846 // topLayout->addWidget(mExtensionManager );
1813 1847
1814 1848
1815/*US 1849/*US
1816#ifndef KAB_NOSPLITTER 1850#ifndef KAB_NOSPLITTER
1817 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1851 QHBoxLayout *topLayout = new QHBoxLayout( this );
1818//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1852//US topLayout->setSpacing( KDialogBase::spacingHint() );
1819 topLayout->setSpacing( 10 ); 1853 topLayout->setSpacing( 10 );
1820 1854
1821 mDetailsSplitter = new QSplitter( this ); 1855 mDetailsSplitter = new QSplitter( this );
1822 1856
1823 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1857 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1824 1858
1825 mViewManager = new ViewManager( this, viewSpace ); 1859 mViewManager = new ViewManager( this, viewSpace );
1826 viewSpace->setStretchFactor( mViewManager, 1 ); 1860 viewSpace->setStretchFactor( mViewManager, 1 );
1827 1861
1828 mDetails = new ViewContainer( mDetailsSplitter ); 1862 mDetails = new ViewContainer( mDetailsSplitter );
1829 1863
1830 topLayout->addWidget( mDetailsSplitter ); 1864 topLayout->addWidget( mDetailsSplitter );
1831 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1865 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1832#else //KAB_NOSPLITTER 1866#else //KAB_NOSPLITTER
1833 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1867 QHBoxLayout *topLayout = new QHBoxLayout( this );
1834//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1868//US topLayout->setSpacing( KDialogBase::spacingHint() );
1835 topLayout->setSpacing( 10 ); 1869 topLayout->setSpacing( 10 );
1836 1870
1837// mDetailsSplitter = new QSplitter( this ); 1871// mDetailsSplitter = new QSplitter( this );
1838 1872
1839 QVBox *viewSpace = new QVBox( this ); 1873 QVBox *viewSpace = new QVBox( this );
1840 1874
1841 mViewManager = new ViewManager( this, viewSpace ); 1875 mViewManager = new ViewManager( this, viewSpace );
1842 viewSpace->setStretchFactor( mViewManager, 1 ); 1876 viewSpace->setStretchFactor( mViewManager, 1 );
1843 1877
1844 mDetails = new ViewContainer( this ); 1878 mDetails = new ViewContainer( this );
1845 1879
1846 topLayout->addWidget( viewSpace ); 1880 topLayout->addWidget( viewSpace );
1847// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1881// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1848 topLayout->addWidget( mDetails ); 1882 topLayout->addWidget( mDetails );
1849#endif //KAB_NOSPLITTER 1883#endif //KAB_NOSPLITTER
1850*/ 1884*/
1851 1885
1852 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1886 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1853 syncManager->setBlockSave(false); 1887 syncManager->setBlockSave(false);
1854 1888
1855 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1889 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1856 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1890 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1857 QString sync_file = sentSyncFile(); 1891 QString sync_file = sentSyncFile();
1858 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1892 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1859 syncManager->setDefaultFileName( sync_file ); 1893 syncManager->setDefaultFileName( sync_file );
1860 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1894 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1861 1895
1862#endif //KAB_EMBEDDED 1896#endif //KAB_EMBEDDED
1863 initActions(); 1897 initActions();
1864 1898
1865#ifdef KAB_EMBEDDED 1899#ifdef KAB_EMBEDDED
1866 addActionsManually(); 1900 addActionsManually();
1867 //US make sure the export and import menues are initialized before creating the xxPortManager. 1901 //US make sure the export and import menues are initialized before creating the xxPortManager.
1868 mXXPortManager = new XXPortManager( this, this ); 1902 mXXPortManager = new XXPortManager( this, this );
1869 1903
1870 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1904 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1871 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1905 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1872 // mActionQuit->plug ( mMainWindow->toolBar()); 1906 // mActionQuit->plug ( mMainWindow->toolBar());
1873 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1907 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1874 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1908 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1875 // mIncSearchWidget->hide(); 1909 // mIncSearchWidget->hide();
1876 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1910 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1877 SLOT( incrementalSearch( const QString& ) ) ); 1911 SLOT( incrementalSearch( const QString& ) ) );
1878 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1912 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1879 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1913 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1880 1914
1881 mJumpButtonBar = new JumpButtonBar( this, this ); 1915 mJumpButtonBar = new JumpButtonBar( this, this );
1882 1916
1883 topLayout->addWidget( mJumpButtonBar ); 1917 topLayout->addWidget( mJumpButtonBar );
1884//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1918//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1885 1919
1886// mMainWindow->getIconToolBar()->raise(); 1920// mMainWindow->getIconToolBar()->raise();
1887 1921
1888#endif //KAB_EMBEDDED 1922#endif //KAB_EMBEDDED
1889 1923
1890} 1924}
1891void KABCore::initActions() 1925void KABCore::initActions()
1892{ 1926{
1893//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1927//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1894 1928
1895#ifndef KAB_EMBEDDED 1929#ifndef KAB_EMBEDDED
1896 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1930 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1897 SLOT( clipboardDataChanged() ) ); 1931 SLOT( clipboardDataChanged() ) );
1898#endif //KAB_EMBEDDED 1932#endif //KAB_EMBEDDED
1899 1933
1900 // file menu 1934 // file menu
1901 1935
1902 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1936 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1903 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1937 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1904 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1938 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1905 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1939 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1906 1940
1907 1941
1908 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1942 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1909 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1943 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1910 1944
1911 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1945 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1912 SLOT( save() ), actionCollection(), "file_sync" ); 1946 SLOT( save() ), actionCollection(), "file_sync" );
1913 1947
1914 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1948 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1915 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1949 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1916 1950
1917 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1951 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1918 this, SLOT( mailVCard() ), 1952 this, SLOT( mailVCard() ),
1919 actionCollection(), "file_mail_vcard"); 1953 actionCollection(), "file_mail_vcard");
1920 1954
1921 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1955 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1922 SLOT( export2phone() ), actionCollection(), 1956 SLOT( export2phone() ), actionCollection(),
1923 "kaddressbook_ex2phone" ); 1957 "kaddressbook_ex2phone" );
1924 1958
1925 mActionBeamVCard = 0; 1959 mActionBeamVCard = 0;
1926 mActionBeam = 0; 1960 mActionBeam = 0;
1927 1961
1928#ifndef DESKTOP_VERSION 1962#ifndef DESKTOP_VERSION
1929 if ( Ir::supported() ) { 1963 if ( Ir::supported() ) {
1930 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1964 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1931 SLOT( beamVCard() ), actionCollection(), 1965 SLOT( beamVCard() ), actionCollection(),
1932 "kaddressbook_beam_vcard" ); 1966 "kaddressbook_beam_vcard" );
1933 1967
1934 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1968 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1935 SLOT( beamMySelf() ), actionCollection(), 1969 SLOT( beamMySelf() ), actionCollection(),
1936 "kaddressbook_beam_myself" ); 1970 "kaddressbook_beam_myself" );
1937 } 1971 }
1938#endif 1972#endif
1939 1973
1940 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1974 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1941 this, SLOT( editContact2() ), 1975 this, SLOT( editContact2() ),
1942 actionCollection(), "file_properties" ); 1976 actionCollection(), "file_properties" );
1943 1977
1944#ifdef KAB_EMBEDDED 1978#ifdef KAB_EMBEDDED
1945 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1979 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1946 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1980 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1947 mMainWindow, SLOT( exit() ), 1981 mMainWindow, SLOT( exit() ),
1948 actionCollection(), "quit" ); 1982 actionCollection(), "quit" );
1949#endif //KAB_EMBEDDED 1983#endif //KAB_EMBEDDED
1950 1984
1951 // edit menu 1985 // edit menu
1952 if ( mIsPart ) { 1986 if ( mIsPart ) {
1953 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1987 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1954 SLOT( copyContacts() ), actionCollection(), 1988 SLOT( copyContacts() ), actionCollection(),
1955 "kaddressbook_copy" ); 1989 "kaddressbook_copy" );
1956 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1990 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1957 SLOT( cutContacts() ), actionCollection(), 1991 SLOT( cutContacts() ), actionCollection(),
1958 "kaddressbook_cut" ); 1992 "kaddressbook_cut" );
1959 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1993 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1960 SLOT( pasteContacts() ), actionCollection(), 1994 SLOT( pasteContacts() ), actionCollection(),
1961 "kaddressbook_paste" ); 1995 "kaddressbook_paste" );
1962 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1996 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1963 SLOT( selectAllContacts() ), actionCollection(), 1997 SLOT( selectAllContacts() ), actionCollection(),
1964 "kaddressbook_select_all" ); 1998 "kaddressbook_select_all" );
1965 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1999 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1966 SLOT( undo() ), actionCollection(), 2000 SLOT( undo() ), actionCollection(),
1967 "kaddressbook_undo" ); 2001 "kaddressbook_undo" );
1968 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2002 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1969 this, SLOT( redo() ), actionCollection(), 2003 this, SLOT( redo() ), actionCollection(),
1970 "kaddressbook_redo" ); 2004 "kaddressbook_redo" );
1971 } else { 2005 } else {
1972 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2006 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1973 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2007 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1974 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2008 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1975 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2009 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1976 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2010 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1977 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2011 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1978 } 2012 }
1979 2013
1980 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2014 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1981 Key_Delete, this, SLOT( deleteContacts() ), 2015 Key_Delete, this, SLOT( deleteContacts() ),
1982 actionCollection(), "edit_delete" ); 2016 actionCollection(), "edit_delete" );
1983 2017
1984 mActionUndo->setEnabled( false ); 2018 mActionUndo->setEnabled( false );
1985 mActionRedo->setEnabled( false ); 2019 mActionRedo->setEnabled( false );
1986 2020
1987 // settings menu 2021 // settings menu
1988#ifdef KAB_EMBEDDED 2022#ifdef KAB_EMBEDDED
1989//US special menuentry to configure the addressbook resources. On KDE 2023//US special menuentry to configure the addressbook resources. On KDE
1990// you do that through the control center !!! 2024// you do that through the control center !!!
1991 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2025 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1992 SLOT( configureResources() ), actionCollection(), 2026 SLOT( configureResources() ), actionCollection(),
1993 "kaddressbook_configure_resources" ); 2027 "kaddressbook_configure_resources" );
1994#endif //KAB_EMBEDDED 2028#endif //KAB_EMBEDDED
1995 2029
1996 if ( mIsPart ) { 2030 if ( mIsPart ) {
1997 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2031 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1998 SLOT( openConfigDialog() ), actionCollection(), 2032 SLOT( openConfigDialog() ), actionCollection(),
1999 "kaddressbook_configure" ); 2033 "kaddressbook_configure" );
2000 2034
2001 //US not implemented yet 2035 //US not implemented yet
2002 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2036 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2003 // this, SLOT( configureKeyBindings() ), actionCollection(), 2037 // this, SLOT( configureKeyBindings() ), actionCollection(),
2004 // "kaddressbook_configure_shortcuts" ); 2038 // "kaddressbook_configure_shortcuts" );
2005#ifdef KAB_EMBEDDED 2039#ifdef KAB_EMBEDDED
2006 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2040 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2007 mActionConfigureToolbars->setEnabled( false ); 2041 mActionConfigureToolbars->setEnabled( false );
2008#endif //KAB_EMBEDDED 2042#endif //KAB_EMBEDDED
2009 2043
2010 } else { 2044 } else {
2011 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 2045 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
2012 2046
2013 //US not implemented yet 2047 //US not implemented yet
2014 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 2048 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
2015 } 2049 }
2016 2050
2017 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2051 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2018 actionCollection(), "options_show_jump_bar" ); 2052 actionCollection(), "options_show_jump_bar" );
2019 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2053 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2020 2054
2021 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2055 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2022 actionCollection(), "options_show_details" ); 2056 actionCollection(), "options_show_details" );
2023 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2057 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2024 2058
2025 2059
2026 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2060 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2027 SLOT( toggleBeamReceive() ), actionCollection(), 2061 SLOT( toggleBeamReceive() ), actionCollection(),
2028 "kaddressbook_beam_rec" ); 2062 "kaddressbook_beam_rec" );
2029 2063
2030 2064
2031 // misc 2065 // misc
2032 // only enable LDAP lookup if we can handle the protocol 2066 // only enable LDAP lookup if we can handle the protocol
2033#ifndef KAB_EMBEDDED 2067#ifndef KAB_EMBEDDED
2034 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2068 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2035 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2069 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2036 this, SLOT( openLDAPDialog() ), actionCollection(), 2070 this, SLOT( openLDAPDialog() ), actionCollection(),
2037 "ldap_lookup" ); 2071 "ldap_lookup" );
2038 } 2072 }
2039#else //KAB_EMBEDDED 2073#else //KAB_EMBEDDED
2040 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2074 //qDebug("KABCore::initActions() LDAP has to be implemented");
2041#endif //KAB_EMBEDDED 2075#endif //KAB_EMBEDDED
2042 2076
2043 2077
2044 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2078 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2045 SLOT( setWhoAmI() ), actionCollection(), 2079 SLOT( setWhoAmI() ), actionCollection(),
2046 "set_personal" ); 2080 "set_personal" );
2047 2081
2048 2082
2049 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2083 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2050 SLOT( setCategories() ), actionCollection(), 2084 SLOT( setCategories() ), actionCollection(),
2051 "edit_set_categories" ); 2085 "edit_set_categories" );
2052 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2086 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2053 SLOT( editCategories() ), actionCollection(), 2087 SLOT( editCategories() ), actionCollection(),
2054 "edit__categories" ); 2088 "edit__categories" );
2055 2089
2056 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2090 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2057 SLOT( removeVoice() ), actionCollection(), 2091 SLOT( removeVoice() ), actionCollection(),
2058 "remove_voice" ); 2092 "remove_voice" );
2059 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2093 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2060 SLOT( setFormattedName() ), actionCollection(), 2094 SLOT( setFormattedName() ), actionCollection(),
2061 "set_formatted" ); 2095 "set_formatted" );
2062 2096
2063 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2097 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2064 SLOT( manageCategories() ), actionCollection(), 2098 SLOT( manageCategories() ), actionCollection(),
2065 "remove_voice" ); 2099 "remove_voice" );
2066 2100
2067 2101
2068 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2102 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2069 SLOT( importFromOL() ), actionCollection(), 2103 SLOT( importFromOL() ), actionCollection(),
2070 "import_OL" ); 2104 "import_OL" );
2071#ifdef KAB_EMBEDDED 2105#ifdef KAB_EMBEDDED
2072 mActionLicence = new KAction( i18n( "Licence" ), 0, 2106 mActionLicence = new KAction( i18n( "Licence" ), 0,
2073 this, SLOT( showLicence() ), actionCollection(), 2107 this, SLOT( showLicence() ), actionCollection(),
2074 "licence_about_data" ); 2108 "licence_about_data" );
2075 mActionFaq = new KAction( i18n( "Faq" ), 0, 2109 mActionFaq = new KAction( i18n( "Faq" ), 0,
2076 this, SLOT( faq() ), actionCollection(), 2110 this, SLOT( faq() ), actionCollection(),
2077 "faq_about_data" ); 2111 "faq_about_data" );
2078 mActionWN = new KAction( i18n( "What's New?" ), 0, 2112 mActionWN = new KAction( i18n( "What's New?" ), 0,
2079 this, SLOT( whatsnew() ), actionCollection(), 2113 this, SLOT( whatsnew() ), actionCollection(),
2080 "wn" ); 2114 "wn" );
2081 2115
2082 2116
2083 2117
2084 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2118 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2085 this, SLOT( storagehowto() ), actionCollection(), 2119 this, SLOT( storagehowto() ), actionCollection(),
2086 "storage" ); 2120 "storage" );
2087 2121
2088 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2122 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2089 this, SLOT( synchowto() ), actionCollection(), 2123 this, SLOT( synchowto() ), actionCollection(),
2090 "sync" ); 2124 "sync" );
2091 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2125 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2092 this, SLOT( kdesynchowto() ), actionCollection(), 2126 this, SLOT( kdesynchowto() ), actionCollection(),
2093 "kdesync" ); 2127 "kdesync" );
2094 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2128 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2095 this, SLOT( multisynchowto() ), actionCollection(), 2129 this, SLOT( multisynchowto() ), actionCollection(),
2096 "multisync" ); 2130 "multisync" );
2097 2131
2098 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2132 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2099 this, SLOT( createAboutData() ), actionCollection(), 2133 this, SLOT( createAboutData() ), actionCollection(),
2100 "kaddressbook_about_data" ); 2134 "kaddressbook_about_data" );
2101#endif //KAB_EMBEDDED 2135#endif //KAB_EMBEDDED
2102 2136
2103 clipboardDataChanged(); 2137 clipboardDataChanged();
2104 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2138 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2105 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2139 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2106} 2140}
2107 2141
2108//US we need this function, to plug all actions into the correct menues. 2142//US we need this function, to plug all actions into the correct menues.
2109// KDE uses a XML format to plug the actions, but we work her without this overhead. 2143// KDE uses a XML format to plug the actions, but we work her without this overhead.
2110void KABCore::addActionsManually() 2144void KABCore::addActionsManually()
2111{ 2145{
2112//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2146//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2113 2147
2114#ifdef KAB_EMBEDDED 2148#ifdef KAB_EMBEDDED
2115 QPopupMenu *fileMenu = new QPopupMenu( this ); 2149 QPopupMenu *fileMenu = new QPopupMenu( this );
2116 QPopupMenu *editMenu = new QPopupMenu( this ); 2150 QPopupMenu *editMenu = new QPopupMenu( this );
2117 QPopupMenu *helpMenu = new QPopupMenu( this ); 2151 QPopupMenu *helpMenu = new QPopupMenu( this );
2118 2152
2119 KToolBar* tb = mMainWindow->toolBar(); 2153 KToolBar* tb = mMainWindow->toolBar();
2120 mMainWindow->setToolBarsMovable (false ); 2154 mMainWindow->setToolBarsMovable (false );
2121#ifndef DESKTOP_VERSION 2155#ifndef DESKTOP_VERSION
2122 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2156 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2123#endif 2157#endif
2124 QMenuBar* mb = mMainWindow->menuBar(); 2158 QMenuBar* mb = mMainWindow->menuBar();
2125 2159
2126 //US setup menubar. 2160 //US setup menubar.
2127 //Disable the following block if you do not want to have a menubar. 2161 //Disable the following block if you do not want to have a menubar.
2128 mb->insertItem( i18n("&File"), fileMenu ); 2162 mb->insertItem( i18n("&File"), fileMenu );
2129 mb->insertItem( i18n("&Edit"), editMenu ); 2163 mb->insertItem( i18n("&Edit"), editMenu );
2130 mb->insertItem( i18n("&View"), viewMenu ); 2164 mb->insertItem( i18n("&View"), viewMenu );
2131 mb->insertItem( i18n("&Settings"), settingsMenu ); 2165 mb->insertItem( i18n("&Settings"), settingsMenu );
2132#ifdef DESKTOP_VERSION 2166#ifdef DESKTOP_VERSION
2133 mb->insertItem( i18n("Synchronize"), syncMenu ); 2167 mb->insertItem( i18n("Synchronize"), syncMenu );
2134#else 2168#else
2135 mb->insertItem( i18n("Sync"), syncMenu ); 2169 mb->insertItem( i18n("Sync"), syncMenu );
2136#endif 2170#endif
2137 //mb->insertItem( i18n("&Change"), changeMenu ); 2171 //mb->insertItem( i18n("&Change"), changeMenu );
2138 mb->insertItem( i18n("&Help"), helpMenu ); 2172 mb->insertItem( i18n("&Help"), helpMenu );
2139 mIncSearchWidget = new IncSearchWidget( tb ); 2173 mIncSearchWidget = new IncSearchWidget( tb );
2140 // tb->insertWidget(-1, 0, mIncSearchWidget); 2174 // tb->insertWidget(-1, 0, mIncSearchWidget);
2141#ifndef DESKTOP_VERSION 2175#ifndef DESKTOP_VERSION
2142 } else { 2176 } else {
2143 //US setup toolbar 2177 //US setup toolbar
2144 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2178 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2145 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2179 QPopupMenu *popupBarTB = new QPopupMenu( this );
2146 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2180 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2147 tb->insertWidget(-1, 0, menuBarTB); 2181 tb->insertWidget(-1, 0, menuBarTB);
2148 mIncSearchWidget = new IncSearchWidget( tb ); 2182 mIncSearchWidget = new IncSearchWidget( tb );
2149 tb->enableMoving(false); 2183 tb->enableMoving(false);
2150 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2184 popupBarTB->insertItem( i18n("&File"), fileMenu );
2151 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2185 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2152 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2186 popupBarTB->insertItem( i18n("&View"), viewMenu );
2153 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2187 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2154 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2188 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2155 mViewManager->getFilterAction()->plug ( popupBarTB); 2189 mViewManager->getFilterAction()->plug ( popupBarTB);
2156 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2190 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2157 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2191 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2158 if (QApplication::desktop()->width() > 320 ) { 2192 if (QApplication::desktop()->width() > 320 ) {
2159 // mViewManager->getFilterAction()->plug ( tb); 2193 // mViewManager->getFilterAction()->plug ( tb);
2160 } 2194 }
2161 } 2195 }
2162#endif 2196#endif
2163 mIncSearchWidget->setSize(); 2197 mIncSearchWidget->setSize();
2164 // mActionQuit->plug ( mMainWindow->toolBar()); 2198 // mActionQuit->plug ( mMainWindow->toolBar());
2165 2199
2166 2200
2167 2201
2168 //US Now connect the actions with the menue entries. 2202 //US Now connect the actions with the menue entries.
2169#ifdef DESKTOP_VERSION 2203#ifdef DESKTOP_VERSION
2170 mActionPrint->plug( fileMenu ); 2204 mActionPrint->plug( fileMenu );
2171 mActionPrintDetails->plug( fileMenu ); 2205 mActionPrintDetails->plug( fileMenu );
2172 fileMenu->insertSeparator(); 2206 fileMenu->insertSeparator();
2173#endif 2207#endif
2174 mActionMail->plug( fileMenu ); 2208 mActionMail->plug( fileMenu );
2175 fileMenu->insertSeparator(); 2209 fileMenu->insertSeparator();
2176 2210
2177 mActionNewContact->plug( editMenu ); 2211 mActionNewContact->plug( editMenu );
2178 mActionNewContact->plug( tb ); 2212 mActionNewContact->plug( tb );
2179 2213
2180 mActionEditAddressee->plug( editMenu ); 2214 mActionEditAddressee->plug( editMenu );
2181 editMenu->insertSeparator(); 2215 editMenu->insertSeparator();
2182 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2216 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2183 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2217 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2184 mActionEditAddressee->plug( tb ); 2218 mActionEditAddressee->plug( tb );
2185 2219
2186 // fileMenu->insertSeparator(); 2220 // fileMenu->insertSeparator();
2187 mActionSave->plug( fileMenu ); 2221 mActionSave->plug( fileMenu );
2188 fileMenu->insertItem( "&Import", ImportMenu ); 2222 fileMenu->insertItem( "&Import", ImportMenu );
2189 fileMenu->insertItem( "&Export", ExportMenu ); 2223 fileMenu->insertItem( "&Export", ExportMenu );
2190 editMenu->insertItem( i18n("&Change"), changeMenu ); 2224 editMenu->insertItem( i18n("&Change"), changeMenu );
2191 editMenu->insertSeparator(); 2225 editMenu->insertSeparator();
2192#ifndef DESKTOP_VERSION 2226#ifndef DESKTOP_VERSION
2193 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2227 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2194#endif 2228#endif
2195#if 0 2229#if 0
2196 // PENDING fix MailVCard 2230 // PENDING fix MailVCard
2197 fileMenu->insertSeparator(); 2231 fileMenu->insertSeparator();
2198 mActionMailVCard->plug( fileMenu ); 2232 mActionMailVCard->plug( fileMenu );
2199#endif 2233#endif
2200#ifndef DESKTOP_VERSION 2234#ifndef DESKTOP_VERSION
2201 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2235 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2202 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2236 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2203 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2237 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2204#endif 2238#endif
2205 fileMenu->insertSeparator(); 2239 fileMenu->insertSeparator();
2206 mActionQuit->plug( fileMenu ); 2240 mActionQuit->plug( fileMenu );
2207#ifdef _OL_IMPORT_ 2241#ifdef _OL_IMPORT_
2208 mActionImportOL->plug( ImportMenu ); 2242 mActionImportOL->plug( ImportMenu );
2209#endif 2243#endif
2210 // edit menu 2244 // edit menu
2211 mActionUndo->plug( editMenu ); 2245 mActionUndo->plug( editMenu );
2212 mActionRedo->plug( editMenu ); 2246 mActionRedo->plug( editMenu );
2213 editMenu->insertSeparator(); 2247 editMenu->insertSeparator();
2214 mActionCut->plug( editMenu ); 2248 mActionCut->plug( editMenu );
2215 mActionCopy->plug( editMenu ); 2249 mActionCopy->plug( editMenu );
2216 mActionPaste->plug( editMenu ); 2250 mActionPaste->plug( editMenu );
2217 mActionDelete->plug( editMenu ); 2251 mActionDelete->plug( editMenu );
2218 editMenu->insertSeparator(); 2252 editMenu->insertSeparator();
2219 mActionSelectAll->plug( editMenu ); 2253 mActionSelectAll->plug( editMenu );
2220 2254
2221 mActionSetFormattedName->plug( changeMenu ); 2255 mActionSetFormattedName->plug( changeMenu );
2222 mActionRemoveVoice->plug( changeMenu ); 2256 mActionRemoveVoice->plug( changeMenu );
2223 // settingsmings menu 2257 // settingsmings menu
2224//US special menuentry to configure the addressbook resources. On KDE 2258//US special menuentry to configure the addressbook resources. On KDE
2225// you do that through the control center !!! 2259// you do that through the control center !!!
2226 // settingsMenu->insertSeparator(); 2260 // settingsMenu->insertSeparator();
2227 2261
2228 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2262 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2229 mActionConfigResources->plug( settingsMenu,1 ); 2263 mActionConfigResources->plug( settingsMenu,1 );
2230 settingsMenu->insertSeparator(2); 2264 settingsMenu->insertSeparator(2);
2231 2265
2232 if ( mIsPart ) { 2266 if ( mIsPart ) {
2233 //US not implemented yet 2267 //US not implemented yet
2234 //mActionConfigShortcuts->plug( settingsMenu ); 2268 //mActionConfigShortcuts->plug( settingsMenu );
2235 //mActionConfigureToolbars->plug( settingsMenu ); 2269 //mActionConfigureToolbars->plug( settingsMenu );
2236 2270
2237 } else { 2271 } else {
2238 //US not implemented yet 2272 //US not implemented yet
2239 //mActionKeyBindings->plug( settingsMenu ); 2273 //mActionKeyBindings->plug( settingsMenu );
2240 } 2274 }
2241 2275
2242 mActionEditCategories->plug( settingsMenu ); 2276 mActionEditCategories->plug( settingsMenu );
2243 mActionManageCategories->plug( settingsMenu ); 2277 mActionManageCategories->plug( settingsMenu );
2244 mActionJumpBar->plug( viewMenu,0 ); 2278 mActionJumpBar->plug( viewMenu,0 );
2245 mActionDetails->plug( viewMenu,0 ); 2279 mActionDetails->plug( viewMenu,0 );
2246 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2280 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2247 mActionDetails->plug( tb ); 2281 mActionDetails->plug( tb );
2248 settingsMenu->insertSeparator(); 2282 settingsMenu->insertSeparator();
2249#ifndef DESKTOP_VERSION 2283#ifndef DESKTOP_VERSION
2250 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2284 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2251 settingsMenu->insertSeparator(); 2285 settingsMenu->insertSeparator();
2252#endif 2286#endif
2253 2287
2254 mActionWhoAmI->plug( settingsMenu ); 2288 mActionWhoAmI->plug( settingsMenu );
2255 //mActionEditCategories->plug( changeMenu ); 2289 //mActionEditCategories->plug( changeMenu );
2256 mActionCategories->plug( changeMenu ); 2290 mActionCategories->plug( changeMenu );
2257 //mActionManageCategories->plug( changeMenu ); 2291 //mActionManageCategories->plug( changeMenu );
2258 2292
2259 //mActionCategories->plug( settingsMenu ); 2293 //mActionCategories->plug( settingsMenu );
2260 2294
2261 2295
2262 mActionWN->plug( helpMenu ); 2296 mActionWN->plug( helpMenu );
2263 mActionStorageHowto->plug( helpMenu ); 2297 mActionStorageHowto->plug( helpMenu );
2264 mActionSyncHowto->plug( helpMenu ); 2298 mActionSyncHowto->plug( helpMenu );
2265 mActionKdeSyncHowto->plug( helpMenu ); 2299 mActionKdeSyncHowto->plug( helpMenu );
2266 mActionMultiSyncHowto->plug( helpMenu ); 2300 mActionMultiSyncHowto->plug( helpMenu );
2267 mActionFaq->plug( helpMenu ); 2301 mActionFaq->plug( helpMenu );
2268 mActionLicence->plug( helpMenu ); 2302 mActionLicence->plug( helpMenu );
2269 mActionAboutKAddressbook->plug( helpMenu ); 2303 mActionAboutKAddressbook->plug( helpMenu );
2270 2304
2271 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2305 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2272 2306
2273 mActionSave->plug( tb ); 2307 mActionSave->plug( tb );
2274 mViewManager->getFilterAction()->plug ( tb); 2308 mViewManager->getFilterAction()->plug ( tb);
2275 //LR hide filteraction on started in 480x640 2309 //LR hide filteraction on started in 480x640
2276 if (QApplication::desktop()->width() == 480 ) { 2310 if (QApplication::desktop()->width() == 480 ) {
2277 mViewManager->getFilterAction()->setComboWidth( 0 ); 2311 mViewManager->getFilterAction()->setComboWidth( 0 );
2278 } 2312 }
2279 mActionUndo->plug( tb ); 2313 mActionUndo->plug( tb );
2280 mActionDelete->plug( tb ); 2314 mActionDelete->plug( tb );
2281 mActionRedo->plug( tb ); 2315 mActionRedo->plug( tb );
2282 } else { 2316 } else {
2283 mActionSave->plug( tb ); 2317 mActionSave->plug( tb );
2284 tb->enableMoving(false); 2318 tb->enableMoving(false);
2285 } 2319 }
2286 //mActionQuit->plug ( tb ); 2320 //mActionQuit->plug ( tb );
2287 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2321 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2288 2322
2289 //US link the searchwidget first to this. 2323 //US link the searchwidget first to this.
2290 // The real linkage to the toolbar happens later. 2324 // The real linkage to the toolbar happens later.
2291//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2325//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2292//US tb->insertItem( mIncSearchWidget ); 2326//US tb->insertItem( mIncSearchWidget );
2293/*US 2327/*US
2294 mIncSearchWidget = new IncSearchWidget( tb ); 2328 mIncSearchWidget = new IncSearchWidget( tb );
2295 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2329 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2296 SLOT( incrementalSearch( const QString& ) ) ); 2330 SLOT( incrementalSearch( const QString& ) ) );
2297 2331
2298 mJumpButtonBar = new JumpButtonBar( this, this ); 2332 mJumpButtonBar = new JumpButtonBar( this, this );
2299 2333
2300//US topLayout->addWidget( mJumpButtonBar ); 2334//US topLayout->addWidget( mJumpButtonBar );
2301 this->layout()->add( mJumpButtonBar ); 2335 this->layout()->add( mJumpButtonBar );
2302*/ 2336*/
2303 2337
2304#endif //KAB_EMBEDDED 2338#endif //KAB_EMBEDDED
2305 2339
2306 mActionExport2phone->plug( ExportMenu ); 2340 mActionExport2phone->plug( ExportMenu );
2307 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2341 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2308 syncManager->fillSyncMenu(); 2342 syncManager->fillSyncMenu();
2309 2343
2310} 2344}
2311void KABCore::showLicence() 2345void KABCore::showLicence()
2312{ 2346{
2313 KApplication::showLicence(); 2347 KApplication::showLicence();
2314} 2348}
2315 2349
2316void KABCore::manageCategories( ) 2350void KABCore::manageCategories( )
2317{ 2351{
2318 KABCatPrefs* cp = new KABCatPrefs(); 2352 KABCatPrefs* cp = new KABCatPrefs();
2319 cp->show(); 2353 cp->show();
2320 int w =cp->sizeHint().width() ; 2354 int w =cp->sizeHint().width() ;
2321 int h = cp->sizeHint().height() ; 2355 int h = cp->sizeHint().height() ;
2322 int dw = QApplication::desktop()->width(); 2356 int dw = QApplication::desktop()->width();
2323 int dh = QApplication::desktop()->height(); 2357 int dh = QApplication::desktop()->height();
2324 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2358 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2325 if ( !cp->exec() ) { 2359 if ( !cp->exec() ) {
2326 delete cp; 2360 delete cp;
2327 return; 2361 return;
2328 } 2362 }
2329 int count = 0; 2363 int count = 0;
2330 int cc = 0; 2364 int cc = 0;
2331 message( i18n("Please wait, processing categories...")); 2365 message( i18n("Please wait, processing categories..."));
2332 if ( cp->addCat() ) { 2366 if ( cp->addCat() ) {
2333 KABC::AddressBook::Iterator it; 2367 KABC::AddressBook::Iterator it;
2334 QStringList catList = KABPrefs::instance()->mCustomCategories; 2368 QStringList catList = KABPrefs::instance()->mCustomCategories;
2335 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2369 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2336 ++cc; 2370 ++cc;
2337 if ( cc %10 == 0) 2371 if ( cc %10 == 0)
2338 message(i18n("Processing contact #%1").arg(cc)); 2372 message(i18n("Processing contact #%1").arg(cc));
2339 QStringList catIncList = (*it).categories(); 2373 QStringList catIncList = (*it).categories();
2340 int i; 2374 int i;
2341 for( i = 0; i< catIncList.count(); ++i ) { 2375 for( i = 0; i< catIncList.count(); ++i ) {
2342 if ( !catList.contains (catIncList[i])) { 2376 if ( !catList.contains (catIncList[i])) {
2343 catList.append( catIncList[i] ); 2377 catList.append( catIncList[i] );
2344 //qDebug("add cat %s ", catIncList[i].latin1()); 2378 //qDebug("add cat %s ", catIncList[i].latin1());
2345 ++count; 2379 ++count;
2346 } 2380 }
2347 } 2381 }
2348 } 2382 }
2349 catList.sort(); 2383 catList.sort();
2350 KABPrefs::instance()->mCustomCategories = catList; 2384 KABPrefs::instance()->mCustomCategories = catList;
2351 KABPrefs::instance()->writeConfig(); 2385 KABPrefs::instance()->writeConfig();
2352 message(QString::number( count )+ i18n(" categories added to list! ")); 2386 message(QString::number( count )+ i18n(" categories added to list! "));
2353 } else { 2387 } else {
2354 QStringList catList = KABPrefs::instance()->mCustomCategories; 2388 QStringList catList = KABPrefs::instance()->mCustomCategories;
2355 QStringList catIncList; 2389 QStringList catIncList;
2356 QStringList newCatList; 2390 QStringList newCatList;
2357 KABC::AddressBook::Iterator it; 2391 KABC::AddressBook::Iterator it;
2358 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2392 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2359 ++cc; 2393 ++cc;
2360 if ( cc %10 == 0) 2394 if ( cc %10 == 0)
2361 message(i18n("Processing contact #%1").arg(cc)); 2395 message(i18n("Processing contact #%1").arg(cc));
2362 QStringList catIncList = (*it).categories(); 2396 QStringList catIncList = (*it).categories();
2363 int i; 2397 int i;
2364 if ( catIncList.count() ) { 2398 if ( catIncList.count() ) {
2365 newCatList.clear(); 2399 newCatList.clear();
2366 for( i = 0; i< catIncList.count(); ++i ) { 2400 for( i = 0; i< catIncList.count(); ++i ) {
2367 if ( catList.contains (catIncList[i])) { 2401 if ( catList.contains (catIncList[i])) {
2368 newCatList.append( catIncList[i] ); 2402 newCatList.append( catIncList[i] );
2369 } 2403 }
2370 } 2404 }
2371 newCatList.sort(); 2405 newCatList.sort();
2372 (*it).setCategories( newCatList ); 2406 (*it).setCategories( newCatList );
2373 mAddressBook->insertAddressee( (*it) ); 2407 mAddressBook->insertAddressee( (*it) );
2374 } 2408 }
2375 } 2409 }
2376 setModified( true ); 2410 setModified( true );
2377 mViewManager->refreshView(); 2411 mViewManager->refreshView();
2378 message( i18n("Removing categories done!")); 2412 message( i18n("Removing categories done!"));
2379 } 2413 }
2380 delete cp; 2414 delete cp;
2381} 2415}
2382void KABCore::removeVoice() 2416void KABCore::removeVoice()
2383{ 2417{
2384 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2418 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2385 return; 2419 return;
2386 XXPortSelectDialog dlg( this, false, this ); 2420 XXPortSelectDialog dlg( this, false, this );
2387 if ( !dlg.exec() ) 2421 if ( !dlg.exec() )
2388 return; 2422 return;
2389 mAddressBook->setUntagged(); 2423 mAddressBook->setUntagged();
2390 dlg.tagSelected(); 2424 dlg.tagSelected();
2391 message(i18n("Removing voice..."), false ); 2425 message(i18n("Removing voice..."), false );
2392 KABC::AddressBook::Iterator it; 2426 KABC::AddressBook::Iterator it;
2393 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2427 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2394 if ( (*it).tagged() ) { 2428 if ( (*it).tagged() ) {
2395 (*it).removeVoice(); 2429 (*it).removeVoice();
2396 } 2430 }
2397 } 2431 }
2398 message(i18n("Refreshing view...") ); 2432 message(i18n("Refreshing view...") );
2399 qApp->processEvents(); 2433 qApp->processEvents();
2400 mViewManager->refreshView( "" ); 2434 mViewManager->refreshView( "" );
2401 Addressee add; 2435 Addressee add;
2402 mDetails->setAddressee( add ); 2436 mDetails->setAddressee( add );
2403 message(i18n("Remove voice completed!") ); 2437 message(i18n("Remove voice completed!") );
2404 2438
2405 2439
2406 2440
2407} 2441}
2408 2442
2409void KABCore::setFormattedName() 2443void KABCore::setFormattedName()
2410{ 2444{
2411 KABFormatPrefs setpref; 2445 KABFormatPrefs setpref;
2412 if ( !setpref.exec() ) { 2446 if ( !setpref.exec() ) {
2413 return; 2447 return;
2414 } 2448 }
2415 XXPortSelectDialog dlg( this, false, this ); 2449 XXPortSelectDialog dlg( this, false, this );
2416 if ( !dlg.exec() ) 2450 if ( !dlg.exec() )
2417 return; 2451 return;
2418 mAddressBook->setUntagged(); 2452 mAddressBook->setUntagged();
2419 dlg.tagSelected(); 2453 dlg.tagSelected();
2420 int count = 0; 2454 int count = 0;
2421 KABC::AddressBook::Iterator it; 2455 KABC::AddressBook::Iterator it;
2422 bool modified = false; 2456 bool modified = false;
2423 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2457 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2424 if ( (*it).tagged() ) { 2458 if ( (*it).tagged() ) {
2425 if ( (*it).uid().left( 2 ) == "la" ) 2459 if ( (*it).uid().left( 2 ) == "la" )
2426 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2460 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2427 continue; 2461 continue;
2428 ++count; 2462 ++count;
2429 if ( count %10 == 0 ) 2463 if ( count %10 == 0 )
2430 message(i18n("Changing contact #%1").arg( count ) ); 2464 message(i18n("Changing contact #%1").arg( count ) );
2431 qApp->processEvents(); 2465 qApp->processEvents();
2432 QString fName; 2466 QString fName;
2433 if ( setpref.simple->isChecked() ) 2467 if ( setpref.simple->isChecked() )
2434 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2468 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2435 else if ( setpref.full->isChecked() ) 2469 else if ( setpref.full->isChecked() )
2436 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2470 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2437 else if ( setpref.reverse->isChecked() ) 2471 else if ( setpref.reverse->isChecked() )
2438 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2472 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2439 else 2473 else
2440 fName = (*it).organization(); 2474 fName = (*it).organization();
2441 if ( setpref.setCompany->isChecked() ) 2475 if ( setpref.setCompany->isChecked() )
2442 if ( fName.isEmpty() || fName =="," ) 2476 if ( fName.isEmpty() || fName =="," )
2443 fName = (*it).organization(); 2477 fName = (*it).organization();
2444 (*it).setFormattedName( fName ); 2478 (*it).setFormattedName( fName );
2445 (*it).setChanged( true ); 2479 (*it).setChanged( true );
2446 modified = true; 2480 modified = true;
2447 (*it).setRevision( QDateTime::currentDateTime() ); 2481 (*it).setRevision( QDateTime::currentDateTime() );
2448 } 2482 }
2449 } 2483 }
2450 message(i18n("Refreshing view...") ); 2484 message(i18n("Refreshing view...") );
2451 qApp->processEvents(); 2485 qApp->processEvents();
2452 if ( modified ) 2486 if ( modified )
2453 setModified( true ); 2487 setModified( true );
2454 Addressee add; 2488 Addressee add;
2455 mDetails->setAddressee( add ); 2489 mDetails->setAddressee( add );
2456 if ( count == 0 ) 2490 if ( count == 0 )
2457 message(i18n("No contact changed!") ); 2491 message(i18n("No contact changed!") );
2458 else 2492 else
2459 message(i18n("%1 contacts changed!").arg( count ) ); 2493 message(i18n("%1 contacts changed!").arg( count ) );
2460} 2494}
2461 2495
2462void KABCore::clipboardDataChanged() 2496void KABCore::clipboardDataChanged()
2463{ 2497{
2464 2498
2465 if ( mReadWrite ) 2499 if ( mReadWrite )
2466 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2500 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2467 2501
2468} 2502}
2469 2503
2470void KABCore::updateActionMenu() 2504void KABCore::updateActionMenu()
2471{ 2505{
2472 UndoStack *undo = UndoStack::instance(); 2506 UndoStack *undo = UndoStack::instance();
2473 RedoStack *redo = RedoStack::instance(); 2507 RedoStack *redo = RedoStack::instance();
2474 2508
2475 if ( undo->isEmpty() ) 2509 if ( undo->isEmpty() )
2476 mActionUndo->setText( i18n( "Undo" ) ); 2510 mActionUndo->setText( i18n( "Undo" ) );
2477 else 2511 else
2478 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2512 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2479 2513
2480 mActionUndo->setEnabled( !undo->isEmpty() ); 2514 mActionUndo->setEnabled( !undo->isEmpty() );
2481 2515
2482 if ( !redo->top() ) 2516 if ( !redo->top() )
2483 mActionRedo->setText( i18n( "Redo" ) ); 2517 mActionRedo->setText( i18n( "Redo" ) );
2484 else 2518 else
2485 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2519 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2486 2520
2487 mActionRedo->setEnabled( !redo->isEmpty() ); 2521 mActionRedo->setEnabled( !redo->isEmpty() );
2488} 2522}
2489 2523
2490void KABCore::configureKeyBindings() 2524void KABCore::configureKeyBindings()
2491{ 2525{
2492#ifndef KAB_EMBEDDED 2526#ifndef KAB_EMBEDDED
2493 KKeyDialog::configure( actionCollection(), true ); 2527 KKeyDialog::configure( actionCollection(), true );
2494#else //KAB_EMBEDDED 2528#else //KAB_EMBEDDED
2495 qDebug("KABCore::configureKeyBindings() not implemented"); 2529 qDebug("KABCore::configureKeyBindings() not implemented");
2496#endif //KAB_EMBEDDED 2530#endif //KAB_EMBEDDED
2497} 2531}
2498 2532
2499#ifdef KAB_EMBEDDED 2533#ifdef KAB_EMBEDDED
2500void KABCore::configureResources() 2534void KABCore::configureResources()
2501{ 2535{
2502 KRES::KCMKResources dlg( this, "" , 0 ); 2536 KRES::KCMKResources dlg( this, "" , 0 );
2503 2537
2504 if ( !dlg.exec() ) 2538 if ( !dlg.exec() )
2505 return; 2539 return;
2506 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2540 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2507} 2541}
2508#endif //KAB_EMBEDDED 2542#endif //KAB_EMBEDDED
2509 2543
2510 2544
2511/* this method will be called through the QCop interface from Ko/Pi to select addresses 2545/* this method will be called through the QCop interface from Ko/Pi to select addresses
2512 * for the attendees list of an event. 2546 * for the attendees list of an event.
2513 */ 2547 */
2514void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2548void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2515{ 2549{
2516 2550
2517 bool ok = false; 2551 bool ok = false;
2518 mEmailSourceChannel = sourceChannel; 2552 mEmailSourceChannel = sourceChannel;
2519 mEmailSourceUID = uid; 2553 mEmailSourceUID = uid;
2520 callContactdialog(); 2554 callContactdialog();
2521#if 0 2555#if 0
2522 int wid = uid.toInt( &ok ); 2556 int wid = uid.toInt( &ok );
2523 qDebug("UID %s ", uid.latin1()); 2557 qDebug("UID %s ", uid.latin1());
2524 if ( ok ) { 2558 if ( ok ) {
2525 if ( wid != QApplication::desktop()->width() ) { 2559 if ( wid != QApplication::desktop()->width() ) {
2526 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2560 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2527 message( i18n("Resizing, please wait...") ); 2561 message( i18n("Resizing, please wait...") );
2528 mMainWindow->showMinimized(); 2562 mMainWindow->showMinimized();
2529 /* 2563 /*
2530 { 2564 {
2531 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2565 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2532 } 2566 }
2533 */ 2567 */
2534 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2568 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2535 return; 2569 return;
2536 } 2570 }
2537 2571
2538 } else { 2572 } else {
2539 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2573 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2540 } 2574 }
2541 callContactdialog(); 2575 callContactdialog();
2542 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2576 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2543#endif 2577#endif
2544} 2578}
2545void KABCore::resizeAndCallContactdialog() 2579void KABCore::resizeAndCallContactdialog()
2546{ 2580{
2547 updateMainWindow(); 2581 updateMainWindow();
2548 QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); 2582 QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) );
2549} 2583}
2550 2584
2551void KABCore::callContactdialog() 2585void KABCore::callContactdialog()
2552{ 2586{
2553 QStringList nameList; 2587 QStringList nameList;
2554 QStringList emailList; 2588 QStringList emailList;
2555 QStringList uidList; 2589 QStringList uidList;
2556 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2590 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2557 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2591 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2558 uint i=0; 2592 uint i=0;
2559 for (i=0; i < list.count(); i++) 2593 for (i=0; i < list.count(); i++)
2560 { 2594 {
2561 nameList.append(list[i].realName()); 2595 nameList.append(list[i].realName());
2562 emailList.append(list[i].preferredEmail()); 2596 emailList.append(list[i].preferredEmail());
2563 uidList.append(list[i].uid()); 2597 uidList.append(list[i].uid());
2564 } 2598 }
2565 QString uid = mEmailSourceUID; 2599 QString uid = mEmailSourceUID;
2566 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2600 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2567 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2601 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2568 2602
2569} 2603}
2570/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2604/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2571 * to put them into the calendar. 2605 * to put them into the calendar.
2572 */ 2606 */
2573void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2607void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2574{ 2608{
2575 // qDebug("KABCore::requestForBirthdayList"); 2609 // qDebug("KABCore::requestForBirthdayList");
2576 QStringList birthdayList; 2610 QStringList birthdayList;
2577 QStringList anniversaryList; 2611 QStringList anniversaryList;
2578 QStringList realNameList; 2612 QStringList realNameList;
2579 QStringList preferredEmailList; 2613 QStringList preferredEmailList;
2580 QStringList assembledNameList; 2614 QStringList assembledNameList;
2581 QStringList uidList; 2615 QStringList uidList;
2582 2616
2583 KABC::AddressBook::Iterator it; 2617 KABC::AddressBook::Iterator it;
2584 2618
2585 int count = 0; 2619 int count = 0;
2586 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2620 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2587 ++count; 2621 ++count;
2588 } 2622 }
2589 QProgressBar bar(count,0 ); 2623 QProgressBar bar(count,0 );
2590 int w = 300; 2624 int w = 300;
2591 if ( QApplication::desktop()->width() < 320 ) 2625 if ( QApplication::desktop()->width() < 320 )
2592 w = 220; 2626 w = 220;
2593 int h = bar.sizeHint().height() ; 2627 int h = bar.sizeHint().height() ;
2594 int dw = QApplication::desktop()->width(); 2628 int dw = QApplication::desktop()->width();
2595 int dh = QApplication::desktop()->height(); 2629 int dh = QApplication::desktop()->height();
2596 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2630 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2597 bar.show(); 2631 bar.show();
2598 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2632 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2599 qApp->processEvents(); 2633 qApp->processEvents();
2600 2634
2601 QDate bday; 2635 QDate bday;
2602 QString anni; 2636 QString anni;
2603 QString formattedbday; 2637 QString formattedbday;
2604 2638
2605 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2639 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2606 { 2640 {
2607 if ( ! bar.isVisible() ) 2641 if ( ! bar.isVisible() )
2608 return; 2642 return;
2609 bar.setProgress( count++ ); 2643 bar.setProgress( count++ );
2610 qApp->processEvents(); 2644 qApp->processEvents();
2611 bday = (*it).birthday().date(); 2645 bday = (*it).birthday().date();
2612 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2646 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2613 2647
2614 if ( bday.isValid() || !anni.isEmpty()) 2648 if ( bday.isValid() || !anni.isEmpty())
2615 { 2649 {
2616 if (bday.isValid()) 2650 if (bday.isValid())
2617 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2651 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2618 else 2652 else
2619 formattedbday = "NOTVALID"; 2653 formattedbday = "NOTVALID";
2620 if (anni.isEmpty()) 2654 if (anni.isEmpty())
2621 anni = "INVALID"; 2655 anni = "INVALID";
2622 2656
2623 birthdayList.append(formattedbday); 2657 birthdayList.append(formattedbday);
2624 anniversaryList.append(anni); //should be ISODate 2658 anniversaryList.append(anni); //should be ISODate
2625 realNameList.append((*it).realName()); 2659 realNameList.append((*it).realName());
2626 preferredEmailList.append((*it).preferredEmail()); 2660 preferredEmailList.append((*it).preferredEmail());
2627 assembledNameList.append((*it).assembledName()); 2661 assembledNameList.append((*it).assembledName());
2628 uidList.append((*it).uid()); 2662 uidList.append((*it).uid());
2629 2663
2630 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2664 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2631 } 2665 }
2632 } 2666 }
2633 2667
2634 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2668 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2635 2669
2636} 2670}
2637 2671
2638/* this method will be called through the QCop interface from other apps to show details of a contact. 2672/* this method will be called through the QCop interface from other apps to show details of a contact.
2639 */ 2673 */
2640void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2674void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2641{ 2675{
2642 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2676 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2643 2677
2644 QString foundUid = QString::null; 2678 QString foundUid = QString::null;
2645 if ( ! uid.isEmpty() ) { 2679 if ( ! uid.isEmpty() ) {
2646 Addressee adrr = mAddressBook->findByUid( uid ); 2680 Addressee adrr = mAddressBook->findByUid( uid );
2647 if ( !adrr.isEmpty() ) { 2681 if ( !adrr.isEmpty() ) {
2648 foundUid = uid; 2682 foundUid = uid;
2649 } 2683 }
2650 if ( email == "sendbacklist" ) { 2684 if ( email == "sendbacklist" ) {
2651 //qDebug("ssssssssssssssssssssssend "); 2685 //qDebug("ssssssssssssssssssssssend ");
2652 QStringList nameList; 2686 QStringList nameList;
2653 QStringList emailList; 2687 QStringList emailList;
2654 QStringList uidList; 2688 QStringList uidList;
2655 nameList.append(adrr.realName()); 2689 nameList.append(adrr.realName());
2656 emailList = adrr.emails(); 2690 emailList = adrr.emails();
2657 uidList.append( adrr.preferredEmail()); 2691 uidList.append( adrr.preferredEmail());
2658 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2692 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2659 return; 2693 return;
2660 } 2694 }
2661 2695
2662 } 2696 }
2663 2697
2664 if ( email == "sendbacklist" ) 2698 if ( email == "sendbacklist" )
2665 return; 2699 return;
2666 if (foundUid.isEmpty()) 2700 if (foundUid.isEmpty())
2667 { 2701 {
2668 //find the uid of the person first 2702 //find the uid of the person first
2669 Addressee::List namelist; 2703 Addressee::List namelist;
2670 Addressee::List emaillist; 2704 Addressee::List emaillist;
2671 2705
2672 if (!name.isEmpty()) 2706 if (!name.isEmpty())
2673 namelist = mAddressBook->findByName( name ); 2707 namelist = mAddressBook->findByName( name );
2674 2708
2675 if (!email.isEmpty()) 2709 if (!email.isEmpty())
2676 emaillist = mAddressBook->findByEmail( email ); 2710 emaillist = mAddressBook->findByEmail( email );
2677 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2711 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2678 //check if we have a match in Namelist and Emaillist 2712 //check if we have a match in Namelist and Emaillist
2679 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2713 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2680 foundUid = emaillist[0].uid(); 2714 foundUid = emaillist[0].uid();
2681 } 2715 }
2682 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2716 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2683 foundUid = namelist[0].uid(); 2717 foundUid = namelist[0].uid();
2684 else 2718 else
2685 { 2719 {
2686 for (int i = 0; i < namelist.count(); i++) 2720 for (int i = 0; i < namelist.count(); i++)
2687 { 2721 {
2688 for (int j = 0; j < emaillist.count(); j++) 2722 for (int j = 0; j < emaillist.count(); j++)
2689 { 2723 {
2690 if (namelist[i] == emaillist[j]) 2724 if (namelist[i] == emaillist[j])
2691 { 2725 {
2692 foundUid = namelist[i].uid(); 2726 foundUid = namelist[i].uid();
2693 } 2727 }
2694 } 2728 }
2695 } 2729 }
2696 } 2730 }
2697 } 2731 }
2698 else 2732 else
2699 { 2733 {
2700 foundUid = uid; 2734 foundUid = uid;
2701 } 2735 }
2702 2736
2703 if (!foundUid.isEmpty()) 2737 if (!foundUid.isEmpty())
2704 { 2738 {
2705 2739
2706 // raise Ka/Pi if it is in the background 2740 // raise Ka/Pi if it is in the background
2707#ifndef DESKTOP_VERSION 2741#ifndef DESKTOP_VERSION
2708#ifndef KORG_NODCOP 2742#ifndef KORG_NODCOP
2709 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2743 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2710#endif 2744#endif
2711#endif 2745#endif
2712 2746
2713 mMainWindow->showMaximized(); 2747 mMainWindow->showMaximized();
2714 mMainWindow-> raise(); 2748 mMainWindow-> raise();
2715 2749
2716 mViewManager->setSelected( "", false); 2750 mViewManager->setSelected( "", false);
2717 mViewManager->refreshView( "" ); 2751 mViewManager->refreshView( "" );
2718 mViewManager->setSelected( foundUid, true ); 2752 mViewManager->setSelected( foundUid, true );
2719 mViewManager->refreshView( foundUid ); 2753 mViewManager->refreshView( foundUid );
2720 2754
2721 if ( !mMultipleViewsAtOnce ) 2755 if ( !mMultipleViewsAtOnce )
2722 { 2756 {
2723 setDetailsVisible( true ); 2757 setDetailsVisible( true );
2724 mActionDetails->setChecked(true); 2758 mActionDetails->setChecked(true);
2725 } 2759 }
2726 } 2760 }
2727} 2761}
2728void KABCore::storagehowto() 2762void KABCore::storagehowto()
2729{ 2763{
2730 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2764 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2731} 2765}
2732void KABCore::whatsnew() 2766void KABCore::whatsnew()
2733{ 2767{
2734 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2768 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2735} 2769}
2736void KABCore::synchowto() 2770void KABCore::synchowto()
2737{ 2771{
2738 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2772 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2739} 2773}
2740void KABCore::kdesynchowto() 2774void KABCore::kdesynchowto()
2741{ 2775{
2742 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2776 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2743} 2777}
2744void KABCore::multisynchowto() 2778void KABCore::multisynchowto()
2745{ 2779{
2746 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2780 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2747} 2781}
2748void KABCore::faq() 2782void KABCore::faq()
2749{ 2783{
2750 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2784 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2751} 2785}
2752 2786
2753#include <libkcal/syncdefines.h> 2787#include <libkcal/syncdefines.h>
2754 2788
2755KABC::Addressee KABCore::getLastSyncAddressee() 2789KABC::Addressee KABCore::getLastSyncAddressee()
2756{ 2790{
2757 Addressee lse; 2791 Addressee lse;
2758 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2792 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2759 2793
2760 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2794 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2761 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2795 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2762 if (lse.isEmpty()) { 2796 if (lse.isEmpty()) {
2763 qDebug("KA: Creating new last-syncAddressee "); 2797 qDebug("KA: Creating new last-syncAddressee ");
2764 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2798 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2765 QString sum = ""; 2799 QString sum = "";
2766 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2800 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2767 sum = "E: "; 2801 sum = "E: ";
2768 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2802 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2769 lse.setRevision( mLastAddressbookSync ); 2803 lse.setRevision( mLastAddressbookSync );
2770 lse.setCategories( i18n("SyncEvent") ); 2804 lse.setCategories( i18n("SyncEvent") );
2771 mAddressBook->insertAddressee( lse ); 2805 mAddressBook->insertAddressee( lse );
2772 } 2806 }
2773 return lse; 2807 return lse;
2774} 2808}
2775int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2809int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2776{ 2810{
2777 2811
2778 //void setZaurusId(int id); 2812 //void setZaurusId(int id);
2779 // int zaurusId() const; 2813 // int zaurusId() const;
2780 // void setZaurusUid(int id); 2814 // void setZaurusUid(int id);
2781 // int zaurusUid() const; 2815 // int zaurusUid() const;
2782 // void setZaurusStat(int id); 2816 // void setZaurusStat(int id);
2783 // int zaurusStat() const; 2817 // int zaurusStat() const;
2784 // 0 equal 2818 // 0 equal
2785 // 1 take local 2819 // 1 take local
2786 // 2 take remote 2820 // 2 take remote
2787 // 3 cancel 2821 // 3 cancel
2788 QDateTime lastSync = mLastAddressbookSync; 2822 QDateTime lastSync = mLastAddressbookSync;
2789 QDateTime localMod = local->revision(); 2823 QDateTime localMod = local->revision();
2790 QDateTime remoteMod = remote->revision(); 2824 QDateTime remoteMod = remote->revision();
2791 2825
2792 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2826 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2793 2827
2794 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2795 bool remCh, locCh; 2829 bool remCh, locCh;
2796 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2830 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2797 //if ( remCh ) 2831 //if ( remCh )
2798 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2832 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2799 locCh = ( localMod > mLastAddressbookSync ); 2833 locCh = ( localMod > mLastAddressbookSync );
2800 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2834 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2801 if ( !remCh && ! locCh ) { 2835 if ( !remCh && ! locCh ) {
2802 //qDebug("both not changed "); 2836 //qDebug("both not changed ");
2803 lastSync = localMod.addDays(1); 2837 lastSync = localMod.addDays(1);
2804 if ( mode <= SYNC_PREF_ASK ) 2838 if ( mode <= SYNC_PREF_ASK )
2805 return 0; 2839 return 0;
2806 } else { 2840 } else {
2807 if ( locCh ) { 2841 if ( locCh ) {
2808 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2842 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2809 lastSync = localMod.addDays( -1 ); 2843 lastSync = localMod.addDays( -1 );
2810 if ( !remCh ) 2844 if ( !remCh )
2811 remoteMod =( lastSync.addDays( -1 ) ); 2845 remoteMod =( lastSync.addDays( -1 ) );
2812 } else { 2846 } else {
2813 //qDebug(" not loc changed "); 2847 //qDebug(" not loc changed ");
2814 lastSync = localMod.addDays( 1 ); 2848 lastSync = localMod.addDays( 1 );
2815 if ( remCh ) { 2849 if ( remCh ) {
2816 //qDebug("rem changed "); 2850 //qDebug("rem changed ");
2817 remoteMod =( lastSync.addDays( 1 ) ); 2851 remoteMod =( lastSync.addDays( 1 ) );
2818 } 2852 }
2819 2853
2820 } 2854 }
2821 } 2855 }
2822 full = true; 2856 full = true;
2823 if ( mode < SYNC_PREF_ASK ) 2857 if ( mode < SYNC_PREF_ASK )
2824 mode = SYNC_PREF_ASK; 2858 mode = SYNC_PREF_ASK;
2825 } else { 2859 } else {
2826 if ( localMod == remoteMod ) 2860 if ( localMod == remoteMod )
2827 return 0; 2861 return 0;
2828 2862
2829 } 2863 }
2830 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2864 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2831 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2865 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2832 //full = true; //debug only 2866 //full = true; //debug only
2833 if ( full ) { 2867 if ( full ) {
2834 bool equ = ( (*local) == (*remote) ); 2868 bool equ = ( (*local) == (*remote) );
2835 if ( equ ) { 2869 if ( equ ) {
2836 //qDebug("equal "); 2870 //qDebug("equal ");
2837 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2871 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2838 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2872 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2839 } 2873 }
2840 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2874 if ( mode < SYNC_PREF_FORCE_LOCAL )
2841 return 0; 2875 return 0;
2842 2876
2843 }//else //debug only 2877 }//else //debug only
2844 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2878 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2845 } 2879 }
2846 int result; 2880 int result;
2847 bool localIsNew; 2881 bool localIsNew;
2848 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2882 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2849 2883
2850 if ( full && mode < SYNC_PREF_NEWEST ) 2884 if ( full && mode < SYNC_PREF_NEWEST )
2851 mode = SYNC_PREF_ASK; 2885 mode = SYNC_PREF_ASK;
2852 2886
2853 switch( mode ) { 2887 switch( mode ) {
2854 case SYNC_PREF_LOCAL: 2888 case SYNC_PREF_LOCAL:
2855 if ( lastSync > remoteMod ) 2889 if ( lastSync > remoteMod )
2856 return 1; 2890 return 1;
2857 if ( lastSync > localMod ) 2891 if ( lastSync > localMod )
2858 return 2; 2892 return 2;
2859 return 1; 2893 return 1;
2860 break; 2894 break;
2861 case SYNC_PREF_REMOTE: 2895 case SYNC_PREF_REMOTE:
2862 if ( lastSync > localMod ) 2896 if ( lastSync > localMod )
2863 return 2; 2897 return 2;
2864 if ( lastSync > remoteMod ) 2898 if ( lastSync > remoteMod )
2865 return 1; 2899 return 1;
2866 return 2; 2900 return 2;
2867 break; 2901 break;
2868 case SYNC_PREF_NEWEST: 2902 case SYNC_PREF_NEWEST:
2869 if ( localMod > remoteMod ) 2903 if ( localMod > remoteMod )
2870 return 1; 2904 return 1;
2871 else 2905 else
2872 return 2; 2906 return 2;
2873 break; 2907 break;
2874 case SYNC_PREF_ASK: 2908 case SYNC_PREF_ASK:
2875 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2909 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2876 if ( lastSync > remoteMod && lastSync > localMod) 2910 if ( lastSync > remoteMod && lastSync > localMod)
2877 return 0; 2911 return 0;
2878 if ( lastSync > remoteMod ) 2912 if ( lastSync > remoteMod )
2879 return 1; 2913 return 1;
2880 if ( lastSync > localMod ) { 2914 if ( lastSync > localMod ) {
2881 return 2; 2915 return 2;
2882 } 2916 }
2883 localIsNew = localMod >= remoteMod; 2917 localIsNew = localMod >= remoteMod;
2884 //qDebug("conflict! ************************************** "); 2918 //qDebug("conflict! ************************************** ");
2885 { 2919 {
2886 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2920 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2887 result = acd.executeD(localIsNew); 2921 result = acd.executeD(localIsNew);
2888 return result; 2922 return result;
2889 } 2923 }
2890 break; 2924 break;
2891 case SYNC_PREF_FORCE_LOCAL: 2925 case SYNC_PREF_FORCE_LOCAL:
2892 return 1; 2926 return 1;
2893 break; 2927 break;
2894 case SYNC_PREF_FORCE_REMOTE: 2928 case SYNC_PREF_FORCE_REMOTE:
2895 return 2; 2929 return 2;
2896 break; 2930 break;
2897 2931
2898 default: 2932 default:
2899 // SYNC_PREF_TAKE_BOTH not implemented 2933 // SYNC_PREF_TAKE_BOTH not implemented
2900 break; 2934 break;
2901 } 2935 }
2902 return 0; 2936 return 0;
2903} 2937}
2904 2938
2905 2939
2906bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2940bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2907{ 2941{
2908 bool syncOK = true; 2942 bool syncOK = true;
2909 int addedAddressee = 0; 2943 int addedAddressee = 0;
2910 int addedAddresseeR = 0; 2944 int addedAddresseeR = 0;
2911 int deletedAddresseeR = 0; 2945 int deletedAddresseeR = 0;
2912 int deletedAddresseeL = 0; 2946 int deletedAddresseeL = 0;
2913 int changedLocal = 0; 2947 int changedLocal = 0;
2914 int changedRemote = 0; 2948 int changedRemote = 0;
2915 int filteredIN = 0; 2949 int filteredIN = 0;
2916 int filteredOUT = 0; 2950 int filteredOUT = 0;
2917 2951
2918 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2952 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2919 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2953 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2920 2954
2921 //QPtrList<Addressee> el = local->rawAddressees(); 2955 //QPtrList<Addressee> el = local->rawAddressees();
2922 Addressee addresseeR; 2956 Addressee addresseeR;
2923 QString uid; 2957 QString uid;
2924 int take; 2958 int take;
2925 Addressee addresseeL; 2959 Addressee addresseeL;
2926 Addressee addresseeRSync; 2960 Addressee addresseeRSync;
2927 Addressee addresseeLSync; 2961 Addressee addresseeLSync;
2928 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2962 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2929 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2963 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2930 bool fullDateRange = false; 2964 bool fullDateRange = false;
2931 local->resetTempSyncStat(); 2965 local->resetTempSyncStat();
2932 mLastAddressbookSync = QDateTime::currentDateTime(); 2966 mLastAddressbookSync = QDateTime::currentDateTime();
2933 if ( syncManager->syncWithDesktop() ) { 2967 if ( syncManager->syncWithDesktop() ) {
2934 // remote->removeSyncInfo( QString());//remove all info 2968 // remote->removeSyncInfo( QString());//remove all info
2935 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2969 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2936 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2970 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2937 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2971 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2938 } else { 2972 } else {
2939 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2973 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2940 } 2974 }
2941 } 2975 }
2942 QDateTime modifiedCalendar = mLastAddressbookSync; 2976 QDateTime modifiedCalendar = mLastAddressbookSync;
2943 addresseeLSync = getLastSyncAddressee(); 2977 addresseeLSync = getLastSyncAddressee();
2944 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2978 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2945 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2979 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2946 if ( !addresseeR.isEmpty() ) { 2980 if ( !addresseeR.isEmpty() ) {
2947 addresseeRSync = addresseeR; 2981 addresseeRSync = addresseeR;
2948 remote->removeAddressee(addresseeR ); 2982 remote->removeAddressee(addresseeR );
2949 2983
2950 } else { 2984 } else {
2951 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2952 addresseeRSync = addresseeLSync ; 2986 addresseeRSync = addresseeLSync ;
2953 } else { 2987 } else {
2954 //qDebug("FULLDATE 1"); 2988 //qDebug("FULLDATE 1");
2955 fullDateRange = true; 2989 fullDateRange = true;
2956 Addressee newAdd; 2990 Addressee newAdd;
2957 addresseeRSync = newAdd; 2991 addresseeRSync = newAdd;
2958 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2992 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2959 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2993 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2960 addresseeRSync.setRevision( mLastAddressbookSync ); 2994 addresseeRSync.setRevision( mLastAddressbookSync );
2961 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2995 addresseeRSync.setCategories( i18n("SyncAddressee") );
2962 } 2996 }
2963 } 2997 }
2964 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2998 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2965 // qDebug("FULLDATE 2"); 2999 // qDebug("FULLDATE 2");
2966 fullDateRange = true; 3000 fullDateRange = true;
2967 } 3001 }
2968 if ( ! fullDateRange ) { 3002 if ( ! fullDateRange ) {
2969 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3003 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2970 3004
2971 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3005 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2972 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3006 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2973 fullDateRange = true; 3007 fullDateRange = true;
2974 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3008 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2975 } 3009 }
2976 } 3010 }
2977 // fullDateRange = true; // debug only! 3011 // fullDateRange = true; // debug only!
2978 if ( fullDateRange ) 3012 if ( fullDateRange )
2979 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3013 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2980 else 3014 else
2981 mLastAddressbookSync = addresseeLSync.revision(); 3015 mLastAddressbookSync = addresseeLSync.revision();
2982 // for resyncing if own file has changed 3016 // for resyncing if own file has changed
2983 // PENDING fixme later when implemented 3017 // PENDING fixme later when implemented
2984#if 0 3018#if 0
2985 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3019 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2986 mLastAddressbookSync = loadedFileVersion; 3020 mLastAddressbookSync = loadedFileVersion;
2987 qDebug("setting mLastAddressbookSync "); 3021 qDebug("setting mLastAddressbookSync ");
2988 } 3022 }
2989#endif 3023#endif
2990 3024
2991 3025
2992 // ********** setting filters **************** 3026 // ********** setting filters ****************
2993 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3027 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2994 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3028 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2995 3029
2996 //qDebug("*************************** "); 3030 //qDebug("*************************** ");
2997 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3031 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2998 QStringList er = remote->uidList(); 3032 QStringList er = remote->uidList();
2999 Addressee inR ;//= er.first(); 3033 Addressee inR ;//= er.first();
3000 Addressee inL; 3034 Addressee inL;
3001 3035
3002 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3036 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3003 3037
3004 int modulo = (er.count()/10)+1; 3038 int modulo = (er.count()/10)+1;
3005 int incCounter = 0; 3039 int incCounter = 0;
3006 while ( incCounter < er.count()) { 3040 while ( incCounter < er.count()) {
3007 if (syncManager->isProgressBarCanceled()) 3041 if (syncManager->isProgressBarCanceled())
3008 return false; 3042 return false;
3009 if ( incCounter % modulo == 0 ) 3043 if ( incCounter % modulo == 0 )
3010 syncManager->showProgressBar(incCounter); 3044 syncManager->showProgressBar(incCounter);
3011 3045
3012 uid = er[ incCounter ]; 3046 uid = er[ incCounter ];
3013 bool skipIncidence = false; 3047 bool skipIncidence = false;
3014 if ( uid.left(19) == QString("last-syncAddressee-") ) 3048 if ( uid.left(19) == QString("last-syncAddressee-") )
3015 skipIncidence = true; 3049 skipIncidence = true;
3016 QString idS,OidS; 3050 QString idS,OidS;
3017 qApp->processEvents(); 3051 qApp->processEvents();
3018 if ( !skipIncidence ) { 3052 if ( !skipIncidence ) {
3019 inL = local->findByUid( uid ); 3053 inL = local->findByUid( uid );
3020 inR = remote->findByUid( uid ); 3054 inR = remote->findByUid( uid );
3021 //inL.setResource( 0 ); 3055 //inL.setResource( 0 );
3022 //inR.setResource( 0 ); 3056 //inR.setResource( 0 );
3023 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3057 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3024 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3058 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3025 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3059 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3026 //qDebug("take %d %s ", take, inL.summary().latin1()); 3060 //qDebug("take %d %s ", take, inL.summary().latin1());
3027 if ( take == 3 ) 3061 if ( take == 3 )
3028 return false; 3062 return false;
3029 if ( take == 1 ) {// take local ********************** 3063 if ( take == 1 ) {// take local **********************
3030 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3064 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3031 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3065 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3032 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3066 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3033 local->insertAddressee( inL, false ); 3067 local->insertAddressee( inL, false );
3034 idS = inR.externalUID(); 3068 idS = inR.externalUID();
3035 OidS = inR.originalExternalUID(); 3069 OidS = inR.originalExternalUID();
3036 } 3070 }
3037 else 3071 else
3038 idS = inR.IDStr(); 3072 idS = inR.IDStr();
3039 remote->removeAddressee( inR ); 3073 remote->removeAddressee( inR );
3040 inR = inL; 3074 inR = inL;
3041 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3075 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3042 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3076 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3043 inR.setOriginalExternalUID( OidS ); 3077 inR.setOriginalExternalUID( OidS );
3044 inR.setExternalUID( idS ); 3078 inR.setExternalUID( idS );
3045 if ( syncManager->syncWithDesktop() ) { 3079 if ( syncManager->syncWithDesktop() ) {
3046 inR.setIDStr("changed" ); 3080 inR.setIDStr("changed" );
3047 } 3081 }
3048 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3082 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3049 } else { 3083 } else {
3050 inR.setIDStr( idS ); 3084 inR.setIDStr( idS );
3051 } 3085 }
3052 inR.setResource( 0 ); 3086 inR.setResource( 0 );
3053 remote->insertAddressee( inR , false); 3087 remote->insertAddressee( inR , false);
3054 ++changedRemote; 3088 ++changedRemote;
3055 } else { // take == 2 take remote ********************** 3089 } else { // take == 2 take remote **********************
3056 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3057 if ( inR.revision().date().year() < 2004 ) 3091 if ( inR.revision().date().year() < 2004 )
3058 inR.setRevision( modifiedCalendar ); 3092 inR.setRevision( modifiedCalendar );
3059 } 3093 }
3060 idS = inL.IDStr(); 3094 idS = inL.IDStr();
3061 local->removeAddressee( inL ); 3095 local->removeAddressee( inL );
3062 inL = inR; 3096 inL = inR;
3063 inL.setIDStr( idS ); 3097 inL.setIDStr( idS );
3064 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3098 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3065 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3099 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3066 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3100 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3067 } 3101 }
3068 inL.setResource( 0 ); 3102 inL.setResource( 0 );
3069 local->insertAddressee( inL , false ); 3103 local->insertAddressee( inL , false );
3070 ++changedLocal; 3104 ++changedLocal;
3071 } 3105 }
3072 } 3106 }
3073 } 3107 }
3074 } else { // no conflict ********** add or delete remote 3108 } else { // no conflict ********** add or delete remote
3075 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3109 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3076 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3110 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3077 QString des = addresseeLSync.note(); 3111 QString des = addresseeLSync.note();
3078 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3112 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3079 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3113 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3080 remote->insertAddressee( inR, false ); 3114 remote->insertAddressee( inR, false );
3081 ++deletedAddresseeR; 3115 ++deletedAddresseeR;
3082 } else { 3116 } else {
3083 inR.setRevision( modifiedCalendar ); 3117 inR.setRevision( modifiedCalendar );
3084 remote->insertAddressee( inR, false ); 3118 remote->insertAddressee( inR, false );
3085 inL = inR; 3119 inL = inR;
3086 inL.setIDStr( ":" ); 3120 inL.setIDStr( ":" );
3087 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3121 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3088 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3122 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3089 inL.setResource( 0 ); 3123 inL.setResource( 0 );
3090 local->insertAddressee( inL , false); 3124 local->insertAddressee( inL , false);
3091 ++addedAddressee; 3125 ++addedAddressee;
3092 } 3126 }
3093 } else { 3127 } else {
3094 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3128 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3095 inR.setRevision( modifiedCalendar ); 3129 inR.setRevision( modifiedCalendar );
3096 remote->insertAddressee( inR, false ); 3130 remote->insertAddressee( inR, false );
3097 inR.setResource( 0 ); 3131 inR.setResource( 0 );
3098 local->insertAddressee( inR, false ); 3132 local->insertAddressee( inR, false );
3099 ++addedAddressee; 3133 ++addedAddressee;
3100 } else { 3134 } else {
3101 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3135 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3102 remote->removeAddressee( inR ); 3136 remote->removeAddressee( inR );
3103 ++deletedAddresseeR; 3137 ++deletedAddresseeR;
3104 } 3138 }
3105 } 3139 }
3106 } else { 3140 } else {
3107 ++filteredIN; 3141 ++filteredIN;
3108 } 3142 }
3109 } 3143 }
3110 } 3144 }
3111 ++incCounter; 3145 ++incCounter;
3112 } 3146 }
3113 er.clear(); 3147 er.clear();
3114 QStringList el = local->uidList(); 3148 QStringList el = local->uidList();
3115 modulo = (el.count()/10)+1; 3149 modulo = (el.count()/10)+1;
3116 3150
3117 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3151 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3118 incCounter = 0; 3152 incCounter = 0;
3119 while ( incCounter < el.count()) { 3153 while ( incCounter < el.count()) {
3120 qApp->processEvents(); 3154 qApp->processEvents();
3121 if (syncManager->isProgressBarCanceled()) 3155 if (syncManager->isProgressBarCanceled())
3122 return false; 3156 return false;
3123 if ( incCounter % modulo == 0 ) 3157 if ( incCounter % modulo == 0 )
3124 syncManager->showProgressBar(incCounter); 3158 syncManager->showProgressBar(incCounter);
3125 uid = el[ incCounter ]; 3159 uid = el[ incCounter ];
3126 bool skipIncidence = false; 3160 bool skipIncidence = false;
3127 if ( uid.left(19) == QString("last-syncAddressee-") ) 3161 if ( uid.left(19) == QString("last-syncAddressee-") )
3128 skipIncidence = true; 3162 skipIncidence = true;
3129 if ( !skipIncidence ) { 3163 if ( !skipIncidence ) {
3130 inL = local->findByUid( uid ); 3164 inL = local->findByUid( uid );
3131 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3165 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3132 inR = remote->findByUid( uid ); 3166 inR = remote->findByUid( uid );
3133 if ( inR.isEmpty() ){ 3167 if ( inR.isEmpty() ){
3134 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3168 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3135 // no conflict ********** add or delete local 3169 // no conflict ********** add or delete local
3136 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3170 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3137 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3171 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3138 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3172 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3139 local->removeAddressee( inL ); 3173 local->removeAddressee( inL );
3140 ++deletedAddresseeL; 3174 ++deletedAddresseeL;
3141 } else { 3175 } else {
3142 if ( ! syncManager->mWriteBackExistingOnly ) { 3176 if ( ! syncManager->mWriteBackExistingOnly ) {
3143 inL.removeID(mCurrentSyncDevice ); 3177 inL.removeID(mCurrentSyncDevice );
3144 ++addedAddresseeR; 3178 ++addedAddresseeR;
3145 inL.setRevision( modifiedCalendar ); 3179 inL.setRevision( modifiedCalendar );
3146 local->insertAddressee( inL, false ); 3180 local->insertAddressee( inL, false );
3147 inR = inL; 3181 inR = inL;
3148 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3182 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3149 inR.setResource( 0 ); 3183 inR.setResource( 0 );
3150 remote->insertAddressee( inR, false ); 3184 remote->insertAddressee( inR, false );
3151 } 3185 }
3152 } 3186 }
3153 } else { 3187 } else {
3154 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3188 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3155 //qDebug("data %s ", inL.revision().toString().latin1()); 3189 //qDebug("data %s ", inL.revision().toString().latin1());
3156 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3190 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3157 local->removeAddressee( inL ); 3191 local->removeAddressee( inL );
3158 ++deletedAddresseeL; 3192 ++deletedAddresseeL;
3159 } else { 3193 } else {
3160 if ( ! syncManager->mWriteBackExistingOnly ) { 3194 if ( ! syncManager->mWriteBackExistingOnly ) {
3161 ++addedAddresseeR; 3195 ++addedAddresseeR;
3162 inL.setRevision( modifiedCalendar ); 3196 inL.setRevision( modifiedCalendar );
3163 local->insertAddressee( inL, false ); 3197 local->insertAddressee( inL, false );
3164 inR = inL; 3198 inR = inL;
3165 inR.setIDStr( ":" ); 3199 inR.setIDStr( ":" );
3166 inR.setResource( 0 ); 3200 inR.setResource( 0 );
3167 remote->insertAddressee( inR, false ); 3201 remote->insertAddressee( inR, false );
3168 } 3202 }
3169 } 3203 }
3170 } 3204 }
3171 } else { 3205 } else {
3172 ++filteredOUT; 3206 ++filteredOUT;
3173 } 3207 }
3174 } 3208 }
3175 } 3209 }
3176 } 3210 }
3177 ++incCounter; 3211 ++incCounter;
3178 } 3212 }
3179 el.clear(); 3213 el.clear();
3180 syncManager->hideProgressBar(); 3214 syncManager->hideProgressBar();
3181 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3215 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3182 // get rid of micro seconds 3216 // get rid of micro seconds
3183 QTime t = mLastAddressbookSync.time(); 3217 QTime t = mLastAddressbookSync.time();
3184 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3218 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3185 addresseeLSync.setRevision( mLastAddressbookSync ); 3219 addresseeLSync.setRevision( mLastAddressbookSync );
3186 addresseeRSync.setRevision( mLastAddressbookSync ); 3220 addresseeRSync.setRevision( mLastAddressbookSync );
3187 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3221 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3188 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3222 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3189 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3223 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3190 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3224 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3191 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3225 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3192 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3226 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3193 addresseeRSync.setNote( "" ) ; 3227 addresseeRSync.setNote( "" ) ;
3194 addresseeLSync.setNote( "" ); 3228 addresseeLSync.setNote( "" );
3195 3229
3196 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3230 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3197 remote->insertAddressee( addresseeRSync, false ); 3231 remote->insertAddressee( addresseeRSync, false );
3198 local->insertAddressee( addresseeLSync, false ); 3232 local->insertAddressee( addresseeLSync, false );
3199 QString mes; 3233 QString mes;
3200 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3234 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3201 qDebug( mes ); 3235 qDebug( mes );
3202 mes = i18n("Local addressbook changed!\n") +mes; 3236 mes = i18n("Local addressbook changed!\n") +mes;
3203 if ( syncManager->mShowSyncSummary ) { 3237 if ( syncManager->mShowSyncSummary ) {
3204 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3238 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3205 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3239 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3206 qDebug("KA: WB cancelled "); 3240 qDebug("KA: WB cancelled ");
3207 syncManager->mWriteBackFile = false; 3241 syncManager->mWriteBackFile = false;
3208 return syncOK; 3242 return syncOK;
3209 } 3243 }
3210 } 3244 }
3211 return syncOK; 3245 return syncOK;
3212} 3246}
3213 3247
3214 3248
3215//this is a overwritten callbackmethods from the syncinterface 3249//this is a overwritten callbackmethods from the syncinterface
3216bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3250bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3217{ 3251{
3218 3252
3219 //pending prepare addresseeview for output 3253 //pending prepare addresseeview for output
3220 //pending detect, if remote file has REV field. if not switch to external sync 3254 //pending detect, if remote file has REV field. if not switch to external sync
3221 mGlobalSyncMode = SYNC_MODE_NORMAL; 3255 mGlobalSyncMode = SYNC_MODE_NORMAL;
3222 if ( manager != syncManager ) 3256 if ( manager != syncManager )
3223 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3257 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3224 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3258 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3225 3259
3226 AddressBook abLocal(filename,"syncContact"); 3260 AddressBook abLocal(filename,"syncContact");
3227 bool syncOK = false; 3261 bool syncOK = false;
3228 if ( abLocal.load() ) { 3262 if ( abLocal.load() ) {
3229 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3263 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3230 bool external = false; 3264 bool external = false;
3231 bool isXML = false; 3265 bool isXML = false;
3232 if ( filename.right(4) == ".xml") { 3266 if ( filename.right(4) == ".xml") {
3233 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3267 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3234 isXML = true; 3268 isXML = true;
3235 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3269 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3236 } else { 3270 } else {
3237 external = !manager->mIsKapiFile; 3271 external = !manager->mIsKapiFile;
3238 if ( external ) { 3272 if ( external ) {
3239 qDebug("KA: Sync::Setting vcf mode to external "); 3273 qDebug("KA: Sync::Setting vcf mode to external ");
3240 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3274 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3241 AddressBook::Iterator it; 3275 AddressBook::Iterator it;
3242 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3276 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3243 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3277 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3244 (*it).computeCsum( mCurrentSyncDevice ); 3278 (*it).computeCsum( mCurrentSyncDevice );
3245 } 3279 }
3246 } 3280 }
3247 } 3281 }
3248 //AddressBook::Iterator it; 3282 //AddressBook::Iterator it;
3249 //QStringList vcards; 3283 //QStringList vcards;
3250 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3284 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3251 // qDebug("Name %s ", (*it).familyName().latin1()); 3285 // qDebug("Name %s ", (*it).familyName().latin1());
3252 //} 3286 //}
3253 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3287 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3254 syncManager->hideProgressBar(); 3288 syncManager->hideProgressBar();
3255 if ( syncOK ) { 3289 if ( syncOK ) {
3256 if ( syncManager->mWriteBackFile ) 3290 if ( syncManager->mWriteBackFile )
3257 { 3291 {
3258 if ( external ) 3292 if ( external )
3259 abLocal.removeSyncAddressees( !isXML); 3293 abLocal.removeSyncAddressees( !isXML);
3260 qDebug("KA: Sync::Saving remote AB "); 3294 qDebug("KA: Sync::Saving remote AB ");
3261 if ( ! abLocal.saveAB()) 3295 if ( ! abLocal.saveAB())
3262 qDebug("KA: sync::Error writing back AB to file "); 3296 qDebug("KA: sync::Error writing back AB to file ");
3263 if ( external ) { 3297 if ( external ) {
3264 // afterwrite processing 3298 // afterwrite processing
3265 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3299 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3266 } 3300 }
3267 } 3301 }
3268 } 3302 }
3269 setModified(); 3303 setModified();
3270 3304
3271 } 3305 }
3272 abLocal.removeResources(); 3306 abLocal.removeResources();
3273 if ( syncOK ) 3307 if ( syncOK )
3274 mViewManager->refreshView(); 3308 mViewManager->refreshView();
3275 return syncOK; 3309 return syncOK;
3276 3310
3277} 3311}
3278void KABCore::removeSyncInfo( QString syncProfile) 3312void KABCore::removeSyncInfo( QString syncProfile)
3279{ 3313{
3280 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3314 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3281 mAddressBook->removeSyncInfo( syncProfile ); 3315 mAddressBook->removeSyncInfo( syncProfile );
3282 setModified(); 3316 setModified();
3283} 3317}
3284 3318
3285 3319
3286//this is a overwritten callbackmethods from the syncinterface 3320//this is a overwritten callbackmethods from the syncinterface
3287bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3321bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3288{ 3322{
3289 if ( resource == "phone" ) 3323 if ( resource == "phone" )
3290 return syncPhone(); 3324 return syncPhone();
3291 disableBR( true ); 3325 disableBR( true );
3292 if ( manager != syncManager ) 3326 if ( manager != syncManager )
3293 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3327 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3294 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3328 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3295 3329
3296 AddressBook abLocal( resource,"syncContact"); 3330 AddressBook abLocal( resource,"syncContact");
3297 bool syncOK = false; 3331 bool syncOK = false;
3298 message(i18n("Loading DTM address data..."), false); 3332 message(i18n("Loading DTM address data..."), false);
3299 if ( abLocal.load() ) { 3333 if ( abLocal.load() ) {
3300 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3334 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3301 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3335 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3302 message(i18n("Sync preprocessing..."),false); 3336 message(i18n("Sync preprocessing..."),false);
3303 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3337 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3304 message(i18n("Synchronizing..."),false); 3338 message(i18n("Synchronizing..."),false);
3305 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3339 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3306 syncManager->hideProgressBar(); 3340 syncManager->hideProgressBar();
3307 if ( syncOK ) { 3341 if ( syncOK ) {
3308 if ( syncManager->mWriteBackFile ) { 3342 if ( syncManager->mWriteBackFile ) {
3309 abLocal.removeSyncAddressees( false ); 3343 abLocal.removeSyncAddressees( false );
3310 message(i18n("Saving DTM address data..."),false); 3344 message(i18n("Saving DTM address data..."),false);
3311 abLocal.saveAB(); 3345 abLocal.saveAB();
3312 message(i18n("Sync postprocessing..."),false); 3346 message(i18n("Sync postprocessing..."),false);
3313 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3347 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3314 } 3348 }
3315 } else 3349 } else
3316 message( i18n("Sync cancelled or failed.") ); 3350 message( i18n("Sync cancelled or failed.") );
3317 setModified(); 3351 setModified();
3318 } 3352 }
3319 abLocal.removeResources(); 3353 abLocal.removeResources();
3320 if ( syncOK ) { 3354 if ( syncOK ) {
3321 mViewManager->refreshView(); 3355 mViewManager->refreshView();
3322 message(i18n("DTM syncing finished.")); 3356 message(i18n("DTM syncing finished."));
3323 } 3357 }
3324 disableBR( false ); 3358 disableBR( false );
3325 return syncOK; 3359 return syncOK;
3326 3360
3327} 3361}
3328void KABCore::message( QString m, bool startTimer) 3362void KABCore::message( QString m, bool startTimer)
3329{ 3363{
3330 topLevelWidget()->setCaption( m ); 3364 topLevelWidget()->setCaption( m );
3331 qApp->processEvents(); 3365 qApp->processEvents();
3332 if ( startTimer ) 3366 if ( startTimer )
3333 mMessageTimer->start( 15000, true ); 3367 mMessageTimer->start( 15000, true );
3334 else 3368 else
3335 mMessageTimer->stop(); 3369 mMessageTimer->stop();
3336} 3370}
3337bool KABCore::syncPhone() 3371bool KABCore::syncPhone()
3338{ 3372{
3339 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3373 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3340 QString fileName = getPhoneFile(); 3374 QString fileName = getPhoneFile();
3341 if ( !PhoneAccess::readFromPhone( fileName) ) { 3375 if ( !PhoneAccess::readFromPhone( fileName) ) {
3342 message(i18n("Phone access failed!")); 3376 message(i18n("Phone access failed!"));
3343 return false; 3377 return false;
3344 } 3378 }
3345 AddressBook abLocal( fileName,"syncContact"); 3379 AddressBook abLocal( fileName,"syncContact");
3346 bool syncOK = false; 3380 bool syncOK = false;
3347 { 3381 {
3348 abLocal.importFromFile( fileName ); 3382 abLocal.importFromFile( fileName );
3349 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3383 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3350 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3384 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3351 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3385 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3352 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3386 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3353 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3387 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3354 syncManager->hideProgressBar(); 3388 syncManager->hideProgressBar();
3355 if ( syncOK ) { 3389 if ( syncOK ) {
3356 if ( syncManager->mWriteBackFile ) { 3390 if ( syncManager->mWriteBackFile ) {
3357 abLocal.removeSyncAddressees( true ); 3391 abLocal.removeSyncAddressees( true );
3358 abLocal.saveABphone( fileName ); 3392 abLocal.saveABphone( fileName );
3359 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3393 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3360 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3394 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3361 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3395 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3362 } 3396 }
3363 } 3397 }
3364 setModified(); 3398 setModified();
3365 } 3399 }
3366 abLocal.removeResources(); 3400 abLocal.removeResources();
3367 if ( syncOK ) 3401 if ( syncOK )
3368 mViewManager->refreshView(); 3402 mViewManager->refreshView();
3369 return syncOK; 3403 return syncOK;
3370} 3404}
3371void KABCore::getFile( bool success ) 3405void KABCore::getFile( bool success )
3372{ 3406{
3373 if ( ! success ) { 3407 if ( ! success ) {
3374 message( i18n("Error receiving file. Nothing changed!") ); 3408 message( i18n("Error receiving file. Nothing changed!") );
3375 return; 3409 return;
3376 } 3410 }
3377 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3411 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3378 if ( count ) 3412 if ( count )
3379 setModified( true ); 3413 setModified( true );
3380 message( i18n("Pi-Sync successful!") ); 3414 message( i18n("Pi-Sync successful!") );
3381 mViewManager->refreshView(); 3415 mViewManager->refreshView();
3382} 3416}
3383void KABCore::syncFileRequest() 3417void KABCore::syncFileRequest()
3384{ 3418{
3385 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3419 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3386 syncManager->slotSyncMenu( 999 ); 3420 syncManager->slotSyncMenu( 999 );
3387 } 3421 }
3388 mAddressBook->export2File( sentSyncFile() ); 3422 mAddressBook->export2File( sentSyncFile() );
3389} 3423}
3390QString KABCore::sentSyncFile() 3424QString KABCore::sentSyncFile()
3391{ 3425{
3392#ifdef DESKTOP_VERSION 3426#ifdef DESKTOP_VERSION
3393 return locateLocal( "tmp", "copysyncab.vcf" ); 3427 return locateLocal( "tmp", "copysyncab.vcf" );
3394#else 3428#else
3395 return QString( "/tmp/copysyncab.vcf" ); 3429 return QString( "/tmp/copysyncab.vcf" );
3396#endif 3430#endif
3397} 3431}
3398 3432
3399void KABCore::setCaptionBack() 3433void KABCore::setCaptionBack()
3400{ 3434{
3401 mMessageTimer->stop(); 3435 mMessageTimer->stop();
3402 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3436 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3403} 3437}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 4366265..30efbf6 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,1203 +1,1203 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108 108
109{ 109{
110 mLastView = -1; 110 mLastView = -1;
111 oldW = 0; 111 oldW = 0;
112 oldH = 0; 112 oldH = 0;
113 myPix.resize( 150, 120 ); 113 myPix.resize( 150, 120 );
114 mRedrawNeeded = true; 114 mRedrawNeeded = true;
115 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 115 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
116 mPendingUpdateBeforeRepaint = false; 116 mPendingUpdateBeforeRepaint = false;
117 mouseDown = false; 117 mouseDown = false;
118 // initialize dynamic arrays 118 // initialize dynamic arrays
119 bDays.resize ( NUMDAYS ); 119 bDays.resize ( NUMDAYS );
120 pDays.resize ( NUMDAYS ); 120 pDays.resize ( NUMDAYS );
121 hDays.resize ( NUMDAYS ); 121 hDays.resize ( NUMDAYS );
122 eDays.resize ( NUMDAYS ); 122 eDays.resize ( NUMDAYS );
123 days = new QDate[NUMDAYS]; 123 days = new QDate[NUMDAYS];
124 daylbls = new QString[NUMDAYS]; 124 daylbls = new QString[NUMDAYS];
125 //events = new int[NUMDAYS]; 125 //events = new int[NUMDAYS];
126 mToolTip = new DynamicTip(this); 126 mToolTip = new DynamicTip(this);
127 127
128 // set default values used for drawing the matrix 128 // set default values used for drawing the matrix
129 mDefaultBackColor = palette().active().base(); 129 mDefaultBackColor = palette().active().base();
130 mDefaultTextColor = palette().active().foreground(); 130 mDefaultTextColor = palette().active().foreground();
131 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 131 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
132 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 132 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
133 mSelectedDaysColor = QColor("white"); 133 mSelectedDaysColor = QColor("white");
134 mTodayMarginWidth = 2; 134 mTodayMarginWidth = 2;
135 mSelEnd = mSelStart = NOSELECTION; 135 mSelEnd = mSelStart = NOSELECTION;
136 136
137 setAcceptDrops(true); 137 setAcceptDrops(true);
138 //setFont( QFont("Arial", 10) ); 138 //setFont( QFont("Arial", 10) );
139 139
140 mUpdateTimer = new QTimer( this ); 140 mUpdateTimer = new QTimer( this );
141 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 141 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
142 mRepaintTimer = new QTimer( this ); 142 mRepaintTimer = new QTimer( this );
143 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 143 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
144 mDayChanged = false; 144 mDayChanged = false;
145 updateView(); 145 updateView();
146} 146}
147QString KODayMatrix::getWhatsThisText( QPoint p ) 147QString KODayMatrix::getWhatsThisText( QPoint p )
148{ 148{
149 149
150 int tmp = getDayIndexFrom(p.x(), p.y()); 150 int tmp = getDayIndexFrom(p.x(), p.y());
151 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 151 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
152 return QString(); 152 return QString();
153 QDate mDate = days[tmp]; 153 QDate mDate = days[tmp];
154 QPtrList<Event> eventlist = mCalendar->events(mDate); 154 QPtrList<Event> eventlist = mCalendar->events(mDate);
155 Event *event; 155 Event *event;
156 QStringList mToolTip; 156 QStringList mToolTip;
157 for(event=eventlist.first();event != 0;event=eventlist.next()) { 157 for(event=eventlist.first();event != 0;event=eventlist.next()) {
158 QString mToolTipText; 158 QString mToolTipText;
159 QString text; 159 QString text;
160 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 160 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
161 if (event->isMultiDay()) { 161 if (event->isMultiDay()) {
162 QString prefix = "<->";multiday = 2; 162 QString prefix = "<->";multiday = 2;
163 QString time; 163 QString time;
164 if ( event->doesRecur() ) { 164 if ( event->doesRecur() ) {
165 if ( event->recursOn( mDate) ) { 165 if ( event->recursOn( mDate) ) {
166 prefix ="->" ;multiday = 1; 166 prefix ="->" ;multiday = 1;
167 } 167 }
168 else { 168 else {
169 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 169 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
170 if ( event->recursOn( mDate.addDays( -days)) ) { 170 if ( event->recursOn( mDate.addDays( -days)) ) {
171 prefix ="<-" ;multiday = 3; 171 prefix ="<-" ;multiday = 3;
172 } 172 }
173 } 173 }
174 } else { 174 } else {
175 if (mDate == event->dtStart().date()) { 175 if (mDate == event->dtStart().date()) {
176 prefix ="->" ;multiday = 1; 176 prefix ="->" ;multiday = 1;
177 } else if (mDate == event->dtEnd().date()) { 177 } else if (mDate == event->dtEnd().date()) {
178 prefix ="<-" ;multiday = 3; 178 prefix ="<-" ;multiday = 3;
179 } 179 }
180 } 180 }
181 if ( !event->doesFloat() ) { 181 if ( !event->doesFloat() ) {
182 if ( mDate == event->dtStart().date () ) 182 if ( mDate == event->dtStart().date () )
183 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 183 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
184 else if ( mDate == event->dtEnd().date () ) 184 else if ( mDate == event->dtEnd().date () )
185 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 185 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
186 186
187 } 187 }
188 text = time + event->summary(); 188 text = time + event->summary();
189 mToolTipText += prefix + text; 189 mToolTipText += prefix + text;
190 } else { 190 } else {
191 if (event->doesFloat()) { 191 if (event->doesFloat()) {
192 text = event->summary(); 192 text = event->summary();
193 mToolTipText += text; 193 mToolTipText += text;
194 } 194 }
195 else { 195 else {
196 text = KGlobal::locale()->formatTime(event->dtStart().time()); 196 text = KGlobal::locale()->formatTime(event->dtStart().time());
197 text += " " + event->summary(); 197 text += " " + event->summary();
198 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 198 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
199 } 199 }
200 } 200 }
201 if ( !event->location().isEmpty() ) 201 if ( !event->location().isEmpty() )
202 mToolTipText += " (" + event->location() + ")"; 202 mToolTipText += " (" + event->location() + ")";
203 //qDebug("TTT: %s ", mToolTipText.latin1()); 203 //qDebug("TTT: %s ", mToolTipText.latin1());
204 mToolTip.append( deTag( mToolTipText ) ); 204 mToolTip.append( deTag( mToolTipText ) );
205 } 205 }
206 mToolTip.sort();
206 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 207 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
207 QPtrList<Todo> todolist = mCalendar->todos(mDate); 208 QPtrList<Todo> todolist = mCalendar->todos(mDate);
208 Todo *todo; 209 Todo *todo;
209 for(todo=todolist.first();todo != 0;todo=todolist.next()) { 210 for(todo=todolist.first();todo != 0;todo=todolist.next()) {
210 QString mToolTipText; 211 QString mToolTipText;
211 if ( !todo->doesFloat() ) 212 if ( !todo->doesFloat() )
212 mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; 213 mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" ";
213 mToolTipText += todo->summary(); 214 mToolTipText += todo->summary();
214 if ( !todo->location().isEmpty() ) 215 if ( !todo->location().isEmpty() )
215 mToolTipText += " (" + todo->location() + ")"; 216 mToolTipText += " (" + todo->location() + ")";
216 mToolTipText = deTag( mToolTipText); 217 mToolTipText = deTag( mToolTipText);
217 mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; 218 mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText;
218 mToolTip.append( mToolTipText ); 219 mToolTip.append( mToolTipText );
219 } 220 }
220 } 221 }
221 mToolTip.sort();
222 if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 222 if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
223 Journal *j = mCalendar->journal( mDate ); 223 Journal *j = mCalendar->journal( mDate );
224 if ( j ) { 224 if ( j ) {
225 QString mToolTipText = j->description().left(100); 225 QString mToolTipText = j->description().left(100);
226 if ( j->description().length() > 100 ) 226 if ( j->description().length() > 100 )
227 mToolTipText += " ..."; 227 mToolTipText += " ...";
228 mToolTipText = deTag( mToolTipText); 228 mToolTipText = deTag( mToolTipText);
229 mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; 229 mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText;
230 mToolTip.append( mToolTipText ); 230 mToolTip.append( mToolTipText );
231 } 231 }
232 } 232 }
233 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 233 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
234} 234}
235 235
236 236
237QString KODayMatrix::deTag( QString mToolTipText ) 237QString KODayMatrix::deTag( QString mToolTipText )
238{ 238{
239 239
240#if QT_VERSION >= 0x030000 240#if QT_VERSION >= 0x030000
241 mToolTipText.replace( '<' , "&lt;" ); 241 mToolTipText.replace( '<' , "&lt;" );
242 mToolTipText.replace( '>' , "&gt;" ); 242 mToolTipText.replace( '>' , "&gt;" );
243#else 243#else
244 if ( mToolTipText.find ('<') >= 0 ) { 244 if ( mToolTipText.find ('<') >= 0 ) {
245 mToolTipText.replace( QRegExp("<") , "&lt;" ); 245 mToolTipText.replace( QRegExp("<") , "&lt;" );
246 } 246 }
247 if ( mToolTipText.find ('>') >= 0 ) { 247 if ( mToolTipText.find ('>') >= 0 ) {
248 mToolTipText.replace( QRegExp(">") , "&gt;" ); 248 mToolTipText.replace( QRegExp(">") , "&gt;" );
249 } 249 }
250#endif 250#endif
251 return mToolTipText; 251 return mToolTipText;
252} 252}
253void KODayMatrix::setCalendar( Calendar *cal ) 253void KODayMatrix::setCalendar( Calendar *cal )
254{ 254{
255 mCalendar = cal; 255 mCalendar = cal;
256 256
257 setAcceptDrops( mCalendar ); 257 setAcceptDrops( mCalendar );
258 258
259 updateEvents(); 259 updateEvents();
260} 260}
261 261
262QColor KODayMatrix::getShadedColor(QColor color) 262QColor KODayMatrix::getShadedColor(QColor color)
263{ 263{
264 QColor shaded; 264 QColor shaded;
265 int h=0; 265 int h=0;
266 int s=0; 266 int s=0;
267 int v=0; 267 int v=0;
268 color.hsv(&h,&s,&v); 268 color.hsv(&h,&s,&v);
269 s = s/4; 269 s = s/4;
270 v = 192+v/4; 270 v = 192+v/4;
271 shaded.setHsv(h,s,v); 271 shaded.setHsv(h,s,v);
272 272
273 return shaded; 273 return shaded;
274} 274}
275 275
276KODayMatrix::~KODayMatrix() 276KODayMatrix::~KODayMatrix()
277{ 277{
278#if QT_VERSION >= 0x030000 278#if QT_VERSION >= 0x030000
279 279
280#else 280#else
281 delete mKODaymatrixWhatsThis; 281 delete mKODaymatrixWhatsThis;
282#endif 282#endif
283 283
284 // delete mKODaymatrixWhatsThis; 284 // delete mKODaymatrixWhatsThis;
285 delete [] days; 285 delete [] days;
286 delete [] daylbls; 286 delete [] daylbls;
287 //delete [] events; 287 //delete [] events;
288 delete mToolTip; 288 delete mToolTip;
289} 289}
290 290
291/* 291/*
292void KODayMatrix::setStartDate(QDate start) 292void KODayMatrix::setStartDate(QDate start)
293{ 293{
294 updateView(start); 294 updateView(start);
295} 295}
296*/ 296*/
297 297
298void KODayMatrix::addSelectedDaysTo(DateList& selDays) 298void KODayMatrix::addSelectedDaysTo(DateList& selDays)
299{ 299{
300 300
301 if (mSelStart == NOSELECTION) { 301 if (mSelStart == NOSELECTION) {
302 return; 302 return;
303 } 303 }
304 304
305 //cope with selection being out of matrix limits at top (< 0) 305 //cope with selection being out of matrix limits at top (< 0)
306 int i0 = mSelStart; 306 int i0 = mSelStart;
307 if (i0 < 0) { 307 if (i0 < 0) {
308 for (int i = i0; i < 0; i++) { 308 for (int i = i0; i < 0; i++) {
309 selDays.append(days[0].addDays(i)); 309 selDays.append(days[0].addDays(i));
310 } 310 }
311 i0 = 0; 311 i0 = 0;
312 } 312 }
313 313
314 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 314 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
315 if (mSelEnd > NUMDAYS-1) { 315 if (mSelEnd > NUMDAYS-1) {
316 for (int i = i0; i <= NUMDAYS-1; i++) { 316 for (int i = i0; i <= NUMDAYS-1; i++) {
317 selDays.append(days[i]); 317 selDays.append(days[i]);
318 } 318 }
319 for (int i = NUMDAYS; i < mSelEnd; i++) { 319 for (int i = NUMDAYS; i < mSelEnd; i++) {
320 selDays.append(days[0].addDays(i)); 320 selDays.append(days[0].addDays(i));
321 } 321 }
322 322
323 // apply normal routine to selection being entirely within matrix limits 323 // apply normal routine to selection being entirely within matrix limits
324 } else { 324 } else {
325 for (int i = i0; i <= mSelEnd; i++) { 325 for (int i = i0; i <= mSelEnd; i++) {
326 selDays.append(days[i]); 326 selDays.append(days[i]);
327 } 327 }
328 } 328 }
329} 329}
330 330
331bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 331bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
332{ 332{
333 mRedrawNeeded = true; 333 mRedrawNeeded = true;
334 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 334 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
335 mSelStart = startdate.daysTo(start); 335 mSelStart = startdate.daysTo(start);
336 if ( mSelStart < 0 ) 336 if ( mSelStart < 0 )
337 mSelStart = 0; 337 mSelStart = 0;
338 mSelEnd = startdate.daysTo(end); 338 mSelEnd = startdate.daysTo(end);
339 if ( mSelEnd > NUMDAYS-1 ) 339 if ( mSelEnd > NUMDAYS-1 )
340 mSelEnd = NUMDAYS-1; 340 mSelEnd = NUMDAYS-1;
341 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 341 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
342 clearSelection(); 342 clearSelection();
343 if ( noSel ) 343 if ( noSel )
344 return false; 344 return false;
345 } 345 }
346 346
347 return true; 347 return true;
348} 348}
349void KODayMatrix::clearSelection() 349void KODayMatrix::clearSelection()
350{ 350{
351 mSelEnd = mSelStart = NOSELECTION; 351 mSelEnd = mSelStart = NOSELECTION;
352} 352}
353 353
354 354
355void KODayMatrix::recalculateToday() 355void KODayMatrix::recalculateToday()
356{ 356{
357 today = -1; 357 today = -1;
358 for (int i=0; i<NUMDAYS; i++) { 358 for (int i=0; i<NUMDAYS; i++) {
359 //events[i] = 0; 359 //events[i] = 0;
360 days[i] = startdate.addDays(i); 360 days[i] = startdate.addDays(i);
361 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 361 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
362 362
363 // if today is in the currently displayed month, hilight today 363 // if today is in the currently displayed month, hilight today
364 if (days[i].year() == QDate::currentDate().year() && 364 if (days[i].year() == QDate::currentDate().year() &&
365 days[i].month() == QDate::currentDate().month() && 365 days[i].month() == QDate::currentDate().month() &&
366 days[i].day() == QDate::currentDate().day()) { 366 days[i].day() == QDate::currentDate().day()) {
367 today = i; 367 today = i;
368 } 368 }
369 } 369 }
370 // qDebug(QString("Today is visible at %1.").arg(today)); 370 // qDebug(QString("Today is visible at %1.").arg(today));
371} 371}
372 372
373void KODayMatrix::updateView() 373void KODayMatrix::updateView()
374{ 374{
375 updateView(startdate); 375 updateView(startdate);
376} 376}
377void KODayMatrix::repaintViewTimed() 377void KODayMatrix::repaintViewTimed()
378{ 378{
379 mRedrawNeeded = true; 379 mRedrawNeeded = true;
380 // bDays.fill( false); 380 // bDays.fill( false);
381 //pDays.fill( false); 381 //pDays.fill( false);
382 //hDays.fill( false); 382 //hDays.fill( false);
383 //eDays.fill( false); 383 //eDays.fill( false);
384 mRepaintTimer->stop(); 384 mRepaintTimer->stop();
385 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 385 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
386 int i; 386 int i;
387 for(i = 0; i < NUMDAYS; i++) { 387 for(i = 0; i < NUMDAYS; i++) {
388 if ( ( (i+startDay) % 7 == 0 ) ) { 388 if ( ( (i+startDay) % 7 == 0 ) ) {
389 pDays.setBit(i); 389 pDays.setBit(i);
390 } 390 }
391 } 391 }
392 repaint(false); 392 repaint(false);
393} 393}
394void KODayMatrix::computeEvent(Event *event, int i ) 394void KODayMatrix::computeEvent(Event *event, int i )
395{ 395{
396 QString holiStr = mHolidays[i]; 396 QString holiStr = mHolidays[i];
397 if ( event->isHoliday()) { 397 if ( event->isHoliday()) {
398 pDays.setBit(i); 398 pDays.setBit(i);
399 hDays.setBit(i); 399 hDays.setBit(i);
400 if ( !holiStr.isEmpty() ) 400 if ( !holiStr.isEmpty() )
401 holiStr += "\n"; 401 holiStr += "\n";
402 holiStr += event->summary(); 402 holiStr += event->summary();
403 if ( !event->location().isEmpty() ) 403 if ( !event->location().isEmpty() )
404 holiStr += " (" + event->location() + ")"; 404 holiStr += " (" + event->location() + ")";
405 mHolidays[i] =holiStr ; 405 mHolidays[i] =holiStr ;
406 eDays.setBit(i); 406 eDays.setBit(i);
407 } 407 }
408 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { 408 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) {
409 if ( event->isBirthday()) { 409 if ( event->isBirthday()) {
410 pDays.setBit(i); 410 pDays.setBit(i);
411 if ( !holiStr.isEmpty() ) 411 if ( !holiStr.isEmpty() )
412 holiStr += "\n"; 412 holiStr += "\n";
413 holiStr += i18n("Birthday") + ": "+event->summary(); 413 holiStr += i18n("Birthday") + ": "+event->summary();
414 if ( !event->location().isEmpty() ) 414 if ( !event->location().isEmpty() )
415 holiStr += " (" + event->location() + ")"; 415 holiStr += " (" + event->location() + ")";
416 bDays.setBit(i); 416 bDays.setBit(i);
417 mHolidays[i] =holiStr ; 417 mHolidays[i] =holiStr ;
418 } 418 }
419 } 419 }
420 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) 420 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW )
421 eDays.setBit(i); 421 eDays.setBit(i);
422} 422}
423void KODayMatrix::updateViewTimed() 423void KODayMatrix::updateViewTimed()
424{ 424{
425 mUpdateTimer->stop(); 425 mUpdateTimer->stop();
426 if ( !mCalendar ) { 426 if ( !mCalendar ) {
427 qDebug("NOT CAL "); 427 qDebug("NOT CAL ");
428 return; 428 return;
429 } 429 }
430#if 1 430#if 1
431 431
432 432
433 int i; 433 int i;
434 int timeSpan = NUMDAYS-1; 434 int timeSpan = NUMDAYS-1;
435 QPtrList<Event> events = mCalendar->events(); 435 QPtrList<Event> events = mCalendar->events();
436 Event *event; 436 Event *event;
437 QDateTime dt; 437 QDateTime dt;
438 bool ok; 438 bool ok;
439 bDays.fill( false); 439 bDays.fill( false);
440 pDays.fill( false); 440 pDays.fill( false);
441 hDays.fill( false); 441 hDays.fill( false);
442 eDays.fill( false); 442 eDays.fill( false);
443 mHolidays.clear(); 443 mHolidays.clear();
444 QDate mStartDate = days[0]; 444 QDate mStartDate = days[0];
445 QDate endDate = mStartDate.addDays( timeSpan ); 445 QDate endDate = mStartDate.addDays( timeSpan );
446 for( event = events.first(); event; event = events.next() ) { // for event 446 for( event = events.first(); event; event = events.next() ) { // for event
447 ushort recurType = event->recurrence()->doesRecur(); 447 ushort recurType = event->recurrence()->doesRecur();
448 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 448 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
449 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 449 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
450 continue; 450 continue;
451 } 451 }
452 if ( event->doesRecur() ) { 452 if ( event->doesRecur() ) {
453 bool last; 453 bool last;
454 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 454 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
455 QDateTime incidenceEnd; 455 QDateTime incidenceEnd;
456 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 456 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
457 bool invalid = false; 457 bool invalid = false;
458 while( true ) { 458 while( true ) {
459 if ( incidenceStart.isValid() ) { 459 if ( incidenceStart.isValid() ) {
460 incidenceEnd = incidenceStart.addDays( eventlen ); 460 incidenceEnd = incidenceStart.addDays( eventlen );
461 int st = incidenceStart.date().daysTo( endDate ); 461 int st = incidenceStart.date().daysTo( endDate );
462 if ( st >= 0 ) { // start before timeend 462 if ( st >= 0 ) { // start before timeend
463 int end = mStartDate.daysTo( incidenceEnd.date() ); 463 int end = mStartDate.daysTo( incidenceEnd.date() );
464 if ( end >= 0 ) { // end after timestart --- got one! 464 if ( end >= 0 ) { // end after timestart --- got one!
465 //normalize 465 //normalize
466 st = timeSpan - st; 466 st = timeSpan - st;
467 if ( st < 0 ) st = 0; 467 if ( st < 0 ) st = 0;
468 if ( end > timeSpan ) end = timeSpan; 468 if ( end > timeSpan ) end = timeSpan;
469 int iii; 469 int iii;
470 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 470 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
471 for ( iii = st;iii<= end;++iii) { 471 for ( iii = st;iii<= end;++iii) {
472 computeEvent( event, iii ); 472 computeEvent( event, iii );
473 } 473 }
474 } 474 }
475 } 475 }
476 } else { 476 } else {
477 if ( invalid ) 477 if ( invalid )
478 break; 478 break;
479 invalid = true; 479 invalid = true;
480 //qDebug("invalid %s", event->summary().latin1()); 480 //qDebug("invalid %s", event->summary().latin1());
481 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 481 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
482 } 482 }
483 if ( last ) 483 if ( last )
484 break; 484 break;
485 bool ok; 485 bool ok;
486 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 486 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
487 if ( ! ok ) 487 if ( ! ok )
488 break; 488 break;
489 if ( incidenceStart.date() > endDate ) 489 if ( incidenceStart.date() > endDate )
490 break; 490 break;
491 } 491 }
492 } else { // no recur 492 } else { // no recur
493 int st = event->dtStart().date().daysTo( endDate ); 493 int st = event->dtStart().date().daysTo( endDate );
494 if ( st >= 0 ) { // start before timeend 494 if ( st >= 0 ) { // start before timeend
495 int end = mStartDate.daysTo( event->dtEnd().date() ); 495 int end = mStartDate.daysTo( event->dtEnd().date() );
496 if ( end >= 0 ) { // end after timestart --- got one! 496 if ( end >= 0 ) { // end after timestart --- got one!
497 //normalize 497 //normalize
498 st = timeSpan - st; 498 st = timeSpan - st;
499 if ( st < 0 ) st = 0; 499 if ( st < 0 ) st = 0;
500 if ( end > timeSpan ) end = timeSpan; 500 if ( end > timeSpan ) end = timeSpan;
501 int iii; 501 int iii;
502 for ( iii = st;iii<= end;++iii) 502 for ( iii = st;iii<= end;++iii)
503 computeEvent( event, iii ); 503 computeEvent( event, iii );
504 } 504 }
505 } 505 }
506 } 506 }
507 } 507 }
508 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 508 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
509 for(i = 0; i < NUMDAYS; i++) { 509 for(i = 0; i < NUMDAYS; i++) {
510 if ( ( (i+startDay) % 7 == 0 ) ) { 510 if ( ( (i+startDay) % 7 == 0 ) ) {
511 pDays.setBit(i); 511 pDays.setBit(i);
512 } 512 }
513 } 513 }
514 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 514 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
515 bDays.fill( false); 515 bDays.fill( false);
516 // insert due todos 516 // insert due todos
517 QPtrList<Todo> todos = mCalendar->todos( ); 517 QPtrList<Todo> todos = mCalendar->todos( );
518 Todo *todo; 518 Todo *todo;
519 for(todo = todos.first(); todo; todo = todos.next()) { 519 for(todo = todos.first(); todo; todo = todos.next()) {
520 //insertTodo( todo ); 520 //insertTodo( todo );
521 if ( todo->hasDueDate() ) { 521 if ( todo->hasDueDate() ) {
522 int day = mStartDate.daysTo( todo->dtDue().date() ); 522 int day = mStartDate.daysTo( todo->dtDue().date() );
523 if ( day >= 0 && day < timeSpan + 1) { 523 if ( day >= 0 && day < timeSpan + 1) {
524 int i = day; 524 int i = day;
525 QString holiStr = mHolidays[i]; 525 QString holiStr = mHolidays[i];
526 pDays.setBit(i); 526 pDays.setBit(i);
527 if ( !holiStr.isEmpty() ) 527 if ( !holiStr.isEmpty() )
528 holiStr += "\n"; 528 holiStr += "\n";
529 holiStr += i18n("Todo") + ": "+todo->summary(); 529 holiStr += i18n("Todo") + ": "+todo->summary();
530 if ( !todo->location().isEmpty() ) 530 if ( !todo->location().isEmpty() )
531 holiStr += " (" + todo->location() + ")"; 531 holiStr += " (" + todo->location() + ")";
532 bDays.setBit(i); 532 bDays.setBit(i);
533 mHolidays[i] =holiStr ; 533 mHolidays[i] =holiStr ;
534 eDays.setBit(i); 534 eDays.setBit(i);
535 } 535 }
536 } 536 }
537 } 537 }
538 } 538 }
539 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 539 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
540 bDays.fill( false); 540 bDays.fill( false);
541 // insert due todos 541 // insert due todos
542 QPtrList<Journal> todos = mCalendar->journals( ); 542 QPtrList<Journal> todos = mCalendar->journals( );
543 Journal *todo; 543 Journal *todo;
544 for(todo = todos.first(); todo; todo = todos.next()) { 544 for(todo = todos.first(); todo; todo = todos.next()) {
545 int day = mStartDate.daysTo( todo->dtStart().date() ); 545 int day = mStartDate.daysTo( todo->dtStart().date() );
546 if ( day >= 0 && day < timeSpan + 1) { 546 if ( day >= 0 && day < timeSpan + 1) {
547 int i = day; 547 int i = day;
548 QString holiStr = mHolidays[i]; 548 QString holiStr = mHolidays[i];
549 pDays.setBit(i); 549 pDays.setBit(i);
550 if ( !holiStr.isEmpty() ) 550 if ( !holiStr.isEmpty() )
551 holiStr += "\n"; 551 holiStr += "\n";
552 holiStr += i18n("Journal"); 552 holiStr += i18n("Journal");
553 bDays.setBit(i); 553 bDays.setBit(i);
554 mHolidays[i] =holiStr ; 554 mHolidays[i] =holiStr ;
555 eDays.setBit(i); 555 eDays.setBit(i);
556 556
557 } 557 }
558 } 558 }
559 } 559 }
560#else 560#else
561 //qDebug("KODayMatrix::updateViewTimed "); 561 //qDebug("KODayMatrix::updateViewTimed ");
562 for(int i = 0; i < NUMDAYS; i++) { 562 for(int i = 0; i < NUMDAYS; i++) {
563 // if events are set for the day then remember to draw it bold 563 // if events are set for the day then remember to draw it bold
564 QPtrList<Event> eventlist = mCalendar->events(days[i]); 564 QPtrList<Event> eventlist = mCalendar->events(days[i]);
565 Event *event; 565 Event *event;
566 int numEvents = eventlist.count(); 566 int numEvents = eventlist.count();
567 QString holiStr = ""; 567 QString holiStr = "";
568 bDays.clearBit(i); 568 bDays.clearBit(i);
569 hDays.clearBit(i); 569 hDays.clearBit(i);
570 eDays.clearBit(i); 570 eDays.clearBit(i);
571 for(event=eventlist.first();event != 0;event=eventlist.next()) { 571 for(event=eventlist.first();event != 0;event=eventlist.next()) {
572 ushort recurType = event->recurrence()->doesRecur(); 572 ushort recurType = event->recurrence()->doesRecur();
573 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 573 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
574 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 574 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
575 numEvents--; 575 numEvents--;
576 } 576 }
577 if ( event->isHoliday()) { 577 if ( event->isHoliday()) {
578 hDays.setBit(i); 578 hDays.setBit(i);
579 if ( !holiStr.isEmpty() ) 579 if ( !holiStr.isEmpty() )
580 holiStr += "\n"; 580 holiStr += "\n";
581 holiStr += event->summary(); 581 holiStr += event->summary();
582 if ( !event->location().isEmpty() ) 582 if ( !event->location().isEmpty() )
583 holiStr += " (" + event->location() + ")"; 583 holiStr += " (" + event->location() + ")";
584 } 584 }
585 if ( event->isBirthday()) { 585 if ( event->isBirthday()) {
586 if ( !holiStr.isEmpty() ) 586 if ( !holiStr.isEmpty() )
587 holiStr += "\n"; 587 holiStr += "\n";
588 holiStr += i18n("Birthday") + ": "+event->summary(); 588 holiStr += i18n("Birthday") + ": "+event->summary();
589 if ( !event->location().isEmpty() ) 589 if ( !event->location().isEmpty() )
590 holiStr += " (" + event->location() + ")"; 590 holiStr += " (" + event->location() + ")";
591 bDays.setBit(i); 591 bDays.setBit(i);
592 } 592 }
593 } 593 }
594 if ( numEvents ) 594 if ( numEvents )
595 eDays.setBit(i); 595 eDays.setBit(i);
596 //if it is a holy day then draw it red. Sundays are consider holidays, too 596 //if it is a holy day then draw it red. Sundays are consider holidays, too
597 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 597 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
598 !holiStr.isEmpty()) { 598 !holiStr.isEmpty()) {
599 mHolidays[i] = holiStr; 599 mHolidays[i] = holiStr;
600 } else { 600 } else {
601 mHolidays[i] = QString::null; 601 mHolidays[i] = QString::null;
602 } 602 }
603 } 603 }
604#endif 604#endif
605 mRedrawNeeded = true; 605 mRedrawNeeded = true;
606 if ( ! mPendingUpdateBeforeRepaint ) 606 if ( ! mPendingUpdateBeforeRepaint )
607 repaint(false); 607 repaint(false);
608} 608}
609void KODayMatrix::updateView(QDate actdate) 609void KODayMatrix::updateView(QDate actdate)
610{ 610{
611 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) 611 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView )
612 mRedrawNeeded = true; 612 mRedrawNeeded = true;
613 mLastView = KOPrefs::instance()->mCurrentDisplayedView; 613 mLastView = KOPrefs::instance()->mCurrentDisplayedView;
614 if ( ! actdate.isValid() ) { 614 if ( ! actdate.isValid() ) {
615 //qDebug("date not valid "); 615 //qDebug("date not valid ");
616 return; 616 return;
617 } 617 }
618 mDayChanged = false; 618 mDayChanged = false;
619 //flag to indicate if the starting day of the matrix has changed by this call 619 //flag to indicate if the starting day of the matrix has changed by this call
620 //mDayChanged = false; 620 //mDayChanged = false;
621 // if a new startdate is to be set then apply Cornelius's calculation 621 // if a new startdate is to be set then apply Cornelius's calculation
622 // of the first day to be shown 622 // of the first day to be shown
623 if (actdate != startdate) { 623 if (actdate != startdate) {
624 // reset index of selection according to shift of starting date from startdate to actdate 624 // reset index of selection according to shift of starting date from startdate to actdate
625 if (mSelStart != NOSELECTION) { 625 if (mSelStart != NOSELECTION) {
626 int tmp = actdate.daysTo(startdate); 626 int tmp = actdate.daysTo(startdate);
627 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 627 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
628 // shift selection if new one would be visible at least partly ! 628 // shift selection if new one would be visible at least partly !
629 629
630 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 630 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
631 // nested if is required for next X display pushed from a different month - correction required 631 // nested if is required for next X display pushed from a different month - correction required
632 // otherwise, for month forward and backward, it must be avoided 632 // otherwise, for month forward and backward, it must be avoided
633 if( mSelStart > NUMDAYS || mSelStart < 0 ) 633 if( mSelStart > NUMDAYS || mSelStart < 0 )
634 mSelStart = mSelStart + tmp; 634 mSelStart = mSelStart + tmp;
635 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 635 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
636 mSelEnd = mSelEnd + tmp; 636 mSelEnd = mSelEnd + tmp;
637 } 637 }
638 } 638 }
639 startdate = actdate; 639 startdate = actdate;
640 mDayChanged = true; 640 mDayChanged = true;
641 recalculateToday(); 641 recalculateToday();
642 mRedrawNeeded = true; 642 mRedrawNeeded = true;
643 } 643 }
644 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 644 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
645 if ( !isVisible() ) { 645 if ( !isVisible() ) {
646 mPendingUpdateBeforeRepaint = true; 646 mPendingUpdateBeforeRepaint = true;
647 } else { 647 } else {
648#ifdef DESKTOP_VERSION 648#ifdef DESKTOP_VERSION
649 //mRepaintTimer->start( 100 ); 649 //mRepaintTimer->start( 100 );
650 //updateViewTimed(); 650 //updateViewTimed();
651 mUpdateTimer->start( 50 ); 651 mUpdateTimer->start( 50 );
652#else 652#else
653 mRepaintTimer->start( 350 ); 653 mRepaintTimer->start( 350 );
654 mUpdateTimer->start( 800 ); 654 mUpdateTimer->start( 800 );
655#endif 655#endif
656 } 656 }
657} 657}
658void KODayMatrix::updateEvents() 658void KODayMatrix::updateEvents()
659{ 659{
660 if ( !mCalendar ) return; 660 if ( !mCalendar ) return;
661 661
662 for( int i = 0; i < NUMDAYS; i++ ) { 662 for( int i = 0; i < NUMDAYS; i++ ) {
663 // if events are set for the day then remember to draw it bold 663 // if events are set for the day then remember to draw it bold
664 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 664 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
665 int numEvents = eventlist.count(); 665 int numEvents = eventlist.count();
666 Event *event; 666 Event *event;
667 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 667 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
668 ushort recurType = event->doesRecur(); 668 ushort recurType = event->doesRecur();
669 669
670 if ( ( recurType == Recurrence::rDaily && 670 if ( ( recurType == Recurrence::rDaily &&
671 !KOPrefs::instance()->mDailyRecur ) || 671 !KOPrefs::instance()->mDailyRecur ) ||
672 ( recurType == Recurrence::rWeekly && 672 ( recurType == Recurrence::rWeekly &&
673 !KOPrefs::instance()->mWeeklyRecur ) ) { 673 !KOPrefs::instance()->mWeeklyRecur ) ) {
674 numEvents--; 674 numEvents--;
675 } 675 }
676 } 676 }
677 if ( numEvents ) 677 if ( numEvents )
678 eDays.setBit(i); 678 eDays.setBit(i);
679 else 679 else
680 eDays.clearBit(i); 680 eDays.clearBit(i);
681 } 681 }
682} 682}
683 683
684const QDate& KODayMatrix::getDate(int offset) 684const QDate& KODayMatrix::getDate(int offset)
685{ 685{
686 if (offset < 0 || offset > NUMDAYS-1) { 686 if (offset < 0 || offset > NUMDAYS-1) {
687 qDebug("Wrong offset2 %d", offset); 687 qDebug("Wrong offset2 %d", offset);
688 return days[0]; 688 return days[0];
689 } 689 }
690 return days[offset]; 690 return days[offset];
691} 691}
692 692
693QString KODayMatrix::getHolidayLabel(int offset) 693QString KODayMatrix::getHolidayLabel(int offset)
694{ 694{
695 if (offset < 0 || offset > NUMDAYS-1) { 695 if (offset < 0 || offset > NUMDAYS-1) {
696 qDebug("Wrong offset1 %d", offset); 696 qDebug("Wrong offset1 %d", offset);
697 return QString(); 697 return QString();
698 } 698 }
699 return mHolidays[offset]; 699 return mHolidays[offset];
700} 700}
701 701
702int KODayMatrix::getDayIndexFrom(int x, int y) 702int KODayMatrix::getDayIndexFrom(int x, int y)
703{ 703{
704 int colModulo = (width()-2) % 7; 704 int colModulo = (width()-2) % 7;
705 int rowModulo = (height()-2) % 6; 705 int rowModulo = (height()-2) % 6;
706#if 0 706#if 0
707 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 707 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
708 6 - x/daysize.width() : x/daysize.width()); 708 6 - x/daysize.width() : x/daysize.width());
709#endif 709#endif
710 int xVal = (x-colModulo/2-2)/daysize.width(); 710 int xVal = (x-colModulo/2-2)/daysize.width();
711 int yVal = (y-rowModulo/2-2)/daysize.height(); 711 int yVal = (y-rowModulo/2-2)/daysize.height();
712 712
713 713
714 return 7*(yVal) + xVal; 714 return 7*(yVal) + xVal;
715 715
716} 716}
717 717
718// ---------------------------------------------------------------------------- 718// ----------------------------------------------------------------------------
719// M O U S E E V E N T H A N D L I N G 719// M O U S E E V E N T H A N D L I N G
720// ---------------------------------------------------------------------------- 720// ----------------------------------------------------------------------------
721 721
722void KODayMatrix::mousePressEvent (QMouseEvent* e) 722void KODayMatrix::mousePressEvent (QMouseEvent* e)
723{ 723{
724 724
725 if ( e->button() == LeftButton ) 725 if ( e->button() == LeftButton )
726 mouseDown = true; 726 mouseDown = true;
727 mSelStart = getDayIndexFrom(e->x(), e->y()); 727 mSelStart = getDayIndexFrom(e->x(), e->y());
728 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 728 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
729 mSelInit = mSelStart; 729 mSelInit = mSelStart;
730 mSelEnd = mSelStart; 730 mSelEnd = mSelStart;
731 mRedrawNeeded = true; 731 mRedrawNeeded = true;
732 repaint(false); 732 repaint(false);
733} 733}
734 734
735void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 735void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
736{ 736{
737 mRedrawNeeded = true; 737 mRedrawNeeded = true;
738 if ( e->button() == LeftButton ) 738 if ( e->button() == LeftButton )
739 if ( ! mouseDown ) { 739 if ( ! mouseDown ) {
740 return; 740 return;
741 } 741 }
742 else 742 else
743 mouseDown = false; 743 mouseDown = false;
744 int tmp = getDayIndexFrom(e->x(), e->y()); 744 int tmp = getDayIndexFrom(e->x(), e->y());
745 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 745 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
746 746
747 if (mSelInit > tmp) { 747 if (mSelInit > tmp) {
748 mSelEnd = mSelInit; 748 mSelEnd = mSelInit;
749 if (tmp != mSelStart) { 749 if (tmp != mSelStart) {
750 mSelStart = tmp; 750 mSelStart = tmp;
751 repaint(false); 751 repaint(false);
752 } 752 }
753 } else { 753 } else {
754 mSelStart = mSelInit; 754 mSelStart = mSelInit;
755 755
756 //repaint only if selection has changed 756 //repaint only if selection has changed
757 if (tmp != mSelEnd) { 757 if (tmp != mSelEnd) {
758 mSelEnd = tmp; 758 mSelEnd = tmp;
759 repaint(false); 759 repaint(false);
760 } 760 }
761 } 761 }
762 762
763 DateList daylist; 763 DateList daylist;
764 if ( mSelStart < 0 ) 764 if ( mSelStart < 0 )
765 mSelStart = 0; 765 mSelStart = 0;
766 for (int i = mSelStart; i <= mSelEnd; i++) { 766 for (int i = mSelStart; i <= mSelEnd; i++) {
767 daylist.append(days[i]); 767 daylist.append(days[i]);
768 } 768 }
769 emit selected((const DateList)daylist); 769 emit selected((const DateList)daylist);
770 770
771} 771}
772 772
773void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 773void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
774{ 774{
775 if ( ! mouseDown ) { 775 if ( ! mouseDown ) {
776 return; 776 return;
777 } 777 }
778 mRedrawNeeded = true; 778 mRedrawNeeded = true;
779 int tmp = getDayIndexFrom(e->x(), e->y()); 779 int tmp = getDayIndexFrom(e->x(), e->y());
780 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 780 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
781 781
782 if (mSelInit > tmp) { 782 if (mSelInit > tmp) {
783 mSelEnd = mSelInit; 783 mSelEnd = mSelInit;
784 if (tmp != mSelStart) { 784 if (tmp != mSelStart) {
785 mSelStart = tmp; 785 mSelStart = tmp;
786 repaint(false); 786 repaint(false);
787 } 787 }
788 } else { 788 } else {
789 mSelStart = mSelInit; 789 mSelStart = mSelInit;
790 790
791 //repaint only if selection has changed 791 //repaint only if selection has changed
792 if (tmp != mSelEnd) { 792 if (tmp != mSelEnd) {
793 mSelEnd = tmp; 793 mSelEnd = tmp;
794 repaint(false); 794 repaint(false);
795 } 795 }
796 } 796 }
797} 797}
798 798
799// ---------------------------------------------------------------------------- 799// ----------------------------------------------------------------------------
800// D R A G ' N D R O P H A N D L I N G 800// D R A G ' N D R O P H A N D L I N G
801// ---------------------------------------------------------------------------- 801// ----------------------------------------------------------------------------
802 802
803void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 803void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
804{ 804{
805#ifndef KORG_NODND 805#ifndef KORG_NODND
806 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 806 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
807 e->ignore(); 807 e->ignore();
808 return; 808 return;
809 } 809 }
810 810
811 // some visual feedback 811 // some visual feedback
812// oldPalette = palette(); 812// oldPalette = palette();
813// setPalette(my_HilitePalette); 813// setPalette(my_HilitePalette);
814// update(); 814// update();
815#endif 815#endif
816} 816}
817 817
818void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 818void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
819{ 819{
820#ifndef KORG_NODND 820#ifndef KORG_NODND
821 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 821 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
822 e->ignore(); 822 e->ignore();
823 return; 823 return;
824 } 824 }
825 825
826 e->accept(); 826 e->accept();
827#endif 827#endif
828} 828}
829 829
830void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 830void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
831{ 831{
832#ifndef KORG_NODND 832#ifndef KORG_NODND
833// setPalette(oldPalette); 833// setPalette(oldPalette);
834// update(); 834// update();
835#endif 835#endif
836} 836}
837 837
838void KODayMatrix::dropEvent(QDropEvent *e) 838void KODayMatrix::dropEvent(QDropEvent *e)
839{ 839{
840#ifndef KORG_NODND 840#ifndef KORG_NODND
841// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 841// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
842 842
843 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 843 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
844 e->ignore(); 844 e->ignore();
845 return; 845 return;
846 } 846 }
847 847
848 DndFactory factory( mCalendar ); 848 DndFactory factory( mCalendar );
849 Event *event = factory.createDrop(e); 849 Event *event = factory.createDrop(e);
850 850
851 if (event) { 851 if (event) {
852 e->acceptAction(); 852 e->acceptAction();
853 853
854 Event *existingEvent = mCalendar->event(event->uid()); 854 Event *existingEvent = mCalendar->event(event->uid());
855 855
856 if(existingEvent) { 856 if(existingEvent) {
857 // uniquify event 857 // uniquify event
858 event->recreate(); 858 event->recreate();
859/* 859/*
860 KMessageBox::sorry(this, 860 KMessageBox::sorry(this,
861 i18n("Event already exists in this calendar."), 861 i18n("Event already exists in this calendar."),
862 i18n("Drop Event")); 862 i18n("Drop Event"));
863 delete event; 863 delete event;
864 return; 864 return;
865*/ 865*/
866 } 866 }
867// kdDebug() << "Drop new Event" << endl; 867// kdDebug() << "Drop new Event" << endl;
868 // Adjust date 868 // Adjust date
869 QDateTime start = event->dtStart(); 869 QDateTime start = event->dtStart();
870 QDateTime end = event->dtEnd(); 870 QDateTime end = event->dtEnd();
871 int duration = start.daysTo(end); 871 int duration = start.daysTo(end);
872 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 872 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
873 873
874 start.setDate(days[idx]); 874 start.setDate(days[idx]);
875 end.setDate(days[idx].addDays(duration)); 875 end.setDate(days[idx].addDays(duration));
876 876
877 event->setDtStart(start); 877 event->setDtStart(start);
878 event->setDtEnd(end); 878 event->setDtEnd(end);
879 mCalendar->addEvent(event); 879 mCalendar->addEvent(event);
880 880
881 emit eventDropped(event); 881 emit eventDropped(event);
882 } else { 882 } else {
883// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 883// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
884 e->ignore(); 884 e->ignore();
885 } 885 }
886#endif 886#endif
887} 887}
888 888
889// ---------------------------------------------------------------------------- 889// ----------------------------------------------------------------------------
890// P A I N T E V E N T H A N D L I N G 890// P A I N T E V E N T H A N D L I N G
891// ---------------------------------------------------------------------------- 891// ----------------------------------------------------------------------------
892 892
893void KODayMatrix::paintEvent(QPaintEvent * pevent) 893void KODayMatrix::paintEvent(QPaintEvent * pevent)
894{ 894{
895 895
896 if ( width() <= 0 || height() <= 0 ) 896 if ( width() <= 0 || height() <= 0 )
897 return; 897 return;
898 if ( mPendingUpdateBeforeRepaint ) { 898 if ( mPendingUpdateBeforeRepaint ) {
899 updateViewTimed(); 899 updateViewTimed();
900 mPendingUpdateBeforeRepaint = false; 900 mPendingUpdateBeforeRepaint = false;
901 } 901 }
902#if 0 902#if 0
903 if ( myPix.width() != width() || myPix.height()!=height() ) { 903 if ( myPix.width() != width() || myPix.height()!=height() ) {
904 myPix.resize(size() ); 904 myPix.resize(size() );
905 mRedrawNeeded = true; 905 mRedrawNeeded = true;
906 } 906 }
907#endif 907#endif
908 if ( oldW != width() || oldH !=height() ) 908 if ( oldW != width() || oldH !=height() )
909 mRedrawNeeded = true; 909 mRedrawNeeded = true;
910 910
911 oldH = height() ; 911 oldH = height() ;
912 oldW = width(); 912 oldW = width();
913 if ( myPix.width() < width() || myPix.height() < height() ) { 913 if ( myPix.width() < width() || myPix.height() < height() ) {
914 myPix.resize(size() ); 914 myPix.resize(size() );
915 mRedrawNeeded = true; 915 mRedrawNeeded = true;
916 916
917 } 917 }
918 918
919 if ( mRedrawNeeded ) { 919 if ( mRedrawNeeded ) {
920 //qDebug("REDRAW "); 920 //qDebug("REDRAW ");
921 QPainter p(&myPix); 921 QPainter p(&myPix);
922 p.setFont(font()); 922 p.setFont(font());
923 923
924 924
925 int dheight = daysize.height(); 925 int dheight = daysize.height();
926 int dwidth = daysize.width(); 926 int dwidth = daysize.width();
927 int row,col; 927 int row,col;
928 int selw, selh; 928 int selw, selh;
929 int xyOff = frameWidth(); 929 int xyOff = frameWidth();
930 int colModulo = (width()-2) % 7; 930 int colModulo = (width()-2) % 7;
931 int rowModulo = (height()-2) % 6; 931 int rowModulo = (height()-2) % 6;
932 //qDebug("col %d row %d ",colModulo,rowModulo ); 932 //qDebug("col %d row %d ",colModulo,rowModulo );
933 933
934 bool isRTL = KOGlobals::self()->reverseLayout(); 934 bool isRTL = KOGlobals::self()->reverseLayout();
935 935
936 // draw background and topleft frame 936 // draw background and topleft frame
937 p.fillRect(0,0,width(),height(), mDefaultBackColor); 937 p.fillRect(0,0,width(),height(), mDefaultBackColor);
938 p.setPen(mDefaultTextColor); 938 p.setPen(mDefaultTextColor);
939 p.drawRect(0, 0, width(), height()); 939 p.drawRect(0, 0, width(), height());
940 int mSelStartT = mSelStart; 940 int mSelStartT = mSelStart;
941 int mSelEndT = mSelEnd; 941 int mSelEndT = mSelEnd;
942 if ( mSelEndT >= NUMDAYS ) 942 if ( mSelEndT >= NUMDAYS )
943 mSelEndT = NUMDAYS-1; 943 mSelEndT = NUMDAYS-1;
944 // draw selected days with highlighted background color 944 // draw selected days with highlighted background color
945 if (mSelStart != NOSELECTION) { 945 if (mSelStart != NOSELECTION) {
946 bool skip = false; 946 bool skip = false;
947 if ( ! mouseDown ) { 947 if ( ! mouseDown ) {
948 int mo = days[20].month(); 948 int mo = days[20].month();
949 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 949 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
950 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 950 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
951 int startMo = days[mSelStartT].month(); 951 int startMo = days[mSelStartT].month();
952 int endMo = days[mSelEndT].month(); 952 int endMo = days[mSelEndT].month();
953 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 953 if ( startMo == 12 && mo == 1 && endMo <= 2 )
954 startMo = 1; 954 startMo = 1;
955 if ( endMo == 1 && mo == 12 ) 955 if ( endMo == 1 && mo == 12 )
956 endMo = 12; 956 endMo = 12;
957 if ( mo == 12 && startMo == 1 ) 957 if ( mo == 12 && startMo == 1 )
958 startMo = 13; 958 startMo = 13;
959 if ( (startMo > mo || endMo < mo) ) { 959 if ( (startMo > mo || endMo < mo) ) {
960 skip = true; 960 skip = true;
961 } else { 961 } else {
962 if ( days[mSelStartT].month() != mo ) { 962 if ( days[mSelStartT].month() != mo ) {
963 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 963 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
964 mSelStartT += add +1; 964 mSelStartT += add +1;
965 } 965 }
966 if ( days[mSelEndT].month() != mo ) { 966 if ( days[mSelEndT].month() != mo ) {
967 int sub = days[mSelEndT].day(); 967 int sub = days[mSelEndT].day();
968 mSelEndT -= sub ; 968 mSelEndT -= sub ;
969 } 969 }
970 } 970 }
971 } 971 }
972 //qDebug("SKIP %d ", skip); 972 //qDebug("SKIP %d ", skip);
973 if ( ! skip ) { 973 if ( ! skip ) {
974 row = mSelStartT/7; 974 row = mSelStartT/7;
975 col = mSelStartT -row*7; 975 col = mSelStartT -row*7;
976 QColor selcol = KOPrefs::instance()->mHighlightColor; 976 QColor selcol = KOPrefs::instance()->mHighlightColor;
977 int addCol = 0; 977 int addCol = 0;
978 int addRow = 0; 978 int addRow = 0;
979 int addRow2 = 0; 979 int addRow2 = 0;
980 int addCol2 = 0; 980 int addCol2 = 0;
981 if (row == mSelEndT/7) { 981 if (row == mSelEndT/7) {
982 if ( rowModulo ) { 982 if ( rowModulo ) {
983 if ( row >= 6 - rowModulo ) 983 if ( row >= 6 - rowModulo )
984 addRow = row - 5 + rowModulo; 984 addRow = row - 5 + rowModulo;
985 } 985 }
986 if ( colModulo ) { 986 if ( colModulo ) {
987 int colt1 = mSelEndT%7; 987 int colt1 = mSelEndT%7;
988 //qDebug("colt1 %d ", colt1 ); 988 //qDebug("colt1 %d ", colt1 );
989 if ( colt1 >= 7 - colModulo ) 989 if ( colt1 >= 7 - colModulo )
990 addCol = colt1 - 7 + colModulo+1; 990 addCol = colt1 - 7 + colModulo+1;
991 int colt = mSelStartT%7; 991 int colt = mSelStartT%7;
992 if ( colt >= 7 - colModulo ) 992 if ( colt >= 7 - colModulo )
993 addCol2 = colt - 7 + colModulo; 993 addCol2 = colt - 7 + colModulo;
994 addCol -= addCol2; 994 addCol -= addCol2;
995 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 995 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
996 } 996 }
997 // Single row selection 997 // Single row selection
998 //if ( row == 0) 998 //if ( row == 0)
999 // addRow = 1; 999 // addRow = 1;
1000 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 1000 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
1001 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 1001 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
1002 } else { 1002 } else {
1003 // draw first row to the right 1003 // draw first row to the right
1004 if ( colModulo ) { 1004 if ( colModulo ) {
1005 if ( col >= 7 - colModulo ) 1005 if ( col >= 7 - colModulo )
1006 addCol2 = col - 7 + colModulo; 1006 addCol2 = col - 7 + colModulo;
1007 } 1007 }
1008 if ( rowModulo ) { 1008 if ( rowModulo ) {
1009 if ( row >= 6 - rowModulo ) 1009 if ( row >= 6 - rowModulo )
1010 addRow = row - 5 + rowModulo; 1010 addRow = row - 5 + rowModulo;
1011 } 1011 }
1012 //if ( row == 0) 1012 //if ( row == 0)
1013 // addRow = 1; 1013 // addRow = 1;
1014 int drawWid = width()-(col*dwidth+1+addCol2)-1; 1014 int drawWid = width()-(col*dwidth+1+addCol2)-1;
1015 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 1015 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
1016 dheight+1, selcol); 1016 dheight+1, selcol);
1017 // draw full block till last line 1017 // draw full block till last line
1018 selh = mSelEndT/7-row; 1018 selh = mSelEndT/7-row;
1019 addRow = 0; 1019 addRow = 0;
1020 if ( rowModulo ) { 1020 if ( rowModulo ) {
1021 if ( mSelEndT/7 >= 6 - rowModulo ) 1021 if ( mSelEndT/7 >= 6 - rowModulo )
1022 addRow = mSelEndT/7 - 5 + rowModulo; 1022 addRow = mSelEndT/7 - 5 + rowModulo;
1023 } 1023 }
1024 //qDebug("%d %d %d ",selh, row, addRow ); 1024 //qDebug("%d %d %d ",selh, row, addRow );
1025 int addrow2 = addRow-selh+1; 1025 int addrow2 = addRow-selh+1;
1026 if ( addrow2 < 0 ) 1026 if ( addrow2 < 0 )
1027 addrow2 = 0; 1027 addrow2 = 0;
1028 if (selh > 1) { 1028 if (selh > 1) {
1029 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 1029 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
1030 } 1030 }
1031 // draw last block from left to mSelEndT 1031 // draw last block from left to mSelEndT
1032 selw = mSelEndT-7*(mSelEndT/7)+1; 1032 selw = mSelEndT-7*(mSelEndT/7)+1;
1033 //qDebug("esl %d ",selw ); 1033 //qDebug("esl %d ",selw );
1034 int add = 0; 1034 int add = 0;
1035 if ( colModulo ) { 1035 if ( colModulo ) {
1036 add = 7 - colModulo; 1036 add = 7 - colModulo;
1037 if ( selw > add ) 1037 if ( selw > add )
1038 add = selw - add; 1038 add = selw - add;
1039 else 1039 else
1040 add = 0; 1040 add = 0;
1041 } 1041 }
1042 //qDebug("add %d ", add); 1042 //qDebug("add %d ", add);
1043 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 1043 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
1044 selw*dwidth+add, dheight+1, selcol); 1044 selw*dwidth+add, dheight+1, selcol);
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 // iterate over all days in the matrix and draw the day label in appropriate colors 1049 // iterate over all days in the matrix and draw the day label in appropriate colors
1050 QColor actcol = mDefaultTextColorShaded; 1050 QColor actcol = mDefaultTextColorShaded;
1051 p.setPen(actcol); 1051 p.setPen(actcol);
1052 QPen tmppen; 1052 QPen tmppen;
1053 for(int i = 0; i < NUMDAYS; i++) { 1053 for(int i = 0; i < NUMDAYS; i++) {
1054 row = i/7; 1054 row = i/7;
1055 col = isRTL ? 6-(i-row*7) : i-row*7; 1055 col = isRTL ? 6-(i-row*7) : i-row*7;
1056 1056
1057 // if it is the first day of a month switch color from normal to shaded and vice versa 1057 // if it is the first day of a month switch color from normal to shaded and vice versa
1058 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 1058 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
1059 if (actcol == mDefaultTextColorShaded) { 1059 if (actcol == mDefaultTextColorShaded) {
1060 actcol = mDefaultTextColor; 1060 actcol = mDefaultTextColor;
1061 } else { 1061 } else {
1062 actcol = mDefaultTextColorShaded; 1062 actcol = mDefaultTextColorShaded;
1063 } 1063 }
1064 p.setPen(actcol); 1064 p.setPen(actcol);
1065 } 1065 }
1066 if (actcol == mDefaultTextColorShaded) { 1066 if (actcol == mDefaultTextColorShaded) {
1067 if ( ! mouseDown ) { 1067 if ( ! mouseDown ) {
1068 continue; 1068 continue;
1069 } 1069 }
1070 } 1070 }
1071 //Reset pen color after selected days block 1071 //Reset pen color after selected days block
1072 if (i == mSelEndT+1) { 1072 if (i == mSelEndT+1) {
1073 p.setPen(actcol); 1073 p.setPen(actcol);
1074 } 1074 }
1075 1075
1076 // if today then draw rectangle around day 1076 // if today then draw rectangle around day
1077 if (today == i) { 1077 if (today == i) {
1078 tmppen = p.pen(); 1078 tmppen = p.pen();
1079 QPen mTodayPen(p.pen()); 1079 QPen mTodayPen(p.pen());
1080 if ( daysize.width() < 20 ) 1080 if ( daysize.width() < 20 )
1081 mTodayPen.setWidth(1); 1081 mTodayPen.setWidth(1);
1082 else 1082 else
1083 mTodayPen.setWidth(mTodayMarginWidth); 1083 mTodayPen.setWidth(mTodayMarginWidth);
1084 //draw red rectangle for holidays 1084 //draw red rectangle for holidays
1085 if (pDays.testBit(i)) { 1085 if (pDays.testBit(i)) {
1086 if (actcol == mDefaultTextColor) { 1086 if (actcol == mDefaultTextColor) {
1087 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1087 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
1088 } else { 1088 } else {
1089 mTodayPen.setColor(mHolidayColorShaded); 1089 mTodayPen.setColor(mHolidayColorShaded);
1090 } 1090 }
1091 } 1091 }
1092 //draw gray rectangle for today if in selection 1092 //draw gray rectangle for today if in selection
1093 if (i >= mSelStartT && i <= mSelEndT) { 1093 if (i >= mSelStartT && i <= mSelEndT) {
1094 QColor grey("grey"); 1094 QColor grey("grey");
1095 mTodayPen.setColor(grey); 1095 mTodayPen.setColor(grey);
1096 } 1096 }
1097 p.setPen(mTodayPen); 1097 p.setPen(mTodayPen);
1098 1098
1099 1099
1100 int addCol = 0; 1100 int addCol = 0;
1101 int addRow = 0; 1101 int addRow = 0;
1102 if (rowModulo) { 1102 if (rowModulo) {
1103 if ( row >= 6 - rowModulo ) 1103 if ( row >= 6 - rowModulo )
1104 addRow = row - 5 + rowModulo; 1104 addRow = row - 5 + rowModulo;
1105 } 1105 }
1106 if ( colModulo ) { 1106 if ( colModulo ) {
1107 if ( col >= 7 - colModulo ) 1107 if ( col >= 7 - colModulo )
1108 addCol = col - 6 + colModulo-1; 1108 addCol = col - 6 + colModulo-1;
1109 } 1109 }
1110 1110
1111 addCol += 1; 1111 addCol += 1;
1112 if ( row == 0 ) 1112 if ( row == 0 )
1113 addRow = 1; 1113 addRow = 1;
1114 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1114 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
1115 p.setPen(tmppen); 1115 p.setPen(tmppen);
1116 } 1116 }
1117 1117
1118 // if any events are on that day then draw it using a bold font 1118 // if any events are on that day then draw it using a bold font
1119 if ( eDays.testBit(i) ) { 1119 if ( eDays.testBit(i) ) {
1120 QFont myFont = font(); 1120 QFont myFont = font();
1121 myFont.setBold(true); 1121 myFont.setBold(true);
1122 p.setFont(myFont); 1122 p.setFont(myFont);
1123 } 1123 }
1124 1124
1125 // if it is a holiday then use the default holiday color 1125 // if it is a holiday then use the default holiday color
1126 if ( pDays.testBit(i)) { 1126 if ( pDays.testBit(i)) {
1127 if ( bDays.testBit(i) ) { 1127 if ( bDays.testBit(i) ) {
1128 if ( hDays.testBit(i) ) 1128 if ( hDays.testBit(i) )
1129 p.setPen(QColor(0,200,0)); 1129 p.setPen(QColor(0,200,0));
1130 else 1130 else
1131 p.setPen(QColor(Qt::blue)); 1131 p.setPen(QColor(Qt::blue));
1132 } else { 1132 } else {
1133 if (actcol == mDefaultTextColor ) { 1133 if (actcol == mDefaultTextColor ) {
1134 p.setPen(KOPrefs::instance()->mHolidayColor); 1134 p.setPen(KOPrefs::instance()->mHolidayColor);
1135 } else { 1135 } else {
1136 p.setPen(mHolidayColorShaded); 1136 p.setPen(mHolidayColorShaded);
1137 } 1137 }
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 // draw selected days with special color 1141 // draw selected days with special color
1142 // DO NOT specially highlight holidays in selection ! 1142 // DO NOT specially highlight holidays in selection !
1143 if (i >= mSelStartT && i <= mSelEndT) { 1143 if (i >= mSelStartT && i <= mSelEndT) {
1144 ;//p.setPen(mSelectedDaysColor); 1144 ;//p.setPen(mSelectedDaysColor);
1145 } 1145 }
1146 1146
1147 int addCol = 0; 1147 int addCol = 0;
1148 int addRow = 0; 1148 int addRow = 0;
1149 if ( colModulo ) { 1149 if ( colModulo ) {
1150 if ( col >= 7 - colModulo ) 1150 if ( col >= 7 - colModulo )
1151 addCol = col - 7 + colModulo; 1151 addCol = col - 7 + colModulo;
1152 } 1152 }
1153 if ( rowModulo ) { 1153 if ( rowModulo ) {
1154 if ( row >= 6 - rowModulo ) 1154 if ( row >= 6 - rowModulo )
1155 addRow = row - 5 + rowModulo; 1155 addRow = row - 5 + rowModulo;
1156 } 1156 }
1157 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1157 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
1158 ++addCol;//++addCol; 1158 ++addCol;//++addCol;
1159 if ( row == 0) 1159 if ( row == 0)
1160 addRow = 1; 1160 addRow = 1;
1161 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1161 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
1162 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1162 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
1163 1163
1164 // reset color to actual color 1164 // reset color to actual color
1165 if (pDays.testBit(i)) { 1165 if (pDays.testBit(i)) {
1166 p.setPen(actcol); 1166 p.setPen(actcol);
1167 } 1167 }
1168 // reset bold font to plain font 1168 // reset bold font to plain font
1169 if ( eDays.testBit(i)) { 1169 if ( eDays.testBit(i)) {
1170 QFont myFont = font(); 1170 QFont myFont = font();
1171 myFont.setBold(false); 1171 myFont.setBold(false);
1172 p.setFont(myFont); 1172 p.setFont(myFont);
1173 } 1173 }
1174 } 1174 }
1175 } else { 1175 } else {
1176 //qDebug("NO redraw "); 1176 //qDebug("NO redraw ");
1177 } 1177 }
1178 1178
1179 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1179 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
1180 mRedrawNeeded = false; 1180 mRedrawNeeded = false;
1181} 1181}
1182 1182
1183// ---------------------------------------------------------------------------- 1183// ----------------------------------------------------------------------------
1184// R E SI Z E E V E N T H A N D L I N G 1184// R E SI Z E E V E N T H A N D L I N G
1185// ---------------------------------------------------------------------------- 1185// ----------------------------------------------------------------------------
1186 1186
1187void KODayMatrix::resizeEvent(QResizeEvent *) 1187void KODayMatrix::resizeEvent(QResizeEvent *)
1188{ 1188{
1189 QRect sz = frameRect(); 1189 QRect sz = frameRect();
1190 daysize.setHeight(sz.height()*7 / NUMDAYS); 1190 daysize.setHeight(sz.height()*7 / NUMDAYS);
1191 daysize.setWidth(sz.width() / 7); 1191 daysize.setWidth(sz.width() / 7);
1192} 1192}
1193 1193
1194QSize KODayMatrix::sizeHint() const 1194QSize KODayMatrix::sizeHint() const
1195{ 1195{
1196 1196
1197 QFontMetrics fm ( font() ); 1197 QFontMetrics fm ( font() );
1198 int wid = fm.width( "30") *7+3; 1198 int wid = fm.width( "30") *7+3;
1199 int hei = fm.height() * 6+3; 1199 int hei = fm.height() * 6+3;
1200 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 1200 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
1201 return QSize ( wid, hei ); 1201 return QSize ( wid, hei );
1202 1202
1203} 1203}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index eed023c..3c0259f 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2488 +1,2490 @@
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 <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h> 64#include <kglobalsettings.h>
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0; 148 p->mCurrentDisplayedView = 0;
149 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
150 p->mHourSize = 22; 150 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 169
170#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
171 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
172#else 172#else
173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
174#endif 174#endif
175 175
176{ 176{
177 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
178 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
179 tbd = Bottom; 179 tbd = Bottom;
180 else 180 else
181 tbd = Top; 181 tbd = Top;
182 } 182 }
183 else { 183 else {
184 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
185 tbd = Right; 185 tbd = Right;
186 else 186 else
187 tbd = Left; 187 tbd = Left;
188 } 188 }
189 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
190 filterMenubar = new QMenuBar( filterToolBar ); 190 filterMenubar = new QMenuBar( 0 );
191 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
192 192
193 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
195 QString addTest = "A"; 195 QString addTest = "A";
196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
197#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
198 addTest = "AAABBBCCCx"; 198 addTest = "AAABBBCCCx";
199#else 199#else
200 addTest = "AAx"; 200 addTest = "AAx";
201#endif 201#endif
202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
203 addToolBar (filterToolBar , tbd ); 203 addToolBar (filterToolBar , tbd );
204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
207 filterToolBar->hide(); 207 filterToolBar->hide();
208 } else { 208 } else {
209 filterToolBar = 0; 209 filterToolBar = 0;
210 filterMenubar = 0; 210 filterMenubar = 0;
211 filterPopupMenu = 0; 211 filterPopupMenu = 0;
212 } 212 }
213 if ( p->mShowIconOnetoolbar ) { 213 if ( p->mShowIconOnetoolbar ) {
214 viewToolBar = iconToolBar ; 214 viewToolBar = iconToolBar ;
215 navigatorToolBar = iconToolBar ; 215 navigatorToolBar = iconToolBar ;
216 } else { 216 } else {
217#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
218 setToolBarsMovable( false ); 218 setToolBarsMovable( false );
219#endif 219#endif
220 if ( p->mToolBarHorV ) { 220 if ( p->mToolBarHorV ) {
221 if ( p->mToolBarUpV ) 221 if ( p->mToolBarUpV )
222 tbd = Bottom; 222 tbd = Bottom;
223 else 223 else
224 tbd = Top; 224 tbd = Top;
225 } 225 }
226 else { 226 else {
227 if ( p->mToolBarUpV ) 227 if ( p->mToolBarUpV )
228 tbd = Right; 228 tbd = Right;
229 else 229 else
230 tbd = Left; 230 tbd = Left;
231 } 231 }
232 viewToolBar = new QPEToolBar( this ); 232 viewToolBar = new QPEToolBar( this );
233 addToolBar (viewToolBar , tbd ); 233 addToolBar (viewToolBar , tbd );
234 if ( p->mToolBarHorN ) { 234 if ( p->mToolBarHorN ) {
235 if ( p->mToolBarUpN ) 235 if ( p->mToolBarUpN )
236 tbd = Bottom; 236 tbd = Bottom;
237 else 237 else
238 tbd = Top; 238 tbd = Top;
239 } 239 }
240 else { 240 else {
241 if ( p->mToolBarUpN ) 241 if ( p->mToolBarUpN )
242 tbd = Right; 242 tbd = Right;
243 else 243 else
244 tbd = Left; 244 tbd = Left;
245 } 245 }
246 navigatorToolBar = new QPEToolBar( this ); 246 navigatorToolBar = new QPEToolBar( this );
247 addToolBar (navigatorToolBar , tbd ); 247 addToolBar (navigatorToolBar , tbd );
248 } 248 }
249 249
250 250
251 251
252 mCalendarModifiedFlag = false; 252 mCalendarModifiedFlag = false;
253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
254 splash->setAlignment ( AlignCenter ); 254 splash->setAlignment ( AlignCenter );
255 setCentralWidget( splash ); 255 setCentralWidget( splash );
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 showMaximized(); 257 showMaximized();
258#endif 258#endif
259 259
260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
261 setDefaultPreferences(); 261 setDefaultPreferences();
262 mCalendar = new CalendarLocal(); 262 mCalendar = new CalendarLocal();
263 mView = new CalendarView( mCalendar, this,"mCalendar " ); 263 mView = new CalendarView( mCalendar, this,"mCalendar " );
264 mView->hide(); 264 mView->hide();
265 //mView->resize(splash->size() ); 265 //mView->resize(splash->size() );
266 initActions(); 266 initActions();
267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
268 mSyncManager->setBlockSave(false); 268 mSyncManager->setBlockSave(false);
269 mView->setSyncManager(mSyncManager); 269 mView->setSyncManager(mSyncManager);
270#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
271 iconToolBar->show(); 271 iconToolBar->show();
272 qApp->processEvents(); 272 qApp->processEvents();
273#endif 273#endif
274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
275 int vh = height() ; 275 int vh = height() ;
276 int vw = width(); 276 int vw = width();
277 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 277 //qDebug("Toolbar hei %d ",iconToolBar->height() );
278 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
279 vh -= iconToolBar->height(); 279 vh -= iconToolBar->height();
280 } else { 280 } else {
281 vw -= iconToolBar->height(); 281 vw -= iconToolBar->height();
282 } 282 }
283 //mView->setMaximumSize( splash->size() ); 283 //mView->setMaximumSize( splash->size() );
284 //mView->resize( splash->size() ); 284 //mView->resize( splash->size() );
285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
286 mView->readSettings(); 286 mView->readSettings();
287 bool newFile = false; 287 bool newFile = false;
288 if( !QFile::exists( defaultFileName() ) ) { 288 if( !QFile::exists( defaultFileName() ) ) {
289 QFileInfo finfo ( defaultFileName() ); 289 QFileInfo finfo ( defaultFileName() );
290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
291 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"; 291 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";
292 finfo.setFile( oldFile ); 292 finfo.setFile( oldFile );
293 if (finfo.exists() ) { 293 if (finfo.exists() ) {
294 KMessageBox::information( this, message); 294 KMessageBox::information( this, message);
295 mView->openCalendar( oldFile ); 295 mView->openCalendar( oldFile );
296 qApp->processEvents(); 296 qApp->processEvents();
297 } else { 297 } else {
298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
299 finfo.setFile( oldFile ); 299 finfo.setFile( oldFile );
300 if (finfo.exists() ) { 300 if (finfo.exists() ) {
301 KMessageBox::information( this, message); 301 KMessageBox::information( this, message);
302 mView->openCalendar( oldFile ); 302 mView->openCalendar( oldFile );
303 qApp->processEvents(); 303 qApp->processEvents();
304 } 304 }
305 } 305 }
306 mView->saveCalendar( defaultFileName() ); 306 mView->saveCalendar( defaultFileName() );
307 newFile = true; 307 newFile = true;
308 } 308 }
309 309
310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 310 QTime neededSaveTime = QDateTime::currentDateTime().time();
311 mView->openCalendar( defaultFileName() ); 311 mView->openCalendar( defaultFileName() );
312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
313 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 313 qDebug("KO: Calendar loading time: %d ms",msNeeded );
314 314
315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
316 KOPrefs::instance()->setAllDefaults(); 316 KOPrefs::instance()->setAllDefaults();
317 int count = mView->addCategories(); 317 int count = mView->addCategories();
318 } 318 }
319 processIncidenceSelection( 0 ); 319 processIncidenceSelection( 0 );
320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
321 SLOT( processIncidenceSelection( Incidence * ) ) ); 321 SLOT( processIncidenceSelection( Incidence * ) ) );
322 connect( mView, SIGNAL( modifiedChanged( bool ) ), 322 connect( mView, SIGNAL( modifiedChanged( bool ) ),
323 SLOT( slotModifiedChanged( bool ) ) ); 323 SLOT( slotModifiedChanged( bool ) ) );
324 324
325 325
326 connect( mView, SIGNAL( tempDisableBR(bool) ), 326 connect( mView, SIGNAL( tempDisableBR(bool) ),
327 SLOT( disableBR(bool) ) ); 327 SLOT( disableBR(bool) ) );
328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
329 mView->setModified( false ); 329 mView->setModified( false );
330 mBlockAtStartup = false; 330 mBlockAtStartup = false;
331 mView->setModified( false ); 331 mView->setModified( false );
332 setCentralWidget( mView ); 332 setCentralWidget( mView );
333 globalFlagBlockStartup = 0; 333 globalFlagBlockStartup = 0;
334 mView->show(); 334 mView->show();
335 delete splash; 335 delete splash;
336 if ( newFile ) 336 if ( newFile )
337 mView->updateConfig(); 337 mView->updateConfig();
338 // qApp->processEvents(); 338 // qApp->processEvents();
339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
340 //fillSyncMenu(); 340 //fillSyncMenu();
341 341
342 342
343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
348 mSyncManager->setDefaultFileName( sentSyncFile()); 348 mSyncManager->setDefaultFileName( sentSyncFile());
349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
350 mSyncManager->fillSyncMenu(); 350 mSyncManager->fillSyncMenu();
351 351
352 352
353 353
354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
355 if ( showWarning ) { 355 if ( showWarning ) {
356 KMessageBox::information( this, 356 KMessageBox::information( this,
357 "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"); 357 "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");
358 qApp->processEvents(); 358 qApp->processEvents();
359 mView->dialogManager()->showSyncOptions(); 359 mView->dialogManager()->showSyncOptions();
360 } 360 }
361 361
362 //US listen for result adressed from Ka/Pi 362 //US listen for result adressed from Ka/Pi
363#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
365#endif 365#endif
366#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
367 infrared = 0; 367 infrared = 0;
368#endif 368#endif
369 updateFilterToolbar(); 369 updateFilterToolbar();
370 updateWeek( mView->startDate() ); 370 updateWeek( mView->startDate() );
371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
372 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 372 SLOT( updateWeekNum( const KCal::DateList & ) ) );
373 mBRdisabled = false; 373 mBRdisabled = false;
374 //toggleBeamReceive(); 374 //toggleBeamReceive();
375} 375}
376MainWindow::~MainWindow() 376MainWindow::~MainWindow()
377{ 377{
378 //qDebug("MainWindow::~MainWindow() "); 378 //qDebug("MainWindow::~MainWindow() ");
379 //save toolbar location 379 //save toolbar location
380 delete mCalendar; 380 delete mCalendar;
381 delete mSyncManager; 381 delete mSyncManager;
382#ifndef DESKTOP_VERSION 382#ifndef DESKTOP_VERSION
383 if ( infrared ) 383 if ( infrared )
384 delete infrared; 384 delete infrared;
385#endif 385#endif
386 386
387 387
388} 388}
389 389
390void MainWindow::disableBR(bool b) 390void MainWindow::disableBR(bool b)
391{ 391{
392#ifndef DESKTOP_VERSION 392#ifndef DESKTOP_VERSION
393 if ( b ) { 393 if ( b ) {
394 if ( infrared ) { 394 if ( infrared ) {
395 toggleBeamReceive(); 395 toggleBeamReceive();
396 mBRdisabled = true; 396 mBRdisabled = true;
397 } 397 }
398 mBRdisabled = true; 398 mBRdisabled = true;
399 } else { 399 } else {
400 if ( mBRdisabled ) { 400 if ( mBRdisabled ) {
401 mBRdisabled = false; 401 mBRdisabled = false;
402 //makes no sense,because other cal ap is probably running 402 //makes no sense,because other cal ap is probably running
403 // toggleBeamReceive(); 403 // toggleBeamReceive();
404 } 404 }
405 } 405 }
406#endif 406#endif
407 407
408} 408}
409bool MainWindow::beamReceiveEnabled() 409bool MainWindow::beamReceiveEnabled()
410{ 410{
411#ifndef DESKTOP_VERSION 411#ifndef DESKTOP_VERSION
412 return ( infrared != 0 ); 412 return ( infrared != 0 );
413#endif 413#endif
414 return false; 414 return false;
415} 415}
416 416
417void MainWindow::toggleBeamReceive() 417void MainWindow::toggleBeamReceive()
418{ 418{
419 if ( mBRdisabled ) 419 if ( mBRdisabled )
420 return; 420 return;
421#ifndef DESKTOP_VERSION 421#ifndef DESKTOP_VERSION
422 if ( infrared ) { 422 if ( infrared ) {
423 qDebug("KO: Disable BeamReceive "); 423 qDebug("KO: Disable BeamReceive ");
424 delete infrared; 424 delete infrared;
425 infrared = 0; 425 infrared = 0;
426 brAction->setOn(false); 426 brAction->setOn(false);
427 return; 427 return;
428 } 428 }
429 qDebug("KO: Enable BeamReceive "); 429 qDebug("KO: Enable BeamReceive ");
430 brAction->setOn(true); 430 brAction->setOn(true);
431 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 431 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
432 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 432 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
433#endif 433#endif
434} 434}
435void MainWindow::showMaximized () 435void MainWindow::showMaximized ()
436{ 436{
437#ifndef DESKTOP_VERSION 437#ifndef DESKTOP_VERSION
438 if ( ! globalFlagBlockStartup ) 438 if ( ! globalFlagBlockStartup )
439 if ( mClosed ) 439 if ( mClosed )
440 mView->goToday(); 440 mView->goToday();
441#endif 441#endif
442 QWidget::showMaximized () ; 442 QWidget::showMaximized () ;
443 mClosed = false; 443 mClosed = false;
444} 444}
445void MainWindow::closeEvent( QCloseEvent* ce ) 445void MainWindow::closeEvent( QCloseEvent* ce )
446{ 446{
447 447
448 448
449 449
450 if ( ! KOPrefs::instance()->mAskForQuit ) { 450 if ( ! KOPrefs::instance()->mAskForQuit ) {
451 saveOnClose(); 451 saveOnClose();
452 mClosed = true; 452 mClosed = true;
453 ce->accept(); 453 ce->accept();
454 return; 454 return;
455 455
456 } 456 }
457 457
458 switch( QMessageBox::information( this, "KO/Pi", 458 switch( QMessageBox::information( this, "KO/Pi",
459 i18n("Do you really want\nto close KO/Pi?"), 459 i18n("Do you really want\nto close KO/Pi?"),
460 i18n("Close"), i18n("No"), 460 i18n("Close"), i18n("No"),
461 0, 0 ) ) { 461 0, 0 ) ) {
462 case 0: 462 case 0:
463 saveOnClose(); 463 saveOnClose();
464 mClosed = true; 464 mClosed = true;
465 ce->accept(); 465 ce->accept();
466 break; 466 break;
467 case 1: 467 case 1:
468 ce->ignore(); 468 ce->ignore();
469 break; 469 break;
470 case 2: 470 case 2:
471 471
472 default: 472 default:
473 break; 473 break;
474 } 474 }
475 475
476 476
477} 477}
478 478
479void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 479void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
480{ 480{
481 QDataStream stream( data, IO_ReadOnly ); 481 QDataStream stream( data, IO_ReadOnly );
482 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 482 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
483 //QString datamess; 483 //QString datamess;
484 //qDebug("message "); 484 //qDebug("message ");
485 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 485 qDebug("KO: QCOP message received: %s ", cmsg.data() );
486 486
487 if ( cmsg == "setDocument(QString)" ) { 487 if ( cmsg == "setDocument(QString)" ) {
488 QDataStream stream( data, IO_ReadOnly ); 488 QDataStream stream( data, IO_ReadOnly );
489 QString fileName; 489 QString fileName;
490 stream >> fileName; 490 stream >> fileName;
491 //qDebug("filename %s ", fileName.latin1()); 491 //qDebug("filename %s ", fileName.latin1());
492 showMaximized(); 492 showMaximized();
493 raise(); 493 raise();
494 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 494 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
495 mSyncManager->slotSyncMenu( 1002 ); 495 mSyncManager->slotSyncMenu( 1002 );
496 return; 496 return;
497 } 497 }
498 498
499 if ( cmsg == "-writeFile" ) { 499 if ( cmsg == "-writeFile" ) {
500 // I made from the "-writeFile" an "-writeAlarm" 500 // I made from the "-writeFile" an "-writeAlarm"
501 mView->viewManager()->showWhatsNextView(); 501 mView->viewManager()->showWhatsNextView();
502 mCalendar->checkAlarmForIncidence( 0, true); 502 mCalendar->checkAlarmForIncidence( 0, true);
503 showMaximized(); 503 showMaximized();
504 raise(); 504 raise();
505 return; 505 return;
506 506
507 } 507 }
508 if ( cmsg == "-writeFileSilent" ) { 508 if ( cmsg == "-writeFileSilent" ) {
509 // I made from the "-writeFile" an "-writeAlarm" 509 // I made from the "-writeFile" an "-writeAlarm"
510 // mView->viewManager()->showWhatsNextView(); 510 // mView->viewManager()->showWhatsNextView();
511 mCalendar->checkAlarmForIncidence( 0, true); 511 mCalendar->checkAlarmForIncidence( 0, true);
512 //showMaximized(); 512 //showMaximized();
513 //raise(); 513 //raise();
514 hide(); 514 hide();
515 return; 515 return;
516 } 516 }
517 if ( cmsg == "-newCountdown" ) { 517 if ( cmsg == "-newCountdown" ) {
518 qDebug("newCountdown "); 518 qDebug("newCountdown ");
519 519
520 } 520 }
521 QString msg ; 521 QString msg ;
522 QString allmsg = cmsg; 522 QString allmsg = cmsg;
523 while ( allmsg.length() > 0 ) { 523 while ( allmsg.length() > 0 ) {
524 int nextC = allmsg.find( "-", 1 ); 524 int nextC = allmsg.find( "-", 1 );
525 if ( nextC == -1 ) { 525 if ( nextC == -1 ) {
526 msg = allmsg; 526 msg = allmsg;
527 allmsg = ""; 527 allmsg = "";
528 } else{ 528 } else{
529 msg = allmsg.left( nextC ); 529 msg = allmsg.left( nextC );
530 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 530 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
531 } 531 }
532 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 532 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
533 if ( msg == "-newEvent" ) { 533 if ( msg == "-newEvent" ) {
534 mView->newEvent(); 534 mView->newEvent();
535 } 535 }
536 if ( msg == "-newTodo" ) { 536 if ( msg == "-newTodo" ) {
537 mView->newTodo(); 537 mView->newTodo();
538 538
539 } 539 }
540 if ( msg == "-showWN" ) { 540 if ( msg == "-showWN" ) {
541 mView->viewManager()->showWhatsNextView(); 541 mView->viewManager()->showWhatsNextView();
542 } 542 }
543 if ( msg == "-showTodo" ) { 543 if ( msg == "-showTodo" ) {
544 mView->viewManager()->showTodoView(); 544 mView->viewManager()->showTodoView();
545 } 545 }
546 if ( msg == "-showList" ) { 546 if ( msg == "-showList" ) {
547 mView->viewManager()->showListView(); 547 mView->viewManager()->showListView();
548 } 548 }
549 else if ( msg == "-showDay" ) { 549 else if ( msg == "-showDay" ) {
550 mView->viewManager()->showDayView(); 550 mView->viewManager()->showDayView();
551 } 551 }
552 else if ( msg == "-showWWeek" ) { 552 else if ( msg == "-showWWeek" ) {
553 mView->viewManager()->showWorkWeekView(); 553 mView->viewManager()->showWorkWeekView();
554 } 554 }
555 else if ( msg == "-ringSync" ) { 555 else if ( msg == "-ringSync" ) {
556 mSyncManager->multiSync( false ); 556 mSyncManager->multiSync( false );
557 } 557 }
558 else if ( msg == "-showWeek" ) { 558 else if ( msg == "-showWeek" ) {
559 mView->viewManager()->showWeekView(); 559 mView->viewManager()->showWeekView();
560 } 560 }
561 else if ( msg == "-showTodo" ) { 561 else if ( msg == "-showTodo" ) {
562 mView->viewManager()->showTodoView(); 562 mView->viewManager()->showTodoView();
563 } 563 }
564 else if ( msg == "-showJournal" ) { 564 else if ( msg == "-showJournal" ) {
565 mView->dateNavigator()->selectDates( 1 ); 565 mView->dateNavigator()->selectDates( 1 );
566 mView->dateNavigator()->selectToday(); 566 mView->dateNavigator()->selectToday();
567 mView->viewManager()->showJournalView(); 567 mView->viewManager()->showJournalView();
568 } 568 }
569 else if ( msg == "-showKO" ) { 569 else if ( msg == "-showKO" ) {
570 mView->viewManager()->showNextXView(); 570 mView->viewManager()->showNextXView();
571 } 571 }
572 else if ( msg == "-showWNext" ) { 572 else if ( msg == "-showWNext" ) {
573 mView->viewManager()->showWhatsNextView(); 573 mView->viewManager()->showWhatsNextView();
574 } 574 }
575 else if ( msg == "nextView()" ) { 575 else if ( msg == "nextView()" ) {
576 mView->viewManager()->showNextView(); 576 mView->viewManager()->showNextView();
577 } 577 }
578 else if ( msg == "-showNextXView" ) { 578 else if ( msg == "-showNextXView" ) {
579 mView->viewManager()->showNextXView(); 579 mView->viewManager()->showNextXView();
580 } 580 }
581 581
582 582
583 } 583 }
584 584
585 showMaximized(); 585 showMaximized();
586 raise(); 586 raise();
587} 587}
588 588
589QPixmap MainWindow::loadPixmap( QString name ) 589QPixmap MainWindow::loadPixmap( QString name )
590{ 590{
591 return SmallIcon( name ); 591 return SmallIcon( name );
592 592
593} 593}
594void MainWindow::setUsesBigPixmaps ( bool b ) 594void MainWindow::setUsesBigPixmaps ( bool b )
595{ 595{
596 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 596 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
597 if ( b ) 597 if ( b )
598 qDebug("KO: BigPixmaps are not supported "); 598 qDebug("KO: BigPixmaps are not supported ");
599} 599}
600void MainWindow::initActions() 600void MainWindow::initActions()
601{ 601{
602 //KOPrefs::instance()->mShowFullMenu 602 //KOPrefs::instance()->mShowFullMenu
603 iconToolBar->clear(); 603 iconToolBar->clear();
604 KOPrefs *p = KOPrefs::instance(); 604 KOPrefs *p = KOPrefs::instance();
605 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 605 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
606 606
607 QPopupMenu *viewMenu = new QPopupMenu( this ); 607 QPopupMenu *viewMenu = new QPopupMenu( this );
608 QPopupMenu *actionMenu = new QPopupMenu( this ); 608 QPopupMenu *actionMenu = new QPopupMenu( this );
609 QPopupMenu *importMenu = new QPopupMenu( this ); 609 QPopupMenu *importMenu = new QPopupMenu( this );
610 QPopupMenu *importMenu_X = new QPopupMenu( this ); 610 QPopupMenu *importMenu_X = new QPopupMenu( this );
611 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 611 QPopupMenu *exportMenu_X = new QPopupMenu( this );
612 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 612 QPopupMenu *beamMenu_X = new QPopupMenu( this );
613 selectFilterMenu = new QPopupMenu( this ); 613 selectFilterMenu = new QPopupMenu( this );
614 selectFilterMenu->setCheckable( true ); 614 selectFilterMenu->setCheckable( true );
615 syncMenu = new QPopupMenu( this ); 615 syncMenu = new QPopupMenu( this );
616 configureAgendaMenu = new QPopupMenu( this ); 616 configureAgendaMenu = new QPopupMenu( this );
617 configureToolBarMenu = new QPopupMenu( this ); 617 configureToolBarMenu = new QPopupMenu( this );
618 QPopupMenu *helpMenu = new QPopupMenu( this ); 618 QPopupMenu *helpMenu = new QPopupMenu( this );
619 QIconSet icon; 619 QIconSet icon;
620 int pixWid = 22, pixHei = 22; 620 int pixWid = 22, pixHei = 22;
621 QString pathString = ""; 621 QString pathString = "";
622 if ( !p->mToolBarMiniIcons ) { 622 if ( !p->mToolBarMiniIcons ) {
623 if ( QApplication::desktop()->width() < 480 ) { 623 if ( QApplication::desktop()->width() < 480 ) {
624 pathString += "icons16/"; 624 pathString += "icons16/";
625 pixWid = 18; pixHei = 16; 625 pixWid = 18; pixHei = 16;
626 } 626 }
627 } else { 627 } else {
628 pathString += "iconsmini/"; 628 pathString += "iconsmini/";
629 pixWid = 18; pixHei = 16; 629 pixWid = 18; pixHei = 16;
630 } 630 }
631 if ( KOPrefs::instance()->mShowFullMenu ) { 631 if ( KOPrefs::instance()->mShowFullMenu ) {
632 QMenuBar *menuBar1; 632 QMenuBar *menuBar1;
633 menuBar1 = menuBar(); 633 menuBar1 = menuBar();
634 menuBar1->insertItem( i18n("File"), importMenu ); 634 menuBar1->insertItem( i18n("File"), importMenu );
635 menuBar1->insertItem( i18n("View"), viewMenu ); 635 menuBar1->insertItem( i18n("View"), viewMenu );
636 menuBar1->insertItem( i18n("Actions"), actionMenu ); 636 menuBar1->insertItem( i18n("Actions"), actionMenu );
637#ifdef DESKTOP_VERSION 637#ifdef DESKTOP_VERSION
638 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 638 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
639 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 639 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
640#else 640#else
641 menuBar1->insertItem( i18n("Sync"), syncMenu ); 641 menuBar1->insertItem( i18n("Sync"), syncMenu );
642 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 642 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
643#endif 643#endif
644 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 644 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
645 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 645 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
646 menuBar1->insertItem( i18n("Help"), helpMenu ); 646 menuBar1->insertItem( i18n("Help"), helpMenu );
647 } else { 647 } else {
648 QPEMenuBar *menuBar1; 648 QPEMenuBar *menuBar1;
649 menuBar1 = new QPEMenuBar( iconToolBar ); 649 menuBar1 = new QPEMenuBar( iconToolBar );
650 QPopupMenu *menuBar = new QPopupMenu( this ); 650 QPopupMenu *menuBar = new QPopupMenu( this );
651 icon = loadPixmap( pathString + "z_menu" ); 651 icon = loadPixmap( pathString + "z_menu" );
652 menuBar1->insertItem( icon.pixmap(), menuBar); 652 menuBar1->insertItem( icon.pixmap(), menuBar);
653 //menuBar1->insertItem( i18n("ME"), menuBar); 653 //menuBar1->insertItem( i18n("ME"), menuBar);
654 menuBar->insertItem( i18n("File"), importMenu ); 654 menuBar->insertItem( i18n("File"), importMenu );
655 menuBar->insertItem( i18n("View"), viewMenu ); 655 menuBar->insertItem( i18n("View"), viewMenu );
656 menuBar->insertItem( i18n("Actions"), actionMenu ); 656 menuBar->insertItem( i18n("Actions"), actionMenu );
657 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 657 menuBar->insertItem( i18n("Synchronize"), syncMenu );
658 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 658 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
659 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 659 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
660 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 660 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
661 menuBar->insertItem( i18n("Help"), helpMenu ); 661 menuBar->insertItem( i18n("Help"), helpMenu );
662 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 662 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
663 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 663 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
664 } 664 }
665 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 665 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
666 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 666 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
667 667
668 668
669 mWeekBgColor = iconToolBar->backgroundColor(); 669 mWeekBgColor = iconToolBar->backgroundColor();
670 mWeekPixmap.resize( pixWid , pixHei ); 670 mWeekPixmap.resize( pixWid , pixHei );
671 mWeekPixmap.fill( mWeekBgColor ); 671 mWeekPixmap.fill( mWeekBgColor );
672 icon = mWeekPixmap; 672 icon = mWeekPixmap;
673 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 673 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
674 if ( p-> mShowIconWeekNum ) 674 if ( p-> mShowIconWeekNum )
675 mWeekAction->addTo( iconToolBar ); 675 mWeekAction->addTo( iconToolBar );
676 mWeekFont = font(); 676 mWeekFont = font();
677 677
678 int fontPoint = mWeekFont.pointSize(); 678 int fontPoint = mWeekFont.pointSize();
679 QFontMetrics f( mWeekFont ); 679 QFontMetrics f( mWeekFont );
680 int fontWid = f.width( "30" ); 680 int fontWid = f.width( "30" );
681 while ( fontWid > pixWid ) { 681 while ( fontWid > pixWid ) {
682 --fontPoint; 682 --fontPoint;
683 mWeekFont.setPointSize( fontPoint ); 683 mWeekFont.setPointSize( fontPoint );
684 QFontMetrics f( mWeekFont ); 684 QFontMetrics f( mWeekFont );
685 fontWid = f.width( "30" ); 685 fontWid = f.width( "30" );
686 //qDebug("dec-- "); 686 //qDebug("dec-- ");
687 } 687 }
688 688
689 connect( mWeekAction, SIGNAL( activated() ), 689 connect( mWeekAction, SIGNAL( activated() ),
690 this, SLOT( weekAction() ) ); 690 this, SLOT( weekAction() ) );
691 691
692 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 692 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
693 if ( p->mShowIconFilterview ) { 693 if ( p->mShowIconFilterview ) {
694 icon = loadPixmap( pathString + "filter" ); 694 icon = loadPixmap( pathString + "filter" );
695 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 695 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
696 connect( actionFilterMenuTB, SIGNAL( activated() ), 696 connect( actionFilterMenuTB, SIGNAL( activated() ),
697 this, SLOT( fillFilterMenuTB() ) ); 697 this, SLOT( fillFilterMenuTB() ) );
698 actionFilterMenuTB->addTo( iconToolBar ); 698 actionFilterMenuTB->addTo( iconToolBar );
699 selectFilterMenuTB = new QPopupMenu( this ); 699 selectFilterMenuTB = new QPopupMenu( this );
700 selectFilterMenuTB->setCheckable( true ); 700 selectFilterMenuTB->setCheckable( true );
701 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 701 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
702 } 702 }
703 703
704 //#endif 704 //#endif
705 // ****************** 705 // ******************
706 QAction *action; 706 QAction *action;
707 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 707 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
708 configureToolBarMenu->setCheckable( true ); 708 configureToolBarMenu->setCheckable( true );
709 709
710 710
711 configureAgendaMenu->setCheckable( true ); 711 configureAgendaMenu->setCheckable( true );
712 int iii ; 712 int iii ;
713 for ( iii = 1;iii<= 10 ;++iii ){ 713 for ( iii = 1;iii<= 10 ;++iii ){
714 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 714 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
715 } 715 }
716 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 716 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
717 717
718 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 718 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
719 this, SLOT( showConfigureAgenda( ) ) ); 719 this, SLOT( showConfigureAgenda( ) ) );
720 720
721 icon = loadPixmap( pathString + "configure" ); 721 icon = loadPixmap( pathString + "configure" );
722 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 722 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
723 action->addTo( actionMenu ); 723 action->addTo( actionMenu );
724 connect( action, SIGNAL( activated() ), 724 connect( action, SIGNAL( activated() ),
725 mView, SLOT( edit_options() ) ); 725 mView, SLOT( edit_options() ) );
726 actionMenu->insertSeparator(); 726 actionMenu->insertSeparator();
727 727
728 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 728 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
729 action->addTo( actionMenu ); 729 action->addTo( actionMenu );
730 connect( action, SIGNAL( activated() ), 730 connect( action, SIGNAL( activated() ),
731 mView, SLOT( undo_delete() ) ); 731 mView, SLOT( undo_delete() ) );
732 actionMenu->insertSeparator(); 732 actionMenu->insertSeparator();
733 733
734 icon = loadPixmap( pathString + "newevent" ); 734 icon = loadPixmap( pathString + "newevent" );
735 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 735 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
736 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 736 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
737 configureToolBarMenu->insertSeparator(); 737 configureToolBarMenu->insertSeparator();
738 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 738 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
739 configureToolBarMenu->insertSeparator(); 739 configureToolBarMenu->insertSeparator();
740 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 740 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
741 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 741 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
742 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 742 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
743 ne_action->addTo( actionMenu ); 743 ne_action->addTo( actionMenu );
744 connect( ne_action, SIGNAL( activated() ), 744 connect( ne_action, SIGNAL( activated() ),
745 mView, SLOT( newEvent() ) ); 745 mView, SLOT( newEvent() ) );
746 icon = loadPixmap( pathString + "newtodo" ); 746 icon = loadPixmap( pathString + "newtodo" );
747 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 747 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
748 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 748 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
749 nt_action->addTo( actionMenu ); 749 nt_action->addTo( actionMenu );
750 connect( nt_action, SIGNAL( activated() ), 750 connect( nt_action, SIGNAL( activated() ),
751 mView, SLOT( newTodo() ) ); 751 mView, SLOT( newTodo() ) );
752 752
753 icon = loadPixmap( pathString + "today" ); 753 icon = loadPixmap( pathString + "today" );
754 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 754 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
755 today_action->addTo( viewMenu ); 755 today_action->addTo( viewMenu );
756 connect( today_action, SIGNAL( activated() ), 756 connect( today_action, SIGNAL( activated() ),
757 mView, SLOT( goToday() ) ); 757 mView, SLOT( goToday() ) );
758 viewMenu->insertSeparator(); 758 viewMenu->insertSeparator();
759 759
760 // *********************** 760 // ***********************
761 if ( KOPrefs::instance()->mVerticalScreen ) { 761 if ( KOPrefs::instance()->mVerticalScreen ) {
762 icon = SmallIcon( "1updownarrow" ); 762 icon = SmallIcon( "1updownarrow" );
763 } else { 763 } else {
764 icon = SmallIcon("1leftrightarrow" ); 764 icon = SmallIcon("1leftrightarrow" );
765 } 765 }
766 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 766 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
767 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 767 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
768 FSaction->addTo( viewMenu ); 768 FSaction->addTo( viewMenu );
769 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 769 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
770 770
771 icon = loadPixmap( pathString + "navi" ); 771 icon = loadPixmap( pathString + "navi" );
772 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 772 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
773 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 773 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
774 action->addTo( viewMenu ); 774 action->addTo( viewMenu );
775 connect( action, SIGNAL( activated() ), 775 connect( action, SIGNAL( activated() ),
776 mView, SLOT( toggleDateNavigatorWidget() ) ); 776 mView, SLOT( toggleDateNavigatorWidget() ) );
777 mToggleNav = action ; 777 mToggleNav = action ;
778 icon = loadPixmap( pathString + "filter" ); 778 icon = loadPixmap( pathString + "filter" );
779 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 779 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
780 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 780 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
781 action->addTo( viewMenu ); 781 action->addTo( viewMenu );
782 connect( action, SIGNAL( activated() ), 782 connect( action, SIGNAL( activated() ),
783 mView, SLOT( toggleFilter() ) ); 783 mView, SLOT( toggleFilter() ) );
784 mToggleFilter = action; 784 mToggleFilter = action;
785 icon = loadPixmap( pathString + "allday" ); 785 icon = loadPixmap( pathString + "allday" );
786 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 786 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
787 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 787 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
788 action->addTo( viewMenu ); 788 action->addTo( viewMenu );
789 connect( action, SIGNAL( activated() ), 789 connect( action, SIGNAL( activated() ),
790 mView, SLOT( toggleAllDaySize() ) ); 790 mView, SLOT( toggleAllDaySize() ) );
791 mToggleAllday = action; 791 mToggleAllday = action;
792 792
793 793
794 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 794 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
795 mToggleNav, SLOT( setEnabled ( bool ) ) ); 795 mToggleNav, SLOT( setEnabled ( bool ) ) );
796 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 796 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
797 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 797 mToggleFilter, SLOT( setEnabled ( bool ) ) );
798 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 798 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
799 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 799 mToggleAllday, SLOT( setEnabled ( bool ) ) );
800 800
801 viewMenu->insertSeparator(); 801 viewMenu->insertSeparator();
802 icon = loadPixmap( pathString + "picker" ); 802 icon = loadPixmap( pathString + "picker" );
803 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 803 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
804 action->addTo( viewMenu ); 804 action->addTo( viewMenu );
805 connect( action, SIGNAL( activated() ), 805 connect( action, SIGNAL( activated() ),
806 mView, SLOT( showDatePicker() ) ); 806 mView, SLOT( showDatePicker() ) );
807 action->addTo( iconToolBar ); 807 action->addTo( iconToolBar );
808 viewMenu->insertSeparator(); 808 viewMenu->insertSeparator();
809 809
810 if ( p-> mShowIconToggleFull ) 810 if ( p-> mShowIconToggleFull )
811 FSaction->addTo( iconToolBar ); 811 FSaction->addTo( iconToolBar );
812 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 812 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
813 813
814 //******************** 814 //********************
815 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 815 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
816 816
817 817
818 icon = loadPixmap( pathString + "whatsnext" ); 818 icon = loadPixmap( pathString + "whatsnext" );
819 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 819 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
820 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 820 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
821 whatsnext_action->addTo( viewMenu ); 821 whatsnext_action->addTo( viewMenu );
822 connect( whatsnext_action, SIGNAL( activated() ), 822 connect( whatsnext_action, SIGNAL( activated() ),
823 mView->viewManager(), SLOT( showWhatsNextView() ) ); 823 mView->viewManager(), SLOT( showWhatsNextView() ) );
824 824
825 icon = loadPixmap( pathString + "xdays" ); 825 icon = loadPixmap( pathString + "xdays" );
826 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 826 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
827 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 827 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
828 xdays_action->addTo( viewMenu ); 828 xdays_action->addTo( viewMenu );
829 connect( xdays_action, SIGNAL( activated() ), 829 connect( xdays_action, SIGNAL( activated() ),
830 mView->viewManager(), SLOT( showNextXView() ) ); 830 mView->viewManager(), SLOT( showNextXView() ) );
831 831
832 832
833 icon = loadPixmap( pathString + "journal" ); 833 icon = loadPixmap( pathString + "journal" );
834 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 834 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
835 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 835 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
836 viewjournal_action->addTo( viewMenu ); 836 viewjournal_action->addTo( viewMenu );
837 connect( viewjournal_action, SIGNAL( activated() ), 837 connect( viewjournal_action, SIGNAL( activated() ),
838 mView->viewManager(), SLOT( showJournalView() ) ); 838 mView->viewManager(), SLOT( showJournalView() ) );
839 839
840 840
841 icon = loadPixmap( pathString + "day" ); 841 icon = loadPixmap( pathString + "day" );
842 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 842 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
843 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 843 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
844 day1_action->addTo( viewMenu ); 844 day1_action->addTo( viewMenu );
845 // action->addTo( toolBar ); 845 // action->addTo( toolBar );
846 connect( day1_action, SIGNAL( activated() ), 846 connect( day1_action, SIGNAL( activated() ),
847 mView->viewManager(), SLOT( showDayView() ) ); 847 mView->viewManager(), SLOT( showDayView() ) );
848 848
849 icon = loadPixmap( pathString + "workweek" ); 849 icon = loadPixmap( pathString + "workweek" );
850 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 850 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
851 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 851 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
852 day5_action->addTo( viewMenu ); 852 day5_action->addTo( viewMenu );
853 connect( day5_action, SIGNAL( activated() ), 853 connect( day5_action, SIGNAL( activated() ),
854 mView->viewManager(), SLOT( showWorkWeekView() ) ); 854 mView->viewManager(), SLOT( showWorkWeekView() ) );
855 855
856 icon = loadPixmap( pathString + "week" ); 856 icon = loadPixmap( pathString + "week" );
857 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 857 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
858 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 858 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
859 day7_action->addTo( viewMenu ); 859 day7_action->addTo( viewMenu );
860 connect( day7_action, SIGNAL( activated() ), 860 connect( day7_action, SIGNAL( activated() ),
861 mView->viewManager(), SLOT( showWeekView() ) ); 861 mView->viewManager(), SLOT( showWeekView() ) );
862 862
863 icon = loadPixmap( pathString + "workweek2" ); 863 icon = loadPixmap( pathString + "workweek2" );
864 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 864 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
865 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 865 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
866 day6_action->addTo( viewMenu ); 866 day6_action->addTo( viewMenu );
867 connect( day6_action, SIGNAL( activated() ), 867 connect( day6_action, SIGNAL( activated() ),
868 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 868 mView->viewManager(), SLOT( showMonthViewWeek() ) );
869 869
870 icon = loadPixmap( pathString + "month" ); 870 icon = loadPixmap( pathString + "month" );
871 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 871 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
872 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 872 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
873 month_action->addTo( viewMenu ); 873 month_action->addTo( viewMenu );
874 connect( month_action, SIGNAL( activated() ), 874 connect( month_action, SIGNAL( activated() ),
875 mView->viewManager(), SLOT( showMonthView() ) ); 875 mView->viewManager(), SLOT( showMonthView() ) );
876 876
877 icon = loadPixmap( pathString + "list" ); 877 icon = loadPixmap( pathString + "list" );
878 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 878 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
879 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 879 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
880 showlist_action->addTo( viewMenu ); 880 showlist_action->addTo( viewMenu );
881 connect( showlist_action, SIGNAL( activated() ), 881 connect( showlist_action, SIGNAL( activated() ),
882 mView->viewManager(), SLOT( showListView() ) ); 882 mView->viewManager(), SLOT( showListView() ) );
883 883
884 icon = loadPixmap( pathString + "todo" ); 884 icon = loadPixmap( pathString + "todo" );
885 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 885 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
886 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 886 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
887 todoview_action->addTo( viewMenu ); 887 todoview_action->addTo( viewMenu );
888 connect( todoview_action, SIGNAL( activated() ), 888 connect( todoview_action, SIGNAL( activated() ),
889 mView->viewManager(), SLOT( showTodoView() ) ); 889 mView->viewManager(), SLOT( showTodoView() ) );
890 890
891 891
892 892
893#if 0 893#if 0
894 action = new QAction( "view_timespan", "Time Span", 0, this ); 894 action = new QAction( "view_timespan", "Time Span", 0, this );
895 action->addTo( viewMenu ); 895 action->addTo( viewMenu );
896 connect( action, SIGNAL( activated() ), 896 connect( action, SIGNAL( activated() ),
897 mView->viewManager(), SLOT( showTimeSpanView() ) ); 897 mView->viewManager(), SLOT( showTimeSpanView() ) );
898#endif 898#endif
899 899
900 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 900 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
901 this ); 901 this );
902 mNewSubTodoAction->addTo( actionMenu ); 902 mNewSubTodoAction->addTo( actionMenu );
903 connect( mNewSubTodoAction, SIGNAL( activated() ), 903 connect( mNewSubTodoAction, SIGNAL( activated() ),
904 mView, SLOT( newSubTodo() ) ); 904 mView, SLOT( newSubTodo() ) );
905 905
906 actionMenu->insertSeparator(); 906 actionMenu->insertSeparator();
907 907
908 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 908 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
909 mShowAction->addTo( actionMenu ); 909 mShowAction->addTo( actionMenu );
910 connect( mShowAction, SIGNAL( activated() ), 910 connect( mShowAction, SIGNAL( activated() ),
911 mView, SLOT( showIncidence() ) ); 911 mView, SLOT( showIncidence() ) );
912 912
913 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 913 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
914 mEditAction->addTo( actionMenu ); 914 mEditAction->addTo( actionMenu );
915 connect( mEditAction, SIGNAL( activated() ), 915 connect( mEditAction, SIGNAL( activated() ),
916 mView, SLOT( editIncidence() ) ); 916 mView, SLOT( editIncidence() ) );
917 917
918 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 918 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
919 mDeleteAction->addTo( actionMenu ); 919 mDeleteAction->addTo( actionMenu );
920 connect( mDeleteAction, SIGNAL( activated() ), 920 connect( mDeleteAction, SIGNAL( activated() ),
921 mView, SLOT( deleteIncidence() ) ); 921 mView, SLOT( deleteIncidence() ) );
922 922
923 923
924 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 924 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
925 mCloneAction->addTo( actionMenu ); 925 mCloneAction->addTo( actionMenu );
926 connect( mCloneAction, SIGNAL( activated() ), 926 connect( mCloneAction, SIGNAL( activated() ),
927 mView, SLOT( cloneIncidence() ) ); 927 mView, SLOT( cloneIncidence() ) );
928 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 928 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
929 mMoveAction->addTo( actionMenu ); 929 mMoveAction->addTo( actionMenu );
930 connect( mMoveAction, SIGNAL( activated() ), 930 connect( mMoveAction, SIGNAL( activated() ),
931 mView, SLOT( moveIncidence() ) ); 931 mView, SLOT( moveIncidence() ) );
932 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 932 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
933 mBeamAction->addTo( actionMenu ); 933 mBeamAction->addTo( actionMenu );
934 connect( mBeamAction, SIGNAL( activated() ), 934 connect( mBeamAction, SIGNAL( activated() ),
935 mView, SLOT( beamIncidence() ) ); 935 mView, SLOT( beamIncidence() ) );
936 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 936 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
937 mCancelAction->addTo( actionMenu ); 937 mCancelAction->addTo( actionMenu );
938 connect( mCancelAction, SIGNAL( activated() ), 938 connect( mCancelAction, SIGNAL( activated() ),
939 mView, SLOT( toggleCancelIncidence() ) ); 939 mView, SLOT( toggleCancelIncidence() ) );
940 940
941 actionMenu->insertSeparator(); 941 actionMenu->insertSeparator();
942 942
943 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 943 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
944 this ); 944 this );
945 action->addTo( actionMenu ); 945 action->addTo( actionMenu );
946 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 946 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
947 947
948 icon = loadPixmap( pathString + "search" ); 948 icon = loadPixmap( pathString + "search" );
949 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 949 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
950 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 950 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
951 search_action->addTo( actionMenu ); 951 search_action->addTo( actionMenu );
952 connect( search_action, SIGNAL( activated() ), 952 connect( search_action, SIGNAL( activated() ),
953 mView->dialogManager(), SLOT( showSearchDialog() ) ); 953 mView->dialogManager(), SLOT( showSearchDialog() ) );
954 954
955 955
956 956
957 if ( KOPrefs::instance()->mShowFullMenu ) { 957 if ( KOPrefs::instance()->mShowFullMenu ) {
958 actionMenu->insertSeparator(); 958 actionMenu->insertSeparator();
959 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 959 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
960 960
961 } 961 }
962 // actionMenu->insertSeparator(); 962 // actionMenu->insertSeparator();
963 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 963 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
964 this ); 964 this );
965 action->addTo( importMenu_X ); 965 action->addTo( importMenu_X );
966 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 966 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
967 action = new QAction( "import_quick", i18n("Import last file"), 0, 967 action = new QAction( "import_quick", i18n("Import last file"), 0,
968 this ); 968 this );
969 action->addTo( importMenu_X ); 969 action->addTo( importMenu_X );
970 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 970 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
971 importMenu_X->insertSeparator(); 971 importMenu_X->insertSeparator();
972 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 972 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
973 this ); 973 this );
974 action->addTo( importMenu_X ); 974 action->addTo( importMenu_X );
975 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 975 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
976 //#ifndef DESKTOP_VERSION 976 //#ifndef DESKTOP_VERSION
977 importMenu_X->insertSeparator(); 977 importMenu_X->insertSeparator();
978 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 978 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
979 this ); 979 this );
980 action->addTo( importMenu_X ); 980 action->addTo( importMenu_X );
981 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 981 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
982 //#else 982 //#else
983#ifdef _OL_IMPORT_ 983#ifdef _OL_IMPORT_
984 importMenu_X->insertSeparator(); 984 importMenu_X->insertSeparator();
985 action = new QAction( "import_ol", i18n("Import from OL"), 0, 985 action = new QAction( "import_ol", i18n("Import from OL"), 0,
986 this ); 986 this );
987 action->addTo( importMenu_X ); 987 action->addTo( importMenu_X );
988 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
989#endif 989#endif
990 //#endif 990 //#endif
991 991
992 //importMenu->insertSeparator(); 992 //importMenu->insertSeparator();
993 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 993 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
994 this ); 994 this );
995 action->addTo( importMenu ); 995 action->addTo( importMenu );
996 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 996 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
997 997
998 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 998 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
999 this ); 999 this );
1000 action->addTo( importMenu ); 1000 action->addTo( importMenu );
1001 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1001 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1002 importMenu->insertSeparator(); 1002 importMenu->insertSeparator();
1003 importMenu->insertItem( i18n("Import"), importMenu_X ); 1003 importMenu->insertItem( i18n("Import"), importMenu_X );
1004 //importMenu->insertSeparator(); 1004 //importMenu->insertSeparator();
1005 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1005 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1006 this ); 1006 this );
1007 action->addTo( exportMenu_X ); 1007 action->addTo( exportMenu_X );
1008 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1008 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1009 1009
1010 1010
1011 //LR 1011 //LR
1012 QPopupMenu *ex2phone = new QPopupMenu( this ); 1012 QPopupMenu *ex2phone = new QPopupMenu( this );
1013 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1013 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1014 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1014 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1015 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1015 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1016 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1016 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1017 1017
1018 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1018 importMenu->insertItem( i18n("Export"), exportMenu_X );
1019#ifndef DESKTOP_VERSION 1019#ifndef DESKTOP_VERSION
1020 //importMenu->insertSeparator(); 1020 //importMenu->insertSeparator();
1021 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1021 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1022 this ); 1022 this );
1023 brAction->addTo( beamMenu_X ); 1023 brAction->addTo( beamMenu_X );
1024 brAction->setToggleAction (true ) ; 1024 brAction->setToggleAction (true ) ;
1025 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1025 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1026 1026
1027 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1027 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1028 this ); 1028 this );
1029 action->addTo( beamMenu_X ); 1029 action->addTo( beamMenu_X );
1030 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1030 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1031 1031
1032 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1032 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1033 this ); 1033 this );
1034 action->addTo( beamMenu_X ); 1034 action->addTo( beamMenu_X );
1035 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1035 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1036 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1036 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1037#else 1037#else
1038 //importMenu->insertSeparator(); 1038 //importMenu->insertSeparator();
1039 icon = loadPixmap( pathString + "print" ); 1039 icon = loadPixmap( pathString + "print" );
1040 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1040 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1041 action->addTo( beamMenu_X ); 1041 action->addTo( beamMenu_X );
1042 connect( action, SIGNAL( activated() ), 1042 connect( action, SIGNAL( activated() ),
1043 this, SLOT( printCal() ) ); 1043 this, SLOT( printCal() ) );
1044 1044
1045 icon = loadPixmap( pathString + "print" ); 1045 icon = loadPixmap( pathString + "print" );
1046 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1046 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1047 action->addTo( beamMenu_X ); 1047 action->addTo( beamMenu_X );
1048 connect( action, SIGNAL( activated() ), 1048 connect( action, SIGNAL( activated() ),
1049 this, SLOT( printSel() ) ); 1049 this, SLOT( printSel() ) );
1050 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1050 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1051 action->addTo( beamMenu_X ); 1051 action->addTo( beamMenu_X );
1052 connect( action, SIGNAL( activated() ), 1052 connect( action, SIGNAL( activated() ),
1053 mView->viewManager(), SLOT( slotprintWNV() ) ); 1053 mView->viewManager(), SLOT( slotprintWNV() ) );
1054 1054
1055 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1055 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1056 action->addTo( beamMenu_X ); 1056 action->addTo( beamMenu_X );
1057 connect( action, SIGNAL( activated() ), 1057 connect( action, SIGNAL( activated() ),
1058 mView, SLOT( slotprintSelInc() ) ); 1058 mView, SLOT( slotprintSelInc() ) );
1059 1059
1060 1060
1061 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1061 importMenu->insertItem( i18n("Print"), beamMenu_X );
1062#endif 1062#endif
1063 importMenu->insertSeparator(); 1063 importMenu->insertSeparator();
1064 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1064 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1065 this ); 1065 this );
1066 action->addTo( importMenu ); 1066 action->addTo( importMenu );
1067 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1067 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1068 importMenu->insertSeparator(); 1068 importMenu->insertSeparator();
1069 action = new QAction( "beam all", i18n("Save"), 0, 1069 action = new QAction( "beam all", i18n("Save"), 0,
1070 this ); 1070 this );
1071 action->addTo( importMenu ); 1071 action->addTo( importMenu );
1072 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1072 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1073 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1073 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1074 this ); 1074 this );
1075 action->addTo( importMenu ); 1075 action->addTo( importMenu );
1076 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1076 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1077 1077
1078 //menuBar->insertItem( "Configure",configureMenu ); 1078 //menuBar->insertItem( "Configure",configureMenu );
1079 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1079 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1080 icon = loadPixmap( "korganizer/korganizer" ); 1080 icon = loadPixmap( "korganizer/korganizer" );
1081 1081
1082 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1082 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1083 action->addTo( helpMenu ); 1083 action->addTo( helpMenu );
1084 connect( action, SIGNAL( activated() ), 1084 connect( action, SIGNAL( activated() ),
1085 SLOT( whatsNew() ) ); 1085 SLOT( whatsNew() ) );
1086 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1086 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1087 action->addTo( helpMenu ); 1087 action->addTo( helpMenu );
1088 connect( action, SIGNAL( activated() ), 1088 connect( action, SIGNAL( activated() ),
1089 SLOT( features() ) ); 1089 SLOT( features() ) );
1090 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1090 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1091 action->addTo( helpMenu ); 1091 action->addTo( helpMenu );
1092 connect( action, SIGNAL( activated() ), 1092 connect( action, SIGNAL( activated() ),
1093 SLOT( keyBindings() ) ); 1093 SLOT( keyBindings() ) );
1094 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1094 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1095 action->addTo( helpMenu ); 1095 action->addTo( helpMenu );
1096 connect( action, SIGNAL( activated() ), 1096 connect( action, SIGNAL( activated() ),
1097 SLOT( storagehowto() ) ); 1097 SLOT( storagehowto() ) );
1098 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1098 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1099 action->addTo( helpMenu ); 1099 action->addTo( helpMenu );
1100 connect( action, SIGNAL( activated() ), 1100 connect( action, SIGNAL( activated() ),
1101 SLOT( timetrackinghowto() ) ); 1101 SLOT( timetrackinghowto() ) );
1102 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1102 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1103 action->addTo( helpMenu ); 1103 action->addTo( helpMenu );
1104 connect( action, SIGNAL( activated() ), 1104 connect( action, SIGNAL( activated() ),
1105 SLOT( synchowto() ) ); 1105 SLOT( synchowto() ) );
1106 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1106 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1107 action->addTo( helpMenu ); 1107 action->addTo( helpMenu );
1108 connect( action, SIGNAL( activated() ), 1108 connect( action, SIGNAL( activated() ),
1109 SLOT( kdesynchowto() ) ); 1109 SLOT( kdesynchowto() ) );
1110 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1110 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1111 action->addTo( helpMenu ); 1111 action->addTo( helpMenu );
1112 connect( action, SIGNAL( activated() ), 1112 connect( action, SIGNAL( activated() ),
1113 SLOT( multisynchowto() ) ); 1113 SLOT( multisynchowto() ) );
1114 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1114 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1115 action->addTo( helpMenu ); 1115 action->addTo( helpMenu );
1116 connect( action, SIGNAL( activated() ), 1116 connect( action, SIGNAL( activated() ),
1117 SLOT( aboutAutoSaving() ) ); 1117 SLOT( aboutAutoSaving() ) );
1118 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1118 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1119 action->addTo( helpMenu ); 1119 action->addTo( helpMenu );
1120 connect( action, SIGNAL( activated() ), 1120 connect( action, SIGNAL( activated() ),
1121 SLOT( aboutKnownBugs() ) ); 1121 SLOT( aboutKnownBugs() ) );
1122 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1122 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1123 action->addTo( helpMenu ); 1123 action->addTo( helpMenu );
1124 connect( action, SIGNAL( activated() ), 1124 connect( action, SIGNAL( activated() ),
1125 SLOT( usertrans() ) ); 1125 SLOT( usertrans() ) );
1126 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1126 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1127 action->addTo( helpMenu ); 1127 action->addTo( helpMenu );
1128 connect( action, SIGNAL( activated() ), 1128 connect( action, SIGNAL( activated() ),
1129 SLOT( faq() ) ); 1129 SLOT( faq() ) );
1130 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1130 action = new QAction( "licence", i18n("Licence..."), 0, this );
1131 action->addTo( helpMenu ); 1131 action->addTo( helpMenu );
1132 connect( action, SIGNAL( activated() ), 1132 connect( action, SIGNAL( activated() ),
1133 SLOT( licence() ) ); 1133 SLOT( licence() ) );
1134 action = new QAction( "about", i18n("About..."), 0, this ); 1134 action = new QAction( "about", i18n("About..."), 0, this );
1135 action->addTo( helpMenu ); 1135 action->addTo( helpMenu );
1136 connect( action, SIGNAL( activated() ), 1136 connect( action, SIGNAL( activated() ),
1137 SLOT( about() ) ); 1137 SLOT( about() ) );
1138 //menuBar->insertSeparator(); 1138 //menuBar->insertSeparator();
1139 1139
1140 // ****************************************************** 1140 // ******************************************************
1141 // menubar icons 1141 // menubar icons
1142 1142
1143 1143
1144 1144
1145 //menuBar->insertItem( iconToolBar ); 1145 //menuBar->insertItem( iconToolBar );
1146 //xdays_action 1146 //xdays_action
1147 if (p-> mShowIconNewEvent) 1147 if (p-> mShowIconNewEvent)
1148 ne_action->addTo( iconToolBar ); 1148 ne_action->addTo( iconToolBar );
1149 if (p->mShowIconNewTodo ) 1149 if (p->mShowIconNewTodo )
1150 nt_action->addTo( iconToolBar ); 1150 nt_action->addTo( iconToolBar );
1151 if (p-> mShowIconSearch) 1151 if (p-> mShowIconSearch)
1152 search_action->addTo( iconToolBar ); 1152 search_action->addTo( iconToolBar );
1153 if (p-> mShowIconWhatsThis) 1153 if (p-> mShowIconWhatsThis)
1154 QWhatsThis::whatsThisButton ( iconToolBar ); 1154 QWhatsThis::whatsThisButton ( iconToolBar );
1155 if (p-> mShowIconNext) 1155 if (p-> mShowIconNext)
1156 whatsnext_action->addTo( viewToolBar ); 1156 whatsnext_action->addTo( viewToolBar );
1157 if (p-> mShowIconNextDays) 1157 if (p-> mShowIconNextDays)
1158 xdays_action->addTo( viewToolBar ); 1158 xdays_action->addTo( viewToolBar );
1159 if (p-> mShowIconJournal) 1159 if (p-> mShowIconJournal)
1160 viewjournal_action->addTo( viewToolBar ); 1160 viewjournal_action->addTo( viewToolBar );
1161 if (p-> mShowIconDay1) 1161 if (p-> mShowIconDay1)
1162 day1_action->addTo( viewToolBar ); 1162 day1_action->addTo( viewToolBar );
1163 if (p-> mShowIconDay5) 1163 if (p-> mShowIconDay5)
1164 day5_action->addTo( viewToolBar ); 1164 day5_action->addTo( viewToolBar );
1165 if (p-> mShowIconDay7) 1165 if (p-> mShowIconDay7)
1166 day7_action->addTo( viewToolBar ); 1166 day7_action->addTo( viewToolBar );
1167 if (p-> mShowIconDay6) 1167 if (p-> mShowIconDay6)
1168 day6_action->addTo( viewToolBar ); 1168 day6_action->addTo( viewToolBar );
1169 if (p-> mShowIconMonth) 1169 if (p-> mShowIconMonth)
1170 month_action->addTo( viewToolBar ); 1170 month_action->addTo( viewToolBar );
1171 if (p-> mShowIconList) 1171 if (p-> mShowIconList)
1172 showlist_action->addTo( viewToolBar ); 1172 showlist_action->addTo( viewToolBar );
1173 if (p-> mShowIconTodoview) 1173 if (p-> mShowIconTodoview)
1174 todoview_action->addTo( viewToolBar ); 1174 todoview_action->addTo( viewToolBar );
1175 1175
1176 icon = loadPixmap( pathString + "2leftarrowB" ); 1176 icon = loadPixmap( pathString + "2leftarrowB" );
1177 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1177 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1178 if (p-> mShowIconBackFast) { 1178 if (p-> mShowIconBackFast) {
1179 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1179 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1180 connect( action, SIGNAL( activated() ), 1180 connect( action, SIGNAL( activated() ),
1181 mView, SLOT( goPreviousMonth() ) ); 1181 mView, SLOT( goPreviousMonth() ) );
1182 action->addTo( navigatorToolBar ); 1182 action->addTo( navigatorToolBar );
1183 } 1183 }
1184 icon = loadPixmap( pathString + "1leftarrowB" ); 1184 icon = loadPixmap( pathString + "1leftarrowB" );
1185 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1185 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1186 if (p-> mShowIconBack) { 1186 if (p-> mShowIconBack) {
1187 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1187 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1188 connect( action, SIGNAL( activated() ), 1188 connect( action, SIGNAL( activated() ),
1189 mView, SLOT( goPrevious() ) ); 1189 mView, SLOT( goPrevious() ) );
1190 action->addTo( navigatorToolBar ); 1190 action->addTo( navigatorToolBar );
1191 } 1191 }
1192 icon = loadPixmap( pathString + "today" ); 1192 icon = loadPixmap( pathString + "today" );
1193 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1193 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1194 if (p-> mShowIconToday) 1194 if (p-> mShowIconToday)
1195 today_action->addTo( navigatorToolBar ); 1195 today_action->addTo( navigatorToolBar );
1196 icon = loadPixmap( pathString + "1rightarrowB" ); 1196 icon = loadPixmap( pathString + "1rightarrowB" );
1197 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1197 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1198 if (p-> mShowIconForward) { 1198 if (p-> mShowIconForward) {
1199 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1199 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1200 connect( action, SIGNAL( activated() ), 1200 connect( action, SIGNAL( activated() ),
1201 mView, SLOT( goNext() ) ); 1201 mView, SLOT( goNext() ) );
1202 action->addTo( navigatorToolBar ); 1202 action->addTo( navigatorToolBar );
1203 } 1203 }
1204 icon = loadPixmap( pathString + "2rightarrowB" ); 1204 icon = loadPixmap( pathString + "2rightarrowB" );
1205 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1205 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1206 if (p-> mShowIconForwardFast) { 1206 if (p-> mShowIconForwardFast) {
1207 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1207 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1208 connect( action, SIGNAL( activated() ), 1208 connect( action, SIGNAL( activated() ),
1209 mView, SLOT( goNextMonth() ) ); 1209 mView, SLOT( goNextMonth() ) );
1210 action->addTo( navigatorToolBar ); 1210 action->addTo( navigatorToolBar );
1211 } 1211 }
1212 1212
1213 1213
1214 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1214 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1215 1215
1216 1216
1217 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1217 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1218 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1218 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1219 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1219 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1220 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1220 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1221 1221
1222 if (p-> mShowIconNewEvent) 1222 if (p-> mShowIconNewEvent)
1223 configureToolBarMenu->setItemChecked( 10, true ); 1223 configureToolBarMenu->setItemChecked( 10, true );
1224 if (p->mShowIconNewTodo ) 1224 if (p->mShowIconNewTodo )
1225 configureToolBarMenu->setItemChecked( 20, true ); 1225 configureToolBarMenu->setItemChecked( 20, true );
1226 if (p-> mShowIconSearch) 1226 if (p-> mShowIconSearch)
1227 configureToolBarMenu->setItemChecked( 120, true ); 1227 configureToolBarMenu->setItemChecked( 120, true );
1228 if (p-> mShowIconList) 1228 if (p-> mShowIconList)
1229 configureToolBarMenu->setItemChecked( 30, true ); 1229 configureToolBarMenu->setItemChecked( 30, true );
1230 if (p-> mShowIconDay1) 1230 if (p-> mShowIconDay1)
1231 configureToolBarMenu->setItemChecked( 40, true ); 1231 configureToolBarMenu->setItemChecked( 40, true );
1232 if (p-> mShowIconDay5) 1232 if (p-> mShowIconDay5)
1233 configureToolBarMenu->setItemChecked( 50, true ); 1233 configureToolBarMenu->setItemChecked( 50, true );
1234 if (p-> mShowIconDay6) 1234 if (p-> mShowIconDay6)
1235 configureToolBarMenu->setItemChecked( 75, true ); 1235 configureToolBarMenu->setItemChecked( 75, true );
1236 if (p-> mShowIconDay7) 1236 if (p-> mShowIconDay7)
1237 configureToolBarMenu->setItemChecked( 60, true ); 1237 configureToolBarMenu->setItemChecked( 60, true );
1238 if (p-> mShowIconMonth) 1238 if (p-> mShowIconMonth)
1239 configureToolBarMenu->setItemChecked( 70, true ); 1239 configureToolBarMenu->setItemChecked( 70, true );
1240 if (p-> mShowIconTodoview) 1240 if (p-> mShowIconTodoview)
1241 configureToolBarMenu->setItemChecked( 80, true ); 1241 configureToolBarMenu->setItemChecked( 80, true );
1242 if (p-> mShowIconBackFast) 1242 if (p-> mShowIconBackFast)
1243 configureToolBarMenu->setItemChecked( 200, true ); 1243 configureToolBarMenu->setItemChecked( 200, true );
1244 if (p-> mShowIconBack) 1244 if (p-> mShowIconBack)
1245 configureToolBarMenu->setItemChecked( 210, true ); 1245 configureToolBarMenu->setItemChecked( 210, true );
1246 if (p-> mShowIconToday) 1246 if (p-> mShowIconToday)
1247 configureToolBarMenu->setItemChecked( 130, true ); 1247 configureToolBarMenu->setItemChecked( 130, true );
1248 if (p-> mShowIconForward) 1248 if (p-> mShowIconForward)
1249 configureToolBarMenu->setItemChecked( 220, true ); 1249 configureToolBarMenu->setItemChecked( 220, true );
1250 if (p-> mShowIconForwardFast) 1250 if (p-> mShowIconForwardFast)
1251 configureToolBarMenu->setItemChecked( 230, true ); 1251 configureToolBarMenu->setItemChecked( 230, true );
1252 if (p-> mShowIconNextDays) 1252 if (p-> mShowIconNextDays)
1253 configureToolBarMenu->setItemChecked( 100, true ); 1253 configureToolBarMenu->setItemChecked( 100, true );
1254 if (p-> mShowIconNext) 1254 if (p-> mShowIconNext)
1255 configureToolBarMenu->setItemChecked( 110, true ); 1255 configureToolBarMenu->setItemChecked( 110, true );
1256 if (p-> mShowIconJournal) 1256 if (p-> mShowIconJournal)
1257 configureToolBarMenu->setItemChecked( 90, true ); 1257 configureToolBarMenu->setItemChecked( 90, true );
1258 if (p-> mShowIconWhatsThis) 1258 if (p-> mShowIconWhatsThis)
1259 configureToolBarMenu->setItemChecked( 300, true ); 1259 configureToolBarMenu->setItemChecked( 300, true );
1260 if (p-> mShowIconWeekNum) 1260 if (p-> mShowIconWeekNum)
1261 configureToolBarMenu->setItemChecked( 400, true ); 1261 configureToolBarMenu->setItemChecked( 400, true );
1262 if (!p-> mShowIconStretch) { 1262 if (!p-> mShowIconStretch) {
1263 QLabel* dummy = new QLabel( iconToolBar ); 1263 QLabel* dummy = new QLabel( iconToolBar );
1264 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1264 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1265 dummy->setMinimumWidth( 0 ); 1265 dummy->setMinimumWidth( 0 );
1266 iconToolBar->setStretchableWidget ( dummy ) ; 1266 iconToolBar->setStretchableWidget ( dummy ) ;
1267 } 1267 }
1268 else { 1268 else {
1269 iconToolBar->setHorizontalStretchable (true ); 1269 iconToolBar->setHorizontalStretchable (true );
1270 viewToolBar->setHorizontalStretchable (true ); 1270 viewToolBar->setHorizontalStretchable (true );
1271 navigatorToolBar->setHorizontalStretchable (true ); 1271 navigatorToolBar->setHorizontalStretchable (true );
1272 iconToolBar->setVerticalStretchable (true ); 1272 iconToolBar->setVerticalStretchable (true );
1273 viewToolBar->setVerticalStretchable (true ); 1273 viewToolBar->setVerticalStretchable (true );
1274 navigatorToolBar->setVerticalStretchable (true ); 1274 navigatorToolBar->setVerticalStretchable (true );
1275 configureToolBarMenu->setItemChecked( 5, true ); 1275 configureToolBarMenu->setItemChecked( 5, true );
1276 } 1276 }
1277 if (p-> mShowIconFilter) 1277 if (p-> mShowIconFilter)
1278 configureToolBarMenu->setItemChecked( 7, true ); 1278 configureToolBarMenu->setItemChecked( 7, true );
1279 if (p-> mShowIconOnetoolbar) 1279 if (p-> mShowIconOnetoolbar)
1280 configureToolBarMenu->setItemChecked( 6, true ); 1280 configureToolBarMenu->setItemChecked( 6, true );
1281 1281
1282 1282
1283 if ( filterMenubar ) 1283 if ( filterMenubar ) {
1284 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1284 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1285 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1286 }
1285 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1287 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1286 configureAgenda( p->mHourSize ); 1288 configureAgenda( p->mHourSize );
1287 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1289 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1288} 1290}
1289 1291
1290void MainWindow::exportToPhone( int mode ) 1292void MainWindow::exportToPhone( int mode )
1291{ 1293{
1292 1294
1293 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1295 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1294 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1296 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1295 KOex2phonePrefs ex2phone; 1297 KOex2phonePrefs ex2phone;
1296 1298
1297 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1299 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1298 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1300 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1299 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1301 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1300 if ( mode == 1 ) 1302 if ( mode == 1 )
1301 ex2phone.setCaption(i18n("Export complete calendar")); 1303 ex2phone.setCaption(i18n("Export complete calendar"));
1302 if ( mode == 2 ) 1304 if ( mode == 2 )
1303 ex2phone.setCaption(i18n("Export filtered calendar")); 1305 ex2phone.setCaption(i18n("Export filtered calendar"));
1304 1306
1305 if ( !ex2phone.exec() ) { 1307 if ( !ex2phone.exec() ) {
1306 return; 1308 return;
1307 } 1309 }
1308 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1310 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1309 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1311 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1310 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1312 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1311 1313
1312 int inFuture = 0; 1314 int inFuture = 0;
1313 if ( ex2phone.mWriteBackFuture->isChecked() ) 1315 if ( ex2phone.mWriteBackFuture->isChecked() )
1314 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1316 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1315 QPtrList<Incidence> delSel; 1317 QPtrList<Incidence> delSel;
1316 if ( mode == 1 ) 1318 if ( mode == 1 )
1317 delSel = mCalendar->rawIncidences(); 1319 delSel = mCalendar->rawIncidences();
1318 if ( mode == 2 ) 1320 if ( mode == 2 )
1319 delSel = mCalendar->incidences(); 1321 delSel = mCalendar->incidences();
1320 CalendarLocal* cal = new CalendarLocal(); 1322 CalendarLocal* cal = new CalendarLocal();
1321 cal->setLocalTime(); 1323 cal->setLocalTime();
1322 Incidence *incidence = delSel.first(); 1324 Incidence *incidence = delSel.first();
1323 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1325 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1324 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1326 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1325 while ( incidence ) { 1327 while ( incidence ) {
1326 if ( incidence->type() != "Journal" ) { 1328 if ( incidence->type() != "Journal" ) {
1327 bool add = true; 1329 bool add = true;
1328 if ( inFuture ) { 1330 if ( inFuture ) {
1329 QDateTime dt; 1331 QDateTime dt;
1330 if ( incidence->type() == "Todo" ) { 1332 if ( incidence->type() == "Todo" ) {
1331 Todo * t = (Todo*)incidence; 1333 Todo * t = (Todo*)incidence;
1332 if ( t->hasDueDate() ) 1334 if ( t->hasDueDate() )
1333 dt = t->dtDue(); 1335 dt = t->dtDue();
1334 else 1336 else
1335 dt = cur.addSecs( 62 ); 1337 dt = cur.addSecs( 62 );
1336 } 1338 }
1337 else { 1339 else {
1338 bool ok; 1340 bool ok;
1339 dt = incidence->getNextOccurence( cur, &ok ); 1341 dt = incidence->getNextOccurence( cur, &ok );
1340 if ( !ok ) 1342 if ( !ok )
1341 dt = cur.addSecs( -62 ); 1343 dt = cur.addSecs( -62 );
1342 } 1344 }
1343 if ( dt < cur || dt > end ) { 1345 if ( dt < cur || dt > end ) {
1344 add = false; 1346 add = false;
1345 } 1347 }
1346 } 1348 }
1347 if ( add ) { 1349 if ( add ) {
1348 Incidence *in = incidence->clone(); 1350 Incidence *in = incidence->clone();
1349 cal->addIncidence( in ); 1351 cal->addIncidence( in );
1350 } 1352 }
1351 } 1353 }
1352 incidence = delSel.next(); 1354 incidence = delSel.next();
1353 } 1355 }
1354 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1356 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1355 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1357 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1356 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1358 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1357 1359
1358 setCaption( i18n("Writing to phone...")); 1360 setCaption( i18n("Writing to phone..."));
1359 if ( PhoneFormat::writeToPhone( cal ) ) 1361 if ( PhoneFormat::writeToPhone( cal ) )
1360 setCaption( i18n("Export to phone successful!")); 1362 setCaption( i18n("Export to phone successful!"));
1361 else 1363 else
1362 setCaption( i18n("Error exporting to phone!")); 1364 setCaption( i18n("Error exporting to phone!"));
1363 delete cal; 1365 delete cal;
1364} 1366}
1365 1367
1366 1368
1367void MainWindow::setDefaultPreferences() 1369void MainWindow::setDefaultPreferences()
1368{ 1370{
1369 KOPrefs *p = KOPrefs::instance(); 1371 KOPrefs *p = KOPrefs::instance();
1370 1372
1371 p->mCompactDialogs = true; 1373 p->mCompactDialogs = true;
1372 p->mConfirm = true; 1374 p->mConfirm = true;
1373 // p->mEnableQuickTodo = false; 1375 // p->mEnableQuickTodo = false;
1374 1376
1375} 1377}
1376 1378
1377QString MainWindow::resourcePath() 1379QString MainWindow::resourcePath()
1378{ 1380{
1379 return KGlobal::iconLoader()->iconPath(); 1381 return KGlobal::iconLoader()->iconPath();
1380} 1382}
1381 1383
1382void MainWindow::displayText( QString text ,QString cap ) 1384void MainWindow::displayText( QString text ,QString cap )
1383{ 1385{
1384 QDialog dia( this, "name", true ); ; 1386 QDialog dia( this, "name", true ); ;
1385 dia.setCaption( cap ); 1387 dia.setCaption( cap );
1386 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1388 QVBoxLayout* lay = new QVBoxLayout( &dia );
1387 lay->setSpacing( 3 ); 1389 lay->setSpacing( 3 );
1388 lay->setMargin( 3 ); 1390 lay->setMargin( 3 );
1389 QTextBrowser tb ( &dia ); 1391 QTextBrowser tb ( &dia );
1390 lay->addWidget( &tb ); 1392 lay->addWidget( &tb );
1391 tb.setText( text ); 1393 tb.setText( text );
1392#ifdef DESKTOP_VERSION 1394#ifdef DESKTOP_VERSION
1393 dia.resize( 640, 480); 1395 dia.resize( 640, 480);
1394#else 1396#else
1395 dia.showMaximized(); 1397 dia.showMaximized();
1396#endif 1398#endif
1397 dia.exec(); 1399 dia.exec();
1398} 1400}
1399 1401
1400void MainWindow::features() 1402void MainWindow::features()
1401{ 1403{
1402 1404
1403 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1405 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1404} 1406}
1405 1407
1406void MainWindow::usertrans() 1408void MainWindow::usertrans()
1407{ 1409{
1408 1410
1409 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1411 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1410} 1412}
1411 1413
1412void MainWindow::storagehowto() 1414void MainWindow::storagehowto()
1413{ 1415{
1414 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1416 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1415} 1417}
1416void MainWindow::timetrackinghowto() 1418void MainWindow::timetrackinghowto()
1417{ 1419{
1418 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1420 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1419} 1421}
1420void MainWindow::kdesynchowto() 1422void MainWindow::kdesynchowto()
1421{ 1423{
1422 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1424 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1423} 1425}
1424void MainWindow::multisynchowto() 1426void MainWindow::multisynchowto()
1425{ 1427{
1426 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1428 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1427} 1429}
1428void MainWindow::synchowto() 1430void MainWindow::synchowto()
1429{ 1431{
1430 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1432 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1431} 1433}
1432void MainWindow::faq() 1434void MainWindow::faq()
1433{ 1435{
1434 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1436 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1435 1437
1436} 1438}
1437void MainWindow::whatsNew() 1439void MainWindow::whatsNew()
1438{ 1440{
1439 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1441 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1440 1442
1441} 1443}
1442void MainWindow::licence() 1444void MainWindow::licence()
1443{ 1445{
1444 KApplication::showLicence(); 1446 KApplication::showLicence();
1445 1447
1446} 1448}
1447void MainWindow::about() 1449void MainWindow::about()
1448{ 1450{
1449 QString version; 1451 QString version;
1450#include <../version> 1452#include <../version>
1451 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1453 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1452 i18n("KOrganizer/Platform-independent\n") + 1454 i18n("KOrganizer/Platform-independent\n") +
1453 "(KO/Pi) " + version + " - " + 1455 "(KO/Pi) " + version + " - " +
1454 1456
1455#ifdef DESKTOP_VERSION 1457#ifdef DESKTOP_VERSION
1456 i18n("Desktop Edition\n") + 1458 i18n("Desktop Edition\n") +
1457#else 1459#else
1458 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1460 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1459#endif 1461#endif
1460 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1462 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1461} 1463}
1462void MainWindow::keyBindings() 1464void MainWindow::keyBindings()
1463{ 1465{
1464 QString cap = i18n("KO/Pi Keys + Colors"); 1466 QString cap = i18n("KO/Pi Keys + Colors");
1465 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1467 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1466 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1468 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1467 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1469 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1468 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1470 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1469 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1471 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1470 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1472 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1471 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1473 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1472 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1474 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1473 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1475 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1474 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1476 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1475 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1477 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1476 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1478 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1477 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1479 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1478 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1480 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1479 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1481 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1480 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1482 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1481 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1483 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1482 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1484 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1483 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1485 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1484 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1486 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1485 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1487 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1486 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1488 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1487 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1489 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1488 i18n("<p><h3>In agenda view:</h3></p>\n") + 1490 i18n("<p><h3>In agenda view:</h3></p>\n") +
1489 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1491 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1490 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1492 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1491 i18n("<p><h3>In todo view:</h3></p>\n") + 1493 i18n("<p><h3>In todo view:</h3></p>\n") +
1492 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1494 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1493 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1495 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1494 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1496 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1495 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1497 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1496 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1498 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1497 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1499 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1498 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1500 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1499 i18n("<p><h3>In list view:</h3></p>\n") + 1501 i18n("<p><h3>In list view:</h3></p>\n") +
1500 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1502 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1501 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1503 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1502 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1504 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1503 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1505 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1504 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1506 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1505 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1507 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1506 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1508 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1507 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1509 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1508 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1510 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1509 i18n("<p><b>E</b>: Edit item</p>\n") + 1511 i18n("<p><b>E</b>: Edit item</p>\n") +
1510 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1512 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1511 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1513 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1512 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1514 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1513 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1515 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1514 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1516 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1515 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1517 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1516 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1518 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1517 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1519 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1518 i18n("<p><b>White</b>: Item readonly</p>\n"); 1520 i18n("<p><b>White</b>: Item readonly</p>\n");
1519 displayText( text, cap); 1521 displayText( text, cap);
1520} 1522}
1521void MainWindow::aboutAutoSaving() 1523void MainWindow::aboutAutoSaving()
1522{ 1524{
1523 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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"); 1525 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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");
1524 1526
1525 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1527 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1526 1528
1527} 1529}
1528void MainWindow::aboutKnownBugs() 1530void MainWindow::aboutKnownBugs()
1529{ 1531{
1530 QMessageBox* msg; 1532 QMessageBox* msg;
1531 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1533 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1532 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")+ 1534 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")+
1533 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1535 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1534 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1536 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1535 i18n("\nor report them in the bugtracker on\n") + 1537 i18n("\nor report them in the bugtracker on\n") +
1536 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1538 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1537 QMessageBox::NoIcon, 1539 QMessageBox::NoIcon,
1538 QMessageBox::Ok, 1540 QMessageBox::Ok,
1539 QMessageBox::NoButton, 1541 QMessageBox::NoButton,
1540 QMessageBox::NoButton); 1542 QMessageBox::NoButton);
1541 msg->exec(); 1543 msg->exec();
1542 delete msg; 1544 delete msg;
1543 1545
1544} 1546}
1545 1547
1546QString MainWindow::defaultFileName() 1548QString MainWindow::defaultFileName()
1547{ 1549{
1548 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1550 return locateLocal( "data", "korganizer/mycalendar.ics" );
1549} 1551}
1550QString MainWindow::syncFileName() 1552QString MainWindow::syncFileName()
1551{ 1553{
1552#ifdef DESKTOP_VERSION 1554#ifdef DESKTOP_VERSION
1553 return locateLocal( "tmp", "synccalendar.ics" ); 1555 return locateLocal( "tmp", "synccalendar.ics" );
1554#else 1556#else
1555 return QString( "/tmp/synccalendar.ics" ); 1557 return QString( "/tmp/synccalendar.ics" );
1556#endif 1558#endif
1557} 1559}
1558#include "koglobals.h" 1560#include "koglobals.h"
1559#include <kcalendarsystem.h> 1561#include <kcalendarsystem.h>
1560void MainWindow::updateWeek(QDate seda) 1562void MainWindow::updateWeek(QDate seda)
1561{ 1563{
1562 int weekNum = KGlobal::locale()->weekNum ( seda ); 1564 int weekNum = KGlobal::locale()->weekNum ( seda );
1563 mWeekPixmap.fill( mWeekBgColor ); 1565 mWeekPixmap.fill( mWeekBgColor );
1564 QPainter p ( &mWeekPixmap ); 1566 QPainter p ( &mWeekPixmap );
1565 p.setFont( mWeekFont ); 1567 p.setFont( mWeekFont );
1566 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1568 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1567 p.end(); 1569 p.end();
1568 QIconSet icon3 ( mWeekPixmap ); 1570 QIconSet icon3 ( mWeekPixmap );
1569 mWeekAction->setIconSet ( icon3 ); 1571 mWeekAction->setIconSet ( icon3 );
1570 1572
1571} 1573}
1572void MainWindow::updateWeekNum(const DateList &selectedDates) 1574void MainWindow::updateWeekNum(const DateList &selectedDates)
1573{ 1575{
1574 updateWeek( selectedDates.first() ); 1576 updateWeek( selectedDates.first() );
1575} 1577}
1576void MainWindow::processIncidenceSelection( Incidence *incidence ) 1578void MainWindow::processIncidenceSelection( Incidence *incidence )
1577{ 1579{
1578 1580
1579 if ( !incidence ) { 1581 if ( !incidence ) {
1580 enableIncidenceActions( false ); 1582 enableIncidenceActions( false );
1581 1583
1582 mNewSubTodoAction->setEnabled( false ); 1584 mNewSubTodoAction->setEnabled( false );
1583 setCaptionToDates(); 1585 setCaptionToDates();
1584 return; 1586 return;
1585 1587
1586 } 1588 }
1587 1589
1588 //KGlobal::locale()->formatDateTime(nextA, true); 1590 //KGlobal::locale()->formatDateTime(nextA, true);
1589 QString startString = ""; 1591 QString startString = "";
1590 if ( incidence->type() != "Todo" ) { 1592 if ( incidence->type() != "Todo" ) {
1591 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1593 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1592 if ( incidence->doesFloat() ) { 1594 if ( incidence->doesFloat() ) {
1593 startString += ": "+incidence->dtStartDateStr( true ); 1595 startString += ": "+incidence->dtStartDateStr( true );
1594 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1596 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1595 1597
1596 } else { 1598 } else {
1597 startString = ": "+incidence->dtStartStr(true); 1599 startString = ": "+incidence->dtStartStr(true);
1598 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1600 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1599 1601
1600 } 1602 }
1601 1603
1602 } else { 1604 } else {
1603 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1605 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1604 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1606 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1605 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1607 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1606 1608
1607 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1609 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1608 bool ok; 1610 bool ok;
1609 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1611 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1610 if ( ok ) { 1612 if ( ok ) {
1611 int years = noc.date().year() - incidence->dtStart().date().year(); 1613 int years = noc.date().year() - incidence->dtStart().date().year();
1612 startString += i18n(" (%1 y.)"). arg( years ); 1614 startString += i18n(" (%1 y.)"). arg( years );
1613 } 1615 }
1614 } 1616 }
1615 else 1617 else
1616 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1618 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1617 } 1619 }
1618 1620
1619 } 1621 }
1620 else 1622 else
1621 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1623 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1622 if ( !incidence->location().isEmpty() ) 1624 if ( !incidence->location().isEmpty() )
1623 startString += " (" +incidence->location()+")"; 1625 startString += " (" +incidence->location()+")";
1624 setCaption( incidence->summary()+startString); 1626 setCaption( incidence->summary()+startString);
1625 1627
1626 enableIncidenceActions( true ); 1628 enableIncidenceActions( true );
1627 1629
1628 if ( incidence->type() == "Event" ) { 1630 if ( incidence->type() == "Event" ) {
1629 mShowAction->setText( i18n("Show Event...") ); 1631 mShowAction->setText( i18n("Show Event...") );
1630 mEditAction->setText( i18n("Edit Event...") ); 1632 mEditAction->setText( i18n("Edit Event...") );
1631 mDeleteAction->setText( i18n("Delete Event...") ); 1633 mDeleteAction->setText( i18n("Delete Event...") );
1632 1634
1633 mNewSubTodoAction->setEnabled( false ); 1635 mNewSubTodoAction->setEnabled( false );
1634 } else if ( incidence->type() == "Todo" ) { 1636 } else if ( incidence->type() == "Todo" ) {
1635 mShowAction->setText( i18n("Show Todo...") ); 1637 mShowAction->setText( i18n("Show Todo...") );
1636 mEditAction->setText( i18n("Edit Todo...") ); 1638 mEditAction->setText( i18n("Edit Todo...") );
1637 mDeleteAction->setText( i18n("Delete Todo...") ); 1639 mDeleteAction->setText( i18n("Delete Todo...") );
1638 1640
1639 mNewSubTodoAction->setEnabled( true ); 1641 mNewSubTodoAction->setEnabled( true );
1640 } else { 1642 } else {
1641 mShowAction->setText( i18n("Show...") ); 1643 mShowAction->setText( i18n("Show...") );
1642 mShowAction->setText( i18n("Edit...") ); 1644 mShowAction->setText( i18n("Edit...") );
1643 mShowAction->setText( i18n("Delete...") ); 1645 mShowAction->setText( i18n("Delete...") );
1644 1646
1645 mNewSubTodoAction->setEnabled( false ); 1647 mNewSubTodoAction->setEnabled( false );
1646 } 1648 }
1647} 1649}
1648 1650
1649void MainWindow::enableIncidenceActions( bool enabled ) 1651void MainWindow::enableIncidenceActions( bool enabled )
1650{ 1652{
1651 mShowAction->setEnabled( enabled ); 1653 mShowAction->setEnabled( enabled );
1652 mEditAction->setEnabled( enabled ); 1654 mEditAction->setEnabled( enabled );
1653 mDeleteAction->setEnabled( enabled ); 1655 mDeleteAction->setEnabled( enabled );
1654 1656
1655 mCloneAction->setEnabled( enabled ); 1657 mCloneAction->setEnabled( enabled );
1656 mMoveAction->setEnabled( enabled ); 1658 mMoveAction->setEnabled( enabled );
1657 mBeamAction->setEnabled( enabled ); 1659 mBeamAction->setEnabled( enabled );
1658 mCancelAction->setEnabled( enabled ); 1660 mCancelAction->setEnabled( enabled );
1659} 1661}
1660 1662
1661void MainWindow::importOL() 1663void MainWindow::importOL()
1662{ 1664{
1663#ifdef _OL_IMPORT_ 1665#ifdef _OL_IMPORT_
1664 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1666 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1665 id->exec(); 1667 id->exec();
1666 delete id; 1668 delete id;
1667 mView->updateView(); 1669 mView->updateView();
1668#endif 1670#endif
1669} 1671}
1670void MainWindow::importBday() 1672void MainWindow::importBday()
1671{ 1673{
1672 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1673 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1675 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1674 i18n("Import!"), i18n("Cancel"), 0, 1676 i18n("Import!"), i18n("Cancel"), 0,
1675 0, 1 ); 1677 0, 1 );
1676 if ( result == 0 ) { 1678 if ( result == 0 ) {
1677 mView->importBday(); 1679 mView->importBday();
1678 1680
1679 } 1681 }
1680 1682
1681 1683
1682} 1684}
1683void MainWindow::importQtopia() 1685void MainWindow::importQtopia()
1684{ 1686{
1685 //#ifndef DESKTOP_VERSION 1687 //#ifndef DESKTOP_VERSION
1686 QString mess = 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"); 1688 QString mess = 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");
1687#ifdef DESKTOP_VERSION 1689#ifdef DESKTOP_VERSION
1688 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1690 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1689#endif 1691#endif
1690 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1692 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1691 i18n("Import!"), i18n("Cancel"), 0, 1693 i18n("Import!"), i18n("Cancel"), 0,
1692 0, 1 ); 1694 0, 1 );
1693 if ( result == 0 ) { 1695 if ( result == 0 ) {
1694#ifndef DESKTOP_VERSION 1696#ifndef DESKTOP_VERSION
1695 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1697 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1696 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1698 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1697 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1699 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1698#else 1700#else
1699 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1701 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1700 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1702 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1701 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1703 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1702#endif 1704#endif
1703 mView->importQtopia( categories, datebook, todolist ); 1705 mView->importQtopia( categories, datebook, todolist );
1704 } 1706 }
1705#if 0 1707#if 0
1706 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1708 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1707 i18n("Not supported \non desktop!\n"), 1709 i18n("Not supported \non desktop!\n"),
1708 i18n("Ok"), i18n("Cancel"), 0, 1710 i18n("Ok"), i18n("Cancel"), 0,
1709 0, 1 ); 1711 0, 1 );
1710 1712
1711#endif 1713#endif
1712} 1714}
1713 1715
1714void MainWindow::saveOnClose() 1716void MainWindow::saveOnClose()
1715{ 1717{
1716 KOPrefs *p = KOPrefs::instance(); 1718 KOPrefs *p = KOPrefs::instance();
1717 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1719 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1718 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1720 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1719 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1721 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1720 if ( filterToolBar ) { 1722 if ( filterToolBar ) {
1721 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1723 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1722 } 1724 }
1723#ifdef DESKTOP_VERSION 1725#ifdef DESKTOP_VERSION
1724 1726
1725 QPoint myP; 1727 QPoint myP;
1726 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1728 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1727 if ( p->mToolBarHor ) 1729 if ( p->mToolBarHor )
1728 p->mToolBarUp = myP.y() > height()/2; 1730 p->mToolBarUp = myP.y() > height()/2;
1729 else 1731 else
1730 p->mToolBarUp = myP.x() > width()/2; 1732 p->mToolBarUp = myP.x() > width()/2;
1731 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1733 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1732 if ( p->mToolBarHorV ) 1734 if ( p->mToolBarHorV )
1733 p->mToolBarUpV = myP.y() > height()/2; 1735 p->mToolBarUpV = myP.y() > height()/2;
1734 else 1736 else
1735 p->mToolBarUpV = myP.x() > width()/2 ; 1737 p->mToolBarUpV = myP.x() > width()/2 ;
1736 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1738 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1737 if ( p->mToolBarHorN ) 1739 if ( p->mToolBarHorN )
1738 p->mToolBarUpN = myP.y() > height()/2; 1740 p->mToolBarUpN = myP.y() > height()/2;
1739 else 1741 else
1740 p->mToolBarUpN = myP.x() > width()/2 ; 1742 p->mToolBarUpN = myP.x() > width()/2 ;
1741 if ( filterToolBar ) { 1743 if ( filterToolBar ) {
1742 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1744 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1743 if ( p->mToolBarHorF ) 1745 if ( p->mToolBarHorF )
1744 p->mToolBarUpF = myP.y() > height()/2; 1746 p->mToolBarUpF = myP.y() > height()/2;
1745 else 1747 else
1746 p->mToolBarUpF = myP.x() > width()/2 ; 1748 p->mToolBarUpF = myP.x() > width()/2 ;
1747 } 1749 }
1748#else 1750#else
1749 if ( p->mToolBarHor ) 1751 if ( p->mToolBarHor )
1750 p->mToolBarUp = iconToolBar->y() > height()/2; 1752 p->mToolBarUp = iconToolBar->y() > height()/2;
1751 else 1753 else
1752 p->mToolBarUp = iconToolBar->x() > width()/2; 1754 p->mToolBarUp = iconToolBar->x() > width()/2;
1753 if ( p->mToolBarHorV ) 1755 if ( p->mToolBarHorV )
1754 p->mToolBarUpV = viewToolBar->y() > height()/2; 1756 p->mToolBarUpV = viewToolBar->y() > height()/2;
1755 else 1757 else
1756 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1758 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1757 1759
1758 if ( p->mToolBarHorN ) 1760 if ( p->mToolBarHorN )
1759 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1761 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1760 else 1762 else
1761 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1763 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1762 if ( filterToolBar ) { 1764 if ( filterToolBar ) {
1763 if ( p->mToolBarHorF ) 1765 if ( p->mToolBarHorF )
1764 p->mToolBarUpF = filterToolBar->y() > height()/2; 1766 p->mToolBarUpF = filterToolBar->y() > height()/2;
1765 else 1767 else
1766 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1768 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1767 } 1769 }
1768#endif 1770#endif
1769 1771
1770 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1772 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1771 save(); 1773 save();
1772 mView->writeSettings(); 1774 mView->writeSettings();
1773} 1775}
1774void MainWindow::slotModifiedChanged( bool changed ) 1776void MainWindow::slotModifiedChanged( bool changed )
1775{ 1777{
1776 if ( mBlockAtStartup ) 1778 if ( mBlockAtStartup )
1777 return; 1779 return;
1778 1780
1779 int msec; 1781 int msec;
1780 // we store the changes after 1 minute, 1782 // we store the changes after 1 minute,
1781 // and for safety reasons after 10 minutes again 1783 // and for safety reasons after 10 minutes again
1782 if ( !mSyncManager->blockSave() ) 1784 if ( !mSyncManager->blockSave() )
1783 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1785 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1784 else 1786 else
1785 msec = 1000 * 600; 1787 msec = 1000 * 600;
1786 mSaveTimer.start( msec, true ); // 1 minute 1788 mSaveTimer.start( msec, true ); // 1 minute
1787 qDebug("KO: Saving File in %d secs!", msec/1000); 1789 qDebug("KO: Saving File in %d secs!", msec/1000);
1788 mCalendarModifiedFlag = true; 1790 mCalendarModifiedFlag = true;
1789} 1791}
1790void MainWindow::saveStopTimer() 1792void MainWindow::saveStopTimer()
1791{ 1793{
1792 mSaveTimer.stop(); 1794 mSaveTimer.stop();
1793} 1795}
1794void MainWindow::save() 1796void MainWindow::save()
1795{ 1797{
1796 if ( !mCalendarModifiedFlag ) { 1798 if ( !mCalendarModifiedFlag ) {
1797 qDebug("KO: Calendar not modified. Nothing saved."); 1799 qDebug("KO: Calendar not modified. Nothing saved.");
1798 return; 1800 return;
1799 } 1801 }
1800 if ( mSyncManager->blockSave() ) 1802 if ( mSyncManager->blockSave() )
1801 return; 1803 return;
1802 mSyncManager->setBlockSave(true); 1804 mSyncManager->setBlockSave(true);
1803 if ( mView->checkFileVersion( defaultFileName()) ) { 1805 if ( mView->checkFileVersion( defaultFileName()) ) {
1804 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1806 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1805 QDate reference ( 2000,1,1); 1807 QDate reference ( 2000,1,1);
1806 int daysTo = reference.daysTo ( QDate::currentDate() ); 1808 int daysTo = reference.daysTo ( QDate::currentDate() );
1807 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1809 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1808 setCaption(i18n("KO/Pi:Creating backup ... please wait ..." )); 1810 setCaption(i18n("KO/Pi:Creating backup ... please wait ..." ));
1809 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1811 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1810 // we need the file path, the backup dir and the number of bups as param 1812 // we need the file path, the backup dir and the number of bups as param
1811 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1813 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1812 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1814 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1813 bupDir = KGlobalSettings::backupDataDir(); 1815 bupDir = KGlobalSettings::backupDataDir();
1814 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1816 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1815 if ( retval == 0 ) { 1817 if ( retval == 0 ) {
1816 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1818 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1817 // retval == 0 : backup skipped for today, try again tomorrow 1819 // retval == 0 : backup skipped for today, try again tomorrow
1818 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1820 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1819 } else if ( retval == 1 ){ 1821 } else if ( retval == 1 ){
1820 qDebug("KO: Backup created."); 1822 qDebug("KO: Backup created.");
1821 // backup ok 1823 // backup ok
1822 KOPrefs::instance()->mLastBackupDate = daysTo; 1824 KOPrefs::instance()->mLastBackupDate = daysTo;
1823 1825
1824 } else if ( retval == 2 ){ 1826 } else if ( retval == 2 ){
1825 qDebug("KO: Backup globally cancelled."); 1827 qDebug("KO: Backup globally cancelled.");
1826 // backup globally cancelled 1828 // backup globally cancelled
1827 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1829 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1828 } 1830 }
1829 // retval == 3: do nothing, try again later 1831 // retval == 3: do nothing, try again later
1830 } 1832 }
1831 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1833 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1832 } 1834 }
1833 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1835 QTime neededSaveTime = QDateTime::currentDateTime().time();
1834 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1836 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1835 qDebug("KO: Start saving data to file!"); 1837 qDebug("KO: Start saving data to file!");
1836 mView->saveCalendar( defaultFileName() ); 1838 mView->saveCalendar( defaultFileName() );
1837 mCalendarModifiedFlag = false; 1839 mCalendarModifiedFlag = false;
1838 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1840 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1839 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1841 qDebug("KO: Needed %d ms for saving.",msNeeded );
1840 QString savemes; 1842 QString savemes;
1841 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1843 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1842 setCaption(savemes); 1844 setCaption(savemes);
1843 } else 1845 } else
1844 setCaption(i18n("Saving cancelled!")); 1846 setCaption(i18n("Saving cancelled!"));
1845 mSyncManager->setBlockSave( false ); 1847 mSyncManager->setBlockSave( false );
1846} 1848}
1847 1849
1848void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1850void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1849{ 1851{
1850 if ( !e->isAutoRepeat() ) { 1852 if ( !e->isAutoRepeat() ) {
1851 mFlagKeyPressed = false; 1853 mFlagKeyPressed = false;
1852 } 1854 }
1853} 1855}
1854void MainWindow::keyPressEvent ( QKeyEvent * e ) 1856void MainWindow::keyPressEvent ( QKeyEvent * e )
1855{ 1857{
1856 qApp->processEvents(); 1858 qApp->processEvents();
1857 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1859 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1858 e->ignore(); 1860 e->ignore();
1859 // qDebug(" ignore %d",e->isAutoRepeat() ); 1861 // qDebug(" ignore %d",e->isAutoRepeat() );
1860 return; 1862 return;
1861 } 1863 }
1862 if (! e->isAutoRepeat() ) 1864 if (! e->isAutoRepeat() )
1863 mFlagKeyPressed = true; 1865 mFlagKeyPressed = true;
1864 KOPrefs *p = KOPrefs::instance(); 1866 KOPrefs *p = KOPrefs::instance();
1865 bool showSelectedDates = false; 1867 bool showSelectedDates = false;
1866 int size; 1868 int size;
1867 int pro = 0; 1869 int pro = 0;
1868 //qDebug("MainWindow::keyPressEvent "); 1870 //qDebug("MainWindow::keyPressEvent ");
1869 switch ( e->key() ) { 1871 switch ( e->key() ) {
1870 case Qt::Key_Right: 1872 case Qt::Key_Right:
1871 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1873 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1872 mView->goNextMonth(); 1874 mView->goNextMonth();
1873 else 1875 else
1874 mView->goNext(); 1876 mView->goNext();
1875 showSelectedDates = true; 1877 showSelectedDates = true;
1876 break; 1878 break;
1877 case Qt::Key_Left: 1879 case Qt::Key_Left:
1878 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1880 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1879 mView->goPreviousMonth(); 1881 mView->goPreviousMonth();
1880 else 1882 else
1881 mView->goPrevious(); 1883 mView->goPrevious();
1882 showSelectedDates = true; 1884 showSelectedDates = true;
1883 break; 1885 break;
1884 case Qt::Key_Down: 1886 case Qt::Key_Down:
1885 mView->viewManager()->agendaView()->scrollOneHourDown(); 1887 mView->viewManager()->agendaView()->scrollOneHourDown();
1886 break; 1888 break;
1887 case Qt::Key_Up: 1889 case Qt::Key_Up:
1888 mView->viewManager()->agendaView()->scrollOneHourUp(); 1890 mView->viewManager()->agendaView()->scrollOneHourUp();
1889 break; 1891 break;
1890 case Qt::Key_K: 1892 case Qt::Key_K:
1891 mView->viewManager()->showMonthViewWeek(); 1893 mView->viewManager()->showMonthViewWeek();
1892 break; 1894 break;
1893 case Qt::Key_I: 1895 case Qt::Key_I:
1894 mView->showIncidence(); 1896 mView->showIncidence();
1895 break; 1897 break;
1896 case Qt::Key_Delete: 1898 case Qt::Key_Delete:
1897 case Qt::Key_Backspace: 1899 case Qt::Key_Backspace:
1898 mView->deleteIncidence(); 1900 mView->deleteIncidence();
1899 break; 1901 break;
1900 case Qt::Key_D: 1902 case Qt::Key_D:
1901 mView->viewManager()->showDayView(); 1903 mView->viewManager()->showDayView();
1902 showSelectedDates = true; 1904 showSelectedDates = true;
1903 break; 1905 break;
1904 case Qt::Key_O: 1906 case Qt::Key_O:
1905 mView->toggleFilerEnabled( ); 1907 mView->toggleFilerEnabled( );
1906 break; 1908 break;
1907 case Qt::Key_0: 1909 case Qt::Key_0:
1908 case Qt::Key_1: 1910 case Qt::Key_1:
1909 case Qt::Key_2: 1911 case Qt::Key_2:
1910 case Qt::Key_3: 1912 case Qt::Key_3:
1911 case Qt::Key_4: 1913 case Qt::Key_4:
1912 case Qt::Key_5: 1914 case Qt::Key_5:
1913 case Qt::Key_6: 1915 case Qt::Key_6:
1914 case Qt::Key_7: 1916 case Qt::Key_7:
1915 case Qt::Key_8: 1917 case Qt::Key_8:
1916 case Qt::Key_9: 1918 case Qt::Key_9:
1917 pro = e->key()-48; 1919 pro = e->key()-48;
1918 if ( pro == 0 ) 1920 if ( pro == 0 )
1919 pro = 10; 1921 pro = 10;
1920 if ( e->state() == Qt::ControlButton) 1922 if ( e->state() == Qt::ControlButton)
1921 pro += 10; 1923 pro += 10;
1922 break; 1924 break;
1923 case Qt::Key_M: 1925 case Qt::Key_M:
1924 mView->viewManager()->showMonthView(); 1926 mView->viewManager()->showMonthView();
1925 showSelectedDates = true; 1927 showSelectedDates = true;
1926 break; 1928 break;
1927 case Qt::Key_Insert: 1929 case Qt::Key_Insert:
1928 mView->newEvent(); 1930 mView->newEvent();
1929 break; 1931 break;
1930 case Qt::Key_S : 1932 case Qt::Key_S :
1931 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1933 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1932 mView->newSubTodo(); 1934 mView->newSubTodo();
1933 else 1935 else
1934 mView->dialogManager()->showSearchDialog(); 1936 mView->dialogManager()->showSearchDialog();
1935 break; 1937 break;
1936 case Qt::Key_Y : 1938 case Qt::Key_Y :
1937 case Qt::Key_Z : 1939 case Qt::Key_Z :
1938 mView->viewManager()->showWorkWeekView(); 1940 mView->viewManager()->showWorkWeekView();
1939 showSelectedDates = true; 1941 showSelectedDates = true;
1940 break; 1942 break;
1941 case Qt::Key_U : 1943 case Qt::Key_U :
1942 mView->viewManager()->showWeekView(); 1944 mView->viewManager()->showWeekView();
1943 showSelectedDates = true; 1945 showSelectedDates = true;
1944 break; 1946 break;
1945 case Qt::Key_H : 1947 case Qt::Key_H :
1946 keyBindings(); 1948 keyBindings();
1947 break; 1949 break;
1948 case Qt::Key_W: 1950 case Qt::Key_W:
1949 mView->viewManager()->showWhatsNextView(); 1951 mView->viewManager()->showWhatsNextView();
1950 break; 1952 break;
1951 case Qt::Key_L: 1953 case Qt::Key_L:
1952 mView->viewManager()->showListView(); 1954 mView->viewManager()->showListView();
1953 break; 1955 break;
1954 case Qt::Key_N: 1956 case Qt::Key_N:
1955 mView->viewManager()->showNextView(); 1957 mView->viewManager()->showNextView();
1956 break; 1958 break;
1957 case Qt::Key_V: 1959 case Qt::Key_V:
1958 mView->viewManager()->showTodoView(); 1960 mView->viewManager()->showTodoView();
1959 break; 1961 break;
1960 case Qt::Key_C: 1962 case Qt::Key_C:
1961 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1963 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1962 break; 1964 break;
1963 case Qt::Key_P: 1965 case Qt::Key_P:
1964 mView->showDatePicker( ); 1966 mView->showDatePicker( );
1965 break; 1967 break;
1966 case Qt::Key_F: 1968 case Qt::Key_F:
1967 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1969 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1968 mView->editFilters(); 1970 mView->editFilters();
1969 else 1971 else
1970 mView->toggleFilter(); 1972 mView->toggleFilter();
1971 break; 1973 break;
1972 case Qt::Key_X: 1974 case Qt::Key_X:
1973 if ( e->state() == Qt::ControlButton ) 1975 if ( e->state() == Qt::ControlButton )
1974 mView->toggleDateNavigatorWidget(); 1976 mView->toggleDateNavigatorWidget();
1975 else { 1977 else {
1976 mView->viewManager()->showNextXView(); 1978 mView->viewManager()->showNextXView();
1977 showSelectedDates = true; 1979 showSelectedDates = true;
1978 } 1980 }
1979 break; 1981 break;
1980 case Qt::Key_Space: 1982 case Qt::Key_Space:
1981 mView->toggleExpand(); 1983 mView->toggleExpand();
1982 break; 1984 break;
1983 case Qt::Key_A: 1985 case Qt::Key_A:
1984 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1986 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1985 mView->showNextAlarms(); 1987 mView->showNextAlarms();
1986 else 1988 else
1987 mView->toggleAllDaySize(); 1989 mView->toggleAllDaySize();
1988 break; 1990 break;
1989 case Qt::Key_T: 1991 case Qt::Key_T:
1990 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1992 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1991 mView->newTodo(); 1993 mView->newTodo();
1992 else { 1994 else {
1993 mView->goToday(); 1995 mView->goToday();
1994 showSelectedDates = true; 1996 showSelectedDates = true;
1995 } 1997 }
1996 break; 1998 break;
1997 case Qt::Key_J: 1999 case Qt::Key_J:
1998 mView->viewManager()->showJournalView(); 2000 mView->viewManager()->showJournalView();
1999 break; 2001 break;
2000 case Qt::Key_B: 2002 case Qt::Key_B:
2001 mView->editIncidenceDescription();; 2003 mView->editIncidenceDescription();;
2002 break; 2004 break;
2003 // case Qt::Key_Return: 2005 // case Qt::Key_Return:
2004 case Qt::Key_E: 2006 case Qt::Key_E:
2005 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2007 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2006 mView->newEvent(); 2008 mView->newEvent();
2007 else 2009 else
2008 mView->editIncidence(); 2010 mView->editIncidence();
2009 break; 2011 break;
2010 case Qt::Key_Plus: 2012 case Qt::Key_Plus:
2011 size = p->mHourSize +2; 2013 size = p->mHourSize +2;
2012 if ( size <= 22 ) 2014 if ( size <= 22 )
2013 configureAgenda( size ); 2015 configureAgenda( size );
2014 break; 2016 break;
2015 case Qt::Key_Minus: 2017 case Qt::Key_Minus:
2016 size = p->mHourSize - 2; 2018 size = p->mHourSize - 2;
2017 if ( size >= 4 ) 2019 if ( size >= 4 )
2018 configureAgenda( size ); 2020 configureAgenda( size );
2019 break; 2021 break;
2020 2022
2021 2023
2022 default: 2024 default:
2023 e->ignore(); 2025 e->ignore();
2024 } 2026 }
2025 if ( pro > 0 ) { 2027 if ( pro > 0 ) {
2026 mView->selectFilter( pro-1 ); 2028 mView->selectFilter( pro-1 );
2027 } 2029 }
2028 if ( showSelectedDates ) { 2030 if ( showSelectedDates ) {
2029 ;// setCaptionToDates(); 2031 ;// setCaptionToDates();
2030 } 2032 }
2031 2033
2032} 2034}
2033void MainWindow::fillFilterMenuTB() 2035void MainWindow::fillFilterMenuTB()
2034{ 2036{
2035 selectFilterMenuTB->clear(); 2037 selectFilterMenuTB->clear();
2036 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2038 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2037 selectFilterMenuTB->insertSeparator(); 2039 selectFilterMenuTB->insertSeparator();
2038 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2040 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2039 2041
2040 selectFilterMenuTB->insertSeparator(); 2042 selectFilterMenuTB->insertSeparator();
2041 QPtrList<CalFilter> fili = mView->filters(); 2043 QPtrList<CalFilter> fili = mView->filters();
2042 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2044 CalFilter *curfilter = mView->filterView()->selectedFilter();
2043 CalFilter *filter = fili.first(); 2045 CalFilter *filter = fili.first();
2044 int iii = 2; 2046 int iii = 2;
2045 bool checkitem = mView->filterView()->filtersEnabled(); 2047 bool checkitem = mView->filterView()->filtersEnabled();
2046 while(filter) { 2048 while(filter) {
2047 selectFilterMenuTB->insertItem( filter->name(), iii ); 2049 selectFilterMenuTB->insertItem( filter->name(), iii );
2048 if ( filter == curfilter) 2050 if ( filter == curfilter)
2049 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2051 selectFilterMenuTB->setItemChecked( iii, checkitem );
2050 filter = fili.next(); 2052 filter = fili.next();
2051 ++iii; 2053 ++iii;
2052 } 2054 }
2053 if ( !checkitem ) 2055 if ( !checkitem )
2054 selectFilterMenuTB->setItemChecked( 1, true ); 2056 selectFilterMenuTB->setItemChecked( 1, true );
2055 2057
2056 int x = 0; 2058 int x = 0;
2057 int y = iconToolBar->height(); 2059 int y = iconToolBar->height();
2058 int dX = 0; 2060 int dX = 0;
2059 int dY = 0; 2061 int dY = 0;
2060 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2062 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2061 if ( iconToolBar->y() > height()/2 ) { 2063 if ( iconToolBar->y() > height()/2 ) {
2062 dY = selectFilterMenuTB->sizeHint().height()+8; 2064 dY = selectFilterMenuTB->sizeHint().height()+8;
2063 y = 0; 2065 y = 0;
2064 } 2066 }
2065 } else { 2067 } else {
2066 if ( iconToolBar->x() > width()/2 ) { // right side 2068 if ( iconToolBar->x() > width()/2 ) { // right side
2067 x=0; 2069 x=0;
2068 dX= selectFilterMenuTB->sizeHint().width()+8; 2070 dX= selectFilterMenuTB->sizeHint().width()+8;
2069 y = 0; 2071 y = 0;
2070 } else { 2072 } else {
2071 x= iconToolBar->width(); 2073 x= iconToolBar->width();
2072 y = 0; 2074 y = 0;
2073 } 2075 }
2074 } 2076 }
2075 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2077 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2076 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2078 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2077} 2079}
2078void MainWindow::fillFilterMenu() 2080void MainWindow::fillFilterMenu()
2079{ 2081{
2080 selectFilterMenu->clear(); 2082 selectFilterMenu->clear();
2081 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2083 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2082 selectFilterMenu->insertSeparator(); 2084 selectFilterMenu->insertSeparator();
2083 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2085 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2084 2086
2085 selectFilterMenu->insertSeparator(); 2087 selectFilterMenu->insertSeparator();
2086 QPtrList<CalFilter> fili = mView->filters(); 2088 QPtrList<CalFilter> fili = mView->filters();
2087 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2089 CalFilter *curfilter = mView->filterView()->selectedFilter();
2088 CalFilter *filter = fili.first(); 2090 CalFilter *filter = fili.first();
2089 int iii = 2; 2091 int iii = 2;
2090 bool checkitem = mView->filterView()->filtersEnabled(); 2092 bool checkitem = mView->filterView()->filtersEnabled();
2091 while(filter) { 2093 while(filter) {
2092 selectFilterMenu->insertItem( filter->name(), iii ); 2094 selectFilterMenu->insertItem( filter->name(), iii );
2093 if ( filter == curfilter) 2095 if ( filter == curfilter)
2094 selectFilterMenu->setItemChecked( iii, checkitem ); 2096 selectFilterMenu->setItemChecked( iii, checkitem );
2095 filter = fili.next(); 2097 filter = fili.next();
2096 ++iii; 2098 ++iii;
2097 } 2099 }
2098 if ( !checkitem ) 2100 if ( !checkitem )
2099 selectFilterMenu->setItemChecked( 1, true ); 2101 selectFilterMenu->setItemChecked( 1, true );
2100} 2102}
2101void MainWindow::fillFilterMenuPopup() 2103void MainWindow::fillFilterMenuPopup()
2102{ 2104{
2103 filterPopupMenu->clear(); 2105 filterPopupMenu->clear();
2104 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2106 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2105 2107
2106 filterPopupMenu->insertSeparator(); 2108 filterPopupMenu->insertSeparator();
2107 QPtrList<CalFilter> fili = mView->filters(); 2109 QPtrList<CalFilter> fili = mView->filters();
2108 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2110 CalFilter *curfilter = mView->filterView()->selectedFilter();
2109 CalFilter *filter = fili.first(); 2111 CalFilter *filter = fili.first();
2110 int iii = 1; 2112 int iii = 1;
2111 bool checkitem = mView->filterView()->filtersEnabled(); 2113 bool checkitem = mView->filterView()->filtersEnabled();
2112 while(filter) { 2114 while(filter) {
2113 filterPopupMenu->insertItem( filter->name(), iii ); 2115 filterPopupMenu->insertItem( filter->name(), iii );
2114 if ( filter == curfilter) 2116 if ( filter == curfilter)
2115 filterPopupMenu->setItemChecked( iii, checkitem ); 2117 filterPopupMenu->setItemChecked( iii, checkitem );
2116 filter = fili.next(); 2118 filter = fili.next();
2117 ++iii; 2119 ++iii;
2118 } 2120 }
2119 if ( !checkitem ) 2121 if ( !checkitem )
2120 filterPopupMenu->setItemChecked( 0, true ); 2122 filterPopupMenu->setItemChecked( 0, true );
2121} 2123}
2122void MainWindow::selectFilter( int fil ) 2124void MainWindow::selectFilter( int fil )
2123{ 2125{
2124 2126
2125 if ( fil == 0 ) { 2127 if ( fil == 0 ) {
2126 mView->editFilters( ); 2128 mView->editFilters( );
2127 } else if ( fil == 1 ){ 2129 } else if ( fil == 1 ){
2128 if ( mView->filterView()->filtersEnabled() ) 2130 if ( mView->filterView()->filtersEnabled() )
2129 mView->toggleFilerEnabled( ); 2131 mView->toggleFilerEnabled( );
2130 } else { 2132 } else {
2131 if ( !mView->filterView()->filtersEnabled() ) { 2133 if ( !mView->filterView()->filtersEnabled() ) {
2132 mView->filterView()->blockSignals( true ); 2134 mView->filterView()->blockSignals( true );
2133 mView->toggleFilerEnabled( ); 2135 mView->toggleFilerEnabled( );
2134 mView->filterView()->blockSignals( false ); 2136 mView->filterView()->blockSignals( false );
2135 } 2137 }
2136 mView->selectFilter( fil-2 ); 2138 mView->selectFilter( fil-2 );
2137 } 2139 }
2138} 2140}
2139void MainWindow::updateFilterToolbar() 2141void MainWindow::updateFilterToolbar()
2140{ 2142{
2141 if ( filterMenubar ) { 2143 if ( filterMenubar ) {
2142 if ( !mView->filterView()->filtersEnabled() ) { 2144 if ( !mView->filterView()->filtersEnabled() ) {
2143 filterMenubar->changeItem( 0, i18n("No Filter") ); 2145 filterMenubar->changeItem( 0, i18n("No Filter") );
2144 } else { 2146 } else {
2145 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2147 CalFilter *curfilter = mView->filterView()->selectedFilter();
2146 if ( curfilter ) { 2148 if ( curfilter ) {
2147 filterMenubar->changeItem( 0, curfilter->name() ); 2149 filterMenubar->changeItem( 0, curfilter->name() );
2148 } 2150 }
2149 } 2151 }
2150 } 2152 }
2151} 2153}
2152void MainWindow::selectFilterPopup( int fil ) 2154void MainWindow::selectFilterPopup( int fil )
2153{ 2155{
2154 selectFilter( fil + 1 ); 2156 selectFilter( fil + 1 );
2155 2157
2156} 2158}
2157void MainWindow::configureToolBar( int item ) 2159void MainWindow::configureToolBar( int item )
2158{ 2160{
2159 2161
2160 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2162 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2161 KOPrefs *p = KOPrefs::instance(); 2163 KOPrefs *p = KOPrefs::instance();
2162 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2164 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2163 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2165 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2164 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2166 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2165 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2167 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2166 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2168 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2167 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2169 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2168 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2170 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2169 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2171 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2170 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2172 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2171 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2173 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2172 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2174 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2173 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2175 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2174 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2176 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2175 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2177 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2176 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2178 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2177 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2179 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2178 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2180 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2179 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2181 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2180 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2182 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2181 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2183 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2182 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2184 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2183 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2185 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2184 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2186 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2185 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2187 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2186 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2188 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2187 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2189 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2188 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2190 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2189 // initActions(); 2191 // initActions();
2190} 2192}
2191void MainWindow::setCaption ( const QString & c ) 2193void MainWindow::setCaption ( const QString & c )
2192{ 2194{
2193 QString cap = c; 2195 QString cap = c;
2194 cap.replace( QRegExp("\n"), " " ); 2196 cap.replace( QRegExp("\n"), " " );
2195 cap = cap.stripWhiteSpace(); 2197 cap = cap.stripWhiteSpace();
2196 if ( cap.isEmpty() ) 2198 if ( cap.isEmpty() )
2197 cap = "KO/Pi"; 2199 cap = "KO/Pi";
2198 QWidget::setCaption( cap ); 2200 QWidget::setCaption( cap );
2199} 2201}
2200void MainWindow::setCaptionToDates() 2202void MainWindow::setCaptionToDates()
2201{ 2203{
2202 QString selDates; 2204 QString selDates;
2203 QDate date = mView->startDate(); 2205 QDate date = mView->startDate();
2204 if ( ! date.isValid() ) { 2206 if ( ! date.isValid() ) {
2205 setCaption(""); 2207 setCaption("");
2206 return; 2208 return;
2207 } 2209 }
2208 selDates = KGlobal::locale()->formatDate( date, true); 2210 selDates = KGlobal::locale()->formatDate( date, true);
2209 if (mView->startDate() < mView->endDate() ) 2211 if (mView->startDate() < mView->endDate() )
2210 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2212 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2211 else { 2213 else {
2212 QString addString; 2214 QString addString;
2213 if ( date == QDateTime::currentDateTime().date() ) 2215 if ( date == QDateTime::currentDateTime().date() )
2214 addString = i18n("Today"); 2216 addString = i18n("Today");
2215 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2217 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2216 addString = i18n("Tomorrow"); 2218 addString = i18n("Tomorrow");
2217 if ( !addString.isEmpty() ) 2219 if ( !addString.isEmpty() )
2218 selDates = addString+", "+selDates ; 2220 selDates = addString+", "+selDates ;
2219 } 2221 }
2220 setCaption( i18n("Dates: ") + selDates ); 2222 setCaption( i18n("Dates: ") + selDates );
2221 2223
2222} 2224}
2223void MainWindow::showConfigureAgenda( ) 2225void MainWindow::showConfigureAgenda( )
2224{ 2226{
2225 int iii; 2227 int iii;
2226 for ( iii = 1;iii<= 10 ;++iii ){ 2228 for ( iii = 1;iii<= 10 ;++iii ){
2227 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2229 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2228 } 2230 }
2229 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2231 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2230} 2232}
2231void MainWindow::configureAgenda( int item ) 2233void MainWindow::configureAgenda( int item )
2232{ 2234{
2233 if ( KOPrefs::instance()->mHourSize == item ) 2235 if ( KOPrefs::instance()->mHourSize == item )
2234 return; 2236 return;
2235 KOPrefs::instance()->mHourSize=item; 2237 KOPrefs::instance()->mHourSize=item;
2236 mView->viewManager()->agendaView()->updateConfig(); 2238 mView->viewManager()->agendaView()->updateConfig();
2237} 2239}
2238 2240
2239void MainWindow::saveCalendar() 2241void MainWindow::saveCalendar()
2240{ 2242{
2241 QString fn = KOPrefs::instance()->mLastSaveFile; 2243 QString fn = KOPrefs::instance()->mLastSaveFile;
2242 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2244 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2243 2245
2244 if ( fn == "" ) 2246 if ( fn == "" )
2245 return; 2247 return;
2246 QFileInfo info; 2248 QFileInfo info;
2247 info.setFile( fn ); 2249 info.setFile( fn );
2248 QString mes; 2250 QString mes;
2249 bool createbup = true; 2251 bool createbup = true;
2250 if ( info. exists() ) { 2252 if ( info. exists() ) {
2251 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 2253 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2252 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2254 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2253 i18n("Overwrite!"), i18n("Cancel"), 0, 2255 i18n("Overwrite!"), i18n("Cancel"), 0,
2254 0, 1 ); 2256 0, 1 );
2255 if ( result != 0 ) { 2257 if ( result != 0 ) {
2256 createbup = false; 2258 createbup = false;
2257 } 2259 }
2258 } 2260 }
2259 if ( createbup ) { 2261 if ( createbup ) {
2260 mView->saveCalendar( fn ); 2262 mView->saveCalendar( fn );
2261 mes = i18n("KO/Pi:Saved %1").arg(fn); 2263 mes = i18n("KO/Pi:Saved %1").arg(fn);
2262 KOPrefs::instance()->mLastSaveFile = fn; 2264 KOPrefs::instance()->mLastSaveFile = fn;
2263 setCaption(mes); 2265 setCaption(mes);
2264 } 2266 }
2265} 2267}
2266void MainWindow::loadCalendar() 2268void MainWindow::loadCalendar()
2267{ 2269{
2268 2270
2269 QString fn = KOPrefs::instance()->mLastLoadFile; 2271 QString fn = KOPrefs::instance()->mLastLoadFile;
2270 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2272 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2271 2273
2272 if ( fn == "" ) 2274 if ( fn == "" )
2273 return; 2275 return;
2274 QFileInfo info; 2276 QFileInfo info;
2275 info.setFile( fn ); 2277 info.setFile( fn );
2276 QString mess; 2278 QString mess;
2277 bool loadbup = true; 2279 bool loadbup = true;
2278 if ( info. exists() ) { 2280 if ( info. exists() ) {
2279 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2281 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2280 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2282 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2281 mess, 2283 mess,
2282 i18n("Load!"), i18n("Cancel"), 0, 2284 i18n("Load!"), i18n("Cancel"), 0,
2283 0, 1 ); 2285 0, 1 );
2284 if ( result != 0 ) { 2286 if ( result != 0 ) {
2285 loadbup = false; 2287 loadbup = false;
2286 } 2288 }
2287 } else { 2289 } else {
2288 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2290 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2289 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2291 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2290 0, 1 ); 2292 0, 1 );
2291 2293
2292 return; 2294 return;
2293 } 2295 }
2294 if ( loadbup ) { 2296 if ( loadbup ) {
2295 mView->openCalendar( fn ); 2297 mView->openCalendar( fn );
2296 KOPrefs::instance()->mLastLoadFile = fn; 2298 KOPrefs::instance()->mLastLoadFile = fn;
2297 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2299 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2298 setCaption(mess); 2300 setCaption(mess);
2299 } 2301 }
2300 2302
2301} 2303}
2302void MainWindow::quickImportIcal() 2304void MainWindow::quickImportIcal()
2303{ 2305{
2304 importFile( KOPrefs::instance()->mLastImportFile, false ); 2306 importFile( KOPrefs::instance()->mLastImportFile, false );
2305} 2307}
2306void MainWindow::importFile( QString fn, bool quick ) 2308void MainWindow::importFile( QString fn, bool quick )
2307{ 2309{
2308 QFileInfo info; 2310 QFileInfo info;
2309 info.setFile( fn ); 2311 info.setFile( fn );
2310 QString mess; 2312 QString mess;
2311 bool loadbup = true; 2313 bool loadbup = true;
2312 if ( !info. exists() ) { 2314 if ( !info. exists() ) {
2313 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2315 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2314 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2316 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2315 mess ); 2317 mess );
2316 return; 2318 return;
2317 } 2319 }
2318 int result = 0; 2320 int result = 0;
2319 if ( !quick ) { 2321 if ( !quick ) {
2320 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 )); 2322 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 ));
2321 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2323 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2322 mess, 2324 mess,
2323 "Import", "Cancel", 0, 2325 "Import", "Cancel", 0,
2324 0, 1 ); 2326 0, 1 );
2325 } 2327 }
2326 if ( result == 0 ) { 2328 if ( result == 0 ) {
2327 if ( mView->openCalendar( fn, true )) { 2329 if ( mView->openCalendar( fn, true )) {
2328 KOPrefs::instance()->mLastImportFile = fn; 2330 KOPrefs::instance()->mLastImportFile = fn;
2329 setCaption(i18n("Imported file successfully")); 2331 setCaption(i18n("Imported file successfully"));
2330 } else { 2332 } else {
2331 setCaption(i18n("Error importing file")); 2333 setCaption(i18n("Error importing file"));
2332 } 2334 }
2333 } 2335 }
2334} 2336}
2335 2337
2336void MainWindow::importIcal() 2338void MainWindow::importIcal()
2337{ 2339{
2338 2340
2339 QString fn =KOPrefs::instance()->mLastImportFile; 2341 QString fn =KOPrefs::instance()->mLastImportFile;
2340 2342
2341 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2343 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2342 if ( fn == "" ) 2344 if ( fn == "" )
2343 return; 2345 return;
2344 importFile( fn, true ); 2346 importFile( fn, true );
2345 2347
2346} 2348}
2347 2349
2348void MainWindow::exportVCalendar() 2350void MainWindow::exportVCalendar()
2349{ 2351{
2350 QString fn = KOPrefs::instance()->mLastVcalFile; 2352 QString fn = KOPrefs::instance()->mLastVcalFile;
2351 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2353 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2352 if ( fn == "" ) 2354 if ( fn == "" )
2353 return; 2355 return;
2354 QFileInfo info; 2356 QFileInfo info;
2355 info.setFile( fn ); 2357 info.setFile( fn );
2356 QString mes; 2358 QString mes;
2357 bool createbup = true; 2359 bool createbup = true;
2358 if ( info. exists() ) { 2360 if ( info. exists() ) {
2359 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2361 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2360 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2362 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2361 i18n("Overwrite!"), i18n("Cancel"), 0, 2363 i18n("Overwrite!"), i18n("Cancel"), 0,
2362 0, 1 ); 2364 0, 1 );
2363 if ( result != 0 ) { 2365 if ( result != 0 ) {
2364 createbup = false; 2366 createbup = false;
2365 } 2367 }
2366 } 2368 }
2367 if ( createbup ) { 2369 if ( createbup ) {
2368 if ( mView->exportVCalendar( fn ) ) { 2370 if ( mView->exportVCalendar( fn ) ) {
2369 KOPrefs::instance()->mLastVcalFile = fn; 2371 KOPrefs::instance()->mLastVcalFile = fn;
2370 if ( fn.length() > 20 ) 2372 if ( fn.length() > 20 )
2371 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2373 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2372 else 2374 else
2373 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2375 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2374 setCaption(mes); 2376 setCaption(mes);
2375 } 2377 }
2376 } 2378 }
2377 2379
2378} 2380}
2379QString MainWindow::sentSyncFile() 2381QString MainWindow::sentSyncFile()
2380{ 2382{
2381#ifdef DESKTOP_VERSION 2383#ifdef DESKTOP_VERSION
2382 return locateLocal( "tmp", "copysynccal.ics" ); 2384 return locateLocal( "tmp", "copysynccal.ics" );
2383#else 2385#else
2384 return QString( "/tmp/copysynccal.ics" ); 2386 return QString( "/tmp/copysynccal.ics" );
2385#endif 2387#endif
2386} 2388}
2387 2389
2388void MainWindow::syncFileRequest() 2390void MainWindow::syncFileRequest()
2389{ 2391{
2390 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2392 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2391 mSyncManager->slotSyncMenu( 999 ); 2393 mSyncManager->slotSyncMenu( 999 );
2392 } 2394 }
2393 2395
2394 setCaption(i18n("Saving Data to temp file ..." )); 2396 setCaption(i18n("Saving Data to temp file ..." ));
2395 mView->saveCalendar( sentSyncFile() ); 2397 mView->saveCalendar( sentSyncFile() );
2396 setCaption(i18n("Data saved to temp file!" )); 2398 setCaption(i18n("Data saved to temp file!" ));
2397 2399
2398} 2400}
2399void MainWindow::getFile( bool success ) 2401void MainWindow::getFile( bool success )
2400{ 2402{
2401 if ( ! success ) { 2403 if ( ! success ) {
2402 setCaption( i18n("Error receiving file. Nothing changed!") ); 2404 setCaption( i18n("Error receiving file. Nothing changed!") );
2403 return; 2405 return;
2404 } 2406 }
2405 mView->openCalendar( sentSyncFile() ); 2407 mView->openCalendar( sentSyncFile() );
2406 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2408 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2407 mSyncManager->slotSyncMenu( 999 ); 2409 mSyncManager->slotSyncMenu( 999 );
2408 } 2410 }
2409 setCaption( i18n("Pi-Sync successful!") ); 2411 setCaption( i18n("Pi-Sync successful!") );
2410} 2412}
2411 2413
2412void MainWindow::printSel( ) 2414void MainWindow::printSel( )
2413{ 2415{
2414 mView->viewManager()->agendaView()->agenda()->printSelection(); 2416 mView->viewManager()->agendaView()->agenda()->printSelection();
2415} 2417}
2416 2418
2417void MainWindow::printCal() 2419void MainWindow::printCal()
2418{ 2420{
2419 mView->print();//mCp->showDialog(); 2421 mView->print();//mCp->showDialog();
2420} 2422}
2421 2423
2422 2424
2423#include "libkdepim/kdatepicker.h" 2425#include "libkdepim/kdatepicker.h"
2424#include <kdatetbl.h> 2426#include <kdatetbl.h>
2425 2427
2426void MainWindow::weekAction() 2428void MainWindow::weekAction()
2427{ 2429{
2428 int month; 2430 int month;
2429 KPopupFrame* popup = new KPopupFrame(this); 2431 KPopupFrame* popup = new KPopupFrame(this);
2430 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2432 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2431 // ----- 2433 // -----
2432 picker->resize(picker->sizeHint()); 2434 picker->resize(picker->sizeHint());
2433 popup->setMainWidget(picker); 2435 popup->setMainWidget(picker);
2434 picker->setFocus(); 2436 picker->setFocus();
2435 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2437 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2436 int x = 0; 2438 int x = 0;
2437 int y = iconToolBar->height(); 2439 int y = iconToolBar->height();
2438 int dX = 0; 2440 int dX = 0;
2439 int dY = 0; 2441 int dY = 0;
2440 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2442 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2441 if ( iconToolBar->y() > height()/2 ) { 2443 if ( iconToolBar->y() > height()/2 ) {
2442 dY = picker->sizeHint().height()+8; 2444 dY = picker->sizeHint().height()+8;
2443 y = 0; 2445 y = 0;
2444 } 2446 }
2445 } else { 2447 } else {
2446 if ( iconToolBar->x() > width()/2 ) { // right side 2448 if ( iconToolBar->x() > width()/2 ) { // right side
2447 x=0; 2449 x=0;
2448 dX= picker->sizeHint().width()+8; 2450 dX= picker->sizeHint().width()+8;
2449 y = 0; 2451 y = 0;
2450 } else { 2452 } else {
2451 x= iconToolBar->width(); 2453 x= iconToolBar->width();
2452 y = 0; 2454 y = 0;
2453 } 2455 }
2454 } 2456 }
2455 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2457 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2456 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2458 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2457 { 2459 {
2458 month = picker->getResult(); 2460 month = picker->getResult();
2459 emit selectWeek ( month ); 2461 emit selectWeek ( month );
2460 //qDebug("weekSelected %d ", month); 2462 //qDebug("weekSelected %d ", month);
2461 } 2463 }
2462 delete popup; 2464 delete popup;
2463} 2465}
2464 2466
2465void MainWindow::hideEvent ( QHideEvent * ) 2467void MainWindow::hideEvent ( QHideEvent * )
2466{ 2468{
2467 QString message; 2469 QString message;
2468 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2470 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2469 if ( nextA.isValid() ) { 2471 if ( nextA.isValid() ) {
2470 QString sum = mCalendar->nextSummary(); 2472 QString sum = mCalendar->nextSummary();
2471 2473
2472 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2474 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2473 setCaption( message ); 2475 setCaption( message );
2474 } 2476 }
2475} 2477}
2476 2478
2477void MainWindow::resizeEvent( QResizeEvent* e) 2479void MainWindow::resizeEvent( QResizeEvent* e)
2478{ 2480{
2479#ifndef DESKTOP_VERSION 2481#ifndef DESKTOP_VERSION
2480 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2482 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2481 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2483 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2482 filterToolBar->hide(); 2484 filterToolBar->hide();
2483 else 2485 else
2484 filterToolBar->show(); 2486 filterToolBar->show();
2485 } 2487 }
2486#endif 2488#endif
2487 QMainWindow::resizeEvent( e); 2489 QMainWindow::resizeEvent( e);
2488} 2490}