summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-17 19:50:38 (UTC)
committer zautrix <zautrix>2005-08-17 19:50:38 (UTC)
commit39f1119563e038a029fd23c4b3af03eda02fe308 (patch) (unidiff)
treeb552570e883436ec451cdb7d4b215206c2ca3ba3 /korganizer
parentdfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5 (diff)
downloadkdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.zip
kdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.tar.gz
kdepimpi-39f1119563e038a029fd23c4b3af03eda02fe308.tar.bz2
kopi save error warning
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp14
-rw-r--r--korganizer/mainwindow.cpp12
2 files changed, 22 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 316826a..ca071b2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -70,1537 +70,1537 @@
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy (NoFocus ); 370 setFocusPolicy (NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 mConflictingEvent = 0; 373 mConflictingEvent = 0;
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 423
424 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
426 426
427 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
428#else 428#else
429 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 439 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 446 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
456#endif 456#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
460#if 0 460#if 0
461 // FIXME 461 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 464#endif
465 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 480
481 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
482#if 0 482#if 0
483 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
484 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
485 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
486 486
487 } else { 487 } else {
488 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
489 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
490 } 490 }
491#endif 491#endif
492 mFilterView->hide(); 492 mFilterView->hide();
493 mCalEditView->hide(); 493 mCalEditView->hide();
494 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
495 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
497 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
498 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
499 499
500 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
501 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
506 } else { 506 } else {
507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
510 } 510 }
511 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
512 mDateNavigator->hide(); 512 mDateNavigator->hide();
513 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
514#endif 514#endif
515 515
516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
517 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
518 518
519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
521 521
522 522
523 523
524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
525 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
528 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
529 529
530 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
531 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
532 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
533 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
534 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
535 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
536 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
537 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
538 538
539 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
540 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
541 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
542 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
544 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
545 545
546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
548#if 0 548#if 0
549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
550 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
551#endif 551#endif
552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
553 553
554 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
555 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
556 556
557 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
558 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
560 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
562 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
564 SLOT( showTodo( Todo *) ) ); 564 SLOT( showTodo( Todo *) ) );
565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
566 SLOT( deleteTodo( Todo *) ) ); 566 SLOT( deleteTodo( Todo *) ) );
567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
569 SLOT( purgeCompleted() ) ); 569 SLOT( purgeCompleted() ) );
570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
571 SIGNAL( todoModified( Todo *, int ) ) ); 571 SIGNAL( todoModified( Todo *, int ) ) );
572 572
573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
574 this, SLOT ( cloneIncidence( Incidence * ) ) ); 574 this, SLOT ( cloneIncidence( Incidence * ) ) );
575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
576 this, SLOT (cancelIncidence( Incidence * ) ) ); 576 this, SLOT (cancelIncidence( Incidence * ) ) );
577 577
578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
579 this, SLOT ( moveIncidence( Incidence * ) ) ); 579 this, SLOT ( moveIncidence( Incidence * ) ) );
580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
581 this, SLOT ( beamIncidence( Incidence * ) ) ); 581 this, SLOT ( beamIncidence( Incidence * ) ) );
582 582
583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
584 this, SLOT ( todo_unsub( Todo * ) ) ); 584 this, SLOT ( todo_unsub( Todo * ) ) );
585 585
586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
587 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 587 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
589 SLOT( updateTodo( Todo *, int ) ) ); 589 SLOT( updateTodo( Todo *, int ) ) );
590 connect( this, SIGNAL( todoModified( Todo *, int )), this, 590 connect( this, SIGNAL( todoModified( Todo *, int )), this,
591 SLOT( changeTodoDisplay( Todo *, int ) ) ); 591 SLOT( changeTodoDisplay( Todo *, int ) ) );
592 592
593 593
594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
598 598
599 599
600 600
601 601
602 602
603 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
604 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
606 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
608 608
609 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
610 610
611 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
614 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
615 mDateFrame->hide(); 615 mDateFrame->hide();
616 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
618 618
619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
620 620
621 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
622 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
623 623
624 mFlagEditDescription = false; 624 mFlagEditDescription = false;
625 625
626 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
627 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
628 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
632 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
634 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
636 636
637 637
638#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
639//US listen for arriving address resultsets 639//US listen for arriving address resultsets
640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
642#endif 642#endif
643 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
644} 644}
645 645
646 646
647CalendarView::~CalendarView() 647CalendarView::~CalendarView()
648{ 648{
649 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658 658
659 659
660void CalendarView::nextConflict( bool all, bool allday ) 660void CalendarView::nextConflict( bool all, bool allday )
661{ 661{
662 static bool block = false; 662 static bool block = false;
663 if ( block ) return; 663 if ( block ) return;
664 block = true; 664 block = true;
665 QPtrList<Event> testlist = mCalendar->events(); 665 QPtrList<Event> testlist = mCalendar->events();
666 Event * test = testlist.first(); 666 Event * test = testlist.first();
667 while ( test ) { 667 while ( test ) {
668 test->setTagged( false ); 668 test->setTagged( false );
669 test = testlist.next(); 669 test = testlist.next();
670 } 670 }
671 QTime st ( 0,0,0); 671 QTime st ( 0,0,0);
672 if ( mViewManager->currentView() == mViewManager->agendaView() ) 672 if ( mViewManager->currentView() == mViewManager->agendaView() )
673 st = mViewManager->agendaView()->agenda()->getEndTime(); 673 st = mViewManager->agendaView()->agenda()->getEndTime();
674 //qDebug("time %s ", st.toString().latin1()); 674 //qDebug("time %s ", st.toString().latin1());
675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
676 QDateTime conflict; 676 QDateTime conflict;
677 QDateTime retVal; 677 QDateTime retVal;
678 bool found = false; 678 bool found = false;
679 Event * cE = 0; 679 Event * cE = 0;
680 Event * cE2 = 0; 680 Event * cE2 = 0;
681 QPtrList<Event> testlist2 = testlist; 681 QPtrList<Event> testlist2 = testlist;
682 test = testlist.first(); 682 test = testlist.first();
683 bool skip = false; 683 bool skip = false;
684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
685 //QTime tm; 685 //QTime tm;
686 //tm.start(); 686 //tm.start();
687 while ( test ) { 687 while ( test ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 skip = false; 689 skip = false;
690 if ( !all ) skip = ( allday != test->doesFloat() ); 690 if ( !all ) skip = ( allday != test->doesFloat() );
691 if ( !skip ) { 691 if ( !skip ) {
692 if ( found ) 692 if ( found )
693 skip = !test->matchTime( &startDT, &conflict ); 693 skip = !test->matchTime( &startDT, &conflict );
694 else 694 else
695 skip = !test->matchTime( &startDT, 0 ); 695 skip = !test->matchTime( &startDT, 0 );
696 } 696 }
697 if ( !skip ) { 697 if ( !skip ) {
698 Event * test2 = testlist2.first(); 698 Event * test2 = testlist2.first();
699 while ( test2 ) { 699 while ( test2 ) {
700 skip = test2->isTagged(); 700 skip = test2->isTagged();
701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
702 if ( !skip ) { 702 if ( !skip ) {
703 if ( found ) 703 if ( found )
704 skip = !test2->matchTime( &startDT, &conflict ); 704 skip = !test2->matchTime( &startDT, &conflict );
705 else 705 else
706 skip = !test2->matchTime( &startDT, 0 ); 706 skip = !test2->matchTime( &startDT, 0 );
707 } 707 }
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
710 //qDebug("overlap "); 710 //qDebug("overlap ");
711 if ( ! found ) { 711 if ( ! found ) {
712 if ( retVal >= startDT ) { 712 if ( retVal >= startDT ) {
713 conflict = retVal; 713 conflict = retVal;
714 cE = test; 714 cE = test;
715 cE2 = test2; 715 cE2 = test2;
716 found = true; 716 found = true;
717 } 717 }
718 } else { 718 } else {
719 if ( retVal >= startDT && retVal < conflict ) { 719 if ( retVal >= startDT && retVal < conflict ) {
720 conflict = retVal; 720 conflict = retVal;
721 cE = test; 721 cE = test;
722 cE2 = test2; 722 cE2 = test2;
723 } 723 }
724 } 724 }
725 } 725 }
726 } 726 }
727 test2 = testlist2.next(); 727 test2 = testlist2.next();
728 } 728 }
729 } 729 }
730 test->setTagged( true ); 730 test->setTagged( true );
731 test = testlist.next(); 731 test = testlist.next();
732 } 732 }
733 //qDebug("Search time : %d", tm.elapsed()); 733 //qDebug("Search time : %d", tm.elapsed());
734 if ( found ) { 734 if ( found ) {
735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
736 mViewManager->showDayView(); 736 mViewManager->showDayView();
737 mNavigator->slotDaySelect( conflict.date() ); 737 mNavigator->slotDaySelect( conflict.date() );
738 int hour = conflict.time().hour(); 738 int hour = conflict.time().hour();
739 mViewManager->agendaView()->setStartHour( hour ); 739 mViewManager->agendaView()->setStartHour( hour );
740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
741 block = false; 741 block = false;
742 return; 742 return;
743 } 743 }
744 744
745 topLevelWidget()->setCaption( i18n("No conflict found") ); 745 topLevelWidget()->setCaption( i18n("No conflict found") );
746 //qDebug("No conflict found "); 746 //qDebug("No conflict found ");
747 block = false; 747 block = false;
748 return; 748 return;
749} 749}
750 750
751void CalendarView::conflictAll() 751void CalendarView::conflictAll()
752{ 752{
753 nextConflict ( true, true ); 753 nextConflict ( true, true );
754} 754}
755void CalendarView::conflictAllday() 755void CalendarView::conflictAllday()
756{ 756{
757 nextConflict ( false, true ); 757 nextConflict ( false, true );
758} 758}
759void CalendarView::conflictNotAll() 759void CalendarView::conflictNotAll()
760{ 760{
761 nextConflict ( false, false ); 761 nextConflict ( false, false );
762} 762}
763 763
764void CalendarView::setCalReadOnly( int id, bool readO ) 764void CalendarView::setCalReadOnly( int id, bool readO )
765{ 765{
766 if ( readO ) { 766 if ( readO ) {
767 emit save(); 767 emit save();
768 } 768 }
769 mCalendar->setReadOnly( id, readO ); 769 mCalendar->setReadOnly( id, readO );
770} 770}
771void CalendarView::setScrollBarStep(int val ) 771void CalendarView::setScrollBarStep(int val )
772{ 772{
773#ifdef DESKTOP_VERSION 773#ifdef DESKTOP_VERSION
774 mDateScrollBar->setLineStep ( val ); 774 mDateScrollBar->setLineStep ( val );
775#endif 775#endif
776} 776}
777void CalendarView::scrollBarValue(int val ) 777void CalendarView::scrollBarValue(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 if ( QApplication::desktop()->width() < 800 ) return; 780 if ( QApplication::desktop()->width() < 800 ) return;
781 static bool block = false; 781 static bool block = false;
782 if ( block ) return; 782 if ( block ) return;
783 block = true; 783 block = true;
784 int count = mNavigator->selectedDates().count(); 784 int count = mNavigator->selectedDates().count();
785 int day = mNavigator->selectedDates().first().dayOfYear(); 785 int day = mNavigator->selectedDates().first().dayOfYear();
786 int stepdays = val; 786 int stepdays = val;
787 if ( mDateScrollBar->lineStep () <= count ) { 787 if ( mDateScrollBar->lineStep () <= count ) {
788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
789 //qDebug("VAL %d ",val ); 789 //qDebug("VAL %d ",val );
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void CalendarView::checkFiles()
826{ 826{
827 QString message; 827 QString message;
828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
829 KopiCalendarFile * cal = calendars.first(); 829 KopiCalendarFile * cal = calendars.first();
830 while ( cal ) { 830 while ( cal ) {
831 if ( cal->mErrorOnLoad ) { 831 if ( cal->mErrorOnLoad ) {
832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
833 } 833 }
834 cal = calendars.next(); 834 cal = calendars.next();
835 } 835 }
836 if ( !message.isEmpty() ) { 836 if ( !message.isEmpty() ) {
837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 838 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
839 } 839 }
840 static bool firstTime = true; 840 static bool firstTime = true;
841 if ( firstTime ) { 841 if ( firstTime ) {
842 firstTime = false; 842 firstTime = false;
843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
844 } 844 }
845} 845}
846void CalendarView::checkAlarms() 846void CalendarView::checkAlarms()
847{ 847{
848 KConfig *config = KOGlobals::config(); 848 KConfig *config = KOGlobals::config();
849 config->setGroup( "AppRun" ); 849 config->setGroup( "AppRun" );
850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
851 int daysto = dt.daysTo( QDate::currentDate() ); 851 int daysto = dt.daysTo( QDate::currentDate() );
852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
853 dt = dt.addDays( days ); 853 dt = dt.addDays( days );
854 int secto = dt.secsTo( QDateTime::currentDateTime() ); 854 int secto = dt.secsTo( QDateTime::currentDateTime() );
855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
856 //qDebug("KO: Reading program stop %d ", secs); 856 //qDebug("KO: Reading program stop %d ", secs);
857 //secs -= ( 3600 * 24*3 ); // debug only 857 //secs -= ( 3600 * 24*3 ); // debug only
858 QDateTime latest = dt.addSecs ( secs ); 858 QDateTime latest = dt.addSecs ( secs );
859 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 859 qDebug("KO: Last termination on %s ", latest.toString().latin1());
860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
861 QPtrList<Incidence> el = mCalendar->rawIncidences(); 861 QPtrList<Incidence> el = mCalendar->rawIncidences();
862 QPtrList<Incidence> al; 862 QPtrList<Incidence> al;
863 Incidence* inL = el.first(); 863 Incidence* inL = el.first();
864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
866 while ( inL ) { 866 while ( inL ) {
867 bool ok = false; 867 bool ok = false;
868 int offset = 0; 868 int offset = 0;
869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
870 if ( ok ) { 870 if ( ok ) {
871 //qDebug("OK %s",next.toString().latin1()); 871 //qDebug("OK %s",next.toString().latin1());
872 if ( next < cur ) { 872 if ( next < cur ) {
873 al.append( inL ); 873 al.append( inL );
874 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 874 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
875 } 875 }
876 } 876 }
877 inL = el.next(); 877 inL = el.next();
878 } 878 }
879 if ( al.count() ) { 879 if ( al.count() ) {
880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
881 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 881 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
882 QVBoxLayout* lay = new QVBoxLayout( dia ); 882 QVBoxLayout* lay = new QVBoxLayout( dia );
883 lay->setSpacing( 0 ); 883 lay->setSpacing( 0 );
884 lay->setMargin( 0 ); 884 lay->setMargin( 0 );
885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
887 lay->addWidget( matb ); 887 lay->addWidget( matb );
888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
889 int wid = 210; 889 int wid = 210;
890 int x = QApplication::desktop()->width() - wid - 7; 890 int x = QApplication::desktop()->width() - wid - 7;
891 int y = QApplication::desktop()->height() - wid - 70; 891 int y = QApplication::desktop()->height() - wid - 70;
892 dia->setGeometry ( x,y,wid,wid); 892 dia->setGeometry ( x,y,wid,wid);
893 } else { 893 } else {
894 int si = 220; 894 int si = 220;
895 if ( QApplication::desktop()->width() > 470 ) 895 if ( QApplication::desktop()->width() > 470 )
896 si = 400; 896 si = 400;
897 dia->resize(si,si/2); 897 dia->resize(si,si/2);
898 } 898 }
899 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 899 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
900 dia->show(); 900 dia->show();
901 901
902 } 902 }
903#if 0 903#if 0
904 // for creating timetracker test data 904 // for creating timetracker test data
905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
906 Todo * nt; 906 Todo * nt;
907 mCalendar->close(); 907 mCalendar->close();
908 { 908 {
909 Todo * root1 = new Todo; 909 Todo * root1 = new Todo;
910 mCalendar->addTodo( root1 ); 910 mCalendar->addTodo( root1 );
911 root1->setSummary( "Project1"); 911 root1->setSummary( "Project1");
912 root1->setPriority( 1 ); 912 root1->setPriority( 1 );
913 root1->setCategories( QString( "Cat_Pro1") ); 913 root1->setCategories( QString( "Cat_Pro1") );
914 root1->setDescription( "This is a test description of a root Project" ); 914 root1->setDescription( "This is a test description of a root Project" );
915 root1->setPercentComplete( 20 ); 915 root1->setPercentComplete( 20 );
916 updateView(); 916 updateView();
917 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 917 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
918 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 918 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
919 919
920 nt = new Todo; 920 nt = new Todo;
921 mCalendar->addTodo( nt ); 921 mCalendar->addTodo( nt );
922 nt->setSummary( "Planning Project1"); 922 nt->setSummary( "Planning Project1");
923 nt->setPriority( 1 ); 923 nt->setPriority( 1 );
924 nt->setDescription( "This is a test description of Planning Project1" ); 924 nt->setDescription( "This is a test description of Planning Project1" );
925 nt->setPercentComplete( 20 ); 925 nt->setPercentComplete( 20 );
926 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 926 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
927 927
928 928
929 Todo * sub1 = nt; 929 Todo * sub1 = nt;
930 sub1->setRelatedTo( root1 ); 930 sub1->setRelatedTo( root1 );
931 931
932 nt = new Todo; 932 nt = new Todo;
933 mCalendar->addTodo( nt ); 933 mCalendar->addTodo( nt );
934 nt->setSummary( "Planning Project1: Lutz"); 934 nt->setSummary( "Planning Project1: Lutz");
935 nt->setPriority( 1 ); 935 nt->setPriority( 1 );
936 nt->setDescription( "This todo counts the actual work of a person on a project" ); 936 nt->setDescription( "This todo counts the actual work of a person on a project" );
937 nt->setPercentComplete( 20 ); 937 nt->setPercentComplete( 20 );
938 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); 938 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") );
939 Todo * workLutz11 = nt; 939 Todo * workLutz11 = nt;
940 workLutz11->setRelatedTo( sub1 ); 940 workLutz11->setRelatedTo( sub1 );
941 941
942 nt = new Todo; 942 nt = new Todo;
943 mCalendar->addTodo( nt ); 943 mCalendar->addTodo( nt );
944 nt->setSummary( "Planning Project1: Norbert"); 944 nt->setSummary( "Planning Project1: Norbert");
945 nt->setPriority( 1 ); 945 nt->setPriority( 1 );
946 nt->setDescription( "This todo counts the actual work of a person on a project" ); 946 nt->setDescription( "This todo counts the actual work of a person on a project" );
947 nt->setPercentComplete( 20 ); 947 nt->setPercentComplete( 20 );
948 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); 948 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") );
949 Todo * workNorbert11 = nt; 949 Todo * workNorbert11 = nt;
950 workNorbert11->setRelatedTo( sub1 ); 950 workNorbert11->setRelatedTo( sub1 );
951 951
952 nt = new Todo; 952 nt = new Todo;
953 mCalendar->addTodo( nt ); 953 mCalendar->addTodo( nt );
954 nt->setSummary( "Work on 1"); 954 nt->setSummary( "Work on 1");
955 nt->setPriority( 1 ); 955 nt->setPriority( 1 );
956 nt->setDescription( "This is a test description of Work Project_1" ); 956 nt->setDescription( "This is a test description of Work Project_1" );
957 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); 957 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") );
958 nt->setPercentComplete( 20 ); 958 nt->setPercentComplete( 20 );
959 959
960 Todo * sub2 = nt; 960 Todo * sub2 = nt;
961 sub2->setRelatedTo( root1 ); 961 sub2->setRelatedTo( root1 );
962 962
963 963
964 nt = new Todo; 964 nt = new Todo;
965 mCalendar->addTodo( nt ); 965 mCalendar->addTodo( nt );
966 nt->setSummary( "Work on 1: Lutz"); 966 nt->setSummary( "Work on 1: Lutz");
967 nt->setPriority( 1 ); 967 nt->setPriority( 1 );
968 nt->setDescription( "This todo counts the actual work of a person on a project" ); 968 nt->setDescription( "This todo counts the actual work of a person on a project" );
969 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); 969 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") );
970 nt->setPercentComplete( 20 ); 970 nt->setPercentComplete( 20 );
971 Todo * workLutz12 = nt; 971 Todo * workLutz12 = nt;
972 workLutz12->setRelatedTo( sub2 ); 972 workLutz12->setRelatedTo( sub2 );
973 973
974 nt = new Todo; 974 nt = new Todo;
975 mCalendar->addTodo( nt ); 975 mCalendar->addTodo( nt );
976 nt->setSummary( "Work on 1: Norbert"); 976 nt->setSummary( "Work on 1: Norbert");
977 nt->setPriority( 1 ); 977 nt->setPriority( 1 );
978 nt->setDescription( "This todo counts the actual work of a person on a project" ); 978 nt->setDescription( "This todo counts the actual work of a person on a project" );
979 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); 979 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") );
980 nt->setPercentComplete( 20 ); 980 nt->setPercentComplete( 20 );
981 Todo * workNorbert12 = nt; 981 Todo * workNorbert12 = nt;
982 workNorbert12->setRelatedTo( sub2 ); 982 workNorbert12->setRelatedTo( sub2 );
983 983
984 int secLenRunning = 7200; 984 int secLenRunning = 7200;
985 int secLenPausing = 3600 * 3; 985 int secLenPausing = 3600 * 3;
986 int dayInterval = 1; 986 int dayInterval = 1;
987 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 987 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
988 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 988 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
989 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 989 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
990 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 990 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
991 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 991 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
992 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 992 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
993 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 993 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
994 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 994 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
995 995
996 } 996 }
997 997
998 { 998 {
999 Todo * root1 = new Todo; 999 Todo * root1 = new Todo;
1000 mCalendar->addTodo( root1 ); 1000 mCalendar->addTodo( root1 );
1001 root1->setSummary( "Project2"); 1001 root1->setSummary( "Project2");
1002 root1->setPriority( 1 ); 1002 root1->setPriority( 1 );
1003 root1->setDescription( "This is a test description of a root Project 2" ); 1003 root1->setDescription( "This is a test description of a root Project 2" );
1004 root1->setPercentComplete( 20 ); 1004 root1->setPercentComplete( 20 );
1005 root1->setCategories( QString( "Cat_Pro2") ); 1005 root1->setCategories( QString( "Cat_Pro2") );
1006 updateView(); 1006 updateView();
1007 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 1007 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1008 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 1008 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
1009 int secLenRunning = 7200; 1009 int secLenRunning = 7200;
1010 int secLenPausing = 3600 * 3; 1010 int secLenPausing = 3600 * 3;
1011 int dayInterval = 1; 1011 int dayInterval = 1;
1012 1012
1013 nt = new Todo; 1013 nt = new Todo;
1014 mCalendar->addTodo( nt ); 1014 mCalendar->addTodo( nt );
1015 nt->setSummary( "Planning Project2"); 1015 nt->setSummary( "Planning Project2");
1016 nt->setPriority( 1 ); 1016 nt->setPriority( 1 );
1017 nt->setDescription( "This is a test description of Planning_Project_2" ); 1017 nt->setDescription( "This is a test description of Planning_Project_2" );
1018 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); 1018 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") );
1019 nt->setPercentComplete( 20 ); 1019 nt->setPercentComplete( 20 );
1020 1020
1021 1021
1022 Todo * sub1 = nt; 1022 Todo * sub1 = nt;
1023 sub1->setRelatedTo( root1 ); 1023 sub1->setRelatedTo( root1 );
1024 1024
1025 nt = new Todo; 1025 nt = new Todo;
1026 mCalendar->addTodo( nt ); 1026 mCalendar->addTodo( nt );
1027 nt->setSummary( "Planning Project2: Lutz"); 1027 nt->setSummary( "Planning Project2: Lutz");
1028 nt->setPriority( 1 ); 1028 nt->setPriority( 1 );
1029 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1029 nt->setDescription( "This todo counts the actual work of a person on a project" );
1030 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); 1030 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") );
1031 nt->setPercentComplete( 20 ); 1031 nt->setPercentComplete( 20 );
1032 Todo * workLutz11 = nt; 1032 Todo * workLutz11 = nt;
1033 workLutz11->setRelatedTo( sub1 ); 1033 workLutz11->setRelatedTo( sub1 );
1034 1034
1035 nt = new Todo; 1035 nt = new Todo;
1036 mCalendar->addTodo( nt ); 1036 mCalendar->addTodo( nt );
1037 nt->setSummary( "Planning Project2: Norbert"); 1037 nt->setSummary( "Planning Project2: Norbert");
1038 nt->setPriority( 1 ); 1038 nt->setPriority( 1 );
1039 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1039 nt->setDescription( "This todo counts the actual work of a person on a project" );
1040 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); 1040 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") );
1041 nt->setPercentComplete( 20 ); 1041 nt->setPercentComplete( 20 );
1042 Todo * workNorbert11 = nt; 1042 Todo * workNorbert11 = nt;
1043 workNorbert11->setRelatedTo( sub1 ); 1043 workNorbert11->setRelatedTo( sub1 );
1044 1044
1045 nt = new Todo; 1045 nt = new Todo;
1046 mCalendar->addTodo( nt ); 1046 mCalendar->addTodo( nt );
1047 nt->setSummary( "Work on 2"); 1047 nt->setSummary( "Work on 2");
1048 nt->setPriority( 1 ); 1048 nt->setPriority( 1 );
1049 nt->setDescription( "This is a test description of Work Project_2" ); 1049 nt->setDescription( "This is a test description of Work Project_2" );
1050 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); 1050 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") );
1051 nt->setPercentComplete( 20 ); 1051 nt->setPercentComplete( 20 );
1052 1052
1053 Todo * sub2 = nt; 1053 Todo * sub2 = nt;
1054 sub2->setRelatedTo( root1 ); 1054 sub2->setRelatedTo( root1 );
1055 1055
1056 1056
1057 nt = new Todo; 1057 nt = new Todo;
1058 mCalendar->addTodo( nt ); 1058 mCalendar->addTodo( nt );
1059 nt->setSummary( "Work on 2: Lutz"); 1059 nt->setSummary( "Work on 2: Lutz");
1060 nt->setPriority( 1 ); 1060 nt->setPriority( 1 );
1061 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1061 nt->setDescription( "This todo counts the actual work of a person on a project" );
1062 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); 1062 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") );
1063 nt->setPercentComplete( 20 ); 1063 nt->setPercentComplete( 20 );
1064 Todo * workLutz12 = nt; 1064 Todo * workLutz12 = nt;
1065 workLutz12->setRelatedTo( sub2 ); 1065 workLutz12->setRelatedTo( sub2 );
1066 1066
1067 nt = new Todo; 1067 nt = new Todo;
1068 mCalendar->addTodo( nt ); 1068 mCalendar->addTodo( nt );
1069 nt->setSummary( "Work on 2: Norbert"); 1069 nt->setSummary( "Work on 2: Norbert");
1070 nt->setPriority( 1 ); 1070 nt->setPriority( 1 );
1071 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1071 nt->setDescription( "This todo counts the actual work of a person on a project" );
1072 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); 1072 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") );
1073 nt->setPercentComplete( 20 ); 1073 nt->setPercentComplete( 20 );
1074 Todo * workNorbert12 = nt; 1074 Todo * workNorbert12 = nt;
1075 workNorbert12->setRelatedTo( sub2 ); 1075 workNorbert12->setRelatedTo( sub2 );
1076 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1076 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1077 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1077 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1078 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1078 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1079 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1079 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1080 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1080 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1081 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1081 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1082 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1082 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1083 } 1083 }
1084 updateView(); 1084 updateView();
1085#endif 1085#endif
1086 1086
1087} 1087}
1088void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1088void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1089{ 1089{
1090 static int ccc = 0; 1090 static int ccc = 0;
1091 ++ccc; 1091 ++ccc;
1092 QDateTime t_start = start; 1092 QDateTime t_start = start;
1093 runT->setPriority( 5 ); 1093 runT->setPriority( 5 );
1094 runT->setPercentComplete( 0 ); 1094 runT->setPercentComplete( 0 );
1095 int count = 0; 1095 int count = 0;
1096 int prio = 5; 1096 int prio = 5;
1097 int complete = 0; 1097 int complete = 0;
1098 while ( t_start < end ) { 1098 while ( t_start < end ) {
1099 ++count; 1099 ++count;
1100 if ( count > ccc ) { 1100 if ( count > ccc ) {
1101 count = 0; 1101 count = 0;
1102 --prio; 1102 --prio;
1103 if ( prio == 0 ) prio = 5; 1103 if ( prio == 0 ) prio = 5;
1104 complete += 20; 1104 complete += 20;
1105 if ( complete > 100 ) complete = 0; 1105 if ( complete > 100 ) complete = 0;
1106 runT->setPriority( prio ); 1106 runT->setPriority( prio );
1107 runT->setPercentComplete( complete ); 1107 runT->setPercentComplete( complete );
1108 } 1108 }
1109 runT->setRunning( true ); 1109 runT->setRunning( true );
1110 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1110 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1111 if ( dayInterval ) 1111 if ( dayInterval )
1112 t_start = t_start.addDays( dayInterval ); 1112 t_start = t_start.addDays( dayInterval );
1113 else { 1113 else {
1114 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1114 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1115 } 1115 }
1116 } 1116 }
1117} 1117}
1118 1118
1119void CalendarView::showDay( QDate d ) 1119void CalendarView::showDay( QDate d )
1120{ 1120{
1121 dateNavigator()->blockSignals( true ); 1121 dateNavigator()->blockSignals( true );
1122 dateNavigator()->selectDate( d ); 1122 dateNavigator()->selectDate( d );
1123 dateNavigator()->blockSignals( false ); 1123 dateNavigator()->blockSignals( false );
1124 mViewManager->showDayView(); 1124 mViewManager->showDayView();
1125 //dateNavigator()->selectDate( d ); 1125 //dateNavigator()->selectDate( d );
1126} 1126}
1127void CalendarView::timerAlarm() 1127void CalendarView::timerAlarm()
1128{ 1128{
1129 //qDebug("CalendarView::timerAlarm() "); 1129 //qDebug("CalendarView::timerAlarm() ");
1130 computeAlarm(mAlarmNotification ); 1130 computeAlarm(mAlarmNotification );
1131} 1131}
1132 1132
1133void CalendarView::suspendAlarm() 1133void CalendarView::suspendAlarm()
1134{ 1134{
1135 //qDebug(" CalendarView::suspendAlarm() "); 1135 //qDebug(" CalendarView::suspendAlarm() ");
1136 computeAlarm(mSuspendAlarmNotification ); 1136 computeAlarm(mSuspendAlarmNotification );
1137 1137
1138} 1138}
1139 1139
1140void CalendarView::startAlarm( QString mess , QString filename) 1140void CalendarView::startAlarm( QString mess , QString filename)
1141{ 1141{
1142 1142
1143 topLevelWidget()->showNormal(); 1143 topLevelWidget()->showNormal();
1144 topLevelWidget()->setActiveWindow(); 1144 topLevelWidget()->setActiveWindow();
1145 topLevelWidget()->raise(); 1145 topLevelWidget()->raise();
1146 1146
1147 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1147 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1148 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1148 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1149 1149
1150} 1150}
1151 1151
1152void CalendarView::checkNextTimerAlarm() 1152void CalendarView::checkNextTimerAlarm()
1153{ 1153{
1154 mCalendar->checkAlarmForIncidence( 0, true ); 1154 mCalendar->checkAlarmForIncidence( 0, true );
1155} 1155}
1156 1156
1157void CalendarView::computeAlarm( QString msg ) 1157void CalendarView::computeAlarm( QString msg )
1158{ 1158{
1159 1159
1160 QString mess = msg; 1160 QString mess = msg;
1161 QString mAlarmMessage = mess.mid( 9 ); 1161 QString mAlarmMessage = mess.mid( 9 );
1162 QString filename = MainWindow::resourcePath(); 1162 QString filename = MainWindow::resourcePath();
1163 filename += "koalarm.wav"; 1163 filename += "koalarm.wav";
1164 QString tempfilename; 1164 QString tempfilename;
1165 if ( mess.left( 13 ) == "suspend_alarm") { 1165 if ( mess.left( 13 ) == "suspend_alarm") {
1166 bool error = false; 1166 bool error = false;
1167 int len = mess.mid( 13 ).find("+++"); 1167 int len = mess.mid( 13 ).find("+++");
1168 if ( len < 2 ) 1168 if ( len < 2 )
1169 error = true; 1169 error = true;
1170 else { 1170 else {
1171 tempfilename = mess.mid( 13, len ); 1171 tempfilename = mess.mid( 13, len );
1172 if ( !QFile::exists( tempfilename ) ) 1172 if ( !QFile::exists( tempfilename ) )
1173 error = true; 1173 error = true;
1174 } 1174 }
1175 if ( ! error ) { 1175 if ( ! error ) {
1176 filename = tempfilename; 1176 filename = tempfilename;
1177 } 1177 }
1178 mAlarmMessage = mess.mid( 13+len+3 ); 1178 mAlarmMessage = mess.mid( 13+len+3 );
1179 //qDebug("suspend file %s ",tempfilename.latin1() ); 1179 //qDebug("suspend file %s ",tempfilename.latin1() );
1180 startAlarm( mAlarmMessage, filename); 1180 startAlarm( mAlarmMessage, filename);
1181 return; 1181 return;
1182 } 1182 }
1183 if ( mess.left( 11 ) == "timer_alarm") { 1183 if ( mess.left( 11 ) == "timer_alarm") {
1184 //mTimerTime = 0; 1184 //mTimerTime = 0;
1185 startAlarm( mess.mid( 11 ), filename ); 1185 startAlarm( mess.mid( 11 ), filename );
1186 return; 1186 return;
1187 } 1187 }
1188 if ( mess.left( 10 ) == "proc_alarm") { 1188 if ( mess.left( 10 ) == "proc_alarm") {
1189 bool error = false; 1189 bool error = false;
1190 int len = mess.mid( 10 ).find("+++"); 1190 int len = mess.mid( 10 ).find("+++");
1191 if ( len < 2 ) 1191 if ( len < 2 )
1192 error = true; 1192 error = true;
1193 else { 1193 else {
1194 tempfilename = mess.mid( 10, len ); 1194 tempfilename = mess.mid( 10, len );
1195 if ( !QFile::exists( tempfilename ) ) 1195 if ( !QFile::exists( tempfilename ) )
1196 error = true; 1196 error = true;
1197 } 1197 }
1198 if ( error ) { 1198 if ( error ) {
1199 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1199 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1200 mAlarmMessage += mess.mid( 10+len+3+9 ); 1200 mAlarmMessage += mess.mid( 10+len+3+9 );
1201 } else { 1201 } else {
1202 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1202 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1203 //qDebug("-----system command %s ",tempfilename.latin1() ); 1203 //qDebug("-----system command %s ",tempfilename.latin1() );
1204#ifndef _WIN32_ 1204#ifndef _WIN32_
1205 if ( vfork () == 0 ) { 1205 if ( vfork () == 0 ) {
1206 execl ( tempfilename.latin1(), 0 ); 1206 execl ( tempfilename.latin1(), 0 );
1207 return; 1207 return;
1208 } 1208 }
1209#else 1209#else
1210 QProcess* p = new QProcess(); 1210 QProcess* p = new QProcess();
1211 p->addArgument( tempfilename.latin1() ); 1211 p->addArgument( tempfilename.latin1() );
1212 p->start(); 1212 p->start();
1213 return; 1213 return;
1214#endif 1214#endif
1215 1215
1216 return; 1216 return;
1217 } 1217 }
1218 1218
1219 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1219 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1220 } 1220 }
1221 if ( mess.left( 11 ) == "audio_alarm") { 1221 if ( mess.left( 11 ) == "audio_alarm") {
1222 bool error = false; 1222 bool error = false;
1223 int len = mess.mid( 11 ).find("+++"); 1223 int len = mess.mid( 11 ).find("+++");
1224 if ( len < 2 ) 1224 if ( len < 2 )
1225 error = true; 1225 error = true;
1226 else { 1226 else {
1227 tempfilename = mess.mid( 11, len ); 1227 tempfilename = mess.mid( 11, len );
1228 if ( !QFile::exists( tempfilename ) ) 1228 if ( !QFile::exists( tempfilename ) )
1229 error = true; 1229 error = true;
1230 } 1230 }
1231 if ( ! error ) { 1231 if ( ! error ) {
1232 filename = tempfilename; 1232 filename = tempfilename;
1233 } 1233 }
1234 mAlarmMessage = mess.mid( 11+len+3+9 ); 1234 mAlarmMessage = mess.mid( 11+len+3+9 );
1235 //qDebug("audio file command %s ",tempfilename.latin1() ); 1235 //qDebug("audio file command %s ",tempfilename.latin1() );
1236 } 1236 }
1237 if ( mess.left( 9 ) == "cal_alarm") { 1237 if ( mess.left( 9 ) == "cal_alarm") {
1238 mAlarmMessage = mess.mid( 9 ) ; 1238 mAlarmMessage = mess.mid( 9 ) ;
1239 } 1239 }
1240 1240
1241 startAlarm( mAlarmMessage, filename ); 1241 startAlarm( mAlarmMessage, filename );
1242 1242
1243 1243
1244} 1244}
1245 1245
1246void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1246void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1247{ 1247{
1248 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1248 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1249 1249
1250 mSuspendAlarmNotification = noti; 1250 mSuspendAlarmNotification = noti;
1251 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1251 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1252 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1252 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1253 mSuspendTimer->start( ms , true ); 1253 mSuspendTimer->start( ms , true );
1254#ifdef DESKTOP_VERSION 1254#ifdef DESKTOP_VERSION
1255 if ( QApplication::desktop()->width() < 1024 ) { 1255 if ( QApplication::desktop()->width() < 1024 ) {
1256 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1256 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1257 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1257 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1258 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1258 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1259 QFile file( fn ); 1259 QFile file( fn );
1260 if (!file.open( IO_WriteOnly ) ) { 1260 if (!file.open( IO_WriteOnly ) ) {
1261 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1261 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1262 } else { 1262 } else {
1263 QTextStream ts( &file ); 1263 QTextStream ts( &file );
1264 ts << mess; 1264 ts << mess;
1265 file.close(); 1265 file.close();
1266 } 1266 }
1267 } 1267 }
1268#endif 1268#endif
1269 1269
1270} 1270}
1271 1271
1272void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1272void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1273{ 1273{
1274 mNextAlarmDateTime = qdt; 1274 mNextAlarmDateTime = qdt;
1275 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1275 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1276 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1276 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1277#ifndef DESKTOP_VERSION 1277#ifndef DESKTOP_VERSION
1278 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1278 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1279#endif 1279#endif
1280 return; 1280 return;
1281 } 1281 }
1282#ifdef DESKTOP_VERSION 1282#ifdef DESKTOP_VERSION
1283 if ( QApplication::desktop()->width() < 1024 ) { 1283 if ( QApplication::desktop()->width() < 1024 ) {
1284 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1284 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1285 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1285 //qDebug("nextalarm = \n%s ",mess.latin1() );
1286 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1286 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1287 QFile file( fn ); 1287 QFile file( fn );
1288 if (!file.open( IO_WriteOnly ) ) { 1288 if (!file.open( IO_WriteOnly ) ) {
1289 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1289 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1290 } else { 1290 } else {
1291 QTextStream ts( &file ); 1291 QTextStream ts( &file );
1292 ts << mess; 1292 ts << mess;
1293 file.close(); 1293 file.close();
1294 } 1294 }
1295 } 1295 }
1296#endif 1296#endif
1297 int maxSec; 1297 int maxSec;
1298 //maxSec = 5; //testing only 1298 //maxSec = 5; //testing only
1299 maxSec = 86400+3600; // one day+1hour 1299 maxSec = 86400+3600; // one day+1hour
1300 mAlarmNotification = noti; 1300 mAlarmNotification = noti;
1301 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1301 int sec = QDateTime::currentDateTime().secsTo( qdt );
1302 if ( sec > maxSec ) { 1302 if ( sec > maxSec ) {
1303 mRecheckAlarmTimer->start( maxSec * 1000 ); 1303 mRecheckAlarmTimer->start( maxSec * 1000 );
1304 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1304 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1305 return; 1305 return;
1306 } else { 1306 } else {
1307 mRecheckAlarmTimer->stop(); 1307 mRecheckAlarmTimer->stop();
1308 } 1308 }
1309 //qDebug("Alarm timer started with secs: %d ", sec); 1309 //qDebug("Alarm timer started with secs: %d ", sec);
1310 mAlarmTimer->start( sec * 1000 , true ); 1310 mAlarmTimer->start( sec * 1000 , true );
1311 1311
1312} 1312}
1313// called by mRecheckAlarmTimer to get next alarm 1313// called by mRecheckAlarmTimer to get next alarm
1314// we need this, because a QTimer has only a max range of 25 days 1314// we need this, because a QTimer has only a max range of 25 days
1315void CalendarView::recheckTimerAlarm() 1315void CalendarView::recheckTimerAlarm()
1316{ 1316{
1317 mAlarmTimer->stop(); 1317 mAlarmTimer->stop();
1318 mRecheckAlarmTimer->stop(); 1318 mRecheckAlarmTimer->stop();
1319 mCalendar->checkAlarmForIncidence( 0, true ); 1319 mCalendar->checkAlarmForIncidence( 0, true );
1320} 1320}
1321#ifndef DESKTOP_VERSION 1321#ifndef DESKTOP_VERSION
1322void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1322void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1323#else 1323#else
1324void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1324void CalendarView::removeAlarm(const QDateTime &, const QString & )
1325#endif 1325#endif
1326{ 1326{
1327 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1327 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1328 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1328 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1329#ifndef DESKTOP_VERSION 1329#ifndef DESKTOP_VERSION
1330 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1330 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1331#endif 1331#endif
1332 return; 1332 return;
1333 } 1333 }
1334 mAlarmTimer->stop(); 1334 mAlarmTimer->stop();
1335} 1335}
1336void CalendarView::selectWeekNum ( int num ) 1336void CalendarView::selectWeekNum ( int num )
1337{ 1337{
1338 dateNavigator()->blockSignals( true ); 1338 dateNavigator()->blockSignals( true );
1339 dateNavigator()->selectWeek( num ); 1339 dateNavigator()->selectWeek( num );
1340 dateNavigator()->blockSignals( false ); 1340 dateNavigator()->blockSignals( false );
1341 mViewManager->showWeekView(); 1341 mViewManager->showWeekView();
1342} 1342}
1343KOViewManager *CalendarView::viewManager() 1343KOViewManager *CalendarView::viewManager()
1344{ 1344{
1345 return mViewManager; 1345 return mViewManager;
1346} 1346}
1347 1347
1348KODialogManager *CalendarView::dialogManager() 1348KODialogManager *CalendarView::dialogManager()
1349{ 1349{
1350 return mDialogManager; 1350 return mDialogManager;
1351} 1351}
1352 1352
1353QDate CalendarView::startDate() 1353QDate CalendarView::startDate()
1354{ 1354{
1355 DateList dates = mNavigator->selectedDates(); 1355 DateList dates = mNavigator->selectedDates();
1356 1356
1357 return dates.first(); 1357 return dates.first();
1358} 1358}
1359 1359
1360QDate CalendarView::endDate() 1360QDate CalendarView::endDate()
1361{ 1361{
1362 DateList dates = mNavigator->selectedDates(); 1362 DateList dates = mNavigator->selectedDates();
1363 1363
1364 return dates.last(); 1364 return dates.last();
1365} 1365}
1366 1366
1367 1367
1368void CalendarView::createPrinter() 1368void CalendarView::createPrinter()
1369{ 1369{
1370#ifndef KORG_NOPRINTER 1370#ifndef KORG_NOPRINTER
1371 if (!mCalPrinter) { 1371 if (!mCalPrinter) {
1372 mCalPrinter = new CalPrinter(this, mCalendar); 1372 mCalPrinter = new CalPrinter(this, mCalendar);
1373 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1373 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1374 } 1374 }
1375#endif 1375#endif
1376} 1376}
1377 1377
1378 1378
1379//KOPrefs::instance()->mWriteBackFile 1379//KOPrefs::instance()->mWriteBackFile
1380//KOPrefs::instance()->mWriteBackExistingOnly 1380//KOPrefs::instance()->mWriteBackExistingOnly
1381 1381
1382// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1382// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1383// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1383// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1384// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1384// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1385// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1385// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1386// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1386// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1387// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1387// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1388 1388
1389int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1389int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1390{ 1390{
1391 1391
1392 // 0 equal 1392 // 0 equal
1393 // 1 take local 1393 // 1 take local
1394 // 2 take remote 1394 // 2 take remote
1395 // 3 cancel 1395 // 3 cancel
1396 QDateTime lastSync = mLastCalendarSync; 1396 QDateTime lastSync = mLastCalendarSync;
1397 QDateTime localMod = local->lastModified(); 1397 QDateTime localMod = local->lastModified();
1398 QDateTime remoteMod = remote->lastModified(); 1398 QDateTime remoteMod = remote->lastModified();
1399 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1399 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1400 bool remCh, locCh; 1400 bool remCh, locCh;
1401 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1401 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1402 //if ( remCh ) 1402 //if ( remCh )
1403 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1403 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1404 locCh = ( localMod > mLastCalendarSync ); 1404 locCh = ( localMod > mLastCalendarSync );
1405 if ( !remCh && ! locCh ) { 1405 if ( !remCh && ! locCh ) {
1406 //qDebug("both not changed "); 1406 //qDebug("both not changed ");
1407 lastSync = localMod.addDays(1); 1407 lastSync = localMod.addDays(1);
1408 if ( mode <= SYNC_PREF_ASK ) 1408 if ( mode <= SYNC_PREF_ASK )
1409 return 0; 1409 return 0;
1410 } else { 1410 } else {
1411 if ( locCh ) { 1411 if ( locCh ) {
1412 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1412 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1413 lastSync = localMod.addDays( -1 ); 1413 lastSync = localMod.addDays( -1 );
1414 if ( !remCh ) 1414 if ( !remCh )
1415 remoteMod = ( lastSync.addDays( -1 ) ); 1415 remoteMod = ( lastSync.addDays( -1 ) );
1416 } else { 1416 } else {
1417 //qDebug(" not loc changed "); 1417 //qDebug(" not loc changed ");
1418 lastSync = localMod.addDays( 1 ); 1418 lastSync = localMod.addDays( 1 );
1419 if ( remCh ) 1419 if ( remCh )
1420 remoteMod =( lastSync.addDays( 1 ) ); 1420 remoteMod =( lastSync.addDays( 1 ) );
1421 1421
1422 } 1422 }
1423 } 1423 }
1424 full = true; 1424 full = true;
1425 if ( mode < SYNC_PREF_ASK ) 1425 if ( mode < SYNC_PREF_ASK )
1426 mode = SYNC_PREF_ASK; 1426 mode = SYNC_PREF_ASK;
1427 } else { 1427 } else {
1428 if ( localMod == remoteMod ) 1428 if ( localMod == remoteMod )
1429 // if ( local->revision() == remote->revision() ) 1429 // if ( local->revision() == remote->revision() )
1430 return 0; 1430 return 0;
1431 1431
1432 } 1432 }
1433 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1433 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1434 1434
1435 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1435 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1436 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1436 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1437 //full = true; //debug only 1437 //full = true; //debug only
1438 if ( full ) { 1438 if ( full ) {
1439 bool equ = false; 1439 bool equ = false;
1440 if ( local->typeID() == eventID ) { 1440 if ( local->typeID() == eventID ) {
1441 equ = (*((Event*) local) == *((Event*) remote)); 1441 equ = (*((Event*) local) == *((Event*) remote));
1442 } 1442 }
1443 else if ( local->typeID() == todoID ) 1443 else if ( local->typeID() == todoID )
1444 equ = (*((Todo*) local) == (*(Todo*) remote)); 1444 equ = (*((Todo*) local) == (*(Todo*) remote));
1445 else if ( local->typeID() == journalID ) 1445 else if ( local->typeID() == journalID )
1446 equ = (*((Journal*) local) == *((Journal*) remote)); 1446 equ = (*((Journal*) local) == *((Journal*) remote));
1447 if ( equ ) { 1447 if ( equ ) {
1448 //qDebug("equal "); 1448 //qDebug("equal ");
1449 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1449 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1450 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1450 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1451 } 1451 }
1452 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1452 if ( mode < SYNC_PREF_FORCE_LOCAL )
1453 return 0; 1453 return 0;
1454 1454
1455 }//else //debug only 1455 }//else //debug only
1456 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1456 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1457 } 1457 }
1458 int result; 1458 int result;
1459 bool localIsNew; 1459 bool localIsNew;
1460 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1460 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1461 1461
1462 1462
1463 // ************************************************ 1463 // ************************************************
1464 // ************************************************ 1464 // ************************************************
1465 // ************************************************ 1465 // ************************************************
1466 // We may have that lastSync > remoteMod AND lastSync > localMod 1466 // We may have that lastSync > remoteMod AND lastSync > localMod
1467 // BUT remoteMod != localMod 1467 // BUT remoteMod != localMod
1468 1468
1469 1469
1470 if ( full && mode < SYNC_PREF_NEWEST ) 1470 if ( full && mode < SYNC_PREF_NEWEST )
1471 mode = SYNC_PREF_ASK; 1471 mode = SYNC_PREF_ASK;
1472 1472
1473 switch( mode ) { 1473 switch( mode ) {
1474 case SYNC_PREF_LOCAL: 1474 case SYNC_PREF_LOCAL:
1475 if ( lastSync > remoteMod ) 1475 if ( lastSync > remoteMod )
1476 return 1; 1476 return 1;
1477 if ( lastSync > localMod ) 1477 if ( lastSync > localMod )
1478 return 2; 1478 return 2;
1479 return 1; 1479 return 1;
1480 break; 1480 break;
1481 case SYNC_PREF_REMOTE: 1481 case SYNC_PREF_REMOTE:
1482 if ( lastSync > localMod ) 1482 if ( lastSync > localMod )
1483 return 2; 1483 return 2;
1484 if ( lastSync > remoteMod ) 1484 if ( lastSync > remoteMod )
1485 return 1; 1485 return 1;
1486 return 2; 1486 return 2;
1487 break; 1487 break;
1488 case SYNC_PREF_NEWEST: 1488 case SYNC_PREF_NEWEST:
1489 if ( localMod >= remoteMod ) 1489 if ( localMod >= remoteMod )
1490 return 1; 1490 return 1;
1491 else 1491 else
1492 return 2; 1492 return 2;
1493 break; 1493 break;
1494 case SYNC_PREF_ASK: 1494 case SYNC_PREF_ASK:
1495 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1495 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1496 if ( lastSync > remoteMod && lastSync > localMod) 1496 if ( lastSync > remoteMod && lastSync > localMod)
1497 return 0; 1497 return 0;
1498 if ( lastSync > remoteMod ) 1498 if ( lastSync > remoteMod )
1499 return 1; 1499 return 1;
1500 if ( lastSync > localMod ) 1500 if ( lastSync > localMod )
1501 return 2; 1501 return 2;
1502 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1502 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1503 localIsNew = localMod >= remoteMod; 1503 localIsNew = localMod >= remoteMod;
1504 if ( localIsNew ) 1504 if ( localIsNew )
1505 getEventViewerDialog()->setColorMode( 1 ); 1505 getEventViewerDialog()->setColorMode( 1 );
1506 else 1506 else
1507 getEventViewerDialog()->setColorMode( 2 ); 1507 getEventViewerDialog()->setColorMode( 2 );
1508 getEventViewerDialog()->setIncidence(local); 1508 getEventViewerDialog()->setIncidence(local);
1509 if ( localIsNew ) 1509 if ( localIsNew )
1510 getEventViewerDialog()->setColorMode( 2 ); 1510 getEventViewerDialog()->setColorMode( 2 );
1511 else 1511 else
1512 getEventViewerDialog()->setColorMode( 1 ); 1512 getEventViewerDialog()->setColorMode( 1 );
1513 getEventViewerDialog()->addIncidence(remote); 1513 getEventViewerDialog()->addIncidence(remote);
1514 getEventViewerDialog()->setColorMode( 0 ); 1514 getEventViewerDialog()->setColorMode( 0 );
1515 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1515 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1516 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1516 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1517 getEventViewerDialog()->showMe(); 1517 getEventViewerDialog()->showMe();
1518 result = getEventViewerDialog()->executeS( localIsNew ); 1518 result = getEventViewerDialog()->executeS( localIsNew );
1519 return result; 1519 return result;
1520 1520
1521 break; 1521 break;
1522 case SYNC_PREF_FORCE_LOCAL: 1522 case SYNC_PREF_FORCE_LOCAL:
1523 return 1; 1523 return 1;
1524 break; 1524 break;
1525 case SYNC_PREF_FORCE_REMOTE: 1525 case SYNC_PREF_FORCE_REMOTE:
1526 return 2; 1526 return 2;
1527 break; 1527 break;
1528 1528
1529 default: 1529 default:
1530 // SYNC_PREF_TAKE_BOTH not implemented 1530 // SYNC_PREF_TAKE_BOTH not implemented
1531 break; 1531 break;
1532 } 1532 }
1533 return 0; 1533 return 0;
1534} 1534}
1535Event* CalendarView::getLastSyncEvent() 1535Event* CalendarView::getLastSyncEvent()
1536{ 1536{
1537 Event* lse; 1537 Event* lse;
1538 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1538 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1539 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1539 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1540 if (!lse) { 1540 if (!lse) {
1541 lse = new Event(); 1541 lse = new Event();
1542 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1542 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1543 QString sum = ""; 1543 QString sum = "";
1544 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1544 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1545 sum = "E: "; 1545 sum = "E: ";
1546 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1546 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1547 lse->setDtStart( mLastCalendarSync ); 1547 lse->setDtStart( mLastCalendarSync );
1548 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1548 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1549 lse->setCategories( i18n("SyncEvent") ); 1549 lse->setCategories( i18n("SyncEvent") );
1550 lse->setReadOnly( true ); 1550 lse->setReadOnly( true );
1551 mCalendar->addEvent( lse ); 1551 mCalendar->addEvent( lse );
1552 } 1552 }
1553 1553
1554 return lse; 1554 return lse;
1555 1555
1556} 1556}
1557 1557
1558// we check, if the to delete event has a id for a profile 1558// we check, if the to delete event has a id for a profile
1559// if yes, we set this id in the profile to delete 1559// if yes, we set this id in the profile to delete
1560void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1560void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1561{ 1561{
1562 if ( lastSync.count() == 0 ) { 1562 if ( lastSync.count() == 0 ) {
1563 //qDebug(" lastSync.count() == 0"); 1563 //qDebug(" lastSync.count() == 0");
1564 return; 1564 return;
1565 } 1565 }
1566 if ( toDelete->typeID() == journalID ) 1566 if ( toDelete->typeID() == journalID )
1567 return; 1567 return;
1568 1568
1569 Event* eve = lastSync.first(); 1569 Event* eve = lastSync.first();
1570 1570
1571 while ( eve ) { 1571 while ( eve ) {
1572 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1572 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1573 if ( !id.isEmpty() ) { 1573 if ( !id.isEmpty() ) {
1574 QString des = eve->description(); 1574 QString des = eve->description();
1575 QString pref = "e"; 1575 QString pref = "e";
1576 if ( toDelete->typeID() == todoID ) 1576 if ( toDelete->typeID() == todoID )
1577 pref = "t"; 1577 pref = "t";
1578 des += pref+ id + ","; 1578 des += pref+ id + ",";
1579 eve->setReadOnly( false ); 1579 eve->setReadOnly( false );
1580 eve->setDescription( des ); 1580 eve->setDescription( des );
1581 //qDebug("setdes %s ", des.latin1()); 1581 //qDebug("setdes %s ", des.latin1());
1582 eve->setReadOnly( true ); 1582 eve->setReadOnly( true );
1583 } 1583 }
1584 eve = lastSync.next(); 1584 eve = lastSync.next();
1585 } 1585 }
1586 1586
1587} 1587}
1588void CalendarView::checkExternalId( Incidence * inc ) 1588void CalendarView::checkExternalId( Incidence * inc )
1589{ 1589{
1590 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1590 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1591 checkExternSyncEvent( lastSync, inc ); 1591 checkExternSyncEvent( lastSync, inc );
1592 1592
1593} 1593}
1594bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1594bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1595{ 1595{
1596 bool syncOK = true; 1596 bool syncOK = true;
1597 int addedEvent = 0; 1597 int addedEvent = 0;
1598 int addedEventR = 0; 1598 int addedEventR = 0;
1599 int deletedEventR = 0; 1599 int deletedEventR = 0;
1600 int deletedEventL = 0; 1600 int deletedEventL = 0;
1601 int changedLocal = 0; 1601 int changedLocal = 0;
1602 int changedRemote = 0; 1602 int changedRemote = 0;
1603 int filteredIN = 0; 1603 int filteredIN = 0;
1604 int filteredOUT = 0; 1604 int filteredOUT = 0;
1605 //QPtrList<Event> el = local->rawEvents(); 1605 //QPtrList<Event> el = local->rawEvents();
1606 Event* eventR; 1606 Event* eventR;
@@ -1766,1548 +1766,1558 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1766 inR->setLastModified( modifiedCalendar ); 1766 inR->setLastModified( modifiedCalendar );
1767 inL = inR->clone(); 1767 inL = inR->clone();
1768 inL->setIDStr( ":" ); 1768 inL->setIDStr( ":" );
1769 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1769 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1770 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1770 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1771 1771
1772 inL->setCalID( 0 );// add to default cal 1772 inL->setCalID( 0 );// add to default cal
1773 local->addIncidence( inL ); 1773 local->addIncidence( inL );
1774 ++addedEvent; 1774 ++addedEvent;
1775 1775
1776 } 1776 }
1777 } else { 1777 } else {
1778 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1778 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1779 inR->setLastModified( modifiedCalendar ); 1779 inR->setLastModified( modifiedCalendar );
1780 inL = inR->clone(); 1780 inL = inR->clone();
1781 inL->setIDStr( ":" ); 1781 inL->setIDStr( ":" );
1782 inL->setCalID( 0 );// add to default cal 1782 inL->setCalID( 0 );// add to default cal
1783 local->addIncidence( inL ); 1783 local->addIncidence( inL );
1784 ++addedEvent; 1784 ++addedEvent;
1785 1785
1786 } else { 1786 } else {
1787 checkExternSyncEvent(eventRSyncSharp, inR); 1787 checkExternSyncEvent(eventRSyncSharp, inR);
1788 remote->deleteIncidence( inR ); 1788 remote->deleteIncidence( inR );
1789 ++deletedEventR; 1789 ++deletedEventR;
1790 } 1790 }
1791 } 1791 }
1792 } else { 1792 } else {
1793 ++filteredIN; 1793 ++filteredIN;
1794 } 1794 }
1795 } 1795 }
1796 } 1796 }
1797 inR = er.next(); 1797 inR = er.next();
1798 } 1798 }
1799 QPtrList<Incidence> el = local->rawIncidences(); 1799 QPtrList<Incidence> el = local->rawIncidences();
1800 inL = el.first(); 1800 inL = el.first();
1801 modulo = (el.count()/10)+1; 1801 modulo = (el.count()/10)+1;
1802 bar.setCaption (i18n("Add / remove events") ); 1802 bar.setCaption (i18n("Add / remove events") );
1803 bar.setTotalSteps ( el.count() ) ; 1803 bar.setTotalSteps ( el.count() ) ;
1804 bar.show(); 1804 bar.show();
1805 incCounter = 0; 1805 incCounter = 0;
1806 1806
1807 while ( inL ) { 1807 while ( inL ) {
1808 1808
1809 qApp->processEvents(); 1809 qApp->processEvents();
1810 if ( ! bar.isVisible() ) 1810 if ( ! bar.isVisible() )
1811 return false; 1811 return false;
1812 if ( incCounter % modulo == 0 ) 1812 if ( incCounter % modulo == 0 )
1813 bar.setProgress( incCounter ); 1813 bar.setProgress( incCounter );
1814 ++incCounter; 1814 ++incCounter;
1815 uid = inL->uid(); 1815 uid = inL->uid();
1816 bool skipIncidence = false; 1816 bool skipIncidence = false;
1817 if ( uid.left(15) == QString("last-syncEvent-") ) 1817 if ( uid.left(15) == QString("last-syncEvent-") )
1818 skipIncidence = true; 1818 skipIncidence = true;
1819 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1819 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1820 skipIncidence = true; 1820 skipIncidence = true;
1821 if ( !skipIncidence ) { 1821 if ( !skipIncidence ) {
1822 inR = remote->incidenceForUid( uid , true ); 1822 inR = remote->incidenceForUid( uid , true );
1823 if ( ! inR ) { 1823 if ( ! inR ) {
1824 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1824 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1825 // no conflict ********** add or delete local 1825 // no conflict ********** add or delete local
1826 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1826 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1827 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1827 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1828 checkExternSyncEvent(eventLSyncSharp, inL); 1828 checkExternSyncEvent(eventLSyncSharp, inL);
1829 local->deleteIncidence( inL ); 1829 local->deleteIncidence( inL );
1830 ++deletedEventL; 1830 ++deletedEventL;
1831 } else { 1831 } else {
1832 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1832 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1833 inL->removeID(mCurrentSyncDevice ); 1833 inL->removeID(mCurrentSyncDevice );
1834 ++addedEventR; 1834 ++addedEventR;
1835 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1835 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1836 inL->setLastModified( modifiedCalendar ); 1836 inL->setLastModified( modifiedCalendar );
1837 inR = inL->clone(); 1837 inR = inL->clone();
1838 inR->setIDStr( ":" ); 1838 inR->setIDStr( ":" );
1839 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1839 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1840 inR->setCalID( 0 );// add to default cal 1840 inR->setCalID( 0 );// add to default cal
1841 remote->addIncidence( inR ); 1841 remote->addIncidence( inR );
1842 } 1842 }
1843 } 1843 }
1844 } else { 1844 } else {
1845 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1845 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1846 checkExternSyncEvent(eventLSyncSharp, inL); 1846 checkExternSyncEvent(eventLSyncSharp, inL);
1847 local->deleteIncidence( inL ); 1847 local->deleteIncidence( inL );
1848 ++deletedEventL; 1848 ++deletedEventL;
1849 } else { 1849 } else {
1850 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1850 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1851 ++addedEventR; 1851 ++addedEventR;
1852 inL->setLastModified( modifiedCalendar ); 1852 inL->setLastModified( modifiedCalendar );
1853 inR = inL->clone(); 1853 inR = inL->clone();
1854 inR->setIDStr( ":" ); 1854 inR->setIDStr( ":" );
1855 inR->setCalID( 0 );// add to default cal 1855 inR->setCalID( 0 );// add to default cal
1856 remote->addIncidence( inR ); 1856 remote->addIncidence( inR );
1857 } 1857 }
1858 } 1858 }
1859 } 1859 }
1860 } else { 1860 } else {
1861 ++filteredOUT; 1861 ++filteredOUT;
1862 } 1862 }
1863 } 1863 }
1864 } 1864 }
1865 inL = el.next(); 1865 inL = el.next();
1866 } 1866 }
1867 int delFut = 0; 1867 int delFut = 0;
1868 int remRem = 0; 1868 int remRem = 0;
1869 if ( mSyncManager->mWriteBackInFuture ) { 1869 if ( mSyncManager->mWriteBackInFuture ) {
1870 er = remote->rawIncidences(); 1870 er = remote->rawIncidences();
1871 remRem = er.count(); 1871 remRem = er.count();
1872 inR = er.first(); 1872 inR = er.first();
1873 QDateTime dt; 1873 QDateTime dt;
1874 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1874 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1875 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1875 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1876 while ( inR ) { 1876 while ( inR ) {
1877 if ( inR->typeID() == todoID ) { 1877 if ( inR->typeID() == todoID ) {
1878 Todo * t = (Todo*)inR; 1878 Todo * t = (Todo*)inR;
1879 if ( t->hasDueDate() ) 1879 if ( t->hasDueDate() )
1880 dt = t->dtDue(); 1880 dt = t->dtDue();
1881 else 1881 else
1882 dt = cur.addSecs( 62 ); 1882 dt = cur.addSecs( 62 );
1883 } 1883 }
1884 else if (inR->typeID() == eventID ) { 1884 else if (inR->typeID() == eventID ) {
1885 bool ok; 1885 bool ok;
1886 dt = inR->getNextOccurence( cur, &ok ); 1886 dt = inR->getNextOccurence( cur, &ok );
1887 if ( !ok ) 1887 if ( !ok )
1888 dt = cur.addSecs( -62 ); 1888 dt = cur.addSecs( -62 );
1889 } 1889 }
1890 else 1890 else
1891 dt = inR->dtStart(); 1891 dt = inR->dtStart();
1892 if ( dt < cur || dt > end ) { 1892 if ( dt < cur || dt > end ) {
1893 remote->deleteIncidence( inR ); 1893 remote->deleteIncidence( inR );
1894 ++delFut; 1894 ++delFut;
1895 } 1895 }
1896 inR = er.next(); 1896 inR = er.next();
1897 } 1897 }
1898 } 1898 }
1899 bar.hide(); 1899 bar.hide();
1900 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1900 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1901 eventLSync->setReadOnly( false ); 1901 eventLSync->setReadOnly( false );
1902 eventLSync->setDtStart( mLastCalendarSync ); 1902 eventLSync->setDtStart( mLastCalendarSync );
1903 eventRSync->setDtStart( mLastCalendarSync ); 1903 eventRSync->setDtStart( mLastCalendarSync );
1904 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1904 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1905 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1905 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1906 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1906 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1907 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1907 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1908 eventLSync->setReadOnly( true ); 1908 eventLSync->setReadOnly( true );
1909 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1909 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1910 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1910 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1911 remote->addEvent( eventRSync ); 1911 remote->addEvent( eventRSync );
1912 else 1912 else
1913 delete eventRSync; 1913 delete eventRSync;
1914 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1914 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1915 QString mes; 1915 QString mes;
1916 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\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1916 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\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1917 QString delmess; 1917 QString delmess;
1918 if ( delFut ) { 1918 if ( delFut ) {
1919 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1919 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1920 mes += delmess; 1920 mes += delmess;
1921 } 1921 }
1922 mes = i18n("Local calendar changed!\n") +mes; 1922 mes = i18n("Local calendar changed!\n") +mes;
1923 mCalendar->checkAlarmForIncidence( 0, true ); 1923 mCalendar->checkAlarmForIncidence( 0, true );
1924 qDebug( mes ); 1924 qDebug( mes );
1925 if ( mSyncManager->mShowSyncSummary ) { 1925 if ( mSyncManager->mShowSyncSummary ) {
1926 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1926 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1927 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1927 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1928 qDebug("KO: WB cancelled "); 1928 qDebug("KO: WB cancelled ");
1929 mSyncManager->mWriteBackFile = false; 1929 mSyncManager->mWriteBackFile = false;
1930 return syncOK; 1930 return syncOK;
1931 } 1931 }
1932 } 1932 }
1933 return syncOK; 1933 return syncOK;
1934} 1934}
1935 1935
1936void CalendarView::setSyncDevice( QString s ) 1936void CalendarView::setSyncDevice( QString s )
1937{ 1937{
1938 mCurrentSyncDevice= s; 1938 mCurrentSyncDevice= s;
1939} 1939}
1940void CalendarView::setSyncName( QString s ) 1940void CalendarView::setSyncName( QString s )
1941{ 1941{
1942 mCurrentSyncName= s; 1942 mCurrentSyncName= s;
1943} 1943}
1944bool CalendarView::syncCalendar(QString filename, int mode) 1944bool CalendarView::syncCalendar(QString filename, int mode)
1945{ 1945{
1946 //qDebug("syncCalendar %s ", filename.latin1()); 1946 //qDebug("syncCalendar %s ", filename.latin1());
1947 mGlobalSyncMode = SYNC_MODE_NORMAL; 1947 mGlobalSyncMode = SYNC_MODE_NORMAL;
1948 CalendarLocal* calendar = new CalendarLocal(); 1948 CalendarLocal* calendar = new CalendarLocal();
1949 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1949 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1950 FileStorage* storage = new FileStorage( calendar ); 1950 FileStorage* storage = new FileStorage( calendar );
1951 bool syncOK = false; 1951 bool syncOK = false;
1952 storage->setFileName( filename ); 1952 storage->setFileName( filename );
1953 // qDebug("loading ... "); 1953 // qDebug("loading ... ");
1954 if ( storage->load() ) { 1954 if ( storage->load() ) {
1955 getEventViewerDialog()->setSyncMode( true ); 1955 getEventViewerDialog()->setSyncMode( true );
1956 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1956 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1957 getEventViewerDialog()->setSyncMode( false ); 1957 getEventViewerDialog()->setSyncMode( false );
1958 if ( syncOK ) { 1958 if ( syncOK ) {
1959 if ( mSyncManager->mWriteBackFile ) 1959 if ( mSyncManager->mWriteBackFile )
1960 { 1960 {
1961 storage->setSaveFormat( new ICalFormat() ); 1961 storage->setSaveFormat( new ICalFormat() );
1962 storage->save(); 1962 storage->save();
1963 } 1963 }
1964 } 1964 }
1965 setModified( true ); 1965 setModified( true );
1966 } 1966 }
1967 delete storage; 1967 delete storage;
1968 delete calendar; 1968 delete calendar;
1969 if ( syncOK ) 1969 if ( syncOK )
1970 updateView(); 1970 updateView();
1971 return syncOK; 1971 return syncOK;
1972} 1972}
1973 1973
1974void CalendarView::syncExternal( int mode ) 1974void CalendarView::syncExternal( int mode )
1975{ 1975{
1976 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1976 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1977 1977
1978 qApp->processEvents(); 1978 qApp->processEvents();
1979 CalendarLocal* calendar = new CalendarLocal(); 1979 CalendarLocal* calendar = new CalendarLocal();
1980 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1980 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1981 bool syncOK = false; 1981 bool syncOK = false;
1982 bool loadSuccess = false; 1982 bool loadSuccess = false;
1983 PhoneFormat* phoneFormat = 0; 1983 PhoneFormat* phoneFormat = 0;
1984 emit tempDisableBR(true); 1984 emit tempDisableBR(true);
1985#ifndef DESKTOP_VERSION 1985#ifndef DESKTOP_VERSION
1986 SharpFormat* sharpFormat = 0; 1986 SharpFormat* sharpFormat = 0;
1987 if ( mode == 0 ) { // sharp 1987 if ( mode == 0 ) { // sharp
1988 sharpFormat = new SharpFormat () ; 1988 sharpFormat = new SharpFormat () ;
1989 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1989 loadSuccess = sharpFormat->load( calendar, mCalendar );
1990 1990
1991 } else 1991 } else
1992#endif 1992#endif
1993 if ( mode == 1 ) { // phone 1993 if ( mode == 1 ) { // phone
1994 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1994 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1995 mSyncManager->mPhoneDevice, 1995 mSyncManager->mPhoneDevice,
1996 mSyncManager->mPhoneConnection, 1996 mSyncManager->mPhoneConnection,
1997 mSyncManager->mPhoneModel); 1997 mSyncManager->mPhoneModel);
1998 loadSuccess = phoneFormat->load( calendar,mCalendar); 1998 loadSuccess = phoneFormat->load( calendar,mCalendar);
1999 1999
2000 } else { 2000 } else {
2001 emit tempDisableBR(false); 2001 emit tempDisableBR(false);
2002 return; 2002 return;
2003 } 2003 }
2004 if ( loadSuccess ) { 2004 if ( loadSuccess ) {
2005 getEventViewerDialog()->setSyncMode( true ); 2005 getEventViewerDialog()->setSyncMode( true );
2006 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2006 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2007 getEventViewerDialog()->setSyncMode( false ); 2007 getEventViewerDialog()->setSyncMode( false );
2008 qApp->processEvents(); 2008 qApp->processEvents();
2009 if ( syncOK ) { 2009 if ( syncOK ) {
2010 if ( mSyncManager->mWriteBackFile ) 2010 if ( mSyncManager->mWriteBackFile )
2011 { 2011 {
2012 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2012 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2013 Incidence* inc = iL.first(); 2013 Incidence* inc = iL.first();
2014 if ( phoneFormat ) { 2014 if ( phoneFormat ) {
2015 while ( inc ) { 2015 while ( inc ) {
2016 inc->removeID(mCurrentSyncDevice); 2016 inc->removeID(mCurrentSyncDevice);
2017 inc = iL.next(); 2017 inc = iL.next();
2018 } 2018 }
2019 } 2019 }
2020#ifndef DESKTOP_VERSION 2020#ifndef DESKTOP_VERSION
2021 if ( sharpFormat ) 2021 if ( sharpFormat )
2022 sharpFormat->save(calendar); 2022 sharpFormat->save(calendar);
2023#endif 2023#endif
2024 if ( phoneFormat ) 2024 if ( phoneFormat )
2025 phoneFormat->save(calendar); 2025 phoneFormat->save(calendar);
2026 iL = calendar->rawIncidences(); 2026 iL = calendar->rawIncidences();
2027 inc = iL.first(); 2027 inc = iL.first();
2028 Incidence* loc; 2028 Incidence* loc;
2029 while ( inc ) { 2029 while ( inc ) {
2030 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2030 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2031 loc = mCalendar->incidence(inc->uid() ); 2031 loc = mCalendar->incidence(inc->uid() );
2032 if ( loc ) { 2032 if ( loc ) {
2033 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2033 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2034 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2034 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2035 } 2035 }
2036 } 2036 }
2037 inc = iL.next(); 2037 inc = iL.next();
2038 } 2038 }
2039 Incidence* lse = getLastSyncEvent(); 2039 Incidence* lse = getLastSyncEvent();
2040 if ( lse ) { 2040 if ( lse ) {
2041 lse->setReadOnly( false ); 2041 lse->setReadOnly( false );
2042 lse->setDescription( "" ); 2042 lse->setDescription( "" );
2043 lse->setReadOnly( true ); 2043 lse->setReadOnly( true );
2044 } 2044 }
2045 } 2045 }
2046 } else { 2046 } else {
2047 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2047 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2048 } 2048 }
2049 setModified( true ); 2049 setModified( true );
2050 } else { 2050 } else {
2051 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2051 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2052 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2052 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2053 question, i18n("Ok")) ; 2053 question, i18n("Ok")) ;
2054 2054
2055 } 2055 }
2056 delete calendar; 2056 delete calendar;
2057 updateView(); 2057 updateView();
2058 emit tempDisableBR(false); 2058 emit tempDisableBR(false);
2059 return ;//syncOK; 2059 return ;//syncOK;
2060 2060
2061} 2061}
2062 2062
2063bool CalendarView::importBday() 2063bool CalendarView::importBday()
2064{ 2064{
2065#ifndef KORG_NOKABC 2065#ifndef KORG_NOKABC
2066 2066
2067#ifdef DESKTOP_VERSION 2067#ifdef DESKTOP_VERSION
2068 int curCal = mCalendar->defaultCalendar(); 2068 int curCal = mCalendar->defaultCalendar();
2069 int bd = mCalEditView->getBirtdayID(); 2069 int bd = mCalEditView->getBirtdayID();
2070 if ( bd == 0 ) 2070 if ( bd == 0 )
2071 return false; 2071 return false;
2072 mCalendar->setDefaultCalendar( bd ); 2072 mCalendar->setDefaultCalendar( bd );
2073 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2073 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2074 KABC::AddressBook::Iterator it; 2074 KABC::AddressBook::Iterator it;
2075 int count = 0; 2075 int count = 0;
2076 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2076 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2077 ++count; 2077 ++count;
2078 } 2078 }
2079 QProgressBar bar(count,0 ); 2079 QProgressBar bar(count,0 );
2080 int w = 300; 2080 int w = 300;
2081 if ( QApplication::desktop()->width() < 320 ) 2081 if ( QApplication::desktop()->width() < 320 )
2082 w = 220; 2082 w = 220;
2083 int h = bar.sizeHint().height() ; 2083 int h = bar.sizeHint().height() ;
2084 int dw = QApplication::desktop()->width(); 2084 int dw = QApplication::desktop()->width();
2085 int dh = QApplication::desktop()->height(); 2085 int dh = QApplication::desktop()->height();
2086 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2086 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2087 bar.show(); 2087 bar.show();
2088 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2088 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2089 qApp->processEvents(); 2089 qApp->processEvents();
2090 count = 0; 2090 count = 0;
2091 int addCount = 0; 2091 int addCount = 0;
2092 KCal::Attendee* a = 0; 2092 KCal::Attendee* a = 0;
2093 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2093 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2094 if ( ! bar.isVisible() ) 2094 if ( ! bar.isVisible() )
2095 return false; 2095 return false;
2096 bar.setProgress( count++ ); 2096 bar.setProgress( count++ );
2097 qApp->processEvents(); 2097 qApp->processEvents();
2098 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2098 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2099 if ( (*it).birthday().date().isValid() ){ 2099 if ( (*it).birthday().date().isValid() ){
2100 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2100 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2101 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2101 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2102 ++addCount; 2102 ++addCount;
2103 } 2103 }
2104 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2104 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2105 if ( anni.isValid() ){ 2105 if ( anni.isValid() ){
2106 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2106 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2107 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2107 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2108 ++addCount; 2108 ++addCount;
2109 } 2109 }
2110 } 2110 }
2111 mCalendar->setDefaultCalendar( curCal ); 2111 mCalendar->setDefaultCalendar( curCal );
2112 updateView(); 2112 updateView();
2113 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2113 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2114#else //DESKTOP_VERSION 2114#else //DESKTOP_VERSION
2115 2115
2116 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2116 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2117 // the result should now arrive through method insertBirthdays 2117 // the result should now arrive through method insertBirthdays
2118 2118
2119#endif //DESKTOP_VERSION 2119#endif //DESKTOP_VERSION
2120 2120
2121#endif //KORG_NOKABC 2121#endif //KORG_NOKABC
2122 2122
2123 2123
2124 return true; 2124 return true;
2125} 2125}
2126 2126
2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2129 const QStringList& anniversaryList, const QStringList& realNameList, 2129 const QStringList& anniversaryList, const QStringList& realNameList,
2130 const QStringList& emailList, const QStringList& assembledNameList, 2130 const QStringList& emailList, const QStringList& assembledNameList,
2131 const QStringList& uidList) 2131 const QStringList& uidList)
2132{ 2132{
2133 2133
2134 //qDebug("KO::CalendarView::insertBirthdays"); 2134 //qDebug("KO::CalendarView::insertBirthdays");
2135 if (uid == this->name()) 2135 if (uid == this->name())
2136 { 2136 {
2137 int curCal = mCalendar->defaultCalendar(); 2137 int curCal = mCalendar->defaultCalendar();
2138 int bd = mCalEditView->getBirtdayID(); 2138 int bd = mCalEditView->getBirtdayID();
2139 if ( bd == 0 ) 2139 if ( bd == 0 )
2140 return; 2140 return;
2141 mCalendar->setDefaultCalendar( bd ); 2141 mCalendar->setDefaultCalendar( bd );
2142 2142
2143 2143
2144 int count = birthdayList.count(); 2144 int count = birthdayList.count();
2145 int addCount = 0; 2145 int addCount = 0;
2146 KCal::Attendee* a = 0; 2146 KCal::Attendee* a = 0;
2147 2147
2148 //qDebug("CalView 1 %i", count); 2148 //qDebug("CalView 1 %i", count);
2149 2149
2150 QProgressBar bar(count,0 ); 2150 QProgressBar bar(count,0 );
2151 int w = 300; 2151 int w = 300;
2152 if ( QApplication::desktop()->width() < 320 ) 2152 if ( QApplication::desktop()->width() < 320 )
2153 w = 220; 2153 w = 220;
2154 int h = bar.sizeHint().height() ; 2154 int h = bar.sizeHint().height() ;
2155 int dw = QApplication::desktop()->width(); 2155 int dw = QApplication::desktop()->width();
2156 int dh = QApplication::desktop()->height(); 2156 int dh = QApplication::desktop()->height();
2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2158 bar.show(); 2158 bar.show();
2159 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2159 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2160 qApp->processEvents(); 2160 qApp->processEvents();
2161 2161
2162 QDate birthday; 2162 QDate birthday;
2163 QDate anniversary; 2163 QDate anniversary;
2164 QString realName; 2164 QString realName;
2165 QString email; 2165 QString email;
2166 QString assembledName; 2166 QString assembledName;
2167 QString uid; 2167 QString uid;
2168 bool ok = true; 2168 bool ok = true;
2169 for ( int i = 0; i < count; i++) 2169 for ( int i = 0; i < count; i++)
2170 { 2170 {
2171 if ( ! bar.isVisible() ) 2171 if ( ! bar.isVisible() )
2172 return; 2172 return;
2173 bar.setProgress( i ); 2173 bar.setProgress( i );
2174 qApp->processEvents(); 2174 qApp->processEvents();
2175 2175
2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2177 if (!ok) { 2177 if (!ok) {
2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2179 } 2179 }
2180 2180
2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2182 if (!ok) { 2182 if (!ok) {
2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2184 } 2184 }
2185 realName = realNameList[i]; 2185 realName = realNameList[i];
2186 email = emailList[i]; 2186 email = emailList[i];
2187 assembledName = assembledNameList[i]; 2187 assembledName = assembledNameList[i];
2188 uid = uidList[i]; 2188 uid = uidList[i];
2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
2190 2190
2191 if ( birthday.isValid() ){ 2191 if ( birthday.isValid() ){
2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2193 KCal::Attendee::ReqParticipant,uid) ; 2193 KCal::Attendee::ReqParticipant,uid) ;
2194 if ( addAnniversary( birthday, assembledName, a, true ) ) 2194 if ( addAnniversary( birthday, assembledName, a, true ) )
2195 ++addCount; 2195 ++addCount;
2196 } 2196 }
2197 2197
2198 if ( anniversary.isValid() ){ 2198 if ( anniversary.isValid() ){
2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2200 KCal::Attendee::ReqParticipant,uid) ; 2200 KCal::Attendee::ReqParticipant,uid) ;
2201 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2201 if ( addAnniversary( anniversary, assembledName, a, false ) )
2202 ++addCount; 2202 ++addCount;
2203 } 2203 }
2204 } 2204 }
2205 2205
2206 mCalendar->setDefaultCalendar( curCal ); 2206 mCalendar->setDefaultCalendar( curCal );
2207 updateView(); 2207 updateView();
2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2209 2209
2210 } 2210 }
2211 2211
2212} 2212}
2213 2213
2214 2214
2215 2215
2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2217{ 2217{
2218 //qDebug("addAnni "); 2218 //qDebug("addAnni ");
2219 Event * ev = new Event(); 2219 Event * ev = new Event();
2220 ev->setOrganizer(KOPrefs::instance()->email()); 2220 ev->setOrganizer(KOPrefs::instance()->email());
2221 if ( a ) { 2221 if ( a ) {
2222 ev->addAttendee( a ); 2222 ev->addAttendee( a );
2223 } 2223 }
2224 QString kind; 2224 QString kind;
2225 if ( birthday ) { 2225 if ( birthday ) {
2226 kind = i18n( "Birthday" ); 2226 kind = i18n( "Birthday" );
2227 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2227 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2228 } 2228 }
2229 else { 2229 else {
2230 kind = i18n( "Anniversary" ); 2230 kind = i18n( "Anniversary" );
2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2232 } 2232 }
2233 ev->setCategories( kind ); 2233 ev->setCategories( kind );
2234 ev->setDtStart( QDateTime(date) ); 2234 ev->setDtStart( QDateTime(date) );
2235 ev->setDtEnd( QDateTime(date) ); 2235 ev->setDtEnd( QDateTime(date) );
2236 ev->setFloats( true ); 2236 ev->setFloats( true );
2237 Recurrence * rec = ev->recurrence(); 2237 Recurrence * rec = ev->recurrence();
2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2239 rec->addYearlyNum( date.month() ); 2239 rec->addYearlyNum( date.month() );
2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2241 delete ev; 2241 delete ev;
2242 return false; 2242 return false;
2243 } 2243 }
2244 return true; 2244 return true;
2245 2245
2246} 2246}
2247bool CalendarView::importQtopia( const QString &categories, 2247bool CalendarView::importQtopia( const QString &categories,
2248 const QString &datebook, 2248 const QString &datebook,
2249 const QString &todolist ) 2249 const QString &todolist )
2250{ 2250{
2251 2251
2252 QtopiaFormat qtopiaFormat; 2252 QtopiaFormat qtopiaFormat;
2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2257 2257
2258 updateView(); 2258 updateView();
2259 return true; 2259 return true;
2260 2260
2261#if 0 2261#if 0
2262 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2262 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2263 mCurrentSyncDevice = "qtopia-XML"; 2263 mCurrentSyncDevice = "qtopia-XML";
2264 if ( mSyncManager->mAskForPreferences ) 2264 if ( mSyncManager->mAskForPreferences )
2265 edit_sync_options(); 2265 edit_sync_options();
2266 qApp->processEvents(); 2266 qApp->processEvents();
2267 CalendarLocal* calendar = new CalendarLocal(); 2267 CalendarLocal* calendar = new CalendarLocal();
2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2269 bool syncOK = false; 2269 bool syncOK = false;
2270 QtopiaFormat qtopiaFormat; 2270 QtopiaFormat qtopiaFormat;
2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2272 bool loadOk = true; 2272 bool loadOk = true;
2273 if ( !categories.isEmpty() ) 2273 if ( !categories.isEmpty() )
2274 loadOk = qtopiaFormat.load( calendar, categories ); 2274 loadOk = qtopiaFormat.load( calendar, categories );
2275 if ( loadOk && !datebook.isEmpty() ) 2275 if ( loadOk && !datebook.isEmpty() )
2276 loadOk = qtopiaFormat.load( calendar, datebook ); 2276 loadOk = qtopiaFormat.load( calendar, datebook );
2277 if ( loadOk && !todolist.isEmpty() ) 2277 if ( loadOk && !todolist.isEmpty() )
2278 loadOk = qtopiaFormat.load( calendar, todolist ); 2278 loadOk = qtopiaFormat.load( calendar, todolist );
2279 2279
2280 if ( loadOk ) { 2280 if ( loadOk ) {
2281 getEventViewerDialog()->setSyncMode( true ); 2281 getEventViewerDialog()->setSyncMode( true );
2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2283 getEventViewerDialog()->setSyncMode( false ); 2283 getEventViewerDialog()->setSyncMode( false );
2284 qApp->processEvents(); 2284 qApp->processEvents();
2285 if ( syncOK ) { 2285 if ( syncOK ) {
2286 if ( mSyncManager->mWriteBackFile ) 2286 if ( mSyncManager->mWriteBackFile )
2287 { 2287 {
2288 // write back XML file 2288 // write back XML file
2289 2289
2290 } 2290 }
2291 setModified( true ); 2291 setModified( true );
2292 } 2292 }
2293 } else { 2293 } else {
2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2296 question, i18n("Ok")) ; 2296 question, i18n("Ok")) ;
2297 } 2297 }
2298 delete calendar; 2298 delete calendar;
2299 updateView(); 2299 updateView();
2300 return syncOK; 2300 return syncOK;
2301 2301
2302 2302
2303#endif 2303#endif
2304 2304
2305} 2305}
2306 2306
2307void CalendarView::setSyncEventsReadOnly() 2307void CalendarView::setSyncEventsReadOnly()
2308{ 2308{
2309 mCalendar->setSyncEventsReadOnly(); 2309 mCalendar->setSyncEventsReadOnly();
2310} 2310}
2311 2311
2312bool CalendarView::loadCalendars() 2312bool CalendarView::loadCalendars()
2313{ 2313{
2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2315 KopiCalendarFile * cal = calendars.first(); 2315 KopiCalendarFile * cal = calendars.first();
2316 mCalendar->setDefaultCalendar( 1 ); 2316 mCalendar->setDefaultCalendar( 1 );
2317 openCalendar( MainWindow::defaultFileName(), false ); 2317 openCalendar( MainWindow::defaultFileName(), false );
2318 cal = calendars.next(); 2318 cal = calendars.next();
2319 while ( cal ) { 2319 while ( cal ) {
2320 addCalendar( cal ); 2320 addCalendar( cal );
2321 cal = calendars.next(); 2321 cal = calendars.next();
2322 } 2322 }
2323 restoreCalendarSettings(); 2323 restoreCalendarSettings();
2324 return true; 2324 return true;
2325} 2325}
2326bool CalendarView::restoreCalendarSettings() 2326bool CalendarView::restoreCalendarSettings()
2327{ 2327{
2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2329 KopiCalendarFile * cal = calendars.first(); 2329 KopiCalendarFile * cal = calendars.first();
2330 while ( cal ) { 2330 while ( cal ) {
2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2334 if ( cal->isStandard ) 2334 if ( cal->isStandard )
2335 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2335 mCalendar->setDefaultCalendar( cal->mCalNumber );
2336 cal = calendars.next(); 2336 cal = calendars.next();
2337 } 2337 }
2338 setSyncEventsReadOnly(); 2338 setSyncEventsReadOnly();
2339 mCalendar->reInitAlarmSettings(); 2339 mCalendar->reInitAlarmSettings();
2340 updateUnmanagedViews(); 2340 updateUnmanagedViews();
2341 updateView(); 2341 updateView();
2342 return true; 2342 return true;
2343} 2343}
2344void CalendarView::addCalendarId( int id ) 2344void CalendarView::addCalendarId( int id )
2345{ 2345{
2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2347 if ( cal ) 2347 if ( cal )
2348 addCalendar( cal ); 2348 addCalendar( cal );
2349} 2349}
2350bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2350bool CalendarView::addCalendar( KopiCalendarFile * cal )
2351{ 2351{
2352 cal->mErrorOnLoad = false; 2352 cal->mErrorOnLoad = false;
2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2354 cal->mLoadDt = QDateTime::currentDateTime(); 2354 cal->mLoadDt = QDateTime::currentDateTime();
2355 return true; 2355 return true;
2356 } 2356 }
2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2358 cal->mErrorOnLoad = true; 2358 cal->mErrorOnLoad = true;
2359 return false; 2359 return false;
2360} 2360}
2361bool CalendarView::openCalendar(QString filename, bool merge) 2361bool CalendarView::openCalendar(QString filename, bool merge)
2362{ 2362{
2363 2363
2364 if (filename.isEmpty()) { 2364 if (filename.isEmpty()) {
2365 return false; 2365 return false;
2366 } 2366 }
2367 2367
2368 if (!QFile::exists(filename)) { 2368 if (!QFile::exists(filename)) {
2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2370 return false; 2370 return false;
2371 } 2371 }
2372 2372
2373 globalFlagBlockAgenda = 1; 2373 globalFlagBlockAgenda = 1;
2374 clearAllViews(); 2374 clearAllViews();
2375 if (!merge) { 2375 if (!merge) {
2376 mViewManager->setDocumentId( filename ); 2376 mViewManager->setDocumentId( filename );
2377 mCalendar->close(); 2377 mCalendar->close();
2378 } 2378 }
2379 mStorage->setFileName( filename ); 2379 mStorage->setFileName( filename );
2380 2380
2381 if ( mStorage->load() ) { 2381 if ( mStorage->load() ) {
2382 if ( merge ) ;//setModified( true ); 2382 if ( merge ) ;//setModified( true );
2383 else { 2383 else {
2384 //setModified( true ); 2384 //setModified( true );
2385 mViewManager->setDocumentId( filename ); 2385 mViewManager->setDocumentId( filename );
2386 mDialogManager->setDocumentId( filename ); 2386 mDialogManager->setDocumentId( filename );
2387 mTodoList->setDocumentId( filename ); 2387 mTodoList->setDocumentId( filename );
2388 } 2388 }
2389 globalFlagBlockAgenda = 2; 2389 globalFlagBlockAgenda = 2;
2390 // if ( getLastSyncEvent() ) 2390 // if ( getLastSyncEvent() )
2391 // getLastSyncEvent()->setReadOnly( true ); 2391 // getLastSyncEvent()->setReadOnly( true );
2392 mCalendar->reInitAlarmSettings(); 2392 mCalendar->reInitAlarmSettings();
2393 setSyncEventsReadOnly(); 2393 setSyncEventsReadOnly();
2394 updateUnmanagedViews(); 2394 updateUnmanagedViews();
2395 updateView(); 2395 updateView();
2396 if ( filename != MainWindow::defaultFileName() ) { 2396 if ( filename != MainWindow::defaultFileName() ) {
2397 saveCalendar( MainWindow::defaultFileName() ); 2397 saveCalendar( MainWindow::defaultFileName() );
2398 } else { 2398 } else {
2399 QFileInfo finf ( MainWindow::defaultFileName()); 2399 QFileInfo finf ( MainWindow::defaultFileName());
2400 if ( finf.exists() ) { 2400 if ( finf.exists() ) {
2401 setLoadedFileVersion( finf.lastModified () ); 2401 setLoadedFileVersion( finf.lastModified () );
2402 } 2402 }
2403 } 2403 }
2404 return true; 2404 return true;
2405 } else { 2405 } else {
2406 // while failing to load, the calendar object could 2406 // while failing to load, the calendar object could
2407 // have become partially populated. Clear it out. 2407 // have become partially populated. Clear it out.
2408 if ( !merge ) { 2408 if ( !merge ) {
2409 mCalendar->close(); 2409 mCalendar->close();
2410 mViewManager->setDocumentId( filename ); 2410 mViewManager->setDocumentId( filename );
2411 mDialogManager->setDocumentId( filename ); 2411 mDialogManager->setDocumentId( filename );
2412 mTodoList->setDocumentId( filename ); 2412 mTodoList->setDocumentId( filename );
2413 } 2413 }
2414 2414
2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2416 2416
2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2418 globalFlagBlockAgenda = 2; 2418 globalFlagBlockAgenda = 2;
2419 mCalendar->reInitAlarmSettings(); 2419 mCalendar->reInitAlarmSettings();
2420 setSyncEventsReadOnly(); 2420 setSyncEventsReadOnly();
2421 updateUnmanagedViews(); 2421 updateUnmanagedViews();
2422 updateView(); 2422 updateView();
2423 } 2423 }
2424 return false; 2424 return false;
2425} 2425}
2426void CalendarView::mergeFile( QString fn ) 2426void CalendarView::mergeFile( QString fn )
2427{ 2427{
2428 clearAllViews(); 2428 clearAllViews();
2429 mCalendar->mergeCalendarFile( fn ); 2429 mCalendar->mergeCalendarFile( fn );
2430 mCalendar->reInitAlarmSettings(); 2430 mCalendar->reInitAlarmSettings();
2431 setSyncEventsReadOnly(); 2431 setSyncEventsReadOnly();
2432 updateUnmanagedViews(); 2432 updateUnmanagedViews();
2433 updateView(); 2433 updateView();
2434} 2434}
2435void CalendarView::showOpenError() 2435void CalendarView::showOpenError()
2436{ 2436{
2437 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2437 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2438} 2438}
2439void CalendarView::setLoadedFileVersion(QDateTime dt) 2439void CalendarView::setLoadedFileVersion(QDateTime dt)
2440{ 2440{
2441 loadedFileVersion = dt; 2441 loadedFileVersion = dt;
2442} 2442}
2443bool CalendarView::checkFileChanged(QString fn) 2443bool CalendarView::checkFileChanged(QString fn)
2444{ 2444{
2445 QFileInfo finf ( fn ); 2445 QFileInfo finf ( fn );
2446 if ( !finf.exists() ) 2446 if ( !finf.exists() )
2447 return true; 2447 return true;
2448 QDateTime dt = finf.lastModified (); 2448 QDateTime dt = finf.lastModified ();
2449 if ( dt <= loadedFileVersion ) 2449 if ( dt <= loadedFileVersion )
2450 return false; 2450 return false;
2451 return true; 2451 return true;
2452 2452
2453} 2453}
2454void CalendarView::watchSavedFile() 2454void CalendarView::watchSavedFile()
2455{ 2455{
2456 QFileInfo finf ( MainWindow::defaultFileName()); 2456 QFileInfo finf ( MainWindow::defaultFileName());
2457 if ( !finf.exists() ) 2457 if ( !finf.exists() )
2458 return; 2458 return;
2459 QDateTime dt = finf.lastModified (); 2459 QDateTime dt = finf.lastModified ();
2460 if ( dt < loadedFileVersion ) { 2460 if ( dt < loadedFileVersion ) {
2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2463 return; 2463 return;
2464 } 2464 }
2465 loadedFileVersion = dt; 2465 loadedFileVersion = dt;
2466} 2466}
2467bool CalendarView::checkAllFileVersions() 2467bool CalendarView::checkAllFileVersions()
2468{ 2468{
2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2470 KopiCalendarFile * cal = calendars.first(); 2470 KopiCalendarFile * cal = calendars.first();
2471 mCalendar->setDefaultCalendar( 1 ); 2471 mCalendar->setDefaultCalendar( 1 );
2472 mCalendar->setDefaultCalendarEnabledOnly(); 2472 mCalendar->setDefaultCalendarEnabledOnly();
2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2474 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2474 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2475 restoreCalendarSettings(); 2475 restoreCalendarSettings();
2476 return false; 2476 return false;
2477 } 2477 }
2478 } 2478 }
2479 cal = calendars.next(); 2479 cal = calendars.next();
2480 QDateTime storeTemp = loadedFileVersion; 2480 QDateTime storeTemp = loadedFileVersion;
2481 while ( cal ) { 2481 while ( cal ) {
2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2483 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2483 mCalendar->setDefaultCalendar( cal->mCalNumber );
2484 mCalendar->setDefaultCalendarEnabledOnly(); 2484 mCalendar->setDefaultCalendarEnabledOnly();
2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2486 if ( !checkFileVersion(cal->mFileName )) { 2486 if ( !checkFileVersion(cal->mFileName )) {
2487 loadedFileVersion = storeTemp; 2487 loadedFileVersion = storeTemp;
2488 restoreCalendarSettings(); 2488 restoreCalendarSettings();
2489 return false; 2489 return false;
2490 } 2490 }
2491 } 2491 }
2492 cal = calendars.next(); 2492 cal = calendars.next();
2493 } 2493 }
2494 loadedFileVersion = storeTemp; 2494 loadedFileVersion = storeTemp;
2495 return true; 2495 return true;
2496} 2496}
2497bool CalendarView::checkFileVersion(QString fn) 2497bool CalendarView::checkFileVersion(QString fn)
2498{ 2498{
2499 QFileInfo finf ( fn ); 2499 QFileInfo finf ( fn );
2500 if ( !finf.exists() ) 2500 if ( !finf.exists() )
2501 return true; 2501 return true;
2502 QDateTime dt = finf.lastModified (); 2502 QDateTime dt = finf.lastModified ();
2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2505 if ( dt <= loadedFileVersion ) 2505 if ( dt <= loadedFileVersion )
2506 return true; 2506 return true;
2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2508 i18n("KO/Pi Warning"),i18n("Overwrite"), 2508 i18n("KO/Pi Warning"),i18n("Overwrite"),
2509 i18n("Sync+save")); 2509 i18n("Sync+save"));
2510 2510
2511 if ( km == KMessageBox::Cancel ) 2511 if ( km == KMessageBox::Cancel )
2512 return false; 2512 return false;
2513 if ( km == KMessageBox::Yes ) 2513 if ( km == KMessageBox::Yes )
2514 return true; 2514 return true;
2515 2515
2516 setSyncDevice("deleteaftersync" ); 2516 setSyncDevice("deleteaftersync" );
2517 mSyncManager->mAskForPreferences = true; 2517 mSyncManager->mAskForPreferences = true;
2518 mSyncManager->mSyncAlgoPrefs = 3; 2518 mSyncManager->mSyncAlgoPrefs = 3;
2519 mSyncManager->mWriteBackFile = false; 2519 mSyncManager->mWriteBackFile = false;
2520 mSyncManager->mWriteBackExistingOnly = false; 2520 mSyncManager->mWriteBackExistingOnly = false;
2521 mSyncManager->mShowSyncSummary = false; 2521 mSyncManager->mShowSyncSummary = false;
2522 syncCalendar( fn, 3 ); 2522 syncCalendar( fn, 3 );
2523 Event * e = getLastSyncEvent(); 2523 Event * e = getLastSyncEvent();
2524 if ( e ) 2524 if ( e )
2525 mCalendar->deleteEvent( e ); 2525 mCalendar->deleteEvent( e );
2526 return true; 2526 return true;
2527} 2527}
2528bool CalendarView::saveCalendars() 2528bool CalendarView::saveCalendars()
2529{ 2529{
2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2531 KopiCalendarFile * cal = calendars.first(); 2531 KopiCalendarFile * cal = calendars.first();
2532 mCalendar->setDefaultCalendar( 1 ); 2532 mCalendar->setDefaultCalendar( 1 );
2533 mCalendar->setDefaultCalendarEnabledOnly(); 2533 mCalendar->setDefaultCalendarEnabledOnly();
2534 saveCalendar( MainWindow::defaultFileName() ); 2534 QString saveError;
2535 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2536 saveError = cal->mName +"\n";
2535 cal = calendars.next(); 2537 cal = calendars.next();
2536 while ( cal ) { 2538 while ( cal ) {
2537 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2539 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2538 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2540 mCalendar->setDefaultCalendar( cal->mCalNumber );
2539 mCalendar->setDefaultCalendarEnabledOnly(); 2541 mCalendar->setDefaultCalendarEnabledOnly();
2540 if ( saveCalendar( cal->mFileName ) ) 2542 if ( saveCalendar( cal->mFileName ) )
2541 cal->mLoadDt = QDateTime::currentDateTime(); 2543 cal->mLoadDt = QDateTime::currentDateTime();
2544 else
2545 saveError += cal->mName + "\n";
2542 } 2546 }
2543 cal = calendars.next(); 2547 cal = calendars.next();
2544 } 2548 }
2545 restoreCalendarSettings(); 2549 restoreCalendarSettings();
2550
2551 if ( !saveError.isEmpty() ) {
2552 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2553 KMessageBox::error(this, saveError, i18n("Error saving data"));
2554 return false;
2555 }
2546 return true; 2556 return true;
2547} 2557}
2548bool CalendarView::saveCalendar( QString filename ) 2558bool CalendarView::saveCalendar( QString filename )
2549{ 2559{
2550 2560
2551 // Store back all unsaved data into calendar object 2561 // Store back all unsaved data into calendar object
2552 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2562 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2553 if ( mViewManager->currentView() ) 2563 if ( mViewManager->currentView() )
2554 mViewManager->currentView()->flushView(); 2564 mViewManager->currentView()->flushView();
2555 2565
2556 2566
2557 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2567 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2558 mStorage->setSaveFormat( new ICalFormat() ); 2568 mStorage->setSaveFormat( new ICalFormat() );
2559 mStorage->setFileName( filename ); 2569 mStorage->setFileName( filename );
2560 bool success; 2570 bool success;
2561 success = mStorage->save(); 2571 success = mStorage->save();
2562 if ( !success ) { 2572 if ( !success ) {
2563 return false; 2573 return false;
2564 } 2574 }
2565 if ( filename == MainWindow::defaultFileName() ) { 2575 if ( filename == MainWindow::defaultFileName() ) {
2566 setLoadedFileVersion( lfv ); 2576 setLoadedFileVersion( lfv );
2567 watchSavedFile(); 2577 watchSavedFile();
2568 } 2578 }
2569 return true; 2579 return true;
2570} 2580}
2571 2581
2572void CalendarView::closeCalendar() 2582void CalendarView::closeCalendar()
2573{ 2583{
2574 2584
2575 // child windows no longer valid 2585 // child windows no longer valid
2576 clearAllViews(); 2586 clearAllViews();
2577 emit closingDown(); 2587 emit closingDown();
2578 2588
2579 mCalendar->close(); 2589 mCalendar->close();
2580 setModified(false); 2590 setModified(false);
2581 updateView(); 2591 updateView();
2582} 2592}
2583 2593
2584void CalendarView::archiveCalendar() 2594void CalendarView::archiveCalendar()
2585{ 2595{
2586 mDialogManager->showArchiveDialog(); 2596 mDialogManager->showArchiveDialog();
2587} 2597}
2588 2598
2589 2599
2590void CalendarView::readSettings() 2600void CalendarView::readSettings()
2591{ 2601{
2592 2602
2593 2603
2594 // mViewManager->showAgendaView(); 2604 // mViewManager->showAgendaView();
2595 QString str; 2605 QString str;
2596 //qDebug("CalendarView::readSettings() "); 2606 //qDebug("CalendarView::readSettings() ");
2597 // read settings from the KConfig, supplying reasonable 2607 // read settings from the KConfig, supplying reasonable
2598 // defaults where none are to be found 2608 // defaults where none are to be found
2599 KConfig *config = KOGlobals::config(); 2609 KConfig *config = KOGlobals::config();
2600#ifndef KORG_NOSPLITTER 2610#ifndef KORG_NOSPLITTER
2601 config->setGroup("KOrganizer Geometry"); 2611 config->setGroup("KOrganizer Geometry");
2602 2612
2603 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2613 QValueList<int> sizes = config->readIntListEntry("Separator1");
2604 if (sizes.count() != 2) { 2614 if (sizes.count() != 2) {
2605 sizes << mDateNavigator->minimumSizeHint().width(); 2615 sizes << mDateNavigator->minimumSizeHint().width();
2606 sizes << 300; 2616 sizes << 300;
2607 } 2617 }
2608 mPanner->setSizes(sizes); 2618 mPanner->setSizes(sizes);
2609 2619
2610 sizes = config->readIntListEntry("Separator2"); 2620 sizes = config->readIntListEntry("Separator2");
2611 if ( ( mResourceView && sizes.count() == 4 ) || 2621 if ( ( mResourceView && sizes.count() == 4 ) ||
2612 ( !mResourceView && sizes.count() == 3 ) ) { 2622 ( !mResourceView && sizes.count() == 3 ) ) {
2613 mLeftSplitter->setSizes(sizes); 2623 mLeftSplitter->setSizes(sizes);
2614 } 2624 }
2615#endif 2625#endif
2616 globalFlagBlockAgenda = 1; 2626 globalFlagBlockAgenda = 1;
2617 mViewManager->showAgendaView(); 2627 mViewManager->showAgendaView();
2618 //mViewManager->readSettings( config ); 2628 //mViewManager->readSettings( config );
2619 mTodoList->restoreLayout(config,QString("Todo Layout")); 2629 mTodoList->restoreLayout(config,QString("Todo Layout"));
2620 readFilterSettings(config); 2630 readFilterSettings(config);
2621 2631
2622#ifdef DESKTOP_VERSION 2632#ifdef DESKTOP_VERSION
2623 config->setGroup("WidgetLayout"); 2633 config->setGroup("WidgetLayout");
2624 QStringList list; 2634 QStringList list;
2625 list = config->readListEntry("MainLayout"); 2635 list = config->readListEntry("MainLayout");
2626 int x,y,w,h; 2636 int x,y,w,h;
2627 if ( ! list.isEmpty() ) { 2637 if ( ! list.isEmpty() ) {
2628 x = list[0].toInt(); 2638 x = list[0].toInt();
2629 y = list[1].toInt(); 2639 y = list[1].toInt();
2630 w = list[2].toInt(); 2640 w = list[2].toInt();
2631 h = list[3].toInt(); 2641 h = list[3].toInt();
2632 KApplication::testCoords( &x,&y,&w,&h ); 2642 KApplication::testCoords( &x,&y,&w,&h );
2633 topLevelWidget()->setGeometry(x,y,w,h); 2643 topLevelWidget()->setGeometry(x,y,w,h);
2634 2644
2635 } else { 2645 } else {
2636 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2646 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2637 } 2647 }
2638 list = config->readListEntry("EditEventLayout"); 2648 list = config->readListEntry("EditEventLayout");
2639 if ( ! list.isEmpty() ) { 2649 if ( ! list.isEmpty() ) {
2640 x = list[0].toInt(); 2650 x = list[0].toInt();
2641 y = list[1].toInt(); 2651 y = list[1].toInt();
2642 w = list[2].toInt(); 2652 w = list[2].toInt();
2643 h = list[3].toInt(); 2653 h = list[3].toInt();
2644 KApplication::testCoords( &x,&y,&w,&h ); 2654 KApplication::testCoords( &x,&y,&w,&h );
2645 mEventEditor->setGeometry(x,y,w,h); 2655 mEventEditor->setGeometry(x,y,w,h);
2646 2656
2647 } 2657 }
2648 list = config->readListEntry("EditTodoLayout"); 2658 list = config->readListEntry("EditTodoLayout");
2649 if ( ! list.isEmpty() ) { 2659 if ( ! list.isEmpty() ) {
2650 x = list[0].toInt(); 2660 x = list[0].toInt();
2651 y = list[1].toInt(); 2661 y = list[1].toInt();
2652 w = list[2].toInt(); 2662 w = list[2].toInt();
2653 h = list[3].toInt(); 2663 h = list[3].toInt();
2654 KApplication::testCoords( &x,&y,&w,&h ); 2664 KApplication::testCoords( &x,&y,&w,&h );
2655 mTodoEditor->setGeometry(x,y,w,h); 2665 mTodoEditor->setGeometry(x,y,w,h);
2656 2666
2657 } 2667 }
2658 list = config->readListEntry("ViewerLayout"); 2668 list = config->readListEntry("ViewerLayout");
2659 if ( ! list.isEmpty() ) { 2669 if ( ! list.isEmpty() ) {
2660 x = list[0].toInt(); 2670 x = list[0].toInt();
2661 y = list[1].toInt(); 2671 y = list[1].toInt();
2662 w = list[2].toInt(); 2672 w = list[2].toInt();
2663 h = list[3].toInt(); 2673 h = list[3].toInt();
2664 KApplication::testCoords( &x,&y,&w,&h ); 2674 KApplication::testCoords( &x,&y,&w,&h );
2665 getEventViewerDialog()->setGeometry(x,y,w,h); 2675 getEventViewerDialog()->setGeometry(x,y,w,h);
2666 } 2676 }
2667#endif 2677#endif
2668 config->setGroup( "Views" ); 2678 config->setGroup( "Views" );
2669 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2679 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2670 2680
2671 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2681 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2672 2682
2673 int resetval = 0; 2683 int resetval = 0;
2674 int maxVal = 0; 2684 int maxVal = 0;
2675 if (sizes.count() != 3) { 2685 if (sizes.count() != 3) {
2676 if ( KOPrefs::instance()->mVerticalScreen ) { 2686 if ( KOPrefs::instance()->mVerticalScreen ) {
2677 resetval = mDateNavigator->sizeHint().width()+2; 2687 resetval = mDateNavigator->sizeHint().width()+2;
2678 } else { 2688 } else {
2679 resetval = mDateNavigator->sizeHint().height()+2; 2689 resetval = mDateNavigator->sizeHint().height()+2;
2680 } 2690 }
2681 } 2691 }
2682 if ( resetval ) { 2692 if ( resetval ) {
2683 sizes.clear(); 2693 sizes.clear();
2684 if ( KOPrefs::instance()->mVerticalScreen ) { 2694 if ( KOPrefs::instance()->mVerticalScreen ) {
2685 maxVal = QApplication::desktop()->width() -10; 2695 maxVal = QApplication::desktop()->width() -10;
2686 } else { 2696 } else {
2687 maxVal = QApplication::desktop()->height()-10; 2697 maxVal = QApplication::desktop()->height()-10;
2688 } 2698 }
2689 sizes << resetval; 2699 sizes << resetval;
2690 if ( maxVal < resetval + resetval) 2700 if ( maxVal < resetval + resetval)
2691 resetval = maxVal - resetval; 2701 resetval = maxVal - resetval;
2692 sizes << resetval; 2702 sizes << resetval;
2693 sizes << 100; 2703 sizes << 100;
2694 } 2704 }
2695 mLeftFrame->setSizes(sizes); 2705 mLeftFrame->setSizes(sizes);
2696 sizes = config->readIntListEntry("Main Splitter Frame"); 2706 sizes = config->readIntListEntry("Main Splitter Frame");
2697 resetval = 0; 2707 resetval = 0;
2698 maxVal = 0; 2708 maxVal = 0;
2699 if (sizes.count() != 2) { 2709 if (sizes.count() != 2) {
2700 if ( !KOPrefs::instance()->mVerticalScreen ) { 2710 if ( !KOPrefs::instance()->mVerticalScreen ) {
2701 resetval = mDateNavigator->sizeHint().width()+2; 2711 resetval = mDateNavigator->sizeHint().width()+2;
2702 } else { 2712 } else {
2703 resetval = mDateNavigator->sizeHint().height()+2; 2713 resetval = mDateNavigator->sizeHint().height()+2;
2704 } 2714 }
2705 } 2715 }
2706 if ( resetval ) { 2716 if ( resetval ) {
2707 sizes.clear(); 2717 sizes.clear();
2708 if ( !KOPrefs::instance()->mVerticalScreen ) { 2718 if ( !KOPrefs::instance()->mVerticalScreen ) {
2709 maxVal = QApplication::desktop()->width() -10; 2719 maxVal = QApplication::desktop()->width() -10;
2710 } else { 2720 } else {
2711 maxVal = QApplication::desktop()->height()-10; 2721 maxVal = QApplication::desktop()->height()-10;
2712 } 2722 }
2713 sizes << resetval; 2723 sizes << resetval;
2714 if ( maxVal < resetval + resetval) 2724 if ( maxVal < resetval + resetval)
2715 resetval = maxVal - resetval; 2725 resetval = maxVal - resetval;
2716 sizes << resetval; 2726 sizes << resetval;
2717 } 2727 }
2718 mMainFrame->setSizes(sizes); 2728 mMainFrame->setSizes(sizes);
2719 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2729 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2720 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2730 else if ( dateCount == 7 ) mNavigator->selectWeek();
2721 else mNavigator->selectDates( dateCount ); 2731 else mNavigator->selectDates( dateCount );
2722 // mViewManager->readSettings( config ); 2732 // mViewManager->readSettings( config );
2723 updateConfig(); 2733 updateConfig();
2724 globalFlagBlockAgenda = 2; 2734 globalFlagBlockAgenda = 2;
2725 mViewManager->readSettings( config ); 2735 mViewManager->readSettings( config );
2726 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2736 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2727} 2737}
2728 2738
2729void CalendarView::checkSuspendAlarm() 2739void CalendarView::checkSuspendAlarm()
2730{ 2740{
2731 if ( mSuspendTimer->isActive() ) { 2741 if ( mSuspendTimer->isActive() ) {
2732 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2742 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2733 } 2743 }
2734} 2744}
2735void CalendarView::writeSettings() 2745void CalendarView::writeSettings()
2736{ 2746{
2737 // kdDebug() << "CalendarView::writeSettings" << endl; 2747 // kdDebug() << "CalendarView::writeSettings" << endl;
2738 2748
2739 KConfig *config = KOGlobals::config(); 2749 KConfig *config = KOGlobals::config();
2740 2750
2741 mViewManager->writeSettings( config ); 2751 mViewManager->writeSettings( config );
2742 mTodoList->saveLayout(config,QString("Todo Layout")); 2752 mTodoList->saveLayout(config,QString("Todo Layout"));
2743 mDialogManager->writeSettings( config ); 2753 mDialogManager->writeSettings( config );
2744 //KOPrefs::instance()->usrWriteConfig(); 2754 //KOPrefs::instance()->usrWriteConfig();
2745 KOPrefs::instance()->writeConfig(); 2755 KOPrefs::instance()->writeConfig();
2746 2756
2747 writeFilterSettings(config); 2757 writeFilterSettings(config);
2748 config->setGroup( "AppRun" ); 2758 config->setGroup( "AppRun" );
2749 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2759 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2750 int days = dt.daysTo( QDate::currentDate() ); 2760 int days = dt.daysTo( QDate::currentDate() );
2751 dt = dt.addDays( days ); 2761 dt = dt.addDays( days );
2752 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2762 int secs = dt.secsTo( QDateTime::currentDateTime() );
2753 config->writeEntry( "LatestProgramStopDays", days ); 2763 config->writeEntry( "LatestProgramStopDays", days );
2754 config->writeEntry( "LatestProgramStopSecs", secs ); 2764 config->writeEntry( "LatestProgramStopSecs", secs );
2755 //qDebug("KO: Writing stop time: %d ", secs); 2765 //qDebug("KO: Writing stop time: %d ", secs);
2756 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2766 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2757 //QDateTime latest = dt.addSecs ( secs ); 2767 //QDateTime latest = dt.addSecs ( secs );
2758 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2768 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2759 config->setGroup( "Views" ); 2769 config->setGroup( "Views" );
2760 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2770 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2761 2771
2762#if 0 2772#if 0
2763 qDebug("********************* "); 2773 qDebug("********************* ");
2764 qDebug("Testcode secsto "); 2774 qDebug("Testcode secsto ");
2765 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2775 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2766 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2776 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2767 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2777 int secsto = dt_nodaylight.secsTo( dt_daylight );
2768 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2778 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2769 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2779 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2770 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2780 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2771 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2781 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2772 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2782 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2773 qDebug("********************* testcode end"); 2783 qDebug("********************* testcode end");
2774 2784
2775#endif 2785#endif
2776 2786
2777 QValueList<int> listINT = mLeftFrame->sizes(); 2787 QValueList<int> listINT = mLeftFrame->sizes();
2778 config->writeEntry("Left Splitter Frame",listINT); 2788 config->writeEntry("Left Splitter Frame",listINT);
2779 QValueList<int> listINT2 = mMainFrame->sizes(); 2789 QValueList<int> listINT2 = mMainFrame->sizes();
2780 config->writeEntry("Main Splitter Frame",listINT2); 2790 config->writeEntry("Main Splitter Frame",listINT2);
2781#ifdef DESKTOP_VERSION 2791#ifdef DESKTOP_VERSION
2782 config->setGroup("WidgetLayout"); 2792 config->setGroup("WidgetLayout");
2783 QStringList list ;//= config->readListEntry("MainLayout"); 2793 QStringList list ;//= config->readListEntry("MainLayout");
2784 int x,y,w,h; 2794 int x,y,w,h;
2785 QWidget* wid; 2795 QWidget* wid;
2786 wid = topLevelWidget(); 2796 wid = topLevelWidget();
2787 x = wid->geometry().x(); 2797 x = wid->geometry().x();
2788 y = wid->geometry().y(); 2798 y = wid->geometry().y();
2789 w = wid->width(); 2799 w = wid->width();
2790 h = wid->height(); 2800 h = wid->height();
2791 list.clear(); 2801 list.clear();
2792 list << QString::number( x ); 2802 list << QString::number( x );
2793 list << QString::number( y ); 2803 list << QString::number( y );
2794 list << QString::number( w ); 2804 list << QString::number( w );
2795 list << QString::number( h ); 2805 list << QString::number( h );
2796 config->writeEntry("MainLayout",list ); 2806 config->writeEntry("MainLayout",list );
2797 2807
2798 wid = mEventEditor; 2808 wid = mEventEditor;
2799 x = wid->geometry().x(); 2809 x = wid->geometry().x();
2800 y = wid->geometry().y(); 2810 y = wid->geometry().y();
2801 w = wid->width(); 2811 w = wid->width();
2802 h = wid->height(); 2812 h = wid->height();
2803 list.clear(); 2813 list.clear();
2804 list << QString::number( x ); 2814 list << QString::number( x );
2805 list << QString::number( y ); 2815 list << QString::number( y );
2806 list << QString::number( w ); 2816 list << QString::number( w );
2807 list << QString::number( h ); 2817 list << QString::number( h );
2808 config->writeEntry("EditEventLayout",list ); 2818 config->writeEntry("EditEventLayout",list );
2809 2819
2810 wid = mTodoEditor; 2820 wid = mTodoEditor;
2811 x = wid->geometry().x(); 2821 x = wid->geometry().x();
2812 y = wid->geometry().y(); 2822 y = wid->geometry().y();
2813 w = wid->width(); 2823 w = wid->width();
2814 h = wid->height(); 2824 h = wid->height();
2815 list.clear(); 2825 list.clear();
2816 list << QString::number( x ); 2826 list << QString::number( x );
2817 list << QString::number( y ); 2827 list << QString::number( y );
2818 list << QString::number( w ); 2828 list << QString::number( w );
2819 list << QString::number( h ); 2829 list << QString::number( h );
2820 config->writeEntry("EditTodoLayout",list ); 2830 config->writeEntry("EditTodoLayout",list );
2821 wid = getEventViewerDialog(); 2831 wid = getEventViewerDialog();
2822 x = wid->geometry().x(); 2832 x = wid->geometry().x();
2823 y = wid->geometry().y(); 2833 y = wid->geometry().y();
2824 w = wid->width(); 2834 w = wid->width();
2825 h = wid->height(); 2835 h = wid->height();
2826 list.clear(); 2836 list.clear();
2827 list << QString::number( x ); 2837 list << QString::number( x );
2828 list << QString::number( y ); 2838 list << QString::number( y );
2829 list << QString::number( w ); 2839 list << QString::number( w );
2830 list << QString::number( h ); 2840 list << QString::number( h );
2831 config->writeEntry("ViewerLayout",list ); 2841 config->writeEntry("ViewerLayout",list );
2832 wid = mDialogManager->getSearchDialog(); 2842 wid = mDialogManager->getSearchDialog();
2833 if ( wid ) { 2843 if ( wid ) {
2834 x = wid->geometry().x(); 2844 x = wid->geometry().x();
2835 y = wid->geometry().y(); 2845 y = wid->geometry().y();
2836 w = wid->width(); 2846 w = wid->width();
2837 h = wid->height(); 2847 h = wid->height();
2838 list.clear(); 2848 list.clear();
2839 list << QString::number( x ); 2849 list << QString::number( x );
2840 list << QString::number( y ); 2850 list << QString::number( y );
2841 list << QString::number( w ); 2851 list << QString::number( w );
2842 list << QString::number( h ); 2852 list << QString::number( h );
2843 config->writeEntry("SearchLayout",list ); 2853 config->writeEntry("SearchLayout",list );
2844 } 2854 }
2845#endif 2855#endif
2846 2856
2847 2857
2848 config->sync(); 2858 config->sync();
2849} 2859}
2850 2860
2851void CalendarView::readFilterSettings(KConfig *config) 2861void CalendarView::readFilterSettings(KConfig *config)
2852{ 2862{
2853 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2863 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2854 2864
2855 mFilters.clear(); 2865 mFilters.clear();
2856 2866
2857 config->setGroup("General"); 2867 config->setGroup("General");
2858 QStringList filterList = config->readListEntry("CalendarFilters"); 2868 QStringList filterList = config->readListEntry("CalendarFilters");
2859 2869
2860 QStringList::ConstIterator it = filterList.begin(); 2870 QStringList::ConstIterator it = filterList.begin();
2861 QStringList::ConstIterator end = filterList.end(); 2871 QStringList::ConstIterator end = filterList.end();
2862 while(it != end) { 2872 while(it != end) {
2863 // kdDebug() << " filter: " << (*it) << endl; 2873 // kdDebug() << " filter: " << (*it) << endl;
2864 2874
2865 CalFilter *filter; 2875 CalFilter *filter;
2866 filter = new CalFilter(*it); 2876 filter = new CalFilter(*it);
2867 config->setGroup("Filter_" + (*it).utf8()); 2877 config->setGroup("Filter_" + (*it).utf8());
2868 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2878 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2869 filter->setCriteria(config->readNumEntry("Criteria",0)); 2879 filter->setCriteria(config->readNumEntry("Criteria",0));
2870 filter->setCategoryList(config->readListEntry("CategoryList")); 2880 filter->setCategoryList(config->readListEntry("CategoryList"));
2871 mFilters.append(filter); 2881 mFilters.append(filter);
2872 2882
2873 ++it; 2883 ++it;
2874 } 2884 }
2875 2885
2876 if (mFilters.count() == 0) { 2886 if (mFilters.count() == 0) {
2877 CalFilter *filter = new CalFilter(i18n("Default")); 2887 CalFilter *filter = new CalFilter(i18n("Default"));
2878 mFilters.append(filter); 2888 mFilters.append(filter);
2879 } 2889 }
2880 mFilterView->updateFilters(); 2890 mFilterView->updateFilters();
2881 config->setGroup("FilterView"); 2891 config->setGroup("FilterView");
2882 2892
2883 mFilterView->blockSignals(true); 2893 mFilterView->blockSignals(true);
2884 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2894 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2885 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2895 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2886 mFilterView->blockSignals(false); 2896 mFilterView->blockSignals(false);
2887 // We do it manually to avoid it being done twice by the above calls 2897 // We do it manually to avoid it being done twice by the above calls
2888 updateFilter(); 2898 updateFilter();
2889} 2899}
2890 2900
2891void CalendarView::writeFilterSettings(KConfig *config) 2901void CalendarView::writeFilterSettings(KConfig *config)
2892{ 2902{
2893 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2903 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2894 2904
2895 QStringList filterList; 2905 QStringList filterList;
2896 2906
2897 CalFilter *filter = mFilters.first(); 2907 CalFilter *filter = mFilters.first();
2898 while(filter) { 2908 while(filter) {
2899 // kdDebug() << " fn: " << filter->name() << endl; 2909 // kdDebug() << " fn: " << filter->name() << endl;
2900 filterList << filter->name(); 2910 filterList << filter->name();
2901 config->setGroup("Filter_" + filter->name().utf8()); 2911 config->setGroup("Filter_" + filter->name().utf8());
2902 config->writeEntry("Criteria",filter->criteria()); 2912 config->writeEntry("Criteria",filter->criteria());
2903 config->writeEntry("CategoryList",filter->categoryList()); 2913 config->writeEntry("CategoryList",filter->categoryList());
2904 filter = mFilters.next(); 2914 filter = mFilters.next();
2905 } 2915 }
2906 config->setGroup("General"); 2916 config->setGroup("General");
2907 config->writeEntry("CalendarFilters",filterList); 2917 config->writeEntry("CalendarFilters",filterList);
2908 2918
2909 config->setGroup("FilterView"); 2919 config->setGroup("FilterView");
2910 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2920 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2911 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2921 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2912} 2922}
2913 2923
2914 2924
2915void CalendarView::goToday() 2925void CalendarView::goToday()
2916{ 2926{
2917 if ( mViewManager->currentView()->isMonthView() ) 2927 if ( mViewManager->currentView()->isMonthView() )
2918 mNavigator->selectTodayMonth(); 2928 mNavigator->selectTodayMonth();
2919 else 2929 else
2920 mNavigator->selectToday(); 2930 mNavigator->selectToday();
2921} 2931}
2922 2932
2923void CalendarView::goNext() 2933void CalendarView::goNext()
2924{ 2934{
2925 mNavigator->selectNext(); 2935 mNavigator->selectNext();
2926} 2936}
2927 2937
2928void CalendarView::goPrevious() 2938void CalendarView::goPrevious()
2929{ 2939{
2930 mNavigator->selectPrevious(); 2940 mNavigator->selectPrevious();
2931} 2941}
2932void CalendarView::goNextMonth() 2942void CalendarView::goNextMonth()
2933{ 2943{
2934 mNavigator->selectNextMonth(); 2944 mNavigator->selectNextMonth();
2935} 2945}
2936 2946
2937void CalendarView::goPreviousMonth() 2947void CalendarView::goPreviousMonth()
2938{ 2948{
2939 mNavigator->selectPreviousMonth(); 2949 mNavigator->selectPreviousMonth();
2940} 2950}
2941 2951
2942void CalendarView::updateConfig() 2952void CalendarView::updateConfig()
2943{ 2953{
2944 if ( KOPrefs::instance()->mUseAppColors ) 2954 if ( KOPrefs::instance()->mUseAppColors )
2945 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2955 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2946 emit configChanged(); 2956 emit configChanged();
2947 mTodoList->updateConfig(); 2957 mTodoList->updateConfig();
2948 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2958 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2949 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2959 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2950 // To make the "fill window" configurations work 2960 // To make the "fill window" configurations work
2951 //mViewManager->raiseCurrentView(); 2961 //mViewManager->raiseCurrentView();
2952} 2962}
2953 2963
2954 2964
2955void CalendarView::eventChanged(Event *event) 2965void CalendarView::eventChanged(Event *event)
2956{ 2966{
2957 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2967 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2958 //updateUnmanagedViews(); 2968 //updateUnmanagedViews();
2959} 2969}
2960 2970
2961void CalendarView::eventAdded(Event *event) 2971void CalendarView::eventAdded(Event *event)
2962{ 2972{
2963 changeEventDisplay(event,KOGlobals::EVENTADDED); 2973 changeEventDisplay(event,KOGlobals::EVENTADDED);
2964} 2974}
2965 2975
2966void CalendarView::eventToBeDeleted(Event *) 2976void CalendarView::eventToBeDeleted(Event *)
2967{ 2977{
2968 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2978 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2969} 2979}
2970 2980
2971void CalendarView::eventDeleted() 2981void CalendarView::eventDeleted()
2972{ 2982{
2973 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2983 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2974} 2984}
2975void CalendarView::changeTodoDisplay(Todo *which, int action) 2985void CalendarView::changeTodoDisplay(Todo *which, int action)
2976{ 2986{
2977 changeIncidenceDisplay((Incidence *)which, action); 2987 changeIncidenceDisplay((Incidence *)which, action);
2978 mDateNavigator->updateView(); //LR 2988 mDateNavigator->updateView(); //LR
2979 //mDialogManager->updateSearchDialog(); 2989 //mDialogManager->updateSearchDialog();
2980 2990
2981 if (which) { 2991 if (which) {
2982 mViewManager->updateWNview(); 2992 mViewManager->updateWNview();
2983 //mTodoList->updateView(); 2993 //mTodoList->updateView();
2984 } 2994 }
2985 2995
2986} 2996}
2987 2997
2988void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2998void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2989{ 2999{
2990 updateUnmanagedViews(); 3000 updateUnmanagedViews();
2991 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 3001 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2992 if ( action == KOGlobals::EVENTDELETED ) { //delete 3002 if ( action == KOGlobals::EVENTDELETED ) { //delete
2993 mCalendar->checkAlarmForIncidence( 0, true ); 3003 mCalendar->checkAlarmForIncidence( 0, true );
2994 if ( mEventViewerDialog ) 3004 if ( mEventViewerDialog )
2995 mEventViewerDialog->hide(); 3005 mEventViewerDialog->hide();
2996 } 3006 }
2997 else 3007 else
2998 mCalendar->checkAlarmForIncidence( which , false ); 3008 mCalendar->checkAlarmForIncidence( which , false );
2999} 3009}
3000 3010
3001// most of the changeEventDisplays() right now just call the view's 3011// most of the changeEventDisplays() right now just call the view's
3002// total update mode, but they SHOULD be recoded to be more refresh-efficient. 3012// total update mode, but they SHOULD be recoded to be more refresh-efficient.
3003void CalendarView::changeEventDisplay(Event *which, int action) 3013void CalendarView::changeEventDisplay(Event *which, int action)
3004{ 3014{
3005 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 3015 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
3006 changeIncidenceDisplay((Incidence *)which, action); 3016 changeIncidenceDisplay((Incidence *)which, action);
3007 static bool clearallviews = false; 3017 static bool clearallviews = false;
3008 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3018 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3009 if ( clearallviews ) { 3019 if ( clearallviews ) {
3010 clearAllViews(); 3020 clearAllViews();
3011 clearallviews = false; 3021 clearallviews = false;
3012 } 3022 }
3013 return; 3023 return;
3014 } 3024 }
3015 clearallviews = true; 3025 clearallviews = true;
3016 mDateNavigator->updateView(); 3026 mDateNavigator->updateView();
3017 //mDialogManager->updateSearchDialog(); 3027 //mDialogManager->updateSearchDialog();
3018 if (which) { 3028 if (which) {
3019 // If there is an event view visible update the display 3029 // If there is an event view visible update the display
3020 mViewManager->currentView()->changeEventDisplay(which,action); 3030 mViewManager->currentView()->changeEventDisplay(which,action);
3021 // TODO: check, if update needed 3031 // TODO: check, if update needed
3022 // if (which->getTodoStatus()) { 3032 // if (which->getTodoStatus()) {
3023 mTodoList->updateView(); 3033 mTodoList->updateView();
3024 if ( action != KOGlobals::EVENTDELETED ) { 3034 if ( action != KOGlobals::EVENTDELETED ) {
3025 mConflictingEvent = which ; 3035 mConflictingEvent = which ;
3026 int time = 1000; 3036 int time = 1000;
3027#ifdef DESKTOP_VERSION 3037#ifdef DESKTOP_VERSION
3028 time = 500; 3038 time = 500;
3029#endif 3039#endif
3030 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3040 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3031 } 3041 }
3032 // } 3042 // }
3033 } else { 3043 } else {
3034 mViewManager->currentView()->updateView(); 3044 mViewManager->currentView()->updateView();
3035 } 3045 }
3036} 3046}
3037void CalendarView::checkConflictForEvent() 3047void CalendarView::checkConflictForEvent()
3038{ 3048{
3039 3049
3040 if (!KOPrefs::instance()->mConfirm) 3050 if (!KOPrefs::instance()->mConfirm)
3041 return; 3051 return;
3042 if ( ! mConflictingEvent ) return; 3052 if ( ! mConflictingEvent ) return;
3043 Event * conflictingEvent = mConflictingEvent; 3053 Event * conflictingEvent = mConflictingEvent;
3044 mConflictingEvent = 0; 3054 mConflictingEvent = 0;
3045 QDateTime current = QDateTime::currentDateTime(); 3055 QDateTime current = QDateTime::currentDateTime();
3046 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3056 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3047 return; 3057 return;
3048 } 3058 }
3049 QPtrList<Event> testlist = mCalendar->events(); 3059 QPtrList<Event> testlist = mCalendar->events();
3050 Event * test = testlist.first(); 3060 Event * test = testlist.first();
3051 QDateTime conflict; 3061 QDateTime conflict;
3052 QDateTime retVal; 3062 QDateTime retVal;
3053 bool found = false; 3063 bool found = false;
3054 Event * cE = 0; 3064 Event * cE = 0;
3055 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3065 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3056 while ( test ) { 3066 while ( test ) {
3057 qApp->processEvents(); 3067 qApp->processEvents();
3058 bool skip = false; 3068 bool skip = false;
3059 if ( found ) 3069 if ( found )
3060 skip = !test->matchTime( &current, &conflict ); 3070 skip = !test->matchTime( &current, &conflict );
3061 else 3071 else
3062 skip = !test->matchTime( &current, 0 ); 3072 skip = !test->matchTime( &current, 0 );
3063 if ( !skip && !test->doesFloat() ) { 3073 if ( !skip && !test->doesFloat() ) {
3064 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3074 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3065 if ( ! found ) { 3075 if ( ! found ) {
3066 conflict = retVal; 3076 conflict = retVal;
3067 cE = test; 3077 cE = test;
3068 } else { 3078 } else {
3069 if ( retVal < conflict ) { 3079 if ( retVal < conflict ) {
3070 conflict = retVal; 3080 conflict = retVal;
3071 cE = test; 3081 cE = test;
3072 } 3082 }
3073 } 3083 }
3074 found = true; 3084 found = true;
3075 } 3085 }
3076 } 3086 }
3077 test = testlist.next(); 3087 test = testlist.next();
3078 } 3088 }
3079 topLevelWidget()->setCaption( i18n("KO/Pi") ); 3089 topLevelWidget()->setCaption( i18n("KO/Pi") );
3080 if ( found ) { 3090 if ( found ) {
3081 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 3091 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
3082 qApp->processEvents(); 3092 qApp->processEvents();
3083 int km = KMessageBox::warningContinueCancel(this,mess, 3093 int km = KMessageBox::warningContinueCancel(this,mess,
3084 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 3094 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
3085 if ( km != KMessageBox::Continue ) { 3095 if ( km != KMessageBox::Continue ) {
3086 return; 3096 return;
3087 } 3097 }
3088 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 3098 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
3089 mViewManager->showDayView(); 3099 mViewManager->showDayView();
3090 mNavigator->slotDaySelect( conflict.date() ); 3100 mNavigator->slotDaySelect( conflict.date() );
3091 int hour = conflict.time().hour(); 3101 int hour = conflict.time().hour();
3092 mViewManager->agendaView()->setStartHour( hour ); 3102 mViewManager->agendaView()->setStartHour( hour );
3093 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 3103 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
3094 } else 3104 } else
3095 topLevelWidget()->setCaption( i18n("No conflict found") ); 3105 topLevelWidget()->setCaption( i18n("No conflict found") );
3096 return; 3106 return;
3097 3107
3098} 3108}
3099 3109
3100void CalendarView::updateTodoViews() 3110void CalendarView::updateTodoViews()
3101{ 3111{
3102 mTodoList->updateView(); 3112 mTodoList->updateView();
3103 mViewManager->currentView()->updateView(); 3113 mViewManager->currentView()->updateView();
3104 3114
3105} 3115}
3106 3116
3107 3117
3108 3118
3109void CalendarView::clearAllViews() 3119void CalendarView::clearAllViews()
3110{ 3120{
3111 mTodoList->clearList(); 3121 mTodoList->clearList();
3112 mViewManager->clearAllViews(); 3122 mViewManager->clearAllViews();
3113 SearchDialog * sd = mDialogManager->getSearchDialog(); 3123 SearchDialog * sd = mDialogManager->getSearchDialog();
3114 if ( sd ) { 3124 if ( sd ) {
3115 KOListView* kol = sd->listview(); 3125 KOListView* kol = sd->listview();
3116 if ( kol ) 3126 if ( kol )
3117 kol->clearList(); 3127 kol->clearList();
3118 } 3128 }
3119} 3129}
3120void CalendarView::updateView() 3130void CalendarView::updateView()
3121{ 3131{
3122 static bool clearallviews = false; 3132 static bool clearallviews = false;
3123 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3133 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3124 if ( clearallviews ) { 3134 if ( clearallviews ) {
3125 clearAllViews(); 3135 clearAllViews();
3126 clearallviews = false; 3136 clearallviews = false;
3127 } 3137 }
3128 return; 3138 return;
3129 } 3139 }
3130 clearallviews = true; 3140 clearallviews = true;
3131 DateList tmpList = mNavigator->selectedDates(); 3141 DateList tmpList = mNavigator->selectedDates();
3132 3142
3133 if ( KOPrefs::instance()->mHideNonStartedTodos ) 3143 if ( KOPrefs::instance()->mHideNonStartedTodos )
3134 mTodoList->updateView(); 3144 mTodoList->updateView();
3135 // We assume that the navigator only selects consecutive days. 3145 // We assume that the navigator only selects consecutive days.
3136 updateView( tmpList.first(), tmpList.last() ); 3146 updateView( tmpList.first(), tmpList.last() );
3137} 3147}
3138 3148
3139void CalendarView::updateUnmanagedViews() 3149void CalendarView::updateUnmanagedViews()
3140{ 3150{
3141 mDateNavigator->updateDayMatrix(); 3151 mDateNavigator->updateDayMatrix();
3142} 3152}
3143 3153
3144int CalendarView::msgItemDelete(const QString name) 3154int CalendarView::msgItemDelete(const QString name)
3145{ 3155{
3146 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 3156 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
3147 i18n("This item will be\npermanently deleted."), 3157 i18n("This item will be\npermanently deleted."),
3148 i18n("KO/Pi Confirmation"),i18n("Delete")); 3158 i18n("KO/Pi Confirmation"),i18n("Delete"));
3149} 3159}
3150 3160
3151 3161
3152void CalendarView::edit_cut() 3162void CalendarView::edit_cut()
3153{ 3163{
3154 Event *anEvent=0; 3164 Event *anEvent=0;
3155 3165
3156 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3166 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3157 3167
3158 if (mViewManager->currentView()->isEventView()) { 3168 if (mViewManager->currentView()->isEventView()) {
3159 if ( incidence && incidence->typeID() == eventID ) { 3169 if ( incidence && incidence->typeID() == eventID ) {
3160 anEvent = static_cast<Event *>(incidence); 3170 anEvent = static_cast<Event *>(incidence);
3161 } 3171 }
3162 } 3172 }
3163 3173
3164 if (!anEvent) { 3174 if (!anEvent) {
3165 KNotifyClient::beep(); 3175 KNotifyClient::beep();
3166 return; 3176 return;
3167 } 3177 }
3168 DndFactory factory( mCalendar ); 3178 DndFactory factory( mCalendar );
3169 factory.cutIncidence(anEvent); 3179 factory.cutIncidence(anEvent);
3170 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3180 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3171} 3181}
3172 3182
3173void CalendarView::edit_copy() 3183void CalendarView::edit_copy()
3174{ 3184{
3175 Event *anEvent=0; 3185 Event *anEvent=0;
3176 3186
3177 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3187 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3178 3188
3179 if (mViewManager->currentView()->isEventView()) { 3189 if (mViewManager->currentView()->isEventView()) {
3180 if ( incidence && incidence->typeID() == eventID ) { 3190 if ( incidence && incidence->typeID() == eventID ) {
3181 anEvent = static_cast<Event *>(incidence); 3191 anEvent = static_cast<Event *>(incidence);
3182 } 3192 }
3183 } 3193 }
3184 3194
3185 if (!anEvent) { 3195 if (!anEvent) {
3186 KNotifyClient::beep(); 3196 KNotifyClient::beep();
3187 return; 3197 return;
3188 } 3198 }
3189 DndFactory factory( mCalendar ); 3199 DndFactory factory( mCalendar );
3190 factory.copyIncidence(anEvent); 3200 factory.copyIncidence(anEvent);
3191} 3201}
3192 3202
3193void CalendarView::edit_paste() 3203void CalendarView::edit_paste()
3194{ 3204{
3195 QDate date = mNavigator->selectedDates().first(); 3205 QDate date = mNavigator->selectedDates().first();
3196 3206
3197 DndFactory factory( mCalendar ); 3207 DndFactory factory( mCalendar );
3198 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 3208 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
3199 3209
3200 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 3210 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
3201} 3211}
3202void CalendarView::edit_global_options() 3212void CalendarView::edit_global_options()
3203{ 3213{
3204 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 3214 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
3205 emit save(); 3215 emit save();
3206 emit saveStopTimer(); 3216 emit saveStopTimer();
3207 mDialogManager->showGlobalOptionsDialog(); 3217 mDialogManager->showGlobalOptionsDialog();
3208 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 3218 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
3209 emit saveStopTimer(); 3219 emit saveStopTimer();
3210 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 3220 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
3211 i18n("Timezone settings"),i18n("Reload"))) { 3221 i18n("Timezone settings"),i18n("Reload"))) {
3212 qDebug("KO: TZ reload cancelled "); 3222 qDebug("KO: TZ reload cancelled ");
3213 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3223 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3214 return; 3224 return;
3215 } 3225 }
3216 qDebug("KO: Timezone change "); 3226 qDebug("KO: Timezone change ");
3217 loadCalendars(); 3227 loadCalendars();
3218 setModified(true); 3228 setModified(true);
3219 } 3229 }
3220 else 3230 else
3221 qDebug("KO: No tz change "); 3231 qDebug("KO: No tz change ");
3222} 3232}
3223void CalendarView::edit_options() 3233void CalendarView::edit_options()
3224{ 3234{
3225 mDialogManager->showOptionsDialog(); 3235 mDialogManager->showOptionsDialog();
3226} 3236}
3227 3237
3228 3238
3229void CalendarView::slotSelectPickerDate( QDate d) 3239void CalendarView::slotSelectPickerDate( QDate d)
3230{ 3240{
3231 mDateFrame->hide(); 3241 mDateFrame->hide();
3232 if ( mDatePickerMode == 1 ) { 3242 if ( mDatePickerMode == 1 ) {
3233 mNavigator->slotDaySelect( d ); 3243 mNavigator->slotDaySelect( d );
3234 } else if ( mDatePickerMode == 2 ) { 3244 } else if ( mDatePickerMode == 2 ) {
3235 if ( mMoveIncidence->typeID() == todoID ) { 3245 if ( mMoveIncidence->typeID() == todoID ) {
3236 Todo * to = (Todo *) mMoveIncidence; 3246 Todo * to = (Todo *) mMoveIncidence;
3237 QTime tim; 3247 QTime tim;
3238 int len = 0; 3248 int len = 0;
3239 if ( to->hasStartDate() && to->hasDueDate() ) 3249 if ( to->hasStartDate() && to->hasDueDate() )
3240 len = to->dtStart().secsTo( to->dtDue()); 3250 len = to->dtStart().secsTo( to->dtDue());
3241 if ( to->hasDueDate() ) 3251 if ( to->hasDueDate() )
3242 tim = to->dtDue().time(); 3252 tim = to->dtDue().time();
3243 else { 3253 else {
3244 tim = QTime ( 0,0,0 ); 3254 tim = QTime ( 0,0,0 );
3245 to->setFloats( true ); 3255 to->setFloats( true );
3246 to->setHasDueDate( true ); 3256 to->setHasDueDate( true );
3247 } 3257 }
3248 QDateTime dt ( d,tim ); 3258 QDateTime dt ( d,tim );
3249 to->setDtDue( dt ); 3259 to->setDtDue( dt );
3250 3260
3251 if ( to->hasStartDate() ) { 3261 if ( to->hasStartDate() ) {
3252 if ( len>0 ) 3262 if ( len>0 )
3253 to->setDtStart(to->dtDue().addSecs( -len )); 3263 to->setDtStart(to->dtDue().addSecs( -len ));
3254 else 3264 else
3255 if (to->dtStart() > to->dtDue() ) 3265 if (to->dtStart() > to->dtDue() )
3256 to->setDtStart(to->dtDue().addDays( -3 )); 3266 to->setDtStart(to->dtDue().addDays( -3 ));
3257 } 3267 }
3258 3268
3259 todoChanged( to ); 3269 todoChanged( to );
3260 } else if ( mMoveIncidence->typeID() == eventID ) { 3270 } else if ( mMoveIncidence->typeID() == eventID ) {
3261 if ( mMoveIncidence->doesRecur() ) { 3271 if ( mMoveIncidence->doesRecur() ) {
3262#if 0 3272#if 0
3263 // PENDING implement this 3273 // PENDING implement this
3264 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3274 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3265 mCalendar()->addIncidence( newInc ); 3275 mCalendar()->addIncidence( newInc );
3266 if ( mMoveIncidence->typeID() == todoID ) 3276 if ( mMoveIncidence->typeID() == todoID )
3267 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3277 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3268 else 3278 else
3269 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3279 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3270 mMoveIncidence = newInc; 3280 mMoveIncidence = newInc;
3271 3281
3272#endif 3282#endif
3273 } 3283 }
3274 QTime tim = mMoveIncidence->dtStart().time(); 3284 QTime tim = mMoveIncidence->dtStart().time();
3275 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3285 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3276 QDateTime dt ( d,tim ); 3286 QDateTime dt ( d,tim );
3277 mMoveIncidence->setDtStart( dt ); 3287 mMoveIncidence->setDtStart( dt );
3278 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3288 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3279 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3289 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3280 } else if ( mMoveIncidence->typeID() == journalID ) { 3290 } else if ( mMoveIncidence->typeID() == journalID ) {
3281 QTime tim = mMoveIncidence->dtStart().time(); 3291 QTime tim = mMoveIncidence->dtStart().time();
3282 QDateTime dt ( d,tim ); 3292 QDateTime dt ( d,tim );
3283 mMoveIncidence->setDtStart( dt ); 3293 mMoveIncidence->setDtStart( dt );
3284 updateView(); 3294 updateView();
3285 } 3295 }
3286 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3296 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3287 } 3297 }
3288} 3298}
3289 3299
3290void CalendarView::removeCategories() 3300void CalendarView::removeCategories()
3291{ 3301{
3292 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3302 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3293 QStringList catList = KOPrefs::instance()->mCustomCategories; 3303 QStringList catList = KOPrefs::instance()->mCustomCategories;
3294 QStringList catIncList; 3304 QStringList catIncList;
3295 QStringList newCatList; 3305 QStringList newCatList;
3296 Incidence* inc = incList.first(); 3306 Incidence* inc = incList.first();
3297 uint i; 3307 uint i;
3298 while ( inc ) { 3308 while ( inc ) {
3299 newCatList.clear(); 3309 newCatList.clear();
3300 catIncList = inc->categories() ; 3310 catIncList = inc->categories() ;
3301 for( i = 0; i< catIncList.count(); ++i ) { 3311 for( i = 0; i< catIncList.count(); ++i ) {
3302 if ( catList.contains (catIncList[i])) 3312 if ( catList.contains (catIncList[i]))
3303 newCatList.append( catIncList[i] ); 3313 newCatList.append( catIncList[i] );
3304 } 3314 }
3305 newCatList.sort(); 3315 newCatList.sort();
3306 inc->setCategories( newCatList.join(",") ); 3316 inc->setCategories( newCatList.join(",") );
3307 inc = incList.next(); 3317 inc = incList.next();
3308 } 3318 }
3309} 3319}
3310 3320
3311int CalendarView::addCategories() 3321int CalendarView::addCategories()
3312{ 3322{
3313 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3323 QPtrList<Incidence> incList = mCalendar->rawIncidences();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 94bc4c1..9c55e9f 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2680 +1,2688 @@
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/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
28#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
29#include <unistd.h> // for sleep 29#include <unistd.h> // for sleep
30#else 30#else
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
39#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
40#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
41#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43 43
44#include "calendarview.h" 44#include "calendarview.h"
45#include "koviewmanager.h" 45#include "koviewmanager.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47#include "koagendaview.h" 47#include "koagendaview.h"
48#include "kojournalview.h" 48#include "kojournalview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "ktoolbar.h" 59#include "ktoolbar.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63#include <kglobalsettings.h> 63#include <kglobalsettings.h>
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
132QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
133 133
134 134
135int globalFlagBlockStartup; 135int globalFlagBlockStartup;
136MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
137 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
138{ 138{
139 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
140 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
141 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
142 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
143 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
144 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
145 //int size = 12; 145 //int size = 12;
146 { 146 {
147 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
148 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
149 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
150 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
151 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
152 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
153 int iii = 0; 153 int iii = 0;
154 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
155 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
156 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
157 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
158 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
159 if ( iii ) 159 if ( iii )
160 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
161 } 161 }
162 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
163 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
164 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
165 { 165 {
166 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
167 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
168 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
169 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
170 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
171 } 171 }
172 } 172 }
173 mClosed = false; 173 mClosed = false;
174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
175 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
176 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
177 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
178 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
179 mBlockAtStartup = true; 179 mBlockAtStartup = true;
180 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
181 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
182 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
183 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
184 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
185 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
186 p->mHourSize = 22; 186 p->mHourSize = 22;
187 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
188 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
189 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
190 tbd = Bottom; 190 tbd = Bottom;
191 else 191 else
192 tbd = Top; 192 tbd = Top;
193 } 193 }
194 else { 194 else {
195 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
196 tbd = Right; 196 tbd = Right;
197 else 197 else
198 tbd = Left; 198 tbd = Left;
199 } 199 }
200 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
202 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
203 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
204 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
205 205
206#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
207 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
208#else 208#else
209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
210#endif 210#endif
211 211
212{ 212{
213 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
214 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
215 tbd = Bottom; 215 tbd = Bottom;
216 else 216 else
217 tbd = Top; 217 tbd = Top;
218 } 218 }
219 else { 219 else {
220 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
221 tbd = Right; 221 tbd = Right;
222 else 222 else
223 tbd = Left; 223 tbd = Left;
224 } 224 }
225 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
226 filterMenubar = new KMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
227 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
228#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
229 filterToolBar->setFocusPolicy( NoFocus ); 229 filterToolBar->setFocusPolicy( NoFocus );
230 filterMenubar->setFocusPolicy( NoFocus ); 230 filterMenubar->setFocusPolicy( NoFocus );
231#endif 231#endif
232 filterPopupMenu = new QPopupMenu( this ); 232 filterPopupMenu = new QPopupMenu( this );
233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
234 QString addTest = "A"; 234 QString addTest = "A";
235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
236#ifdef DESKTOP_VERSION 236#ifdef DESKTOP_VERSION
237 addTest = "AAAAAABBBCCCx"; 237 addTest = "AAAAAABBBCCCx";
238#else 238#else
239 addTest = "AAAAAx"; 239 addTest = "AAAAAx";
240#endif 240#endif
241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
242 addToolBar (filterToolBar , tbd ); 242 addToolBar (filterToolBar , tbd );
243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
246 filterToolBar->hide(); 246 filterToolBar->hide();
247 } else { 247 } else {
248 filterToolBar = 0; 248 filterToolBar = 0;
249 filterMenubar = 0; 249 filterMenubar = 0;
250 filterPopupMenu = 0; 250 filterPopupMenu = 0;
251 } 251 }
252 if ( p->mShowIconOnetoolbar ) { 252 if ( p->mShowIconOnetoolbar ) {
253 viewToolBar = iconToolBar ; 253 viewToolBar = iconToolBar ;
254 navigatorToolBar = iconToolBar ; 254 navigatorToolBar = iconToolBar ;
255 } else { 255 } else {
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 setToolBarsMovable( false ); 257 setToolBarsMovable( false );
258#endif 258#endif
259 if ( p->mToolBarHorV ) { 259 if ( p->mToolBarHorV ) {
260 if ( p->mToolBarUpV ) 260 if ( p->mToolBarUpV )
261 tbd = Bottom; 261 tbd = Bottom;
262 else 262 else
263 tbd = Top; 263 tbd = Top;
264 } 264 }
265 else { 265 else {
266 if ( p->mToolBarUpV ) 266 if ( p->mToolBarUpV )
267 tbd = Right; 267 tbd = Right;
268 else 268 else
269 tbd = Left; 269 tbd = Left;
270 } 270 }
271 viewToolBar = new QPEToolBar( this ); 271 viewToolBar = new QPEToolBar( this );
272 addToolBar (viewToolBar , tbd ); 272 addToolBar (viewToolBar , tbd );
273 if ( p->mToolBarHorN ) { 273 if ( p->mToolBarHorN ) {
274 if ( p->mToolBarUpN ) 274 if ( p->mToolBarUpN )
275 tbd = Bottom; 275 tbd = Bottom;
276 else 276 else
277 tbd = Top; 277 tbd = Top;
278 } 278 }
279 else { 279 else {
280 if ( p->mToolBarUpN ) 280 if ( p->mToolBarUpN )
281 tbd = Right; 281 tbd = Right;
282 else 282 else
283 tbd = Left; 283 tbd = Left;
284 } 284 }
285 navigatorToolBar = new QPEToolBar( this ); 285 navigatorToolBar = new QPEToolBar( this );
286 addToolBar (navigatorToolBar , tbd ); 286 addToolBar (navigatorToolBar , tbd );
287 } 287 }
288 288
289 289
290 290
291 mCalendarModifiedFlag = false; 291 mCalendarModifiedFlag = false;
292 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 292 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
293 splash->setAlignment ( AlignCenter ); 293 splash->setAlignment ( AlignCenter );
294 setCentralWidget( splash ); 294 setCentralWidget( splash );
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 showMaximized(); 296 showMaximized();
297#endif 297#endif
298 298
299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
300 setDefaultPreferences(); 300 setDefaultPreferences();
301 mCalendar = new CalendarLocal(); 301 mCalendar = new CalendarLocal();
302 mView = new CalendarView( mCalendar, this,"mCalendar " ); 302 mView = new CalendarView( mCalendar, this,"mCalendar " );
303 mView->hide(); 303 mView->hide();
304 //mView->resize(splash->size() ); 304 //mView->resize(splash->size() );
305 initActions(); 305 initActions();
306 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 306 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
307 mSyncManager->setBlockSave(false); 307 mSyncManager->setBlockSave(false);
308 mView->setSyncManager(mSyncManager); 308 mView->setSyncManager(mSyncManager);
309#ifndef DESKTOP_VERSION 309#ifndef DESKTOP_VERSION
310 iconToolBar->show(); 310 iconToolBar->show();
311 qApp->processEvents(); 311 qApp->processEvents();
312#endif 312#endif
313 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 313 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
314 int vh = height() ; 314 int vh = height() ;
315 int vw = width(); 315 int vw = width();
316 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 316 //qDebug("Toolbar hei %d ",iconToolBar->height() );
317 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 317 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
318 vh -= iconToolBar->height(); 318 vh -= iconToolBar->height();
319 } else { 319 } else {
320 vw -= iconToolBar->height(); 320 vw -= iconToolBar->height();
321 } 321 }
322 //mView->setMaximumSize( splash->size() ); 322 //mView->setMaximumSize( splash->size() );
323 //mView->resize( splash->size() ); 323 //mView->resize( splash->size() );
324 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 324 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
325 mView->readSettings(); 325 mView->readSettings();
326 bool newFile = false; 326 bool newFile = false;
327 if( !QFile::exists( defaultFileName() ) ) { 327 if( !QFile::exists( defaultFileName() ) ) {
328 QFileInfo finfo ( defaultFileName() ); 328 QFileInfo finfo ( defaultFileName() );
329 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 329 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
330 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"; 330 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";
331 finfo.setFile( oldFile ); 331 finfo.setFile( oldFile );
332 if (finfo.exists() ) { 332 if (finfo.exists() ) {
333 KMessageBox::information( this, message); 333 KMessageBox::information( this, message);
334 mView->openCalendar( oldFile ); 334 mView->openCalendar( oldFile );
335 qApp->processEvents(); 335 qApp->processEvents();
336 } else { 336 } else {
337 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 337 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
338 finfo.setFile( oldFile ); 338 finfo.setFile( oldFile );
339 if (finfo.exists() ) { 339 if (finfo.exists() ) {
340 KMessageBox::information( this, message); 340 KMessageBox::information( this, message);
341 mView->openCalendar( oldFile ); 341 mView->openCalendar( oldFile );
342 qApp->processEvents(); 342 qApp->processEvents();
343 } 343 }
344 } 344 }
345 mView->saveCalendar( defaultFileName() ); 345 mView->saveCalendar( defaultFileName() );
346 newFile = true; 346 newFile = true;
347 } 347 }
348 348
349 QTime neededSaveTime = QDateTime::currentDateTime().time(); 349 QTime neededSaveTime = QDateTime::currentDateTime().time();
350 mView->loadCalendars(); 350 mView->loadCalendars();
351 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 351 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
352 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 352 qDebug("KO: Calendar loading time: %d ms",msNeeded );
353 353
354 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 354 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
355 KOPrefs::instance()->setAllDefaults(); 355 KOPrefs::instance()->setAllDefaults();
356 } 356 }
357 processIncidenceSelection( 0 ); 357 processIncidenceSelection( 0 );
358 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 358 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
359 SLOT( processIncidenceSelection( Incidence * ) ) ); 359 SLOT( processIncidenceSelection( Incidence * ) ) );
360 connect( mView, SIGNAL( modifiedChanged( bool ) ), 360 connect( mView, SIGNAL( modifiedChanged( bool ) ),
361 SLOT( slotModifiedChanged( bool ) ) ); 361 SLOT( slotModifiedChanged( bool ) ) );
362 362
363 363
364 connect( mView, SIGNAL( tempDisableBR(bool) ), 364 connect( mView, SIGNAL( tempDisableBR(bool) ),
365 SLOT( disableBR(bool) ) ); 365 SLOT( disableBR(bool) ) );
366 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 366 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
367 mView->setModified( false ); 367 mView->setModified( false );
368 mBlockAtStartup = false; 368 mBlockAtStartup = false;
369 mView->setModified( false ); 369 mView->setModified( false );
370 setCentralWidget( mView ); 370 setCentralWidget( mView );
371 globalFlagBlockStartup = 0; 371 globalFlagBlockStartup = 0;
372 mView->show(); 372 mView->show();
373 delete splash; 373 delete splash;
374 if ( newFile ) 374 if ( newFile )
375 mView->updateConfig(); 375 mView->updateConfig();
376 // qApp->processEvents(); 376 // qApp->processEvents();
377 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 377 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
378 //fillSyncMenu(); 378 //fillSyncMenu();
379 379
380 380
381 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 381 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
382 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 382 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
383 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 383 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
384 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 384 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
385 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 385 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
386 mSyncManager->setDefaultFileName( sentSyncFile()); 386 mSyncManager->setDefaultFileName( sentSyncFile());
387 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 387 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
388 mSyncManager->fillSyncMenu(); 388 mSyncManager->fillSyncMenu();
389 389
390 390
391 391
392 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 392 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
393 if ( showWarning ) { 393 if ( showWarning ) {
394 KMessageBox::information( this, 394 KMessageBox::information( this,
395 "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"); 395 "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");
396 qApp->processEvents(); 396 qApp->processEvents();
397 mView->dialogManager()->showSyncOptions(); 397 mView->dialogManager()->showSyncOptions();
398 } 398 }
399 399
400 //US listen for result adressed from Ka/Pi 400 //US listen for result adressed from Ka/Pi
401#ifndef DESKTOP_VERSION 401#ifndef DESKTOP_VERSION
402 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 402 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
403#endif 403#endif
404#ifndef DESKTOP_VERSION 404#ifndef DESKTOP_VERSION
405 infrared = 0; 405 infrared = 0;
406#endif 406#endif
407 updateFilterToolbar(); 407 updateFilterToolbar();
408 updateWeek( mView->startDate() ); 408 updateWeek( mView->startDate() );
409 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 409 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
410 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 410 SLOT( updateWeekNum( const KCal::DateList & ) ) );
411 mBRdisabled = false; 411 mBRdisabled = false;
412 //toggleBeamReceive(); 412 //toggleBeamReceive();
413 413
414 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 414 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
415} 415}
416MainWindow::~MainWindow() 416MainWindow::~MainWindow()
417{ 417{
418 //qDebug("MainWindow::~MainWindow() "); 418 //qDebug("MainWindow::~MainWindow() ");
419 //save toolbar location 419 //save toolbar location
420 delete mCalendar; 420 delete mCalendar;
421 delete mSyncManager; 421 delete mSyncManager;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 if ( infrared ) 423 if ( infrared )
424 delete infrared; 424 delete infrared;
425#endif 425#endif
426 426
427 427
428} 428}
429void MainWindow::slotResetFocus() 429void MainWindow::slotResetFocus()
430{ 430{
431 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 431 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
432 mFocusLoop = 3; 432 mFocusLoop = 3;
433 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 433 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
434} 434}
435void MainWindow::slotResetFocusLoop() 435void MainWindow::slotResetFocusLoop()
436{ 436{
437 --mFocusLoop; 437 --mFocusLoop;
438 QWidget* fw = mView->viewManager()->currentView(); 438 QWidget* fw = mView->viewManager()->currentView();
439 if ( fw ) { 439 if ( fw ) {
440 //qDebug("loop "); 440 //qDebug("loop ");
441 fw->setFocus(); 441 fw->setFocus();
442 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 442 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
443 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 443 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
444 } 444 }
445 445
446} 446}
447void MainWindow::disableBR(bool b) 447void MainWindow::disableBR(bool b)
448{ 448{
449#ifndef DESKTOP_VERSION 449#ifndef DESKTOP_VERSION
450 if ( b ) { 450 if ( b ) {
451 if ( infrared ) { 451 if ( infrared ) {
452 toggleBeamReceive(); 452 toggleBeamReceive();
453 mBRdisabled = true; 453 mBRdisabled = true;
454 } 454 }
455 mBRdisabled = true; 455 mBRdisabled = true;
456 } else { 456 } else {
457 if ( mBRdisabled ) { 457 if ( mBRdisabled ) {
458 mBRdisabled = false; 458 mBRdisabled = false;
459 //makes no sense,because other cal ap is probably running 459 //makes no sense,because other cal ap is probably running
460 // toggleBeamReceive(); 460 // toggleBeamReceive();
461 } 461 }
462 } 462 }
463#endif 463#endif
464 464
465} 465}
466bool MainWindow::beamReceiveEnabled() 466bool MainWindow::beamReceiveEnabled()
467{ 467{
468#ifndef DESKTOP_VERSION 468#ifndef DESKTOP_VERSION
469 return ( infrared != 0 ); 469 return ( infrared != 0 );
470#endif 470#endif
471 return false; 471 return false;
472} 472}
473 473
474void MainWindow::toggleBeamReceive() 474void MainWindow::toggleBeamReceive()
475{ 475{
476 if ( mBRdisabled ) 476 if ( mBRdisabled )
477 return; 477 return;
478#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
479 if ( infrared ) { 479 if ( infrared ) {
480 qDebug("KO: Disable BeamReceive "); 480 qDebug("KO: Disable BeamReceive ");
481 delete infrared; 481 delete infrared;
482 infrared = 0; 482 infrared = 0;
483 brAction->setOn(false); 483 brAction->setOn(false);
484 return; 484 return;
485 } 485 }
486 qDebug("KO: Enable BeamReceive "); 486 qDebug("KO: Enable BeamReceive ");
487 brAction->setOn(true); 487 brAction->setOn(true);
488 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 488 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
489 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 489 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
490#endif 490#endif
491} 491}
492void MainWindow::showMaximized () 492void MainWindow::showMaximized ()
493{ 493{
494#ifndef DESKTOP_VERSION 494#ifndef DESKTOP_VERSION
495 if ( ! globalFlagBlockStartup ) 495 if ( ! globalFlagBlockStartup )
496 if ( mClosed ) 496 if ( mClosed )
497 mView->goToday(); 497 mView->goToday();
498#endif 498#endif
499 QWidget::showMaximized () ; 499 QWidget::showMaximized () ;
500 mClosed = false; 500 mClosed = false;
501} 501}
502void MainWindow::closeEvent( QCloseEvent* ce ) 502void MainWindow::closeEvent( QCloseEvent* ce )
503{ 503{
504 504
505 505
506 506
507 if ( ! KOPrefs::instance()->mAskForQuit ) { 507 if ( ! KOPrefs::instance()->mAskForQuit ) {
508 saveOnClose(); 508 saveOnClose();
509 if ( mCalendarModifiedFlag ) {
510 ce->ignore();
511 return;
512 }
509 mClosed = true; 513 mClosed = true;
510 ce->accept(); 514 ce->accept();
511 return; 515 return;
512 516
513 } 517 }
514 518
515 switch( QMessageBox::information( this, "KO/Pi", 519 switch( QMessageBox::information( this, "KO/Pi",
516 i18n("Do you really want\nto close KO/Pi?"), 520 i18n("Do you really want\nto close KO/Pi?"),
517 i18n("Close"), i18n("No"), 521 i18n("Close"), i18n("No"),
518 0, 0 ) ) { 522 0, 0 ) ) {
519 case 0: 523 case 0:
520 saveOnClose(); 524 saveOnClose();
525 if ( mCalendarModifiedFlag ) {
526 ce->ignore();
527 return;
528 }
521 mClosed = true; 529 mClosed = true;
522 ce->accept(); 530 ce->accept();
523 break; 531 break;
524 case 1: 532 case 1:
525 ce->ignore(); 533 ce->ignore();
526 break; 534 break;
527 case 2: 535 case 2:
528 536
529 default: 537 default:
530 break; 538 break;
531 } 539 }
532 540
533 541
534} 542}
535 543
536void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 544void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
537{ 545{
538 QDataStream stream( data, IO_ReadOnly ); 546 QDataStream stream( data, IO_ReadOnly );
539 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 547 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
540 //QString datamess; 548 //QString datamess;
541 //qDebug("message "); 549 //qDebug("message ");
542 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 550 qDebug("KO: QCOP message received: %s ", cmsg.data() );
543 551
544 if ( cmsg == "setDocument(QString)" ) { 552 if ( cmsg == "setDocument(QString)" ) {
545 QDataStream stream( data, IO_ReadOnly ); 553 QDataStream stream( data, IO_ReadOnly );
546 QString fileName; 554 QString fileName;
547 stream >> fileName; 555 stream >> fileName;
548 //qDebug("filename %s ", fileName.latin1()); 556 //qDebug("filename %s ", fileName.latin1());
549 showMaximized(); 557 showMaximized();
550 raise(); 558 raise();
551 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 559 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
552 mSyncManager->slotSyncMenu( 1002 ); 560 mSyncManager->slotSyncMenu( 1002 );
553 return; 561 return;
554 } 562 }
555 563
556 if ( cmsg == "-writeFile" ) { 564 if ( cmsg == "-writeFile" ) {
557 // I made from the "-writeFile" an "-writeAlarm" 565 // I made from the "-writeFile" an "-writeAlarm"
558 mView->viewManager()->showWhatsNextView(); 566 mView->viewManager()->showWhatsNextView();
559 mCalendar->checkAlarmForIncidence( 0, true); 567 mCalendar->checkAlarmForIncidence( 0, true);
560 showMaximized(); 568 showMaximized();
561 raise(); 569 raise();
562 return; 570 return;
563 571
564 } 572 }
565 if ( cmsg == "-writeFileSilent" ) { 573 if ( cmsg == "-writeFileSilent" ) {
566 // I made from the "-writeFile" an "-writeAlarm" 574 // I made from the "-writeFile" an "-writeAlarm"
567 // mView->viewManager()->showWhatsNextView(); 575 // mView->viewManager()->showWhatsNextView();
568 mCalendar->checkAlarmForIncidence( 0, true); 576 mCalendar->checkAlarmForIncidence( 0, true);
569 //showMaximized(); 577 //showMaximized();
570 //raise(); 578 //raise();
571 hide(); 579 hide();
572 return; 580 return;
573 } 581 }
574 if ( cmsg == "-newCountdown" ) { 582 if ( cmsg == "-newCountdown" ) {
575 qDebug("newCountdown "); 583 qDebug("newCountdown ");
576 584
577 } 585 }
578 QString msg ; 586 QString msg ;
579 QString allmsg = cmsg; 587 QString allmsg = cmsg;
580 while ( allmsg.length() > 0 ) { 588 while ( allmsg.length() > 0 ) {
581 int nextC = allmsg.find( "-", 1 ); 589 int nextC = allmsg.find( "-", 1 );
582 if ( nextC == -1 ) { 590 if ( nextC == -1 ) {
583 msg = allmsg; 591 msg = allmsg;
584 allmsg = ""; 592 allmsg = "";
585 } else{ 593 } else{
586 msg = allmsg.left( nextC ); 594 msg = allmsg.left( nextC );
587 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 595 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
588 } 596 }
589 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 597 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
590 if ( msg == "-newEvent" ) { 598 if ( msg == "-newEvent" ) {
591 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 599 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
592 } 600 }
593 if ( msg == "-newTodo" ) { 601 if ( msg == "-newTodo" ) {
594 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 602 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
595 } 603 }
596 if ( msg == "-showWN" ) { 604 if ( msg == "-showWN" ) {
597 mView->viewManager()->showWhatsNextView(); 605 mView->viewManager()->showWhatsNextView();
598 } 606 }
599 if ( msg == "-showTodo" ) { 607 if ( msg == "-showTodo" ) {
600 mView->viewManager()->showTodoView(); 608 mView->viewManager()->showTodoView();
601 } 609 }
602 if ( msg == "-showList" ) { 610 if ( msg == "-showList" ) {
603 mView->viewManager()->showListView(); 611 mView->viewManager()->showListView();
604 } 612 }
605 else if ( msg == "-showDay" ) { 613 else if ( msg == "-showDay" ) {
606 mView->viewManager()->showDayView(); 614 mView->viewManager()->showDayView();
607 } 615 }
608 else if ( msg == "-showWWeek" ) { 616 else if ( msg == "-showWWeek" ) {
609 mView->viewManager()->showWorkWeekView(); 617 mView->viewManager()->showWorkWeekView();
610 } 618 }
611 else if ( msg == "-ringSync" ) { 619 else if ( msg == "-ringSync" ) {
612 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 620 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
613 } 621 }
614 else if ( msg == "-showWeek" ) { 622 else if ( msg == "-showWeek" ) {
615 mView->viewManager()->showWeekView(); 623 mView->viewManager()->showWeekView();
616 } 624 }
617 else if ( msg == "-showTodo" ) { 625 else if ( msg == "-showTodo" ) {
618 mView->viewManager()->showTodoView(); 626 mView->viewManager()->showTodoView();
619 } 627 }
620 else if ( msg == "-showJournal" ) { 628 else if ( msg == "-showJournal" ) {
621 mView->dateNavigator()->selectDates( 1 ); 629 mView->dateNavigator()->selectDates( 1 );
622 mView->dateNavigator()->selectToday(); 630 mView->dateNavigator()->selectToday();
623 mView->viewManager()->showJournalView(); 631 mView->viewManager()->showJournalView();
624 } 632 }
625 else if ( msg == "-showKO" ) { 633 else if ( msg == "-showKO" ) {
626 mView->viewManager()->showNextXView(); 634 mView->viewManager()->showNextXView();
627 } 635 }
628 else if ( msg == "-showWNext" ) { 636 else if ( msg == "-showWNext" ) {
629 mView->viewManager()->showWhatsNextView(); 637 mView->viewManager()->showWhatsNextView();
630 } 638 }
631 else if ( msg == "nextView()" ) { 639 else if ( msg == "nextView()" ) {
632 mView->viewManager()->showNextView(); 640 mView->viewManager()->showNextView();
633 } 641 }
634 else if ( msg == "-showNextXView" ) { 642 else if ( msg == "-showNextXView" ) {
635 mView->viewManager()->showNextXView(); 643 mView->viewManager()->showNextXView();
636 } 644 }
637 645
638 646
639 } 647 }
640 648
641 showMaximized(); 649 showMaximized();
642 raise(); 650 raise();
643} 651}
644void MainWindow::startMultiSync() 652void MainWindow::startMultiSync()
645{ 653{
646 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 654 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
647 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 655 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
648 question, 656 question,
649 i18n("Yes"), i18n("No"), 657 i18n("Yes"), i18n("No"),
650 0, 0 ) != 0 ) { 658 0, 0 ) != 0 ) {
651 setCaption(i18n("Aborted! Nothing synced!")); 659 setCaption(i18n("Aborted! Nothing synced!"));
652 return; 660 return;
653 } 661 }
654 mSyncManager->multiSync( false ); 662 mSyncManager->multiSync( false );
655#ifndef DESKTOP_VERSION 663#ifndef DESKTOP_VERSION
656 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 664 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
657#endif 665#endif
658} 666}
659QPixmap MainWindow::loadPixmap( QString name ) 667QPixmap MainWindow::loadPixmap( QString name )
660{ 668{
661 return SmallIcon( name ); 669 return SmallIcon( name );
662 670
663} 671}
664void MainWindow::setUsesBigPixmaps ( bool b ) 672void MainWindow::setUsesBigPixmaps ( bool b )
665{ 673{
666 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 674 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
667 if ( b ) 675 if ( b )
668 qDebug("KO: BigPixmaps are not supported "); 676 qDebug("KO: BigPixmaps are not supported ");
669} 677}
670void MainWindow::initActions() 678void MainWindow::initActions()
671{ 679{
672 //KOPrefs::instance()->mShowFullMenu 680 //KOPrefs::instance()->mShowFullMenu
673 iconToolBar->clear(); 681 iconToolBar->clear();
674 KOPrefs *p = KOPrefs::instance(); 682 KOPrefs *p = KOPrefs::instance();
675 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 683 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
676 684
677 QPopupMenu *viewMenu = new QPopupMenu( this ); 685 QPopupMenu *viewMenu = new QPopupMenu( this );
678 QPopupMenu *actionMenu = new QPopupMenu( this ); 686 QPopupMenu *actionMenu = new QPopupMenu( this );
679 mCurrentItemMenu = new QPopupMenu ( this ); 687 mCurrentItemMenu = new QPopupMenu ( this );
680 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 688 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
681 QPopupMenu *importMenu = new QPopupMenu( this ); 689 QPopupMenu *importMenu = new QPopupMenu( this );
682 QPopupMenu *importMenu_X = new QPopupMenu( this ); 690 QPopupMenu *importMenu_X = new QPopupMenu( this );
683 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 691 QPopupMenu *exportMenu_X = new QPopupMenu( this );
684 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 692 QPopupMenu *beamMenu_X = new QPopupMenu( this );
685 selectFilterMenu = new QPopupMenu( this ); 693 selectFilterMenu = new QPopupMenu( this );
686 selectFilterMenu->setCheckable( true ); 694 selectFilterMenu->setCheckable( true );
687 syncMenu = new QPopupMenu( this ); 695 syncMenu = new QPopupMenu( this );
688 configureAgendaMenu = new QPopupMenu( this ); 696 configureAgendaMenu = new QPopupMenu( this );
689 configureToolBarMenu = new QPopupMenu( this ); 697 configureToolBarMenu = new QPopupMenu( this );
690 QPopupMenu *helpMenu = new QPopupMenu( this ); 698 QPopupMenu *helpMenu = new QPopupMenu( this );
691 QIconSet icon; 699 QIconSet icon;
692 int pixWid = 22, pixHei = 22; 700 int pixWid = 22, pixHei = 22;
693 QString pathString = ""; 701 QString pathString = "";
694 if ( !p->mToolBarMiniIcons ) { 702 if ( !p->mToolBarMiniIcons ) {
695 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 703 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
696 pathString += "icons16/"; 704 pathString += "icons16/";
697 pixWid = 18; pixHei = 16; 705 pixWid = 18; pixHei = 16;
698 } 706 }
699 } else { 707 } else {
700 pathString += "iconsmini/"; 708 pathString += "iconsmini/";
701 pixWid = 18; pixHei = 16; 709 pixWid = 18; pixHei = 16;
702 } 710 }
703 711
704 if ( KOPrefs::instance()->mShowFullMenu ) { 712 if ( KOPrefs::instance()->mShowFullMenu ) {
705 menuBar1 = new KMenuBar( this );//menuBar(); 713 menuBar1 = new KMenuBar( this );//menuBar();
706 //setMenuBar( menuBar1 ); 714 //setMenuBar( menuBar1 );
707 menuBar1->show(); 715 menuBar1->show();
708 menuBar1->insertItem( i18n("File"), importMenu ); 716 menuBar1->insertItem( i18n("File"), importMenu );
709 menuBar1->insertItem( i18n("View"), viewMenu ); 717 menuBar1->insertItem( i18n("View"), viewMenu );
710 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 718 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
711 menuBar1->insertItem( i18n("Action"), actionMenu ); 719 menuBar1->insertItem( i18n("Action"), actionMenu );
712#ifdef DESKTOP_VERSION 720#ifdef DESKTOP_VERSION
713 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 721 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
714 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 722 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
715#else 723#else
716 menuBar1->insertItem( i18n("Sync"), syncMenu ); 724 menuBar1->insertItem( i18n("Sync"), syncMenu );
717 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 725 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
718#endif 726#endif
719 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 727 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
720 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 728 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
721 menuBar1->insertItem( i18n("Help"), helpMenu ); 729 menuBar1->insertItem( i18n("Help"), helpMenu );
722 } else { 730 } else {
723 menuBar1 = new KMenuBar( iconToolBar ); 731 menuBar1 = new KMenuBar( iconToolBar );
724 QPopupMenu *menuBar = new QPopupMenu( this ); 732 QPopupMenu *menuBar = new QPopupMenu( this );
725 icon = loadPixmap( pathString + "z_menu" ); 733 icon = loadPixmap( pathString + "z_menu" );
726 menuBar1->insertItem( icon.pixmap(), menuBar); 734 menuBar1->insertItem( icon.pixmap(), menuBar);
727 //menuBar1->insertItem( i18n("ME"), menuBar); 735 //menuBar1->insertItem( i18n("ME"), menuBar);
728 menuBar->insertItem( i18n("File"), importMenu ); 736 menuBar->insertItem( i18n("File"), importMenu );
729 menuBar->insertItem( i18n("View"), viewMenu ); 737 menuBar->insertItem( i18n("View"), viewMenu );
730 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 738 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
731 menuBar->insertItem( i18n("Action"), actionMenu ); 739 menuBar->insertItem( i18n("Action"), actionMenu );
732 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 740 menuBar->insertItem( i18n("Synchronize"), syncMenu );
733 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 741 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
734 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 742 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
735 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 743 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
736 menuBar->insertItem( i18n("Help"), helpMenu ); 744 menuBar->insertItem( i18n("Help"), helpMenu );
737 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 745 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
738 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 746 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
739 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 747 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
740 } 748 }
741 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 749 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
742 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 750 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
743 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 751 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
744 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 752 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
745 753
746 754
747 mWeekBgColor = iconToolBar->backgroundColor(); 755 mWeekBgColor = iconToolBar->backgroundColor();
748 mWeekPixmap.resize( pixWid , pixHei ); 756 mWeekPixmap.resize( pixWid , pixHei );
749 mWeekPixmap.fill( mWeekBgColor ); 757 mWeekPixmap.fill( mWeekBgColor );
750 icon = mWeekPixmap; 758 icon = mWeekPixmap;
751 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 759 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
752 if ( p-> mShowIconWeekNum ) 760 if ( p-> mShowIconWeekNum )
753 mWeekAction->addTo( iconToolBar ); 761 mWeekAction->addTo( iconToolBar );
754 mWeekFont = font(); 762 mWeekFont = font();
755 763
756 int fontPoint = mWeekFont.pointSize(); 764 int fontPoint = mWeekFont.pointSize();
757 QFontMetrics f( mWeekFont ); 765 QFontMetrics f( mWeekFont );
758 int fontWid = f.width( "30" ); 766 int fontWid = f.width( "30" );
759 while ( fontWid > pixWid ) { 767 while ( fontWid > pixWid ) {
760 --fontPoint; 768 --fontPoint;
761 mWeekFont.setPointSize( fontPoint ); 769 mWeekFont.setPointSize( fontPoint );
762 QFontMetrics f( mWeekFont ); 770 QFontMetrics f( mWeekFont );
763 fontWid = f.width( "30" ); 771 fontWid = f.width( "30" );
764 //qDebug("dec-- "); 772 //qDebug("dec-- ");
765 } 773 }
766 774
767 connect( mWeekAction, SIGNAL( activated() ), 775 connect( mWeekAction, SIGNAL( activated() ),
768 this, SLOT( weekAction() ) ); 776 this, SLOT( weekAction() ) );
769 777
770 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 778 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
771 if ( p->mShowIconFilterview ) { 779 if ( p->mShowIconFilterview ) {
772 icon = loadPixmap( pathString + "filter" ); 780 icon = loadPixmap( pathString + "filter" );
773 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 781 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
774 connect( actionFilterMenuTB, SIGNAL( activated() ), 782 connect( actionFilterMenuTB, SIGNAL( activated() ),
775 this, SLOT( fillFilterMenuTB() ) ); 783 this, SLOT( fillFilterMenuTB() ) );
776 actionFilterMenuTB->addTo( iconToolBar ); 784 actionFilterMenuTB->addTo( iconToolBar );
777 selectFilterMenuTB = new QPopupMenu( this ); 785 selectFilterMenuTB = new QPopupMenu( this );
778 selectFilterMenuTB->setCheckable( true ); 786 selectFilterMenuTB->setCheckable( true );
779 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 787 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
780 } 788 }
781 789
782 //#endif 790 //#endif
783 // ****************** 791 // ******************
784 QAction *action; 792 QAction *action;
785 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 793 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
786 configureToolBarMenu->setCheckable( true ); 794 configureToolBarMenu->setCheckable( true );
787 795
788 796
789 configureAgendaMenu->setCheckable( true ); 797 configureAgendaMenu->setCheckable( true );
790 int iii ; 798 int iii ;
791 for ( iii = 1;iii<= 10 ;++iii ){ 799 for ( iii = 1;iii<= 10 ;++iii ){
792 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 800 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
793 } 801 }
794 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 802 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
795 803
796 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 804 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
797 this, SLOT( showConfigureAgenda( ) ) ); 805 this, SLOT( showConfigureAgenda( ) ) );
798 icon = loadPixmap( pathString + "today" ); 806 icon = loadPixmap( pathString + "today" );
799 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 807 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
800 today_action->addTo( actionMenu ); 808 today_action->addTo( actionMenu );
801 connect( today_action, SIGNAL( activated() ), 809 connect( today_action, SIGNAL( activated() ),
802 mView, SLOT( goToday() ) ); 810 mView, SLOT( goToday() ) );
803 811
804 icon = loadPixmap( pathString + "picker" ); 812 icon = loadPixmap( pathString + "picker" );
805 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); 813 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this );
806 dPickerAction->addTo( actionMenu ); 814 dPickerAction->addTo( actionMenu );
807 connect( dPickerAction, SIGNAL( activated() ), 815 connect( dPickerAction, SIGNAL( activated() ),
808 mView, SLOT( showDatePicker() ) ); 816 mView, SLOT( showDatePicker() ) );
809 817
810 icon = loadPixmap( pathString + "search" ); 818 icon = loadPixmap( pathString + "search" );
811 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 819 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
812 search_action->addTo( actionMenu ); 820 search_action->addTo( actionMenu );
813 connect( search_action, SIGNAL( activated() ), 821 connect( search_action, SIGNAL( activated() ),
814 mView->dialogManager(), SLOT( showSearchDialog() ) ); 822 mView->dialogManager(), SLOT( showSearchDialog() ) );
815 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); 823 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu );
816 824
817 action = new QAction( "Undo Delete", i18n("All events"), 0, this ); 825 action = new QAction( "Undo Delete", i18n("All events"), 0, this );
818 action->addTo( nextConflictMenu ); 826 action->addTo( nextConflictMenu );
819 connect( action, SIGNAL( activated() ), 827 connect( action, SIGNAL( activated() ),
820 mView, SLOT( conflictAll() ) ); 828 mView, SLOT( conflictAll() ) );
821 829
822 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); 830 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this );
823 action->addTo( nextConflictMenu ); 831 action->addTo( nextConflictMenu );
824 connect( action, SIGNAL( activated() ), 832 connect( action, SIGNAL( activated() ),
825 mView, SLOT( conflictAllday() ) ); 833 mView, SLOT( conflictAllday() ) );
826 834
827 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); 835 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this );
828 action->addTo( nextConflictMenu ); 836 action->addTo( nextConflictMenu );
829 connect( action, SIGNAL( activated() ), 837 connect( action, SIGNAL( activated() ),
830 mView, SLOT( conflictNotAll() ) ); 838 mView, SLOT( conflictNotAll() ) );
831 839
832 actionMenu->insertSeparator(); 840 actionMenu->insertSeparator();
833 841
834 icon = loadPixmap( pathString + "newevent" ); 842 icon = loadPixmap( pathString + "newevent" );
835 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 843 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
836 ne_action->addTo( mCurrentItemMenu ); 844 ne_action->addTo( mCurrentItemMenu );
837 connect( ne_action, SIGNAL( activated() ), 845 connect( ne_action, SIGNAL( activated() ),
838 mView, SLOT( newEvent() ) ); 846 mView, SLOT( newEvent() ) );
839 icon = loadPixmap( pathString + "newtodo" ); 847 icon = loadPixmap( pathString + "newtodo" );
840 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 848 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
841 nt_action->addTo( mCurrentItemMenu ); 849 nt_action->addTo( mCurrentItemMenu );
842 connect( nt_action, SIGNAL( activated() ), 850 connect( nt_action, SIGNAL( activated() ),
843 mView, SLOT( newTodo() ) ); 851 mView, SLOT( newTodo() ) );
844 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 852 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
845 this ); 853 this );
846 mNewSubTodoAction->addTo( mCurrentItemMenu ); 854 mNewSubTodoAction->addTo( mCurrentItemMenu );
847 connect( mNewSubTodoAction, SIGNAL( activated() ), 855 connect( mNewSubTodoAction, SIGNAL( activated() ),
848 mView, SLOT( newSubTodo() ) ); 856 mView, SLOT( newSubTodo() ) );
849 857
850 mCurrentItemMenu->insertSeparator(); 858 mCurrentItemMenu->insertSeparator();
851 icon = loadPixmap( pathString + "newevent" ); 859 icon = loadPixmap( pathString + "newevent" );
852 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 860 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
853 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 861 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
854 configureToolBarMenu->insertSeparator(); 862 configureToolBarMenu->insertSeparator();
855 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 863 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
856 configureToolBarMenu->insertSeparator(); 864 configureToolBarMenu->insertSeparator();
857 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 865 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
858 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 866 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
859 icon = loadPixmap( pathString + "newtodo" ); 867 icon = loadPixmap( pathString + "newtodo" );
860 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 868 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
861 869
862 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); 870 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu);
863 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); 871 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this );
864 mShowAction->addTo( mCurrentItemMenu ); 872 mShowAction->addTo( mCurrentItemMenu );
865 connect( mShowAction, SIGNAL( activated() ), 873 connect( mShowAction, SIGNAL( activated() ),
866 mView, SLOT( showIncidence() ) ); 874 mView, SLOT( showIncidence() ) );
867 875
868 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 876 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
869 mEditAction->addTo( mCurrentItemMenu ); 877 mEditAction->addTo( mCurrentItemMenu );
870 connect( mEditAction, SIGNAL( activated() ), 878 connect( mEditAction, SIGNAL( activated() ),
871 mView, SLOT( editIncidence() ) ); 879 mView, SLOT( editIncidence() ) );
872 880
873 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 881 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
874 mDeleteAction->addTo( mCurrentItemMenu ); 882 mDeleteAction->addTo( mCurrentItemMenu );
875 connect( mDeleteAction, SIGNAL( activated() ), 883 connect( mDeleteAction, SIGNAL( activated() ),
876 mView, SLOT( deleteIncidence() ) ); 884 mView, SLOT( deleteIncidence() ) );
877 885
878 886
879 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 887 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
880 mCloneAction->addTo( mCurrentItemMenu ); 888 mCloneAction->addTo( mCurrentItemMenu );
881 connect( mCloneAction, SIGNAL( activated() ), 889 connect( mCloneAction, SIGNAL( activated() ),
882 mView, SLOT( cloneIncidence() ) ); 890 mView, SLOT( cloneIncidence() ) );
883 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 891 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
884 mMoveAction->addTo( mCurrentItemMenu ); 892 mMoveAction->addTo( mCurrentItemMenu );
885 connect( mMoveAction, SIGNAL( activated() ), 893 connect( mMoveAction, SIGNAL( activated() ),
886 mView, SLOT( moveIncidence() ) ); 894 mView, SLOT( moveIncidence() ) );
887#ifndef DESKTOP_VERSION 895#ifndef DESKTOP_VERSION
888 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 896 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
889 mBeamAction->addTo(mCurrentItemMenu ); 897 mBeamAction->addTo(mCurrentItemMenu );
890 connect( mBeamAction, SIGNAL( activated() ), 898 connect( mBeamAction, SIGNAL( activated() ),
891 mView, SLOT( beamIncidence() ) ); 899 mView, SLOT( beamIncidence() ) );
892#endif 900#endif
893 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 901 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
894 mCancelAction->addTo( mCurrentItemMenu ); 902 mCancelAction->addTo( mCurrentItemMenu );
895 connect( mCancelAction, SIGNAL( activated() ), 903 connect( mCancelAction, SIGNAL( activated() ),
896 mView, SLOT( toggleCancelIncidence() ) ); 904 mView, SLOT( toggleCancelIncidence() ) );
897 905
898 906
899 mCurrentItemMenu->insertSeparator(); 907 mCurrentItemMenu->insertSeparator();
900 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 908 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
901 action->addTo( mCurrentItemMenu ); 909 action->addTo( mCurrentItemMenu );
902 connect( action, SIGNAL( activated() ), 910 connect( action, SIGNAL( activated() ),
903 mView, SLOT( undo_delete() ) ); 911 mView, SLOT( undo_delete() ) );
904 912
905 // *********************** 913 // ***********************
906 if ( KOPrefs::instance()->mVerticalScreen ) { 914 if ( KOPrefs::instance()->mVerticalScreen ) {
907 icon = SmallIcon( "1updownarrow" ); 915 icon = SmallIcon( "1updownarrow" );
908 } else { 916 } else {
909 icon = SmallIcon("1leftrightarrow" ); 917 icon = SmallIcon("1leftrightarrow" );
910 } 918 }
911 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 919 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
912 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 920 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
913 FSaction->addTo( viewMenu ); 921 FSaction->addTo( viewMenu );
914 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 922 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
915 923
916 924
917 icon = loadPixmap( pathString + "filter" ); 925 icon = loadPixmap( pathString + "filter" );
918 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 926 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
919 icon = loadPixmap( pathString + "configure" ); 927 icon = loadPixmap( pathString + "configure" );
920 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 928 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
921 action->addTo( viewMenu ); 929 action->addTo( viewMenu );
922 connect( action, SIGNAL( activated() ), 930 connect( action, SIGNAL( activated() ),
923 mView, SLOT( toggleFilter() ) ); 931 mView, SLOT( toggleFilter() ) );
924 mToggleFilter = action; 932 mToggleFilter = action;
925 icon = loadPixmap( pathString + "navi" ); 933 icon = loadPixmap( pathString + "navi" );
926 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 934 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
927 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 935 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
928 action->addTo( viewMenu ); 936 action->addTo( viewMenu );
929 connect( action, SIGNAL( activated() ), 937 connect( action, SIGNAL( activated() ),
930 mView, SLOT( toggleDateNavigatorWidget() ) ); 938 mView, SLOT( toggleDateNavigatorWidget() ) );
931 mToggleNav = action ; 939 mToggleNav = action ;
932 icon = loadPixmap( pathString + "allday" ); 940 icon = loadPixmap( pathString + "allday" );
933 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 941 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
934 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 942 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
935 action->addTo( viewMenu ); 943 action->addTo( viewMenu );
936 connect( action, SIGNAL( activated() ), 944 connect( action, SIGNAL( activated() ),
937 mView, SLOT( toggleAllDaySize() ) ); 945 mView, SLOT( toggleAllDaySize() ) );
938 mToggleAllday = action; 946 mToggleAllday = action;
939 947
940 948
941 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 949 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
942 mToggleNav, SLOT( setEnabled ( bool ) ) ); 950 mToggleNav, SLOT( setEnabled ( bool ) ) );
943 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 951 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
944 // mToggleFilter, SLOT( setEnabled ( bool ) ) ); 952 // mToggleFilter, SLOT( setEnabled ( bool ) ) );
945 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 953 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
946 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 954 mToggleAllday, SLOT( setEnabled ( bool ) ) );
947 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 955 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
948 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 956 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
949 957
950 958
951 dPickerAction->addTo( iconToolBar ); 959 dPickerAction->addTo( iconToolBar );
952 viewMenu->insertSeparator(); 960 viewMenu->insertSeparator();
953 961
954 if ( p-> mShowIconToggleFull ) 962 if ( p-> mShowIconToggleFull )
955 FSaction->addTo( iconToolBar ); 963 FSaction->addTo( iconToolBar );
956 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 964 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
957 965
958 //******************** 966 //********************
959 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 967 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
960 968
961 969
962 icon = loadPixmap( pathString + "whatsnext" ); 970 icon = loadPixmap( pathString + "whatsnext" );
963 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 971 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
964 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 972 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
965 whatsnext_action->addTo( viewMenu ); 973 whatsnext_action->addTo( viewMenu );
966 connect( whatsnext_action, SIGNAL( activated() ), 974 connect( whatsnext_action, SIGNAL( activated() ),
967 mView->viewManager(), SLOT( showWhatsNextView() ) ); 975 mView->viewManager(), SLOT( showWhatsNextView() ) );
968 976
969 icon = loadPixmap( pathString + "xdays" ); 977 icon = loadPixmap( pathString + "xdays" );
970 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 978 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
971 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 979 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
972 xdays_action->addTo( viewMenu ); 980 xdays_action->addTo( viewMenu );
973 connect( xdays_action, SIGNAL( activated() ), 981 connect( xdays_action, SIGNAL( activated() ),
974 mView->viewManager(), SLOT( showNextXView() ) ); 982 mView->viewManager(), SLOT( showNextXView() ) );
975 983
976 984
977 icon = loadPixmap( pathString + "journal" ); 985 icon = loadPixmap( pathString + "journal" );
978 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 986 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
979 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 987 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
980 viewjournal_action->addTo( viewMenu ); 988 viewjournal_action->addTo( viewMenu );
981 connect( viewjournal_action, SIGNAL( activated() ), 989 connect( viewjournal_action, SIGNAL( activated() ),
982 mView->viewManager(), SLOT( showJournalView() ) ); 990 mView->viewManager(), SLOT( showJournalView() ) );
983 991
984 992
985 icon = loadPixmap( pathString + "day" ); 993 icon = loadPixmap( pathString + "day" );
986 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 994 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
987 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 995 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
988 day1_action->addTo( viewMenu ); 996 day1_action->addTo( viewMenu );
989 // action->addTo( toolBar ); 997 // action->addTo( toolBar );
990 connect( day1_action, SIGNAL( activated() ), 998 connect( day1_action, SIGNAL( activated() ),
991 mView->viewManager(), SLOT( showDayView() ) ); 999 mView->viewManager(), SLOT( showDayView() ) );
992 1000
993 icon = loadPixmap( pathString + "workweek" ); 1001 icon = loadPixmap( pathString + "workweek" );
994 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 1002 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
995 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 1003 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
996 day5_action->addTo( viewMenu ); 1004 day5_action->addTo( viewMenu );
997 connect( day5_action, SIGNAL( activated() ), 1005 connect( day5_action, SIGNAL( activated() ),
998 mView->viewManager(), SLOT( showWorkWeekView() ) ); 1006 mView->viewManager(), SLOT( showWorkWeekView() ) );
999 1007
1000 icon = loadPixmap( pathString + "week" ); 1008 icon = loadPixmap( pathString + "week" );
1001 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 1009 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
1002 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 1010 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
1003 day7_action->addTo( viewMenu ); 1011 day7_action->addTo( viewMenu );
1004 connect( day7_action, SIGNAL( activated() ), 1012 connect( day7_action, SIGNAL( activated() ),
1005 mView->viewManager(), SLOT( showWeekView() ) ); 1013 mView->viewManager(), SLOT( showWeekView() ) );
1006 1014
1007 icon = loadPixmap( pathString + "workweek2" ); 1015 icon = loadPixmap( pathString + "workweek2" );
1008 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 1016 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
1009 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 1017 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
1010 day6_action->addTo( viewMenu ); 1018 day6_action->addTo( viewMenu );
1011 connect( day6_action, SIGNAL( activated() ), 1019 connect( day6_action, SIGNAL( activated() ),
1012 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 1020 mView->viewManager(), SLOT( showMonthViewWeek() ) );
1013 1021
1014 icon = loadPixmap( pathString + "month" ); 1022 icon = loadPixmap( pathString + "month" );
1015 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 1023 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
1016 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 1024 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
1017 month_action->addTo( viewMenu ); 1025 month_action->addTo( viewMenu );
1018 connect( month_action, SIGNAL( activated() ), 1026 connect( month_action, SIGNAL( activated() ),
1019 mView->viewManager(), SLOT( showMonthView() ) ); 1027 mView->viewManager(), SLOT( showMonthView() ) );
1020 1028
1021 icon = loadPixmap( pathString + "list" ); 1029 icon = loadPixmap( pathString + "list" );
1022 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 1030 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
1023 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 1031 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
1024 showlist_action->addTo( viewMenu ); 1032 showlist_action->addTo( viewMenu );
1025 connect( showlist_action, SIGNAL( activated() ), 1033 connect( showlist_action, SIGNAL( activated() ),
1026 mView->viewManager(), SLOT( showListView() ) ); 1034 mView->viewManager(), SLOT( showListView() ) );
1027 1035
1028 icon = loadPixmap( pathString + "todo" ); 1036 icon = loadPixmap( pathString + "todo" );
1029 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 1037 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
1030 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 1038 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
1031 todoview_action->addTo( viewMenu ); 1039 todoview_action->addTo( viewMenu );
1032 connect( todoview_action, SIGNAL( activated() ), 1040 connect( todoview_action, SIGNAL( activated() ),
1033 mView->viewManager(), SLOT( showTodoView() ) ); 1041 mView->viewManager(), SLOT( showTodoView() ) );
1034 1042
1035 1043
1036 1044
1037#if 0 1045#if 0
1038 action = new QAction( "view_timespan", "Time Span", 0, this ); 1046 action = new QAction( "view_timespan", "Time Span", 0, this );
1039 action->addTo( viewMenu ); 1047 action->addTo( viewMenu );
1040 connect( action, SIGNAL( activated() ), 1048 connect( action, SIGNAL( activated() ),
1041 mView->viewManager(), SLOT( showTimeSpanView() ) ); 1049 mView->viewManager(), SLOT( showTimeSpanView() ) );
1042#endif 1050#endif
1043 1051
1044 1052
1045 1053
1046 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, 1054 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0,
1047 this ); 1055 this );
1048 action->addTo( actionMenu ); 1056 action->addTo( actionMenu );
1049 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 1057 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
1050 1058
1051 1059
1052 icon = loadPixmap( pathString + "search" ); 1060 icon = loadPixmap( pathString + "search" );
1053 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 1061 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
1054 1062
1055 1063
1056 1064
1057 actionMenu->insertSeparator(); 1065 actionMenu->insertSeparator();
1058 action = new QAction( "manage cat", i18n("Edit category list..."), 0, 1066 action = new QAction( "manage cat", i18n("Edit category list..."), 0,
1059 this ); 1067 this );
1060 action->addTo( actionMenu ); 1068 action->addTo( actionMenu );
1061 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); 1069 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) );
1062 1070
1063 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1071 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1064 this ); 1072 this );
1065 action->addTo( actionMenu ); 1073 action->addTo( actionMenu );
1066 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1074 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1067 1075
1068 1076
1069 actionMenu->insertSeparator(); 1077 actionMenu->insertSeparator();
1070 icon = loadPixmap( pathString + "configure" ); 1078 icon = loadPixmap( pathString + "configure" );
1071 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 1079 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
1072 action->addTo( actionMenu ); 1080 action->addTo( actionMenu );
1073 connect( action, SIGNAL( activated() ), 1081 connect( action, SIGNAL( activated() ),
1074 mView, SLOT( edit_options() ) ); 1082 mView, SLOT( edit_options() ) );
1075 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); 1083 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this );
1076 action->addTo( actionMenu ); 1084 action->addTo( actionMenu );
1077 connect( action, SIGNAL( activated() ), 1085 connect( action, SIGNAL( activated() ),
1078 this, SLOT( calHint() ) ); 1086 this, SLOT( calHint() ) );
1079 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 1087 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
1080 action->addTo( actionMenu ); 1088 action->addTo( actionMenu );
1081 connect( action, SIGNAL( activated() ), 1089 connect( action, SIGNAL( activated() ),
1082 mView, SLOT( edit_global_options() ) ); 1090 mView, SLOT( edit_global_options() ) );
1083 if ( KOPrefs::instance()->mShowFullMenu ) { 1091 if ( KOPrefs::instance()->mShowFullMenu ) {
1084 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 1092 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
1085 1093
1086 } 1094 }
1087 // actionMenu->insertSeparator(); 1095 // actionMenu->insertSeparator();
1088 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 1096 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
1089 this ); 1097 this );
1090 action->addTo( importMenu_X ); 1098 action->addTo( importMenu_X );
1091 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 1099 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
1092 action = new QAction( "import_quick", i18n("Import last file"), 0, 1100 action = new QAction( "import_quick", i18n("Import last file"), 0,
1093 this ); 1101 this );
1094 action->addTo( importMenu_X ); 1102 action->addTo( importMenu_X );
1095 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 1103 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
1096 importMenu_X->insertSeparator(); 1104 importMenu_X->insertSeparator();
1097 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 1105 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
1098 this ); 1106 this );
1099 action->addTo( importMenu_X ); 1107 action->addTo( importMenu_X );
1100 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 1108 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
1101 //#ifndef DESKTOP_VERSION 1109 //#ifndef DESKTOP_VERSION
1102 importMenu_X->insertSeparator(); 1110 importMenu_X->insertSeparator();
1103 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 1111 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
1104 this ); 1112 this );
1105 action->addTo( importMenu_X ); 1113 action->addTo( importMenu_X );
1106 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1114 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1107 //#else 1115 //#else
1108#ifdef _OL_IMPORT_ 1116#ifdef _OL_IMPORT_
1109 importMenu_X->insertSeparator(); 1117 importMenu_X->insertSeparator();
1110 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1118 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1111 this ); 1119 this );
1112 action->addTo( importMenu_X ); 1120 action->addTo( importMenu_X );
1113 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1121 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1114#endif 1122#endif
1115 //#endif 1123 //#endif
1116 1124
1117 //importMenu->insertSeparator(); 1125 //importMenu->insertSeparator();
1118#if 0 1126#if 0
1119 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1127 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1120 this ); 1128 this );
1121 action->addTo( importMenu ); 1129 action->addTo( importMenu );
1122 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1130 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1123#endif 1131#endif
1124 action = new QAction( "save_cal", i18n("Save Backup..."), 0, 1132 action = new QAction( "save_cal", i18n("Save Backup..."), 0,
1125 this ); 1133 this );
1126 action->addTo( importMenu ); 1134 action->addTo( importMenu );
1127 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1135 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1128 importMenu->insertSeparator(); 1136 importMenu->insertSeparator();
1129 importMenu->insertItem( i18n("Import"), importMenu_X ); 1137 importMenu->insertItem( i18n("Import"), importMenu_X );
1130 //importMenu->insertSeparator(); 1138 //importMenu->insertSeparator();
1131 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1139 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1132 this ); 1140 this );
1133 action->addTo( exportMenu_X ); 1141 action->addTo( exportMenu_X );
1134 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1142 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1135 1143
1136 1144
1137 //LR 1145 //LR
1138 QPopupMenu *ex2phone = new QPopupMenu( this ); 1146 QPopupMenu *ex2phone = new QPopupMenu( this );
1139 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1147 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1140 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1148 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1141 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1149 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1142 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1150 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1143 1151
1144 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1152 importMenu->insertItem( i18n("Export"), exportMenu_X );
1145 mPrintSelAction = 0; 1153 mPrintSelAction = 0;
1146#ifndef DESKTOP_VERSION 1154#ifndef DESKTOP_VERSION
1147 //importMenu->insertSeparator(); 1155 //importMenu->insertSeparator();
1148 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1156 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1149 this ); 1157 this );
1150 brAction->addTo( beamMenu_X ); 1158 brAction->addTo( beamMenu_X );
1151 brAction->setToggleAction (true ) ; 1159 brAction->setToggleAction (true ) ;
1152 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1160 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1153 1161
1154 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1162 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1155 this ); 1163 this );
1156 action->addTo( beamMenu_X ); 1164 action->addTo( beamMenu_X );
1157 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1165 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1158 1166
1159 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1167 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1160 this ); 1168 this );
1161 action->addTo( beamMenu_X ); 1169 action->addTo( beamMenu_X );
1162 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1170 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1163 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1171 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1164#else 1172#else
1165 //importMenu->insertSeparator(); 1173 //importMenu->insertSeparator();
1166 icon = loadPixmap( pathString + "print" ); 1174 icon = loadPixmap( pathString + "print" );
1167 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1175 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1168 action->addTo( beamMenu_X ); 1176 action->addTo( beamMenu_X );
1169 connect( action, SIGNAL( activated() ), 1177 connect( action, SIGNAL( activated() ),
1170 this, SLOT( printCal() ) ); 1178 this, SLOT( printCal() ) );
1171 1179
1172 icon = loadPixmap( pathString + "week" ); 1180 icon = loadPixmap( pathString + "week" );
1173 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1181 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1174 action->addTo( beamMenu_X ); 1182 action->addTo( beamMenu_X );
1175 connect( action, SIGNAL( activated() ), 1183 connect( action, SIGNAL( activated() ),
1176 this, SLOT( printSel() ) ); 1184 this, SLOT( printSel() ) );
1177 icon = loadPixmap( pathString + "whatsnext" ); 1185 icon = loadPixmap( pathString + "whatsnext" );
1178 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1186 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1179 action->addTo( beamMenu_X ); 1187 action->addTo( beamMenu_X );
1180 connect( action, SIGNAL( activated() ), 1188 connect( action, SIGNAL( activated() ),
1181 mView->viewManager(), SLOT( slotprintWNV() ) ); 1189 mView->viewManager(), SLOT( slotprintWNV() ) );
1182 1190
1183 1191
1184 icon = loadPixmap( pathString + "list" ); 1192 icon = loadPixmap( pathString + "list" );
1185 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1193 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1186 action->addTo( beamMenu_X ); 1194 action->addTo( beamMenu_X );
1187 connect( action, SIGNAL( activated() ), 1195 connect( action, SIGNAL( activated() ),
1188 this, SLOT( printListView() ) ); 1196 this, SLOT( printListView() ) );
1189 1197
1190 icon = loadPixmap( pathString + "newevent" ); 1198 icon = loadPixmap( pathString + "newevent" );
1191 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1199 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1192 action->addTo( beamMenu_X ); 1200 action->addTo( beamMenu_X );
1193 connect( action, SIGNAL( activated() ), 1201 connect( action, SIGNAL( activated() ),
1194 mView, SLOT( slotprintSelInc() ) ); 1202 mView, SLOT( slotprintSelInc() ) );
1195 mPrintSelAction = action; 1203 mPrintSelAction = action;
1196 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1204 importMenu->insertItem( i18n("Print"), beamMenu_X );
1197#endif 1205#endif
1198 1206
1199 importMenu->insertSeparator(); 1207 importMenu->insertSeparator();
1200 action = new QAction( "beam all", i18n("Save"), 0, 1208 action = new QAction( "beam all", i18n("Save"), 0,
1201 this ); 1209 this );
1202 action->addTo( importMenu ); 1210 action->addTo( importMenu );
1203 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1211 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1204 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1212 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1205 this ); 1213 this );
1206 action->addTo( importMenu ); 1214 action->addTo( importMenu );
1207 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1215 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1208 1216
1209 //menuBar->insertItem( "Configure",configureMenu ); 1217 //menuBar->insertItem( "Configure",configureMenu );
1210 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1218 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1211 icon = loadPixmap( "korganizer/korganizer" ); 1219 icon = loadPixmap( "korganizer/korganizer" );
1212 1220
1213 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1221 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1214 action->addTo( helpMenu ); 1222 action->addTo( helpMenu );
1215 connect( action, SIGNAL( activated() ), 1223 connect( action, SIGNAL( activated() ),
1216 SLOT( whatsNew() ) ); 1224 SLOT( whatsNew() ) );
1217 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1225 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1218 action->addTo( helpMenu ); 1226 action->addTo( helpMenu );
1219 connect( action, SIGNAL( activated() ), 1227 connect( action, SIGNAL( activated() ),
1220 SLOT( features() ) ); 1228 SLOT( features() ) );
1221 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1229 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1222 action->addTo( helpMenu ); 1230 action->addTo( helpMenu );
1223 connect( action, SIGNAL( activated() ), 1231 connect( action, SIGNAL( activated() ),
1224 SLOT( keyBindings() ) ); 1232 SLOT( keyBindings() ) );
1225 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1233 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1226 action->addTo( helpMenu ); 1234 action->addTo( helpMenu );
1227 connect( action, SIGNAL( activated() ), 1235 connect( action, SIGNAL( activated() ),
1228 SLOT( storagehowto() ) ); 1236 SLOT( storagehowto() ) );
1229 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1237 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1230 action->addTo( helpMenu ); 1238 action->addTo( helpMenu );
1231 connect( action, SIGNAL( activated() ), 1239 connect( action, SIGNAL( activated() ),
1232 SLOT( timetrackinghowto() ) ); 1240 SLOT( timetrackinghowto() ) );
1233 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1241 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1234 action->addTo( helpMenu ); 1242 action->addTo( helpMenu );
1235 connect( action, SIGNAL( activated() ), 1243 connect( action, SIGNAL( activated() ),
1236 SLOT( synchowto() ) ); 1244 SLOT( synchowto() ) );
1237 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1245 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1238 action->addTo( helpMenu ); 1246 action->addTo( helpMenu );
1239 connect( action, SIGNAL( activated() ), 1247 connect( action, SIGNAL( activated() ),
1240 SLOT( kdesynchowto() ) ); 1248 SLOT( kdesynchowto() ) );
1241 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1249 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1242 action->addTo( helpMenu ); 1250 action->addTo( helpMenu );
1243 connect( action, SIGNAL( activated() ), 1251 connect( action, SIGNAL( activated() ),
1244 SLOT( multisynchowto() ) ); 1252 SLOT( multisynchowto() ) );
1245 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1253 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1246 action->addTo( helpMenu ); 1254 action->addTo( helpMenu );
1247 connect( action, SIGNAL( activated() ), 1255 connect( action, SIGNAL( activated() ),
1248 SLOT( aboutAutoSaving() ) ); 1256 SLOT( aboutAutoSaving() ) );
1249 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1257 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1250 action->addTo( helpMenu ); 1258 action->addTo( helpMenu );
1251 connect( action, SIGNAL( activated() ), 1259 connect( action, SIGNAL( activated() ),
1252 SLOT( aboutKnownBugs() ) ); 1260 SLOT( aboutKnownBugs() ) );
1253 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1261 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1254 action->addTo( helpMenu ); 1262 action->addTo( helpMenu );
1255 connect( action, SIGNAL( activated() ), 1263 connect( action, SIGNAL( activated() ),
1256 SLOT( usertrans() ) ); 1264 SLOT( usertrans() ) );
1257 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1265 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1258 action->addTo( helpMenu ); 1266 action->addTo( helpMenu );
1259 connect( action, SIGNAL( activated() ), 1267 connect( action, SIGNAL( activated() ),
1260 SLOT( faq() ) ); 1268 SLOT( faq() ) );
1261 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1269 action = new QAction( "licence", i18n("Licence..."), 0, this );
1262 action->addTo( helpMenu ); 1270 action->addTo( helpMenu );
1263 connect( action, SIGNAL( activated() ), 1271 connect( action, SIGNAL( activated() ),
1264 SLOT( licence() ) ); 1272 SLOT( licence() ) );
1265 action = new QAction( "about", i18n("About..."), 0, this ); 1273 action = new QAction( "about", i18n("About..."), 0, this );
1266 action->addTo( helpMenu ); 1274 action->addTo( helpMenu );
1267 connect( action, SIGNAL( activated() ), 1275 connect( action, SIGNAL( activated() ),
1268 SLOT( about() ) ); 1276 SLOT( about() ) );
1269 //menuBar->insertSeparator(); 1277 //menuBar->insertSeparator();
1270 1278
1271 // ****************************************************** 1279 // ******************************************************
1272 // menubar icons 1280 // menubar icons
1273 1281
1274 1282
1275 1283
1276 //menuBar->insertItem( iconToolBar ); 1284 //menuBar->insertItem( iconToolBar );
1277 //xdays_action 1285 //xdays_action
1278 if (p-> mShowIconNewEvent) 1286 if (p-> mShowIconNewEvent)
1279 ne_action->addTo( iconToolBar ); 1287 ne_action->addTo( iconToolBar );
1280 if (p->mShowIconNewTodo ) 1288 if (p->mShowIconNewTodo )
1281 nt_action->addTo( iconToolBar ); 1289 nt_action->addTo( iconToolBar );
1282 if (p-> mShowIconSearch) 1290 if (p-> mShowIconSearch)
1283 search_action->addTo( iconToolBar ); 1291 search_action->addTo( iconToolBar );
1284 if (p-> mShowIconWhatsThis) 1292 if (p-> mShowIconWhatsThis)
1285 QWhatsThis::whatsThisButton ( iconToolBar ); 1293 QWhatsThis::whatsThisButton ( iconToolBar );
1286 if (p-> mShowIconNext) 1294 if (p-> mShowIconNext)
1287 whatsnext_action->addTo( viewToolBar ); 1295 whatsnext_action->addTo( viewToolBar );
1288 if (p-> mShowIconNextDays) 1296 if (p-> mShowIconNextDays)
1289 xdays_action->addTo( viewToolBar ); 1297 xdays_action->addTo( viewToolBar );
1290 if (p-> mShowIconJournal) 1298 if (p-> mShowIconJournal)
1291 viewjournal_action->addTo( viewToolBar ); 1299 viewjournal_action->addTo( viewToolBar );
1292 if (p-> mShowIconDay1) 1300 if (p-> mShowIconDay1)
1293 day1_action->addTo( viewToolBar ); 1301 day1_action->addTo( viewToolBar );
1294 if (p-> mShowIconDay5) 1302 if (p-> mShowIconDay5)
1295 day5_action->addTo( viewToolBar ); 1303 day5_action->addTo( viewToolBar );
1296 if (p-> mShowIconDay7) 1304 if (p-> mShowIconDay7)
1297 day7_action->addTo( viewToolBar ); 1305 day7_action->addTo( viewToolBar );
1298 if (p-> mShowIconDay6) 1306 if (p-> mShowIconDay6)
1299 day6_action->addTo( viewToolBar ); 1307 day6_action->addTo( viewToolBar );
1300 if (p-> mShowIconMonth) 1308 if (p-> mShowIconMonth)
1301 month_action->addTo( viewToolBar ); 1309 month_action->addTo( viewToolBar );
1302 if (p-> mShowIconList) 1310 if (p-> mShowIconList)
1303 showlist_action->addTo( viewToolBar ); 1311 showlist_action->addTo( viewToolBar );
1304 if (p-> mShowIconTodoview) 1312 if (p-> mShowIconTodoview)
1305 todoview_action->addTo( viewToolBar ); 1313 todoview_action->addTo( viewToolBar );
1306 1314
1307 icon = loadPixmap( pathString + "2leftarrowB" ); 1315 icon = loadPixmap( pathString + "2leftarrowB" );
1308 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1316 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1309 if (p-> mShowIconBackFast) { 1317 if (p-> mShowIconBackFast) {
1310 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1318 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1311 connect( action, SIGNAL( activated() ), 1319 connect( action, SIGNAL( activated() ),
1312 mView, SLOT( goPreviousMonth() ) ); 1320 mView, SLOT( goPreviousMonth() ) );
1313 action->addTo( navigatorToolBar ); 1321 action->addTo( navigatorToolBar );
1314 } 1322 }
1315 icon = loadPixmap( pathString + "1leftarrowB" ); 1323 icon = loadPixmap( pathString + "1leftarrowB" );
1316 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1324 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1317 if (p-> mShowIconBack) { 1325 if (p-> mShowIconBack) {
1318 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1326 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1319 connect( action, SIGNAL( activated() ), 1327 connect( action, SIGNAL( activated() ),
1320 mView, SLOT( goPrevious() ) ); 1328 mView, SLOT( goPrevious() ) );
1321 action->addTo( navigatorToolBar ); 1329 action->addTo( navigatorToolBar );
1322 } 1330 }
1323 icon = loadPixmap( pathString + "today" ); 1331 icon = loadPixmap( pathString + "today" );
1324 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1332 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1325 if (p-> mShowIconToday) 1333 if (p-> mShowIconToday)
1326 today_action->addTo( navigatorToolBar ); 1334 today_action->addTo( navigatorToolBar );
1327 icon = loadPixmap( pathString + "1rightarrowB" ); 1335 icon = loadPixmap( pathString + "1rightarrowB" );
1328 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1336 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1329 if (p-> mShowIconForward) { 1337 if (p-> mShowIconForward) {
1330 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1338 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1331 connect( action, SIGNAL( activated() ), 1339 connect( action, SIGNAL( activated() ),
1332 mView, SLOT( goNext() ) ); 1340 mView, SLOT( goNext() ) );
1333 action->addTo( navigatorToolBar ); 1341 action->addTo( navigatorToolBar );
1334 } 1342 }
1335 icon = loadPixmap( pathString + "2rightarrowB" ); 1343 icon = loadPixmap( pathString + "2rightarrowB" );
1336 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1344 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1337 if (p-> mShowIconForwardFast) { 1345 if (p-> mShowIconForwardFast) {
1338 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1346 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1339 connect( action, SIGNAL( activated() ), 1347 connect( action, SIGNAL( activated() ),
1340 mView, SLOT( goNextMonth() ) ); 1348 mView, SLOT( goNextMonth() ) );
1341 action->addTo( navigatorToolBar ); 1349 action->addTo( navigatorToolBar );
1342 } 1350 }
1343 1351
1344 1352
1345 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1353 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1346 1354
1347 1355
1348 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1356 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1349 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1357 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1350 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1358 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1351 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1359 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1352 1360
1353 if (p-> mShowIconNewEvent) 1361 if (p-> mShowIconNewEvent)
1354 configureToolBarMenu->setItemChecked( 10, true ); 1362 configureToolBarMenu->setItemChecked( 10, true );
1355 if (p->mShowIconNewTodo ) 1363 if (p->mShowIconNewTodo )
1356 configureToolBarMenu->setItemChecked( 20, true ); 1364 configureToolBarMenu->setItemChecked( 20, true );
1357 if (p-> mShowIconSearch) 1365 if (p-> mShowIconSearch)
1358 configureToolBarMenu->setItemChecked( 120, true ); 1366 configureToolBarMenu->setItemChecked( 120, true );
1359 if (p-> mShowIconList) 1367 if (p-> mShowIconList)
1360 configureToolBarMenu->setItemChecked( 30, true ); 1368 configureToolBarMenu->setItemChecked( 30, true );
1361 if (p-> mShowIconDay1) 1369 if (p-> mShowIconDay1)
1362 configureToolBarMenu->setItemChecked( 40, true ); 1370 configureToolBarMenu->setItemChecked( 40, true );
1363 if (p-> mShowIconDay5) 1371 if (p-> mShowIconDay5)
1364 configureToolBarMenu->setItemChecked( 50, true ); 1372 configureToolBarMenu->setItemChecked( 50, true );
1365 if (p-> mShowIconDay6) 1373 if (p-> mShowIconDay6)
1366 configureToolBarMenu->setItemChecked( 75, true ); 1374 configureToolBarMenu->setItemChecked( 75, true );
1367 if (p-> mShowIconDay7) 1375 if (p-> mShowIconDay7)
1368 configureToolBarMenu->setItemChecked( 60, true ); 1376 configureToolBarMenu->setItemChecked( 60, true );
1369 if (p-> mShowIconMonth) 1377 if (p-> mShowIconMonth)
1370 configureToolBarMenu->setItemChecked( 70, true ); 1378 configureToolBarMenu->setItemChecked( 70, true );
1371 if (p-> mShowIconTodoview) 1379 if (p-> mShowIconTodoview)
1372 configureToolBarMenu->setItemChecked( 80, true ); 1380 configureToolBarMenu->setItemChecked( 80, true );
1373 if (p-> mShowIconBackFast) 1381 if (p-> mShowIconBackFast)
1374 configureToolBarMenu->setItemChecked( 200, true ); 1382 configureToolBarMenu->setItemChecked( 200, true );
1375 if (p-> mShowIconBack) 1383 if (p-> mShowIconBack)
1376 configureToolBarMenu->setItemChecked( 210, true ); 1384 configureToolBarMenu->setItemChecked( 210, true );
1377 if (p-> mShowIconToday) 1385 if (p-> mShowIconToday)
1378 configureToolBarMenu->setItemChecked( 130, true ); 1386 configureToolBarMenu->setItemChecked( 130, true );
1379 if (p-> mShowIconForward) 1387 if (p-> mShowIconForward)
1380 configureToolBarMenu->setItemChecked( 220, true ); 1388 configureToolBarMenu->setItemChecked( 220, true );
1381 if (p-> mShowIconForwardFast) 1389 if (p-> mShowIconForwardFast)
1382 configureToolBarMenu->setItemChecked( 230, true ); 1390 configureToolBarMenu->setItemChecked( 230, true );
1383 if (p-> mShowIconNextDays) 1391 if (p-> mShowIconNextDays)
1384 configureToolBarMenu->setItemChecked( 100, true ); 1392 configureToolBarMenu->setItemChecked( 100, true );
1385 if (p-> mShowIconNext) 1393 if (p-> mShowIconNext)
1386 configureToolBarMenu->setItemChecked( 110, true ); 1394 configureToolBarMenu->setItemChecked( 110, true );
1387 if (p-> mShowIconJournal) 1395 if (p-> mShowIconJournal)
1388 configureToolBarMenu->setItemChecked( 90, true ); 1396 configureToolBarMenu->setItemChecked( 90, true );
1389 if (p-> mShowIconWhatsThis) 1397 if (p-> mShowIconWhatsThis)
1390 configureToolBarMenu->setItemChecked( 300, true ); 1398 configureToolBarMenu->setItemChecked( 300, true );
1391 if (p-> mShowIconWeekNum) 1399 if (p-> mShowIconWeekNum)
1392 configureToolBarMenu->setItemChecked( 400, true ); 1400 configureToolBarMenu->setItemChecked( 400, true );
1393 if (!p-> mShowIconStretch) { 1401 if (!p-> mShowIconStretch) {
1394 QLabel* dummy = new QLabel( iconToolBar ); 1402 QLabel* dummy = new QLabel( iconToolBar );
1395 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1403 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1396 dummy->setMinimumWidth( 0 ); 1404 dummy->setMinimumWidth( 0 );
1397 iconToolBar->setStretchableWidget ( dummy ) ; 1405 iconToolBar->setStretchableWidget ( dummy ) ;
1398 } 1406 }
1399 else { 1407 else {
1400 iconToolBar->setHorizontalStretchable (true ); 1408 iconToolBar->setHorizontalStretchable (true );
1401 viewToolBar->setHorizontalStretchable (true ); 1409 viewToolBar->setHorizontalStretchable (true );
1402 navigatorToolBar->setHorizontalStretchable (true ); 1410 navigatorToolBar->setHorizontalStretchable (true );
1403 iconToolBar->setVerticalStretchable (true ); 1411 iconToolBar->setVerticalStretchable (true );
1404 viewToolBar->setVerticalStretchable (true ); 1412 viewToolBar->setVerticalStretchable (true );
1405 navigatorToolBar->setVerticalStretchable (true ); 1413 navigatorToolBar->setVerticalStretchable (true );
1406 configureToolBarMenu->setItemChecked( 5, true ); 1414 configureToolBarMenu->setItemChecked( 5, true );
1407 } 1415 }
1408 if (p-> mShowIconFilter) 1416 if (p-> mShowIconFilter)
1409 configureToolBarMenu->setItemChecked( 7, true ); 1417 configureToolBarMenu->setItemChecked( 7, true );
1410 if (p-> mShowIconOnetoolbar) 1418 if (p-> mShowIconOnetoolbar)
1411 configureToolBarMenu->setItemChecked( 6, true ); 1419 configureToolBarMenu->setItemChecked( 6, true );
1412 1420
1413 1421
1414 if ( filterMenubar ) { 1422 if ( filterMenubar ) {
1415 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1423 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1416 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1424 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1417 } 1425 }
1418 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1426 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1419 configureAgenda( p->mHourSize ); 1427 configureAgenda( p->mHourSize );
1420 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1428 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1421} 1429}
1422void MainWindow::calHint() 1430void MainWindow::calHint()
1423{ 1431{
1424 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); 1432 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.");
1425 1433
1426 KMessageBox::information( this, message); 1434 KMessageBox::information( this, message);
1427} 1435}
1428void MainWindow::exportToPhone( int mode ) 1436void MainWindow::exportToPhone( int mode )
1429{ 1437{
1430 1438
1431 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1439 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1432 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1440 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1433 KOex2phonePrefs ex2phone; 1441 KOex2phonePrefs ex2phone;
1434 1442
1435 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1443 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1436 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1444 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1437 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1445 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1438 if ( mode == 1 ) 1446 if ( mode == 1 )
1439 ex2phone.setCaption(i18n("Export complete calendar")); 1447 ex2phone.setCaption(i18n("Export complete calendar"));
1440 if ( mode == 2 ) 1448 if ( mode == 2 )
1441 ex2phone.setCaption(i18n("Export filtered calendar")); 1449 ex2phone.setCaption(i18n("Export filtered calendar"));
1442 1450
1443 if ( !ex2phone.exec() ) { 1451 if ( !ex2phone.exec() ) {
1444 return; 1452 return;
1445 } 1453 }
1446 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1454 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1447 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1455 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1448 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1456 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1449 1457
1450 int inFuture = 0; 1458 int inFuture = 0;
1451 if ( ex2phone.mWriteBackFuture->isChecked() ) 1459 if ( ex2phone.mWriteBackFuture->isChecked() )
1452 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1460 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1453 QPtrList<Incidence> delSel; 1461 QPtrList<Incidence> delSel;
1454 if ( mode == 1 ) 1462 if ( mode == 1 )
1455 delSel = mCalendar->rawIncidences(); 1463 delSel = mCalendar->rawIncidences();
1456 if ( mode == 2 ) 1464 if ( mode == 2 )
1457 delSel = mCalendar->incidences(); 1465 delSel = mCalendar->incidences();
1458 CalendarLocal* cal = new CalendarLocal(); 1466 CalendarLocal* cal = new CalendarLocal();
1459 cal->setLocalTime(); 1467 cal->setLocalTime();
1460 Incidence *incidence = delSel.first(); 1468 Incidence *incidence = delSel.first();
1461 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1469 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1462 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1470 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1463 while ( incidence ) { 1471 while ( incidence ) {
1464 if ( incidence->typeID() != journalID ) { 1472 if ( incidence->typeID() != journalID ) {
1465 bool add = true; 1473 bool add = true;
1466 if ( inFuture ) { 1474 if ( inFuture ) {
1467 QDateTime dt; 1475 QDateTime dt;
1468 if ( incidence->typeID() == todoID ) { 1476 if ( incidence->typeID() == todoID ) {
1469 Todo * t = (Todo*)incidence; 1477 Todo * t = (Todo*)incidence;
1470 if ( t->hasDueDate() ) 1478 if ( t->hasDueDate() )
1471 dt = t->dtDue(); 1479 dt = t->dtDue();
1472 else 1480 else
1473 dt = cur.addSecs( 62 ); 1481 dt = cur.addSecs( 62 );
1474 } 1482 }
1475 else { 1483 else {
1476 bool ok; 1484 bool ok;
1477 dt = incidence->getNextOccurence( cur, &ok ); 1485 dt = incidence->getNextOccurence( cur, &ok );
1478 if ( !ok ) 1486 if ( !ok )
1479 dt = cur.addSecs( -62 ); 1487 dt = cur.addSecs( -62 );
1480 } 1488 }
1481 if ( dt < cur || dt > end ) { 1489 if ( dt < cur || dt > end ) {
1482 add = false; 1490 add = false;
1483 } 1491 }
1484 } 1492 }
1485 if ( add ) { 1493 if ( add ) {
1486 Incidence *in = incidence->clone(); 1494 Incidence *in = incidence->clone();
1487 cal->addIncidence( in ); 1495 cal->addIncidence( in );
1488 } 1496 }
1489 } 1497 }
1490 incidence = delSel.next(); 1498 incidence = delSel.next();
1491 } 1499 }
1492 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1500 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1493 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1501 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1494 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1502 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1495 1503
1496 setCaption( i18n("Writing to phone...")); 1504 setCaption( i18n("Writing to phone..."));
1497 if ( PhoneFormat::writeToPhone( cal ) ) 1505 if ( PhoneFormat::writeToPhone( cal ) )
1498 setCaption( i18n("Export to phone successful!")); 1506 setCaption( i18n("Export to phone successful!"));
1499 else 1507 else
1500 setCaption( i18n("Error exporting to phone!")); 1508 setCaption( i18n("Error exporting to phone!"));
1501 delete cal; 1509 delete cal;
1502} 1510}
1503 1511
1504 1512
1505void MainWindow::setDefaultPreferences() 1513void MainWindow::setDefaultPreferences()
1506{ 1514{
1507 KOPrefs *p = KOPrefs::instance(); 1515 KOPrefs *p = KOPrefs::instance();
1508 1516
1509 p->mCompactDialogs = true; 1517 p->mCompactDialogs = true;
1510 p->mConfirm = true; 1518 p->mConfirm = true;
1511 // p->mEnableQuickTodo = false; 1519 // p->mEnableQuickTodo = false;
1512 1520
1513} 1521}
1514 1522
1515QString MainWindow::resourcePath() 1523QString MainWindow::resourcePath()
1516{ 1524{
1517 return KGlobal::iconLoader()->iconPath(); 1525 return KGlobal::iconLoader()->iconPath();
1518} 1526}
1519 1527
1520void MainWindow::displayText( QString text ,QString cap ) 1528void MainWindow::displayText( QString text ,QString cap )
1521{ 1529{
1522 QDialog dia( this, "name", true ); ; 1530 QDialog dia( this, "name", true ); ;
1523 dia.setCaption( cap ); 1531 dia.setCaption( cap );
1524 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1532 QVBoxLayout* lay = new QVBoxLayout( &dia );
1525 lay->setSpacing( 3 ); 1533 lay->setSpacing( 3 );
1526 lay->setMargin( 3 ); 1534 lay->setMargin( 3 );
1527 QTextBrowser tb ( &dia ); 1535 QTextBrowser tb ( &dia );
1528 lay->addWidget( &tb ); 1536 lay->addWidget( &tb );
1529 tb.setText( text ); 1537 tb.setText( text );
1530#ifdef DESKTOP_VERSION 1538#ifdef DESKTOP_VERSION
1531 dia.resize( 640, 480); 1539 dia.resize( 640, 480);
1532#else 1540#else
1533 dia.showMaximized(); 1541 dia.showMaximized();
1534#endif 1542#endif
1535 dia.exec(); 1543 dia.exec();
1536} 1544}
1537 1545
1538void MainWindow::features() 1546void MainWindow::features()
1539{ 1547{
1540 1548
1541 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1549 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1542} 1550}
1543 1551
1544void MainWindow::usertrans() 1552void MainWindow::usertrans()
1545{ 1553{
1546 1554
1547 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1555 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1548} 1556}
1549 1557
1550void MainWindow::storagehowto() 1558void MainWindow::storagehowto()
1551{ 1559{
1552 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1560 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1553} 1561}
1554void MainWindow::timetrackinghowto() 1562void MainWindow::timetrackinghowto()
1555{ 1563{
1556 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1564 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1557} 1565}
1558void MainWindow::kdesynchowto() 1566void MainWindow::kdesynchowto()
1559{ 1567{
1560 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1568 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1561} 1569}
1562void MainWindow::multisynchowto() 1570void MainWindow::multisynchowto()
1563{ 1571{
1564 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1572 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1565} 1573}
1566void MainWindow::synchowto() 1574void MainWindow::synchowto()
1567{ 1575{
1568 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1576 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1569} 1577}
1570void MainWindow::faq() 1578void MainWindow::faq()
1571{ 1579{
1572 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1580 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1573 1581
1574} 1582}
1575void MainWindow::whatsNew() 1583void MainWindow::whatsNew()
1576{ 1584{
1577 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1585 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1578 1586
1579} 1587}
1580void MainWindow::licence() 1588void MainWindow::licence()
1581{ 1589{
1582 KApplication::showLicence(); 1590 KApplication::showLicence();
1583 1591
1584} 1592}
1585void MainWindow::about() 1593void MainWindow::about()
1586{ 1594{
1587 QString version; 1595 QString version;
1588#include <../version> 1596#include <../version>
1589 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1597 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1590 i18n("KOrganizer/Platform-independent\n") + 1598 i18n("KOrganizer/Platform-independent\n") +
1591 "(KO/Pi) " + version + " - " + 1599 "(KO/Pi) " + version + " - " +
1592 1600
1593#ifdef DESKTOP_VERSION 1601#ifdef DESKTOP_VERSION
1594 i18n("Desktop Edition\n") + 1602 i18n("Desktop Edition\n") +
1595#else 1603#else
1596 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1604 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1597#endif 1605#endif
1598 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!") ); 1606 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!") );
1599} 1607}
1600void MainWindow::keyBindings() 1608void MainWindow::keyBindings()
1601{ 1609{
1602 QString cap = i18n("KO/Pi Keys + Colors"); 1610 QString cap = i18n("KO/Pi Keys + Colors");
1603 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1611 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1604 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1612 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1605 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1613 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1606 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1614 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1607 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1615 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1608 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1616 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1609 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1617 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1610 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1618 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1611 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1619 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1612 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1620 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1613 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1621 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1614 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1622 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1615 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1623 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1616 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1624 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1617 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1625 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1618 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1626 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1619 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1627 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1620 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1628 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1621 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1629 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1622 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1630 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1623 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1631 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1624 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1632 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1625 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1633 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1626 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1634 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1627 i18n("<p><h3>In agenda view:</h3></p>\n") + 1635 i18n("<p><h3>In agenda view:</h3></p>\n") +
1628 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1636 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1629 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1637 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1630 i18n("<p><h3>In todo view:</h3></p>\n") + 1638 i18n("<p><h3>In todo view:</h3></p>\n") +
1631 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1639 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1632 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1640 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1633 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1641 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1634 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1642 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1635 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1643 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1636 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1644 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1637 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1645 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1638 i18n("<p><h3>In list view:</h3></p>\n") + 1646 i18n("<p><h3>In list view:</h3></p>\n") +
1639 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1647 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1640 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1648 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1641 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1649 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1642 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1650 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1643 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1651 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1644 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1652 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1645 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1653 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1646 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1654 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1647 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1655 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1648 i18n("<p><b>E</b>: Edit item</p>\n") + 1656 i18n("<p><b>E</b>: Edit item</p>\n") +
1649 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1657 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1650 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1658 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1651 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1659 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1652 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1660 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1653 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1661 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1654 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1662 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1655 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1663 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1656 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1664 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1657 i18n("<p><b>White</b>: Item readonly</p>\n"); 1665 i18n("<p><b>White</b>: Item readonly</p>\n");
1658 displayText( text, cap); 1666 displayText( text, cap);
1659} 1667}
1660void MainWindow::aboutAutoSaving() 1668void MainWindow::aboutAutoSaving()
1661{ 1669{
1662 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"); 1670 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");
1663 1671
1664 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1672 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1665 1673
1666} 1674}
1667void MainWindow::aboutKnownBugs() 1675void MainWindow::aboutKnownBugs()
1668{ 1676{
1669 QMessageBox* msg; 1677 QMessageBox* msg;
1670 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1678 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1671 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")+ 1679 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")+
1672 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1680 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1673 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1681 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1674 i18n("\nor report them in the bugtracker on\n") + 1682 i18n("\nor report them in the bugtracker on\n") +
1675 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1683 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1676 QMessageBox::NoIcon, 1684 QMessageBox::NoIcon,
1677 QMessageBox::Ok, 1685 QMessageBox::Ok,
1678 QMessageBox::NoButton, 1686 QMessageBox::NoButton,
1679 QMessageBox::NoButton); 1687 QMessageBox::NoButton);
1680 msg->exec(); 1688 msg->exec();
1681 delete msg; 1689 delete msg;
1682 1690
1683} 1691}
1684 1692
1685QString MainWindow::defaultFileName() 1693QString MainWindow::defaultFileName()
1686{ 1694{
1687 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1695 return locateLocal( "data", "korganizer/mycalendar.ics" );
1688} 1696}
1689QString MainWindow::syncFileName() 1697QString MainWindow::syncFileName()
1690{ 1698{
1691#ifdef DESKTOP_VERSION 1699#ifdef DESKTOP_VERSION
1692 return locateLocal( "tmp", "synccalendar.ics" ); 1700 return locateLocal( "tmp", "synccalendar.ics" );
1693#else 1701#else
1694 return QString( "/tmp/synccalendar.ics" ); 1702 return QString( "/tmp/synccalendar.ics" );
1695#endif 1703#endif
1696} 1704}
1697#include "koglobals.h" 1705#include "koglobals.h"
1698#include <kcalendarsystem.h> 1706#include <kcalendarsystem.h>
1699void MainWindow::updateWeek(QDate seda) 1707void MainWindow::updateWeek(QDate seda)
1700{ 1708{
1701 int weekNum = KGlobal::locale()->weekNum ( seda ); 1709 int weekNum = KGlobal::locale()->weekNum ( seda );
1702 mWeekPixmap.fill( mWeekBgColor ); 1710 mWeekPixmap.fill( mWeekBgColor );
1703 QPainter p ( &mWeekPixmap ); 1711 QPainter p ( &mWeekPixmap );
1704 p.setFont( mWeekFont ); 1712 p.setFont( mWeekFont );
1705 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1713 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1706 p.end(); 1714 p.end();
1707 QIconSet icon3 ( mWeekPixmap ); 1715 QIconSet icon3 ( mWeekPixmap );
1708 mWeekAction->setIconSet ( icon3 ); 1716 mWeekAction->setIconSet ( icon3 );
1709 1717
1710} 1718}
1711void MainWindow::updateWeekNum(const DateList &selectedDates) 1719void MainWindow::updateWeekNum(const DateList &selectedDates)
1712{ 1720{
1713 updateWeek( selectedDates.first() ); 1721 updateWeek( selectedDates.first() );
1714} 1722}
1715void MainWindow::processIncidenceSelection( Incidence *incidence ) 1723void MainWindow::processIncidenceSelection( Incidence *incidence )
1716{ 1724{
1717 if ( !incidence ) { 1725 if ( !incidence ) {
1718 mShowAction->setMenuText( i18n("Show") ); 1726 mShowAction->setMenuText( i18n("Show") );
1719 enableIncidenceActions( false ); 1727 enableIncidenceActions( false );
1720 mNewSubTodoAction->setEnabled( false ); 1728 mNewSubTodoAction->setEnabled( false );
1721 setCaptionToDates(); 1729 setCaptionToDates();
1722 return; 1730 return;
1723 } 1731 }
1724 QString startString = ""; 1732 QString startString = "";
1725 if ( incidence->typeID() != todoID ) { 1733 if ( incidence->typeID() != todoID ) {
1726 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1734 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1727 if ( incidence->doesFloat() ) { 1735 if ( incidence->doesFloat() ) {
1728 startString += ": "+incidence->dtStartDateStr( true ); 1736 startString += ": "+incidence->dtStartDateStr( true );
1729 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1737 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1730 } else { 1738 } else {
1731 startString = ": "+incidence->dtStartStr(true); 1739 startString = ": "+incidence->dtStartStr(true);
1732 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1740 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1733 } 1741 }
1734 } else { 1742 } else {
1735 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1743 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1736 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1744 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1737 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1745 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1738 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1746 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1739 bool ok; 1747 bool ok;
1740 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1748 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1741 if ( ok ) { 1749 if ( ok ) {
1742 int years = noc.date().year() - incidence->dtStart().date().year(); 1750 int years = noc.date().year() - incidence->dtStart().date().year();
1743 startString += i18n(" (%1 y.)"). arg( years ); 1751 startString += i18n(" (%1 y.)"). arg( years );
1744 } 1752 }
1745 } 1753 }
1746 else 1754 else
1747 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1755 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1748 } 1756 }
1749 } 1757 }
1750 else { 1758 else {
1751 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1759 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1752 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1760 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1753 else 1761 else
1754 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1762 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1755 } 1763 }
1756 if ( !incidence->location().isEmpty() ) 1764 if ( !incidence->location().isEmpty() )
1757 startString += " (" +incidence->location()+")"; 1765 startString += " (" +incidence->location()+")";
1758 setCaption( incidence->summary()+startString); 1766 setCaption( incidence->summary()+startString);
1759 enableIncidenceActions( true ); 1767 enableIncidenceActions( true );
1760 if ( incidence->typeID() == eventID ) { 1768 if ( incidence->typeID() == eventID ) {
1761 mShowAction->setMenuText( i18n("Show Event") ); 1769 mShowAction->setMenuText( i18n("Show Event") );
1762 mNewSubTodoAction->setEnabled( false ); 1770 mNewSubTodoAction->setEnabled( false );
1763 } else if ( incidence->typeID() == todoID ) { 1771 } else if ( incidence->typeID() == todoID ) {
1764 mShowAction->setMenuText( i18n("Show Todo") ); 1772 mShowAction->setMenuText( i18n("Show Todo") );
1765 mNewSubTodoAction->setEnabled( true ); 1773 mNewSubTodoAction->setEnabled( true );
1766 } else { 1774 } else {
1767 mShowAction->setMenuText( i18n("Show") ); 1775 mShowAction->setMenuText( i18n("Show") );
1768 mNewSubTodoAction->setEnabled( false ); 1776 mNewSubTodoAction->setEnabled( false );
1769 } 1777 }
1770#ifdef DESKTOP_VERSION 1778#ifdef DESKTOP_VERSION
1771 static QPixmap jP = SmallIcon( "journal" ); 1779 static QPixmap jP = SmallIcon( "journal" );
1772 static QPixmap eP = SmallIcon( "newevent" ); 1780 static QPixmap eP = SmallIcon( "newevent" );
1773 static QPixmap tP = SmallIcon( "newtodo" ); 1781 static QPixmap tP = SmallIcon( "newtodo" );
1774 QIconSet icon; 1782 QIconSet icon;
1775 if ( incidence->typeID() == todoID ) 1783 if ( incidence->typeID() == todoID )
1776 icon = QIconSet ( tP ); 1784 icon = QIconSet ( tP );
1777 else if ( incidence->typeID() == eventID ) 1785 else if ( incidence->typeID() == eventID )
1778 icon = QIconSet ( eP ); 1786 icon = QIconSet ( eP );
1779 else if ( incidence->typeID() == journalID ) 1787 else if ( incidence->typeID() == journalID )
1780 icon = QIconSet ( jP ); 1788 icon = QIconSet ( jP );
1781 mPrintSelAction->setIconSet ( icon ); 1789 mPrintSelAction->setIconSet ( icon );
1782#endif 1790#endif
1783} 1791}
1784 1792
1785void MainWindow::enableIncidenceActions( bool enabled ) 1793void MainWindow::enableIncidenceActions( bool enabled )
1786{ 1794{
1787 mShowAction->setEnabled( enabled ); 1795 mShowAction->setEnabled( enabled );
1788 mEditAction->setEnabled( enabled ); 1796 mEditAction->setEnabled( enabled );
1789 mDeleteAction->setEnabled( enabled ); 1797 mDeleteAction->setEnabled( enabled );
1790 1798
1791 mCloneAction->setEnabled( enabled ); 1799 mCloneAction->setEnabled( enabled );
1792 mMoveAction->setEnabled( enabled ); 1800 mMoveAction->setEnabled( enabled );
1793#ifndef DESKTOP_VERSION 1801#ifndef DESKTOP_VERSION
1794 mBeamAction->setEnabled( enabled ); 1802 mBeamAction->setEnabled( enabled );
1795#else 1803#else
1796 mPrintSelAction->setEnabled( enabled ); 1804 mPrintSelAction->setEnabled( enabled );
1797#endif 1805#endif
1798 mCancelAction->setEnabled( enabled ); 1806 mCancelAction->setEnabled( enabled );
1799} 1807}
1800 1808
1801void MainWindow::importOL() 1809void MainWindow::importOL()
1802{ 1810{
1803#ifdef _OL_IMPORT_ 1811#ifdef _OL_IMPORT_
1804 mView->clearAllViews(); 1812 mView->clearAllViews();
1805 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1813 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1806 id->exec(); 1814 id->exec();
1807 delete id; 1815 delete id;
1808 mView->calendar()->checkAlarmForIncidence( 0, true ); 1816 mView->calendar()->checkAlarmForIncidence( 0, true );
1809 mView->updateView(); 1817 mView->updateView();
1810#endif 1818#endif
1811} 1819}
1812void MainWindow::importBday() 1820void MainWindow::importBday()
1813{ 1821{
1814 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1822 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1815 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1823 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1816 i18n("Import!"), i18n("Cancel"), 0, 1824 i18n("Import!"), i18n("Cancel"), 0,
1817 0, 1 ); 1825 0, 1 );
1818 if ( result == 0 ) { 1826 if ( result == 0 ) {
1819 mView->importBday(); 1827 mView->importBday();
1820 1828
1821 } 1829 }
1822 1830
1823 1831
1824} 1832}
1825void MainWindow::importQtopia() 1833void MainWindow::importQtopia()
1826{ 1834{
1827 //#ifndef DESKTOP_VERSION 1835 //#ifndef DESKTOP_VERSION
1828 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"); 1836 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");
1829#ifdef DESKTOP_VERSION 1837#ifdef DESKTOP_VERSION
1830 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"); 1838 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");
1831#endif 1839#endif
1832 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1840 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1833 i18n("Import!"), i18n("Cancel"), 0, 1841 i18n("Import!"), i18n("Cancel"), 0,
1834 0, 1 ); 1842 0, 1 );
1835 if ( result == 0 ) { 1843 if ( result == 0 ) {
1836#ifndef DESKTOP_VERSION 1844#ifndef DESKTOP_VERSION
1837 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1845 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1838 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1846 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1839 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1847 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1840#else 1848#else
1841 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1849 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1842 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1850 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1843 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1851 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1844#endif 1852#endif
1845 mView->importQtopia( categories, datebook, todolist ); 1853 mView->importQtopia( categories, datebook, todolist );
1846 } 1854 }
1847 mView->calendar()->reInitAlarmSettings(); 1855 mView->calendar()->reInitAlarmSettings();
1848#if 0 1856#if 0
1849 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1857 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1850 i18n("Not supported \non desktop!\n"), 1858 i18n("Not supported \non desktop!\n"),
1851 i18n("Ok"), i18n("Cancel"), 0, 1859 i18n("Ok"), i18n("Cancel"), 0,
1852 0, 1 ); 1860 0, 1 );
1853 1861
1854#endif 1862#endif
1855} 1863}
1856 1864
1857void MainWindow::saveOnClose() 1865void MainWindow::saveOnClose()
1858{ 1866{
1859 KOPrefs *p = KOPrefs::instance(); 1867 KOPrefs *p = KOPrefs::instance();
1860 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1868 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1861 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1869 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1862 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1870 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1863 if ( filterToolBar ) { 1871 if ( filterToolBar ) {
1864 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1872 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1865 } 1873 }
1866#ifdef DESKTOP_VERSION 1874#ifdef DESKTOP_VERSION
1867 1875
1868 QPoint myP; 1876 QPoint myP;
1869 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1877 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1870 if ( p->mToolBarHor ) 1878 if ( p->mToolBarHor )
1871 p->mToolBarUp = myP.y() > height()/2; 1879 p->mToolBarUp = myP.y() > height()/2;
1872 else 1880 else
1873 p->mToolBarUp = myP.x() > width()/2; 1881 p->mToolBarUp = myP.x() > width()/2;
1874 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1882 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1875 if ( p->mToolBarHorV ) 1883 if ( p->mToolBarHorV )
1876 p->mToolBarUpV = myP.y() > height()/2; 1884 p->mToolBarUpV = myP.y() > height()/2;
1877 else 1885 else
1878 p->mToolBarUpV = myP.x() > width()/2 ; 1886 p->mToolBarUpV = myP.x() > width()/2 ;
1879 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1887 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1880 if ( p->mToolBarHorN ) 1888 if ( p->mToolBarHorN )
1881 p->mToolBarUpN = myP.y() > height()/2; 1889 p->mToolBarUpN = myP.y() > height()/2;
1882 else 1890 else
1883 p->mToolBarUpN = myP.x() > width()/2 ; 1891 p->mToolBarUpN = myP.x() > width()/2 ;
1884 if ( filterToolBar ) { 1892 if ( filterToolBar ) {
1885 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1893 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1886 if ( p->mToolBarHorF ) 1894 if ( p->mToolBarHorF )
1887 p->mToolBarUpF = myP.y() > height()/2; 1895 p->mToolBarUpF = myP.y() > height()/2;
1888 else 1896 else
1889 p->mToolBarUpF = myP.x() > width()/2 ; 1897 p->mToolBarUpF = myP.x() > width()/2 ;
1890 } 1898 }
1891#else 1899#else
1892 if ( p->mToolBarHor ) 1900 if ( p->mToolBarHor )
1893 p->mToolBarUp = iconToolBar->y() > height()/2; 1901 p->mToolBarUp = iconToolBar->y() > height()/2;
1894 else 1902 else
1895 p->mToolBarUp = iconToolBar->x() > width()/2; 1903 p->mToolBarUp = iconToolBar->x() > width()/2;
1896 if ( p->mToolBarHorV ) 1904 if ( p->mToolBarHorV )
1897 p->mToolBarUpV = viewToolBar->y() > height()/2; 1905 p->mToolBarUpV = viewToolBar->y() > height()/2;
1898 else 1906 else
1899 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1907 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1900 1908
1901 if ( p->mToolBarHorN ) 1909 if ( p->mToolBarHorN )
1902 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1910 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1903 else 1911 else
1904 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1912 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1905 if ( filterToolBar ) { 1913 if ( filterToolBar ) {
1906 if ( p->mToolBarHorF ) 1914 if ( p->mToolBarHorF )
1907 p->mToolBarUpF = filterToolBar->y() > height()/2; 1915 p->mToolBarUpF = filterToolBar->y() > height()/2;
1908 else 1916 else
1909 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1917 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1910 } 1918 }
1911#endif 1919#endif
1912 save(); 1920 save();
1913 mView->writeSettings(); 1921 mView->writeSettings();
1914 mView->checkSuspendAlarm(); 1922 mView->checkSuspendAlarm();
1915} 1923}
1916void MainWindow::slotModifiedChanged( bool ) 1924void MainWindow::slotModifiedChanged( bool )
1917{ 1925{
1918 if ( mBlockAtStartup ) 1926 if ( mBlockAtStartup )
1919 return; 1927 return;
1920 1928
1921 int msec; 1929 int msec;
1922 if ( mCalendarModifiedFlag ) { 1930 if ( mCalendarModifiedFlag ) {
1923 //qDebug(" MainWindow timer is running "); 1931 //qDebug(" MainWindow timer is running ");
1924 return; 1932 return;
1925 } 1933 }
1926 // we store the changes after 1 minute, 1934 // we store the changes after 1 minute,
1927 // and for safety reasons after 10 minutes again 1935 // and for safety reasons after 10 minutes again
1928 if ( !mSyncManager->blockSave() ) 1936 if ( !mSyncManager->blockSave() )
1929 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1937 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1930 else 1938 else
1931 msec = 1000 * 600; 1939 msec = 1000 * 600;
1932 mSaveTimer.start( msec, true ); // 1 minute 1940 mSaveTimer.start( msec, true ); // 1 minute
1933 qDebug("KO: Saving File in %d secs!", msec/1000); 1941 qDebug("KO: Saving File in %d secs!", msec/1000);
1934 mCalendarModifiedFlag = true; 1942 mCalendarModifiedFlag = true;
1935} 1943}
1936void MainWindow::saveStopTimer() 1944void MainWindow::saveStopTimer()
1937{ 1945{
1938 mSaveTimer.stop(); 1946 mSaveTimer.stop();
1939} 1947}
1940void MainWindow::backupAllFiles() 1948void MainWindow::backupAllFiles()
1941{ 1949{
1942 QDate reference ( 2000,1,1); 1950 QDate reference ( 2000,1,1);
1943 int daysTo = reference.daysTo ( QDate::currentDate() ); 1951 int daysTo = reference.daysTo ( QDate::currentDate() );
1944 setCaption(i18n("Creating backup ... please wait ..." )); 1952 setCaption(i18n("Creating backup ... please wait ..." ));
1945 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1953 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1946 // we need the file path, the backup dir and the number of bups as param 1954 // we need the file path, the backup dir and the number of bups as param
1947 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1955 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1948 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1956 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1949 bupDir = KGlobalSettings::backupDataDir(); 1957 bupDir = KGlobalSettings::backupDataDir();
1950 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1958 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1951 if ( retval == 0 ) { 1959 if ( retval == 0 ) {
1952 setCaption(i18n("Backup cancelled" )); 1960 setCaption(i18n("Backup cancelled" ));
1953 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1961 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1954 // retval == 0 : backup skipped for today, try again tomorrow 1962 // retval == 0 : backup skipped for today, try again tomorrow
1955 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1963 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1956 } else if ( retval == 1 ){ 1964 } else if ( retval == 1 ){
1957 qDebug("KO: Backup created."); 1965 qDebug("KO: Backup created.");
1958 // backup ok 1966 // backup ok
1959 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1967 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1960 KopiCalendarFile * cal = calendars.first(); 1968 KopiCalendarFile * cal = calendars.first();
1961 cal = calendars.next(); 1969 cal = calendars.next();
1962 while ( cal ) { 1970 while ( cal ) {
1963 if ( !cal->mErrorOnLoad ) { 1971 if ( !cal->mErrorOnLoad ) {
1964 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1972 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1965 } 1973 }
1966 cal = calendars.next(); 1974 cal = calendars.next();
1967 } 1975 }
1968 KOPrefs::instance()->mLastBackupDate = daysTo; 1976 KOPrefs::instance()->mLastBackupDate = daysTo;
1969 setCaption(i18n("Backup succesfully finished" )); 1977 setCaption(i18n("Backup succesfully finished" ));
1970 } else if ( retval == 2 ){ 1978 } else if ( retval == 2 ){
1971 setCaption(i18n("Backup globally disabled" )); 1979 setCaption(i18n("Backup globally disabled" ));
1972 qDebug("KO: Backup globally cancelled."); 1980 qDebug("KO: Backup globally cancelled.");
1973 // backup globally cancelled 1981 // backup globally cancelled
1974 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1982 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1975 } 1983 }
1976 // retval == 3: do nothing, try again later 1984 // retval == 3: do nothing, try again later
1977} 1985}
1978void MainWindow::save() 1986void MainWindow::save()
1979{ 1987{
1980 1988
1981 if ( mView->viewManager()->journalView() ) 1989 if ( mView->viewManager()->journalView() )
1982 mView->viewManager()->journalView()->checkModified(); 1990 mView->viewManager()->journalView()->checkModified();
1983 if ( !mCalendarModifiedFlag ) { 1991 if ( !mCalendarModifiedFlag ) {
1984 qDebug("KO: Calendar not modified. Nothing saved."); 1992 qDebug("KO: Calendar not modified. Nothing saved.");
1985 return; 1993 return;
1986 } 1994 }
1987 if ( mSyncManager->blockSave() ) { 1995 if ( mSyncManager->blockSave() ) {
1988 slotModifiedChanged( true ); 1996 slotModifiedChanged( true );
1989 return; 1997 return;
1990 } 1998 }
1991 mSyncManager->setBlockSave(true); 1999 mSyncManager->setBlockSave(true);
1992 if ( mView->checkAllFileVersions() ) { 2000 if ( mView->checkAllFileVersions() ) {
1993 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2001 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1994 QDate reference ( 2000,1,1); 2002 QDate reference ( 2000,1,1);
1995 int daysTo = reference.daysTo ( QDate::currentDate() ); 2003 int daysTo = reference.daysTo ( QDate::currentDate() );
1996 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2004 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1997 backupAllFiles(); 2005 backupAllFiles();
1998 } 2006 }
1999 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2007 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2000 } 2008 }
2001 QTime neededSaveTime = QDateTime::currentDateTime().time(); 2009 QTime neededSaveTime = QDateTime::currentDateTime().time();
2002 if ( !isMinimized () ) 2010 if ( !isMinimized () )
2003 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2011 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2004 qDebug("KO: Start saving data to file!"); 2012 qDebug("KO: Start saving data to file!");
2005 mView->saveCalendars(); 2013 if ( mView->saveCalendars() )
2006 mCalendarModifiedFlag = false; 2014 mCalendarModifiedFlag = false;
2007 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 2015 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
2008 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2016 qDebug("KO: Needed %d ms for saving.",msNeeded );
2009 QString savemes; 2017 QString savemes;
2010 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2018 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2011 if ( !isMinimized () ) 2019 if ( !isMinimized () )
2012 setCaption(savemes); 2020 setCaption(savemes);
2013 else 2021 else
2014 qDebug(savemes); 2022 qDebug(savemes);
2015 } else { 2023 } else {
2016 setCaption(i18n("Saving cancelled!")); 2024 setCaption(i18n("Saving cancelled!"));
2017 mCalendarModifiedFlag = false; 2025 mCalendarModifiedFlag = false;
2018 slotModifiedChanged( true ); 2026 slotModifiedChanged( true );
2019 } 2027 }
2020 mSyncManager->setBlockSave( false ); 2028 mSyncManager->setBlockSave( false );
2021} 2029}
2022 2030
2023void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2031void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2024{ 2032{
2025 if ( !e->isAutoRepeat() ) { 2033 if ( !e->isAutoRepeat() ) {
2026 mFlagKeyPressed = false; 2034 mFlagKeyPressed = false;
2027 } 2035 }
2028} 2036}
2029void MainWindow::keyPressEvent ( QKeyEvent * e ) 2037void MainWindow::keyPressEvent ( QKeyEvent * e )
2030{ 2038{
2031 qApp->processEvents(); 2039 qApp->processEvents();
2032 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2040 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2033 e->ignore(); 2041 e->ignore();
2034 // qDebug(" ignore %d",e->isAutoRepeat() ); 2042 // qDebug(" ignore %d",e->isAutoRepeat() );
2035 return; 2043 return;
2036 } 2044 }
2037 if (! e->isAutoRepeat() ) 2045 if (! e->isAutoRepeat() )
2038 mFlagKeyPressed = true; 2046 mFlagKeyPressed = true;
2039 KOPrefs *p = KOPrefs::instance(); 2047 KOPrefs *p = KOPrefs::instance();
2040 bool showSelectedDates = false; 2048 bool showSelectedDates = false;
2041 int size; 2049 int size;
2042 int pro = 0; 2050 int pro = 0;
2043 //qDebug("MainWindow::keyPressEvent "); 2051 //qDebug("MainWindow::keyPressEvent ");
2044 switch ( e->key() ) { 2052 switch ( e->key() ) {
2045 case Qt::Key_Right: 2053 case Qt::Key_Right:
2046 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2054 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2047 mView->goNextMonth(); 2055 mView->goNextMonth();
2048 else 2056 else
2049 mView->goNext(); 2057 mView->goNext();
2050 showSelectedDates = true; 2058 showSelectedDates = true;
2051 break; 2059 break;
2052 case Qt::Key_Left: 2060 case Qt::Key_Left:
2053 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2061 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2054 mView->goPreviousMonth(); 2062 mView->goPreviousMonth();
2055 else 2063 else
2056 mView->goPrevious(); 2064 mView->goPrevious();
2057 showSelectedDates = true; 2065 showSelectedDates = true;
2058 break; 2066 break;
2059 case Qt::Key_Down: 2067 case Qt::Key_Down:
2060 mView->viewManager()->agendaView()->scrollOneHourDown(); 2068 mView->viewManager()->agendaView()->scrollOneHourDown();
2061 break; 2069 break;
2062 case Qt::Key_Up: 2070 case Qt::Key_Up:
2063 mView->viewManager()->agendaView()->scrollOneHourUp(); 2071 mView->viewManager()->agendaView()->scrollOneHourUp();
2064 break; 2072 break;
2065 case Qt::Key_K: 2073 case Qt::Key_K:
2066 mView->viewManager()->showMonthViewWeek(); 2074 mView->viewManager()->showMonthViewWeek();
2067 break; 2075 break;
2068 case Qt::Key_I: 2076 case Qt::Key_I:
2069 mView->showIncidence(); 2077 mView->showIncidence();
2070 break; 2078 break;
2071 case Qt::Key_Delete: 2079 case Qt::Key_Delete:
2072 case Qt::Key_Backspace: 2080 case Qt::Key_Backspace:
2073 mView->deleteIncidence(); 2081 mView->deleteIncidence();
2074 break; 2082 break;
2075 case Qt::Key_D: 2083 case Qt::Key_D:
2076 mView->viewManager()->showDayView(); 2084 mView->viewManager()->showDayView();
2077 showSelectedDates = true; 2085 showSelectedDates = true;
2078 break; 2086 break;
2079 case Qt::Key_O: 2087 case Qt::Key_O:
2080 mView->toggleFilerEnabled( ); 2088 mView->toggleFilerEnabled( );
2081 break; 2089 break;
2082 case Qt::Key_0: 2090 case Qt::Key_0:
2083 case Qt::Key_1: 2091 case Qt::Key_1:
2084 case Qt::Key_2: 2092 case Qt::Key_2:
2085 case Qt::Key_3: 2093 case Qt::Key_3:
2086 case Qt::Key_4: 2094 case Qt::Key_4:
2087 case Qt::Key_5: 2095 case Qt::Key_5:
2088 case Qt::Key_6: 2096 case Qt::Key_6:
2089 case Qt::Key_7: 2097 case Qt::Key_7:
2090 case Qt::Key_8: 2098 case Qt::Key_8:
2091 case Qt::Key_9: 2099 case Qt::Key_9:
2092 pro = e->key()-48; 2100 pro = e->key()-48;
2093 if ( pro == 0 ) 2101 if ( pro == 0 )
2094 pro = 10; 2102 pro = 10;
2095 if ( e->state() == Qt::ControlButton) 2103 if ( e->state() == Qt::ControlButton)
2096 pro += 10; 2104 pro += 10;
2097 break; 2105 break;
2098 case Qt::Key_M: 2106 case Qt::Key_M:
2099 mView->viewManager()->showMonthView(); 2107 mView->viewManager()->showMonthView();
2100 showSelectedDates = true; 2108 showSelectedDates = true;
2101 break; 2109 break;
2102 case Qt::Key_Insert: 2110 case Qt::Key_Insert:
2103 mView->newEvent(); 2111 mView->newEvent();
2104 break; 2112 break;
2105 case Qt::Key_S : 2113 case Qt::Key_S :
2106 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2114 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2107 mView->newSubTodo(); 2115 mView->newSubTodo();
2108 else 2116 else
2109 mView->dialogManager()->showSearchDialog(); 2117 mView->dialogManager()->showSearchDialog();
2110 break; 2118 break;
2111 case Qt::Key_Y : 2119 case Qt::Key_Y :
2112 case Qt::Key_Z : 2120 case Qt::Key_Z :
2113 mView->viewManager()->showWorkWeekView(); 2121 mView->viewManager()->showWorkWeekView();
2114 showSelectedDates = true; 2122 showSelectedDates = true;
2115 break; 2123 break;
2116 case Qt::Key_U : 2124 case Qt::Key_U :
2117 mView->viewManager()->showWeekView(); 2125 mView->viewManager()->showWeekView();
2118 showSelectedDates = true; 2126 showSelectedDates = true;
2119 break; 2127 break;
2120 case Qt::Key_H : 2128 case Qt::Key_H :
2121 keyBindings(); 2129 keyBindings();
2122 break; 2130 break;
2123 case Qt::Key_W: 2131 case Qt::Key_W:
2124 mView->viewManager()->showWhatsNextView(); 2132 mView->viewManager()->showWhatsNextView();
2125 break; 2133 break;
2126 case Qt::Key_L: 2134 case Qt::Key_L:
2127 mView->viewManager()->showListView(); 2135 mView->viewManager()->showListView();
2128 break; 2136 break;
2129 case Qt::Key_N: 2137 case Qt::Key_N:
2130 mView->viewManager()->showNextView(); 2138 mView->viewManager()->showNextView();
2131 break; 2139 break;
2132 case Qt::Key_V: 2140 case Qt::Key_V:
2133 mView->viewManager()->showTodoView(); 2141 mView->viewManager()->showTodoView();
2134 break; 2142 break;
2135 case Qt::Key_C: 2143 case Qt::Key_C:
2136 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2144 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2137 break; 2145 break;
2138 case Qt::Key_P: 2146 case Qt::Key_P:
2139 mView->showDatePicker( ); 2147 mView->showDatePicker( );
2140 break; 2148 break;
2141 case Qt::Key_F: 2149 case Qt::Key_F:
2142 mView->editFilters(); 2150 mView->editFilters();
2143 break; 2151 break;
2144 case Qt::Key_R: 2152 case Qt::Key_R:
2145 mView->toggleFilter(); 2153 mView->toggleFilter();
2146 break; 2154 break;
2147 case Qt::Key_X: 2155 case Qt::Key_X:
2148 if ( e->state() == Qt::ControlButton ) 2156 if ( e->state() == Qt::ControlButton )
2149 mView->toggleDateNavigatorWidget(); 2157 mView->toggleDateNavigatorWidget();
2150 else { 2158 else {
2151 mView->viewManager()->showNextXView(); 2159 mView->viewManager()->showNextXView();
2152 showSelectedDates = true; 2160 showSelectedDates = true;
2153 } 2161 }
2154 break; 2162 break;
2155 case Qt::Key_Space: 2163 case Qt::Key_Space:
2156 mView->toggleExpand(); 2164 mView->toggleExpand();
2157 break; 2165 break;
2158 case Qt::Key_A: 2166 case Qt::Key_A:
2159 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2167 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2160 mView->showNextAlarms(); 2168 mView->showNextAlarms();
2161 else 2169 else
2162 mView->toggleAllDaySize(); 2170 mView->toggleAllDaySize();
2163 break; 2171 break;
2164 case Qt::Key_T: 2172 case Qt::Key_T:
2165 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2173 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2166 mView->newTodo(); 2174 mView->newTodo();
2167 else { 2175 else {
2168 mView->goToday(); 2176 mView->goToday();
2169 showSelectedDates = true; 2177 showSelectedDates = true;
2170 } 2178 }
2171 break; 2179 break;
2172 case Qt::Key_Q: 2180 case Qt::Key_Q:
2173 if ( e->state() == Qt::ControlButton ) 2181 if ( e->state() == Qt::ControlButton )
2174 mView->conflictNotAll(); 2182 mView->conflictNotAll();
2175 else if ( e->state() == Qt::ShiftButton ) 2183 else if ( e->state() == Qt::ShiftButton )
2176 mView->conflictAllday(); 2184 mView->conflictAllday();
2177 else 2185 else
2178 mView->conflictAll(); 2186 mView->conflictAll();
2179 break; 2187 break;
2180 case Qt::Key_J: 2188 case Qt::Key_J:
2181 mView->viewManager()->showJournalView(); 2189 mView->viewManager()->showJournalView();
2182 break; 2190 break;
2183 case Qt::Key_B: 2191 case Qt::Key_B:
2184 mView->editIncidenceDescription();; 2192 mView->editIncidenceDescription();;
2185 break; 2193 break;
2186 // case Qt::Key_Return: 2194 // case Qt::Key_Return:
2187 case Qt::Key_E: 2195 case Qt::Key_E:
2188 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2196 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2189 mView->newEvent(); 2197 mView->newEvent();
2190 else 2198 else
2191 mView->editIncidence(); 2199 mView->editIncidence();
2192 break; 2200 break;
2193 case Qt::Key_Plus: 2201 case Qt::Key_Plus:
2194 size = p->mHourSize +2; 2202 size = p->mHourSize +2;
2195 if ( size <= 22 ) 2203 if ( size <= 22 )
2196 configureAgenda( size ); 2204 configureAgenda( size );
2197 break; 2205 break;
2198 case Qt::Key_Minus: 2206 case Qt::Key_Minus:
2199 size = p->mHourSize - 2; 2207 size = p->mHourSize - 2;
2200 if ( size >= 4 ) 2208 if ( size >= 4 )
2201 configureAgenda( size ); 2209 configureAgenda( size );
2202 break; 2210 break;
2203 2211
2204 2212
2205 default: 2213 default:
2206 e->ignore(); 2214 e->ignore();
2207 } 2215 }
2208 if ( pro > 0 ) { 2216 if ( pro > 0 ) {
2209 selectFilter( pro+1 ); 2217 selectFilter( pro+1 );
2210 } 2218 }
2211 if ( showSelectedDates ) { 2219 if ( showSelectedDates ) {
2212 ;// setCaptionToDates(); 2220 ;// setCaptionToDates();
2213 } 2221 }
2214 2222
2215} 2223}
2216void MainWindow::fillFilterMenuTB() 2224void MainWindow::fillFilterMenuTB()
2217{ 2225{
2218 selectFilterMenuTB->clear(); 2226 selectFilterMenuTB->clear();
2219 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2227 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2220 selectFilterMenuTB->insertSeparator(); 2228 selectFilterMenuTB->insertSeparator();
2221 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2229 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2222 2230
2223 selectFilterMenuTB->insertSeparator(); 2231 selectFilterMenuTB->insertSeparator();
2224 QPtrList<CalFilter> fili = mView->filters(); 2232 QPtrList<CalFilter> fili = mView->filters();
2225 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2233 CalFilter *curfilter = mView->filterView()->selectedFilter();
2226 CalFilter *filter = fili.first(); 2234 CalFilter *filter = fili.first();
2227 int iii = 2; 2235 int iii = 2;
2228 bool checkitem = mView->filterView()->filtersEnabled(); 2236 bool checkitem = mView->filterView()->filtersEnabled();
2229 while(filter) { 2237 while(filter) {
2230 selectFilterMenuTB->insertItem( filter->name(), iii ); 2238 selectFilterMenuTB->insertItem( filter->name(), iii );
2231 if ( filter == curfilter) 2239 if ( filter == curfilter)
2232 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2240 selectFilterMenuTB->setItemChecked( iii, checkitem );
2233 filter = fili.next(); 2241 filter = fili.next();
2234 ++iii; 2242 ++iii;
2235 } 2243 }
2236 if ( !checkitem ) 2244 if ( !checkitem )
2237 selectFilterMenuTB->setItemChecked( 1, true ); 2245 selectFilterMenuTB->setItemChecked( 1, true );
2238 2246
2239 int x = 0; 2247 int x = 0;
2240 int y = iconToolBar->height(); 2248 int y = iconToolBar->height();
2241 int dX = 0; 2249 int dX = 0;
2242 int dY = 0; 2250 int dY = 0;
2243 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2251 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2244 if ( iconToolBar->y() > height()/2 ) { 2252 if ( iconToolBar->y() > height()/2 ) {
2245 dY = selectFilterMenuTB->sizeHint().height()+8; 2253 dY = selectFilterMenuTB->sizeHint().height()+8;
2246 y = 0; 2254 y = 0;
2247 } 2255 }
2248 } else { 2256 } else {
2249 if ( iconToolBar->x() > width()/2 ) { // right side 2257 if ( iconToolBar->x() > width()/2 ) { // right side
2250 x=0; 2258 x=0;
2251 dX= selectFilterMenuTB->sizeHint().width()+8; 2259 dX= selectFilterMenuTB->sizeHint().width()+8;
2252 y = 0; 2260 y = 0;
2253 } else { 2261 } else {
2254 x= iconToolBar->width(); 2262 x= iconToolBar->width();
2255 y = 0; 2263 y = 0;
2256 } 2264 }
2257 } 2265 }
2258 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2266 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2259 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2267 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2260} 2268}
2261void MainWindow::fillFilterMenu() 2269void MainWindow::fillFilterMenu()
2262{ 2270{
2263 selectFilterMenu->clear(); 2271 selectFilterMenu->clear();
2264 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2272 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2265 selectFilterMenu->insertSeparator(); 2273 selectFilterMenu->insertSeparator();
2266 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2274 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2267 2275
2268 selectFilterMenu->insertSeparator(); 2276 selectFilterMenu->insertSeparator();
2269 QPtrList<CalFilter> fili = mView->filters(); 2277 QPtrList<CalFilter> fili = mView->filters();
2270 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2278 CalFilter *curfilter = mView->filterView()->selectedFilter();
2271 CalFilter *filter = fili.first(); 2279 CalFilter *filter = fili.first();
2272 int iii = 2; 2280 int iii = 2;
2273 bool checkitem = mView->filterView()->filtersEnabled(); 2281 bool checkitem = mView->filterView()->filtersEnabled();
2274 while(filter) { 2282 while(filter) {
2275 selectFilterMenu->insertItem( filter->name(), iii ); 2283 selectFilterMenu->insertItem( filter->name(), iii );
2276 if ( filter == curfilter) 2284 if ( filter == curfilter)
2277 selectFilterMenu->setItemChecked( iii, checkitem ); 2285 selectFilterMenu->setItemChecked( iii, checkitem );
2278 filter = fili.next(); 2286 filter = fili.next();
2279 ++iii; 2287 ++iii;
2280 } 2288 }
2281 if ( !checkitem ) 2289 if ( !checkitem )
2282 selectFilterMenu->setItemChecked( 1, true ); 2290 selectFilterMenu->setItemChecked( 1, true );
2283} 2291}
2284void MainWindow::fillFilterMenuPopup() 2292void MainWindow::fillFilterMenuPopup()
2285{ 2293{
2286 filterPopupMenu->clear(); 2294 filterPopupMenu->clear();
2287 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2295 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2288 2296
2289 filterPopupMenu->insertSeparator(); 2297 filterPopupMenu->insertSeparator();
2290 QPtrList<CalFilter> fili = mView->filters(); 2298 QPtrList<CalFilter> fili = mView->filters();
2291 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2299 CalFilter *curfilter = mView->filterView()->selectedFilter();
2292 CalFilter *filter = fili.first(); 2300 CalFilter *filter = fili.first();
2293 int iii = 1; 2301 int iii = 1;
2294 bool checkitem = mView->filterView()->filtersEnabled(); 2302 bool checkitem = mView->filterView()->filtersEnabled();
2295 while(filter) { 2303 while(filter) {
2296 filterPopupMenu->insertItem( filter->name(), iii ); 2304 filterPopupMenu->insertItem( filter->name(), iii );
2297 if ( filter == curfilter) 2305 if ( filter == curfilter)
2298 filterPopupMenu->setItemChecked( iii, checkitem ); 2306 filterPopupMenu->setItemChecked( iii, checkitem );
2299 filter = fili.next(); 2307 filter = fili.next();
2300 ++iii; 2308 ++iii;
2301 } 2309 }
2302 if ( !checkitem ) 2310 if ( !checkitem )
2303 filterPopupMenu->setItemChecked( 0, true ); 2311 filterPopupMenu->setItemChecked( 0, true );
2304} 2312}
2305void MainWindow::selectFilter( int fil ) 2313void MainWindow::selectFilter( int fil )
2306{ 2314{
2307 2315
2308 if ( fil == 0 ) { 2316 if ( fil == 0 ) {
2309 mView->editFilters( ); 2317 mView->editFilters( );
2310 } else if ( fil == 1 ){ 2318 } else if ( fil == 1 ){
2311 if ( mView->filterView()->filtersEnabled() ) 2319 if ( mView->filterView()->filtersEnabled() )
2312 mView->toggleFilerEnabled( ); 2320 mView->toggleFilerEnabled( );
2313 } else { 2321 } else {
2314 if ( !mView->filterView()->filtersEnabled() ) { 2322 if ( !mView->filterView()->filtersEnabled() ) {
2315 mView->filterView()->blockSignals( true ); 2323 mView->filterView()->blockSignals( true );
2316 mView->toggleFilerEnabled( ); 2324 mView->toggleFilerEnabled( );
2317 mView->filterView()->blockSignals( false ); 2325 mView->filterView()->blockSignals( false );
2318 } 2326 }
2319 mView->selectFilter( fil-2 ); 2327 mView->selectFilter( fil-2 );
2320 } 2328 }
2321} 2329}
2322void MainWindow::updateFilterToolbar() 2330void MainWindow::updateFilterToolbar()
2323{ 2331{
2324 if ( filterMenubar ) { 2332 if ( filterMenubar ) {
2325 if ( !mView->filterView()->filtersEnabled() ) { 2333 if ( !mView->filterView()->filtersEnabled() ) {
2326 filterMenubar->changeItem( 0, i18n("No Filter") ); 2334 filterMenubar->changeItem( 0, i18n("No Filter") );
2327 } else { 2335 } else {
2328 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2336 CalFilter *curfilter = mView->filterView()->selectedFilter();
2329 if ( curfilter ) { 2337 if ( curfilter ) {
2330 QString name = curfilter->name(); 2338 QString name = curfilter->name();
2331 if ( name.length() > 12 ) 2339 if ( name.length() > 12 )
2332 name = name.left(10)+"..."; 2340 name = name.left(10)+"...";
2333 filterMenubar->changeItem( 0, name ); 2341 filterMenubar->changeItem( 0, name );
2334 } 2342 }
2335 } 2343 }
2336 } 2344 }
2337} 2345}
2338void MainWindow::selectFilterPopup( int fil ) 2346void MainWindow::selectFilterPopup( int fil )
2339{ 2347{
2340 selectFilter( fil + 1 ); 2348 selectFilter( fil + 1 );
2341 2349
2342} 2350}
2343void MainWindow::configureToolBar( int item ) 2351void MainWindow::configureToolBar( int item )
2344{ 2352{
2345 2353
2346 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2354 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2347 KOPrefs *p = KOPrefs::instance(); 2355 KOPrefs *p = KOPrefs::instance();
2348 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2356 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2349 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2357 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2350 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2358 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2351 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2359 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2352 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2360 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2353 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2361 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2354 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2362 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2355 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2363 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2356 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2364 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2357 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2365 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2358 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2366 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2359 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2367 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2360 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2368 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2361 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2369 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2362 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2370 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2363 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2371 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2364 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2372 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2365 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2373 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2366 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2374 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2367 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2375 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2368 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2376 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2369 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2377 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2370 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2378 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2371 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2379 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2372 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2380 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2373 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2381 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2374 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2382 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2375 // initActions(); 2383 // initActions();
2376 setCaption ( i18n("Toolbar changes needs a restart!") ); 2384 setCaption ( i18n("Toolbar changes needs a restart!") );
2377} 2385}
2378void MainWindow::setCaption ( const QString & c ) 2386void MainWindow::setCaption ( const QString & c )
2379{ 2387{
2380 QString cap = c; 2388 QString cap = c;
2381 cap.replace( QRegExp("\n"), " " ); 2389 cap.replace( QRegExp("\n"), " " );
2382 cap = cap.stripWhiteSpace(); 2390 cap = cap.stripWhiteSpace();
2383 if ( cap.isEmpty() ) 2391 if ( cap.isEmpty() )
2384 cap = "KO/Pi"; 2392 cap = "KO/Pi";
2385 QWidget::setCaption( cap ); 2393 QWidget::setCaption( cap );
2386} 2394}
2387void MainWindow::setCaptionToDates() 2395void MainWindow::setCaptionToDates()
2388{ 2396{
2389 QString selDates; 2397 QString selDates;
2390 QDate date = mView->startDate(); 2398 QDate date = mView->startDate();
2391 if ( ! date.isValid() ) { 2399 if ( ! date.isValid() ) {
2392 setCaption(""); 2400 setCaption("");
2393 return; 2401 return;
2394 } 2402 }
2395 selDates = KGlobal::locale()->formatDate( date, true); 2403 selDates = KGlobal::locale()->formatDate( date, true);
2396 if (mView->startDate() < mView->endDate() ) 2404 if (mView->startDate() < mView->endDate() )
2397 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2405 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2398 else { 2406 else {
2399 QString addString; 2407 QString addString;
2400 if ( date == QDateTime::currentDateTime().date() ) 2408 if ( date == QDateTime::currentDateTime().date() )
2401 addString = i18n("Today"); 2409 addString = i18n("Today");
2402 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2410 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2403 addString = i18n("Tomorrow"); 2411 addString = i18n("Tomorrow");
2404 if ( !addString.isEmpty() ) 2412 if ( !addString.isEmpty() )
2405 selDates = addString+", "+selDates ; 2413 selDates = addString+", "+selDates ;
2406 } 2414 }
2407 setCaption( i18n("Dates: ") + selDates ); 2415 setCaption( i18n("Dates: ") + selDates );
2408 2416
2409} 2417}
2410void MainWindow::showConfigureAgenda( ) 2418void MainWindow::showConfigureAgenda( )
2411{ 2419{
2412 int iii; 2420 int iii;
2413 for ( iii = 1;iii<= 10 ;++iii ){ 2421 for ( iii = 1;iii<= 10 ;++iii ){
2414 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2422 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2415 } 2423 }
2416 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2424 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2417} 2425}
2418void MainWindow::configureAgenda( int item ) 2426void MainWindow::configureAgenda( int item )
2419{ 2427{
2420 if ( KOPrefs::instance()->mHourSize == item ) 2428 if ( KOPrefs::instance()->mHourSize == item )
2421 return; 2429 return;
2422 KOPrefs::instance()->mHourSize=item; 2430 KOPrefs::instance()->mHourSize=item;
2423 mView->viewManager()->agendaView()->updateConfig(); 2431 mView->viewManager()->agendaView()->updateConfig();
2424} 2432}
2425 2433
2426void MainWindow::saveCalendar() 2434void MainWindow::saveCalendar()
2427{ 2435{
2428 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2436 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2429 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2437 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2430 bupDir = KGlobalSettings::backupDataDir(); 2438 bupDir = KGlobalSettings::backupDataDir();
2431 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2439 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2432 QString bupHint; 2440 QString bupHint;
2433 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2441 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2434 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2442 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2435 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2443 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2436 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2444 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2437 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2445 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2438 save(); 2446 save();
2439 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2447 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2440 backupAllFiles(); 2448 backupAllFiles();
2441} 2449}
2442void MainWindow::loadCalendar() 2450void MainWindow::loadCalendar()
2443{ 2451{
2444 2452
2445 2453
2446#if 0 2454#if 0
2447 QString fn = KOPrefs::instance()->mLastLoadFile; 2455 QString fn = KOPrefs::instance()->mLastLoadFile;
2448 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2456 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2449 2457
2450 if ( fn == "" ) 2458 if ( fn == "" )
2451 return; 2459 return;
2452 QFileInfo info; 2460 QFileInfo info;
2453 info.setFile( fn ); 2461 info.setFile( fn );
2454 QString mess; 2462 QString mess;
2455 bool loadbup = true; 2463 bool loadbup = true;
2456 if ( info. exists() ) { 2464 if ( info. exists() ) {
2457 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2465 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2458 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2466 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2459 mess, 2467 mess,
2460 i18n("Load!"), i18n("Cancel"), 0, 2468 i18n("Load!"), i18n("Cancel"), 0,
2461 0, 1 ); 2469 0, 1 );
2462 if ( result != 0 ) { 2470 if ( result != 0 ) {
2463 loadbup = false; 2471 loadbup = false;
2464 } 2472 }
2465 } else { 2473 } else {
2466 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2474 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2467 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2475 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2468 0, 1 ); 2476 0, 1 );
2469 2477
2470 return; 2478 return;
2471 } 2479 }
2472 if ( loadbup ) { 2480 if ( loadbup ) {
2473 mView->openCalendar( fn ); 2481 mView->openCalendar( fn );
2474 KOPrefs::instance()->mLastLoadFile = fn; 2482 KOPrefs::instance()->mLastLoadFile = fn;
2475 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2483 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2476 setCaption(mess); 2484 setCaption(mess);
2477 } 2485 }
2478#endif 2486#endif
2479 2487
2480} 2488}
2481void MainWindow::quickImportIcal() 2489void MainWindow::quickImportIcal()
2482{ 2490{
2483 importFile( KOPrefs::instance()->mLastImportFile, false ); 2491 importFile( KOPrefs::instance()->mLastImportFile, false );
2484} 2492}
2485void MainWindow::importFile( QString fn, bool quick ) 2493void MainWindow::importFile( QString fn, bool quick )
2486{ 2494{
2487 QFileInfo info; 2495 QFileInfo info;
2488 info.setFile( fn ); 2496 info.setFile( fn );
2489 QString mess; 2497 QString mess;
2490 if ( !info. exists() ) { 2498 if ( !info. exists() ) {
2491 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2499 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2492 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2500 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2493 mess ); 2501 mess );
2494 return; 2502 return;
2495 } 2503 }
2496 int result = 0; 2504 int result = 0;
2497 if ( !quick ) { 2505 if ( !quick ) {
2498 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 )); 2506 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 ));
2499 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2507 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2500 mess, 2508 mess,
2501 "Import", "Cancel", 0, 2509 "Import", "Cancel", 0,
2502 0, 1 ); 2510 0, 1 );
2503 } 2511 }
2504 if ( result == 0 ) { 2512 if ( result == 0 ) {
2505 if ( mView->openCalendar( fn, true )) { 2513 if ( mView->openCalendar( fn, true )) {
2506 KOPrefs::instance()->mLastImportFile = fn; 2514 KOPrefs::instance()->mLastImportFile = fn;
2507 setCaption(i18n("Imported file successfully")); 2515 setCaption(i18n("Imported file successfully"));
2508 } else { 2516 } else {
2509 setCaption(i18n("Error importing file")); 2517 setCaption(i18n("Error importing file"));
2510 } 2518 }
2511 } 2519 }
2512} 2520}
2513 2521
2514void MainWindow::importIcal() 2522void MainWindow::importIcal()
2515{ 2523{
2516 2524
2517 QString fn =KOPrefs::instance()->mLastImportFile; 2525 QString fn =KOPrefs::instance()->mLastImportFile;
2518 2526
2519 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2527 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2520 if ( fn == "" ) 2528 if ( fn == "" )
2521 return; 2529 return;
2522 importFile( fn, true ); 2530 importFile( fn, true );
2523 2531
2524} 2532}
2525 2533
2526void MainWindow::exportVCalendar() 2534void MainWindow::exportVCalendar()
2527{ 2535{
2528 QString fn = KOPrefs::instance()->mLastVcalFile; 2536 QString fn = KOPrefs::instance()->mLastVcalFile;
2529 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2537 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2530 if ( fn == "" ) 2538 if ( fn == "" )
2531 return; 2539 return;
2532 QFileInfo info; 2540 QFileInfo info;
2533 info.setFile( fn ); 2541 info.setFile( fn );
2534 QString mes; 2542 QString mes;
2535 bool createbup = true; 2543 bool createbup = true;
2536 if ( info. exists() ) { 2544 if ( info. exists() ) {
2537 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2545 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2538 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2546 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2539 i18n("Overwrite!"), i18n("Cancel"), 0, 2547 i18n("Overwrite!"), i18n("Cancel"), 0,
2540 0, 1 ); 2548 0, 1 );
2541 if ( result != 0 ) { 2549 if ( result != 0 ) {
2542 createbup = false; 2550 createbup = false;
2543 } 2551 }
2544 } 2552 }
2545 if ( createbup ) { 2553 if ( createbup ) {
2546 if ( mView->exportVCalendar( fn ) ) { 2554 if ( mView->exportVCalendar( fn ) ) {
2547 KOPrefs::instance()->mLastVcalFile = fn; 2555 KOPrefs::instance()->mLastVcalFile = fn;
2548 if ( fn.length() > 20 ) 2556 if ( fn.length() > 20 )
2549 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2557 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2550 else 2558 else
2551 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2559 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2552 setCaption(mes); 2560 setCaption(mes);
2553 } 2561 }
2554 } 2562 }
2555 2563
2556} 2564}
2557QString MainWindow::sentSyncFile() 2565QString MainWindow::sentSyncFile()
2558{ 2566{
2559#ifdef DESKTOP_VERSION 2567#ifdef DESKTOP_VERSION
2560 return locateLocal( "tmp", "copysynccal.ics" ); 2568 return locateLocal( "tmp", "copysynccal.ics" );
2561#else 2569#else
2562 return QString( "/tmp/copysynccal.ics" ); 2570 return QString( "/tmp/copysynccal.ics" );
2563#endif 2571#endif
2564} 2572}
2565 2573
2566void MainWindow::syncFileRequest() 2574void MainWindow::syncFileRequest()
2567{ 2575{
2568 while ( mSyncManager->blockSave() ) { 2576 while ( mSyncManager->blockSave() ) {
2569 qApp->processEvents(); 2577 qApp->processEvents();
2570 } 2578 }
2571 mSyncManager->setBlockSave(true); 2579 mSyncManager->setBlockSave(true);
2572 2580
2573 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2581 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2574 mSyncManager->slotSyncMenu( 999 ); 2582 mSyncManager->slotSyncMenu( 999 );
2575 } 2583 }
2576 2584
2577 setCaption(i18n("Saving Data to temp file ..." )); 2585 setCaption(i18n("Saving Data to temp file ..." ));
2578 mView->saveCalendar( sentSyncFile() ); 2586 mView->saveCalendar( sentSyncFile() );
2579 setCaption(i18n("Data saved to temp file!" )); 2587 setCaption(i18n("Data saved to temp file!" ));
2580 mSyncManager->setBlockSave( false ); 2588 mSyncManager->setBlockSave( false );
2581 2589
2582} 2590}
2583void MainWindow::getFile( bool success ) 2591void MainWindow::getFile( bool success )
2584{ 2592{
2585 if ( ! success ) { 2593 if ( ! success ) {
2586 setCaption( i18n("Error receiving file. Nothing changed!") ); 2594 setCaption( i18n("Error receiving file. Nothing changed!") );
2587 return; 2595 return;
2588 } 2596 }
2589 mView->mergeFile( sentSyncFile() ); 2597 mView->mergeFile( sentSyncFile() );
2590 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2598 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2591 mSyncManager->slotSyncMenu( 999 ); 2599 mSyncManager->slotSyncMenu( 999 );
2592 } 2600 }
2593 setCaption( i18n("Pi-Sync successful!") ); 2601 setCaption( i18n("Pi-Sync successful!") );
2594} 2602}
2595void MainWindow::printListView() 2603void MainWindow::printListView()
2596{ 2604{
2597 2605
2598 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2606 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2599 2607
2600 KMessageBox::information( this, message); 2608 KMessageBox::information( this, message);
2601} 2609}
2602void MainWindow::printSel( ) 2610void MainWindow::printSel( )
2603{ 2611{
2604 mView->viewManager()->agendaView()->agenda()->printSelection(); 2612 mView->viewManager()->agendaView()->agenda()->printSelection();
2605} 2613}
2606 2614
2607void MainWindow::printCal() 2615void MainWindow::printCal()
2608{ 2616{
2609 mView->print();//mCp->showDialog(); 2617 mView->print();//mCp->showDialog();
2610} 2618}
2611 2619
2612 2620
2613#include "libkdepim/kdatepicker.h" 2621#include "libkdepim/kdatepicker.h"
2614#include <kdatetbl.h> 2622#include <kdatetbl.h>
2615 2623
2616void MainWindow::weekAction() 2624void MainWindow::weekAction()
2617{ 2625{
2618 int month; 2626 int month;
2619 KPopupFrame* popup = new KPopupFrame(this); 2627 KPopupFrame* popup = new KPopupFrame(this);
2620 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2628 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2621 // ----- 2629 // -----
2622 picker->resize(picker->sizeHint()); 2630 picker->resize(picker->sizeHint());
2623 popup->setMainWidget(picker); 2631 popup->setMainWidget(picker);
2624 picker->setFocus(); 2632 picker->setFocus();
2625 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2633 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2626 int x = 0; 2634 int x = 0;
2627 int y = iconToolBar->height(); 2635 int y = iconToolBar->height();
2628 int dX = 0; 2636 int dX = 0;
2629 int dY = 0; 2637 int dY = 0;
2630 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2638 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2631 if ( iconToolBar->y() > height()/2 ) { 2639 if ( iconToolBar->y() > height()/2 ) {
2632 dY = picker->sizeHint().height()+8; 2640 dY = picker->sizeHint().height()+8;
2633 y = 0; 2641 y = 0;
2634 } 2642 }
2635 } else { 2643 } else {
2636 if ( iconToolBar->x() > width()/2 ) { // right side 2644 if ( iconToolBar->x() > width()/2 ) { // right side
2637 x=0; 2645 x=0;
2638 dX= picker->sizeHint().width()+8; 2646 dX= picker->sizeHint().width()+8;
2639 y = 0; 2647 y = 0;
2640 } else { 2648 } else {
2641 x= iconToolBar->width(); 2649 x= iconToolBar->width();
2642 y = 0; 2650 y = 0;
2643 } 2651 }
2644 } 2652 }
2645 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2653 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2646 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2654 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2647 { 2655 {
2648 month = picker->getResult(); 2656 month = picker->getResult();
2649 emit selectWeek ( month ); 2657 emit selectWeek ( month );
2650 //qDebug("weekSelected %d ", month); 2658 //qDebug("weekSelected %d ", month);
2651 } 2659 }
2652 delete popup; 2660 delete popup;
2653} 2661}
2654 2662
2655void MainWindow::hideEvent ( QHideEvent * ) 2663void MainWindow::hideEvent ( QHideEvent * )
2656{ 2664{
2657 QString message; 2665 QString message;
2658 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2666 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2659 if ( nextA.isValid() ) { 2667 if ( nextA.isValid() ) {
2660 QString sum = mCalendar->nextSummary(); 2668 QString sum = mCalendar->nextSummary();
2661 2669
2662 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)); 2670 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));
2663 setCaption( message ); 2671 setCaption( message );
2664 } 2672 }
2665} 2673}
2666 2674
2667void MainWindow::resizeEvent( QResizeEvent* e) 2675void MainWindow::resizeEvent( QResizeEvent* e)
2668{ 2676{
2669#ifndef DESKTOP_VERSION 2677#ifndef DESKTOP_VERSION
2670 if ( filterToolBar ) { 2678 if ( filterToolBar ) {
2671 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2679 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2672 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2680 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2673 filterToolBar->hide(); 2681 filterToolBar->hide();
2674 else 2682 else
2675 filterToolBar->show(); 2683 filterToolBar->show();
2676 } 2684 }
2677 } 2685 }
2678#endif 2686#endif
2679 QMainWindow::resizeEvent( e); 2687 QMainWindow::resizeEvent( e);
2680} 2688}