summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-02 15:12:43 (UTC)
committer zautrix <zautrix>2005-03-02 15:12:43 (UTC)
commit9e0ceaa58a686fb64f8133ffa9e73866e985a464 (patch) (unidiff)
tree794d5af071dba939d4ff6b27544274c36b5ecec5
parent6733b0548df446fade0a58d409d5f80314e5ed4b (diff)
downloadkdepimpi-9e0ceaa58a686fb64f8133ffa9e73866e985a464.zip
kdepimpi-9e0ceaa58a686fb64f8133ffa9e73866e985a464.tar.gz
kdepimpi-9e0ceaa58a686fb64f8133ffa9e73866e985a464.tar.bz2
print fix. added desktop Qtopia import
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calprintbase.cpp2
-rw-r--r--korganizer/mainwindow.cpp23
2 files changed, 17 insertions, 8 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp
index af32ebc..6bb407d 100644
--- a/korganizer/calprintbase.cpp
+++ b/korganizer/calprintbase.cpp
@@ -1,1304 +1,1304 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qfontmetrics.h> 32#include <qfontmetrics.h>
33 33
34#include <kglobal.h> 34#include <kglobal.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kconfig.h> 37#include <kconfig.h>
38#include <kcalendarsystem.h> 38#include <kcalendarsystem.h>
39#include <kprinter.h> 39#include <kprinter.h>
40 40
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42#include <libkcal/event.h> 42#include <libkcal/event.h>
43#include <libkcal/calendar.h> 43#include <libkcal/calendar.h>
44 44
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47#ifndef KORG_NOPLUGINS 47#ifndef KORG_NOPLUGINS
48#include "kocore.h" 48#include "kocore.h"
49#endif 49#endif
50#include "cellitem.h" 50#include "cellitem.h"
51 51
52#include "calprintbase.h" 52#include "calprintbase.h"
53 53
54#ifndef KORG_NOPRINTER 54#ifndef KORG_NOPRINTER
55//#include "calprintbase.moc" 55//#include "calprintbase.moc"
56 56
57int CalPrintBase::mHeaderHeight=90; 57int CalPrintBase::mHeaderHeight=90;
58int CalPrintBase::mSubHeaderHeight=20; 58int CalPrintBase::mSubHeaderHeight=20;
59int CalPrintBase::mMargin=36; 59int CalPrintBase::mMargin=36;
60 60
61 61
62 62
63class CalPrintBase::TodoParentStart 63class CalPrintBase::TodoParentStart
64{ 64{
65 public: 65 public:
66 TodoParentStart( QRect pt = QRect(), bool page = true ) 66 TodoParentStart( QRect pt = QRect(), bool page = true )
67 : mRect( pt ), mSamePage( page ) {} 67 : mRect( pt ), mSamePage( page ) {}
68 68
69 QRect mRect; 69 QRect mRect;
70 bool mSamePage; 70 bool mSamePage;
71}; 71};
72 72
73class PrintCellItem : public KOrg::CellItem 73class PrintCellItem : public KOrg::CellItem
74{ 74{
75 public: 75 public:
76 PrintCellItem( Event *event, const QDate &day ) 76 PrintCellItem( Event *event, const QDate &day )
77 : mEvent( event ), mDay( day ) 77 : mEvent( event ), mDay( day )
78 { 78 {
79 } 79 }
80 80
81 Event *event() const { return mEvent; } 81 Event *event() const { return mEvent; }
82 82
83 QString label() const { return mEvent->summary(); } 83 QString label() const { return mEvent->summary(); }
84 84
85 bool overlaps( KOrg::CellItem *o ) const 85 bool overlaps( KOrg::CellItem *o ) const
86 { 86 {
87 PrintCellItem *other = static_cast<PrintCellItem *>( o ); 87 PrintCellItem *other = static_cast<PrintCellItem *>( o );
88 88
89 QDateTime start = event()->dtStart(); 89 QDateTime start = event()->dtStart();
90 QDateTime end = event()->dtEnd(); 90 QDateTime end = event()->dtEnd();
91 if ( event()->doesRecur() ) { 91 if ( event()->doesRecur() ) {
92 start.setDate( mDay ); 92 start.setDate( mDay );
93 end.setDate( mDay ); 93 end.setDate( mDay );
94 } 94 }
95 QDateTime otherStart = other->event()->dtStart(); 95 QDateTime otherStart = other->event()->dtStart();
96 QDateTime otherEnd = other->event()->dtEnd(); 96 QDateTime otherEnd = other->event()->dtEnd();
97 if ( other->event()->doesRecur() ) { 97 if ( other->event()->doesRecur() ) {
98 otherStart.setDate( mDay ); 98 otherStart.setDate( mDay );
99 otherEnd.setDate( mDay ); 99 otherEnd.setDate( mDay );
100 } 100 }
101 101
102#if 0 102#if 0
103 kdDebug() << "PrintCellItem::overlaps() " << event()->summary() 103 kdDebug() << "PrintCellItem::overlaps() " << event()->summary()
104 << " <-> " << other->event()->summary() << endl; 104 << " <-> " << other->event()->summary() << endl;
105 kdDebug() << " start : " << start.toString() << endl; 105 kdDebug() << " start : " << start.toString() << endl;
106 kdDebug() << " end : " << end.toString() << endl; 106 kdDebug() << " end : " << end.toString() << endl;
107 kdDebug() << " otherStart: " << otherStart.toString() << endl; 107 kdDebug() << " otherStart: " << otherStart.toString() << endl;
108 kdDebug() << " otherEnd : " << otherEnd.toString() << endl; 108 kdDebug() << " otherEnd : " << otherEnd.toString() << endl;
109#endif 109#endif
110 110
111 return !( otherStart >= end || otherEnd <= start ); 111 return !( otherStart >= end || otherEnd <= start );
112 } 112 }
113 113
114 private: 114 private:
115 Event *mEvent; 115 Event *mEvent;
116 QDate mDay; 116 QDate mDay;
117}; 117};
118 118
119void setCategoryColors( QPainter &p, Incidence *incidence) 119void setCategoryColors( QPainter &p, Incidence *incidence)
120{ 120{
121 QColor bgColor; 121 QColor bgColor;
122 QStringList categories = incidence->categories(); 122 QStringList categories = incidence->categories();
123 QString cat = categories.first(); 123 QString cat = categories.first();
124 if (cat.isEmpty()) 124 if (cat.isEmpty())
125 bgColor = KOPrefs::instance()->mEventColor; 125 bgColor = KOPrefs::instance()->mEventColor;
126 else 126 else
127 bgColor = *(KOPrefs::instance()->categoryColor(cat)); 127 bgColor = *(KOPrefs::instance()->categoryColor(cat));
128 QColor textColor = Qt::black;//getTextColor(bgColor); 128 QColor textColor = Qt::black;//getTextColor(bgColor);
129 p.setPen( textColor ); 129 p.setPen( textColor );
130 p.setBrush( bgColor ); 130 p.setBrush( bgColor );
131} 131}
132 132
133 133
134 134
135CalPrintBase::CalPrintBase( KPrinter *printer, Calendar *cal, KConfig *cfg ) 135CalPrintBase::CalPrintBase( KPrinter *printer, Calendar *cal, KConfig *cfg )
136 : QObject(), mPrinter( printer ), mCalendar( cal ), mConfig( cfg ) 136 : QObject(), mPrinter( printer ), mCalendar( cal ), mConfig( cfg )
137{ 137{
138} 138}
139 139
140CalPrintBase::~CalPrintBase() 140CalPrintBase::~CalPrintBase()
141{ 141{
142} 142}
143 143
144 144
145 145
146QWidget *CalPrintBase::configWidget( QWidget *w ) 146QWidget *CalPrintBase::configWidget( QWidget *w )
147{ 147{
148 QFrame *wdg = new QFrame( w ); 148 QFrame *wdg = new QFrame( w );
149 QVBoxLayout *layout = new QVBoxLayout( wdg ); 149 QVBoxLayout *layout = new QVBoxLayout( wdg );
150 150
151 QLabel *title = new QLabel( description(), wdg ); 151 QLabel *title = new QLabel( description(), wdg );
152 QFont titleFont( title->font() ); 152 QFont titleFont( title->font() );
153 titleFont.setPointSize( 20 ); 153 titleFont.setPointSize( 20 );
154 titleFont.setBold( true ); 154 titleFont.setBold( true );
155 title->setFont( titleFont ); 155 title->setFont( titleFont );
156 156
157 layout->addWidget( title ); 157 layout->addWidget( title );
158 layout->addWidget( new QLabel( longDescription(), wdg ) ); 158 layout->addWidget( new QLabel( longDescription(), wdg ) );
159 layout->addSpacing( 20 ); 159 layout->addSpacing( 20 );
160 layout->addWidget( new QLabel( i18n("This printing style does not " 160 layout->addWidget( new QLabel( i18n("This printing style does not "
161 "have any configuration options."), 161 "have any configuration options."),
162 wdg ) ); 162 wdg ) );
163 layout->addStretch(); 163 layout->addStretch();
164 return wdg; 164 return wdg;
165} 165}
166#include <qapplication.h> 166#include <qapplication.h>
167void CalPrintBase::doPrint() 167void CalPrintBase::doPrint()
168{ 168{
169 QPainter p; 169 QPainter p;
170 170
171 mPrinter->setColorMode( (mUseColors)?(KPrinter::Color):(KPrinter::GrayScale)); 171 mPrinter->setColorMode( (mUseColors)?(KPrinter::Color):(KPrinter::GrayScale));
172 //#define DUMMY_PRINTER 172 //#define DUMMY_PRINTER
173#ifdef DUMMY_PRINTER 173#ifdef DUMMY_PRINTER
174 174
175 static QWidget* dummy = 0; 175 static QWidget* dummy = 0;
176 if ( ! dummy ) 176 if ( ! dummy )
177 dummy = new QWidget( ); 177 dummy = new QWidget( );
178 else { 178 else {
179 delete dummy; 179 delete dummy;
180 dummy = new QWidget( ); 180 dummy = new QWidget( );
181 181
182 } 182 }
183 dummy->resize( 1024, 1024 ); 183 dummy->resize( 1024, 1024 );
184 dummy->repaint(); 184 dummy->repaint();
185 dummy->show(); 185 dummy->show();
186 dummy->raise(); 186 dummy->raise();
187 dummy->setBackgroundColor( Qt::white); 187 dummy->setBackgroundColor( Qt::white);
188 qApp->processEvents(); 188 qApp->processEvents();
189 p.begin(dummy); 189 p.begin(dummy);
190#else 190#else
191 p.begin(mPrinter); 191 p.begin(mPrinter);
192#endif 192#endif
193 // the painter initially begins at 72 dpi per the Qt docs. 193 // the painter initially begins at 72 dpi per the Qt docs.
194 // we want half-inch margins. 194 // we want half-inch margins.
195 p.setViewport(mMargin, mMargin, 195 p.setViewport(mMargin, mMargin,
196 p.viewport().width()-mMargin, 196 p.viewport().width()-mMargin,
197 p.viewport().height()-mMargin); 197 p.viewport().height()-mMargin);
198 int pageWidth = p.viewport().width(); 198 int pageWidth = p.viewport().width();
199 int pageHeight = p.viewport().height(); 199 int pageHeight = p.viewport().height();
200 200
201 print(p, pageWidth, pageHeight); 201 print(p, pageWidth, pageHeight);
202 202
203 p.end(); 203 p.end();
204} 204}
205 205
206void CalPrintBase::doLoadConfig() 206void CalPrintBase::doLoadConfig()
207{ 207{
208 if ( mConfig ) { 208 if ( mConfig ) {
209 mConfig->setGroup(description()); 209 mConfig->setGroup(description());
210 //KConfigGroupSaver saver( mConfig, description() ); 210 //KConfigGroupSaver saver( mConfig, description() );
211 mConfig->sync(); 211 mConfig->sync();
212 QDateTime currDate( QDate::currentDate() ); 212 QDateTime currDate( QDate::currentDate() );
213 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date(); 213 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date();
214 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date(); 214 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date();
215 mUseColors = mConfig->readBoolEntry( "UseColors", false ); 215 mUseColors = mConfig->readBoolEntry( "UseColors", false );
216 loadConfig(); 216 loadConfig();
217 } else { 217 } else {
218 qDebug("no config in CalPrintBase::doLoadConfig "); 218 qDebug("no config in CalPrintBase::doLoadConfig ");
219 } 219 }
220} 220}
221 221
222void CalPrintBase::doSaveConfig() 222void CalPrintBase::doSaveConfig()
223{ 223{
224 if ( mConfig ) { 224 if ( mConfig ) {
225 mConfig->setGroup(description()); 225 mConfig->setGroup(description());
226 // KConfigGroupSaver saver( mConfig, description() ); 226 // KConfigGroupSaver saver( mConfig, description() );
227 saveConfig(); 227 saveConfig();
228 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) ); 228 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) );
229 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) ); 229 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) );
230 mConfig->writeEntry( "UseColors", mUseColors ); 230 mConfig->writeEntry( "UseColors", mUseColors );
231 mConfig->sync(); 231 mConfig->sync();
232 } else { 232 } else {
233 qDebug("no config in CalPrintBase::doSveConfig "); 233 qDebug("no config in CalPrintBase::doSveConfig ");
234 } 234 }
235} 235}
236 236
237/////////////////////////////////////////////////////////////////////////////// 237///////////////////////////////////////////////////////////////////////////////
238 238
239void CalPrintBase::drawHeader( QPainter &p, QString title, 239void CalPrintBase::drawHeader( QPainter &p, QString title,
240 const QDate &month1, const QDate &month2, 240 const QDate &month1, const QDate &month2,
241 int x, int y, int width, int height ) 241 int x, int y, int width, int height )
242{ 242{
243 p.drawRect(x, y, width, height); 243 p.drawRect(x, y, width, height);
244 // p.fillRect( x+1, y+1, 244 // p.fillRect( x+1, y+1,
245// width-2,height-2, 245// width-2,height-2,
246// QBrush(Dense7Pattern) ); 246// QBrush(Dense7Pattern) );
247 247
248 QString myOwner(mCalendar->getOwner()); 248 QString myOwner(mCalendar->getOwner());
249 249
250 int right=x+width; 250 int right=x+width;
251 251
252 // print previous month for month view, print current for todo, day and week 252 // print previous month for month view, print current for todo, day and week
253 int smallMonthWidth=width/4-10; 253 int smallMonthWidth=width/4-10;
254 if (smallMonthWidth>100) smallMonthWidth=100; 254 if (smallMonthWidth>100) smallMonthWidth=100;
255 if (month2.isValid()) { 255 if (month2.isValid()) {
256 right -= (10+smallMonthWidth); 256 right -= (10+smallMonthWidth);
257 drawSmallMonth(p, QDate(month2.year(), month2.month(), 1), 257 drawSmallMonth(p, QDate(month2.year(), month2.month(), 1),
258 right, y+2, smallMonthWidth, height-4); 258 right, y+2, smallMonthWidth, height-4);
259 right-=10; 259 right-=10;
260 } 260 }
261 if (month1.isValid()) { 261 if (month1.isValid()) {
262 right -= (10+smallMonthWidth); 262 right -= (10+smallMonthWidth);
263 drawSmallMonth(p, QDate(month1.year(), month1.month(), 1), 263 drawSmallMonth(p, QDate(month1.year(), month1.month(), 1),
264 right, y+2, smallMonthWidth, height-4); 264 right, y+2, smallMonthWidth, height-4);
265 right-=10; 265 right-=10;
266 } 266 }
267 267
268 // Print the titles... 268 // Print the titles...
269 QFont font("helvetica", 18, QFont::Bold); 269 QFont font("helvetica", 18, QFont::Bold);
270 p.setFont(font); 270 p.setFont(font);
271 QRect textRect( x+5, y+5, right-10-x, height-10 ); 271 QRect textRect( x+5, y+5, right-10-x, height-10 );
272 p.drawText( textRect, Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak, title ); 272 p.drawText( textRect, Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak, title );
273} 273}
274 274
275 275
276void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, 276void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd,
277 int x, int y, int width, int height) 277 int x, int y, int width, int height)
278{ 278{
279 bool firstCol = true; 279 bool firstCol = true;
280 QDate monthDate(QDate(qd.year(), qd.month(), 1)); 280 QDate monthDate(QDate(qd.year(), qd.month(), 1));
281 QDate monthDate2; 281 QDate monthDate2;
282 int month = monthDate.month(); 282 int month = monthDate.month();
283 283
284 // draw the title 284 // draw the title
285 p.setFont(QFont("helvetica", 7, QFont::Bold)); 285 p.setFont(QFont("helvetica", 7, QFont::Bold));
286 // int lineSpacing = p.fontMetrics().lineSpacing(); 286 // int lineSpacing = p.fontMetrics().lineSpacing();
287 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 287 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
288 p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) ); 288 p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) );
289 289
290 int cellWidth = width/7; 290 int cellWidth = width/7;
291 int cellHeight = height/8; 291 int cellHeight = height/8;
292 QString tmpStr; 292 QString tmpStr;
293 293
294 // correct begin of week 294 // correct begin of week
295 int weekdayCol = weekdayColumn( qd.dayOfWeek() ); 295 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
296 monthDate2 = monthDate.addDays(-weekdayCol); 296 monthDate2 = monthDate.addDays(-weekdayCol);
297 297
298 // draw days of week 298 // draw days of week
299 p.setFont(QFont("helvetica", 7, QFont::Bold)); 299 p.setFont(QFont("helvetica", 7, QFont::Bold));
300 for (int col = 0; col < 7; col++) { 300 for (int col = 0; col < 7; col++) {
301 // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek())); 301 // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek()));
302 tmpStr=calSys->weekDayName( monthDate2 )[0].upper(); 302 tmpStr=calSys->weekDayName( monthDate2 )[0].upper();
303 p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight, 303 p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight,
304 AlignCenter, tmpStr); 304 AlignCenter, tmpStr);
305 monthDate2 = monthDate2.addDays(1); 305 monthDate2 = monthDate2.addDays(1);
306 } 306 }
307 307
308 // draw separator line 308 // draw separator line
309 p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight); 309 p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight);
310 310
311 for (int row = 0; row < 5; row++) { 311 for (int row = 0; row < 5; row++) {
312 for (int col = 0; col < 7; col++) { 312 for (int col = 0; col < 7; col++) {
313 if (monthDate.month() != month) 313 if (monthDate.month() != month)
314 break; 314 break;
315 if (firstCol) { 315 if (firstCol) {
316 firstCol = true; 316 firstCol = true;
317 col = weekdayColumn( monthDate.dayOfWeek() ); 317 col = weekdayColumn( monthDate.dayOfWeek() );
318 } 318 }
319 p.drawText( x+col*cellWidth, 319 p.drawText( x+col*cellWidth,
320 y+height/4+cellHeight+(row*cellHeight), 320 y+height/4+cellHeight+(row*cellHeight),
321 cellWidth, cellHeight, AlignCenter, 321 cellWidth, cellHeight, AlignCenter,
322 tmpStr.setNum(monthDate.day()) ); 322 tmpStr.setNum(monthDate.day()) );
323 monthDate = monthDate.addDays(1); 323 monthDate = monthDate.addDays(1);
324 } 324 }
325 } 325 }
326} 326}
327 327
328 328
329/////////////////////////////////////////////////////////////////////////////// 329///////////////////////////////////////////////////////////////////////////////
330 330
331/* 331/*
332 * This routine draws a header box over the main part of the calendar 332 * This routine draws a header box over the main part of the calendar
333 * containing the days of the week. 333 * containing the days of the week.
334 */ 334 */
335void CalPrintBase::drawDaysOfWeek(QPainter &p, 335void CalPrintBase::drawDaysOfWeek(QPainter &p,
336 const QDate &fromDate, const QDate &toDate, 336 const QDate &fromDate, const QDate &toDate,
337 int x, int y, int width, int height) 337 int x, int y, int width, int height)
338{ 338{
339 int cellWidth = width/(fromDate.daysTo( toDate )+1); 339 int cellWidth = width/(fromDate.daysTo( toDate )+1);
340 int currx=x; 340 int currx=x;
341 QDate cellDate(fromDate); 341 QDate cellDate(fromDate);
342 342
343 while (cellDate<=toDate) { 343 while (cellDate<=toDate) {
344 drawDaysOfWeekBox(p, cellDate, currx, y, cellWidth, height); 344 drawDaysOfWeekBox(p, cellDate, currx, y, cellWidth, height);
345 currx+=cellWidth; 345 currx+=cellWidth;
346 cellDate = cellDate.addDays(1); 346 cellDate = cellDate.addDays(1);
347 } 347 }
348} 348}
349 349
350 350
351void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd, 351void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd,
352 int x, int y, int width, int height) 352 int x, int y, int width, int height)
353{ 353{
354 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 354 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
355 355
356 p.setFont( QFont( "helvetica", 10, QFont::Bold ) ); 356 p.setFont( QFont( "helvetica", 10, QFont::Bold ) );
357 p.drawRect( x, y, width, height ); 357 p.drawRect( x, y, width, height );
358// p.fillRect( x+1, y+1, 358// p.fillRect( x+1, y+1,
359// width-2, height-2, 359// width-2, height-2,
360// QBrush( Dense7Pattern ) ); 360// QBrush( Dense7Pattern ) );
361 p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter, 361 p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter,
362 calSys->weekDayName( qd ) ); 362 calSys->weekDayName( qd ) );
363} 363}
364 364
365 365
366void CalPrintBase::drawTimeLine(QPainter &p, 366void CalPrintBase::drawTimeLine(QPainter &p,
367 const QTime &fromTime, const QTime &toTime, 367 const QTime &fromTime, const QTime &toTime,
368 int x, int y, int width, int height) 368 int x, int y, int width, int height)
369{ 369{
370 p.drawRect(x, y, width, height); 370 p.drawRect(x, y, width, height);
371 371
372 int totalsecs=fromTime.secsTo(toTime); 372 int totalsecs=fromTime.secsTo(toTime);
373 float minlen=(float)height*60./(float)totalsecs; 373 float minlen=(float)height*60./(float)totalsecs;
374 float cellHeight=(60.*(float)minlen); 374 float cellHeight=(60.*(float)minlen);
375 float currY=y; 375 float currY=y;
376 376
377 QTime curTime( fromTime ); 377 QTime curTime( fromTime );
378 QTime endTime( toTime ); 378 QTime endTime( toTime );
379 if ( fromTime.minute() > 30 ) 379 if ( fromTime.minute() > 30 )
380 curTime = QTime( fromTime.hour()+1, 0, 0 ); 380 curTime = QTime( fromTime.hour()+1, 0, 0 );
381 else if ( fromTime.minute() > 0 ) { 381 else if ( fromTime.minute() > 0 ) {
382 curTime = QTime( fromTime.hour(), 30, 0 ); 382 curTime = QTime( fromTime.hour(), 30, 0 );
383 float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.; 383 float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.;
384 p.drawLine( x+width/2, (int)yy, x+width, (int)yy ); 384 p.drawLine( x+width/2, (int)yy, x+width, (int)yy );
385 curTime = QTime( fromTime.hour()+1, 0, 0 ); 385 curTime = QTime( fromTime.hour()+1, 0, 0 );
386 } 386 }
387 currY += ( fromTime.secsTo(curTime)*minlen/60 ); 387 currY += ( fromTime.secsTo(curTime)*minlen/60 );
388 388
389 while ( curTime < endTime ) { 389 while ( curTime < endTime ) {
390 p.drawLine( x, (int)currY, x+width, (int)currY ); 390 p.drawLine( x, (int)currY, x+width, (int)currY );
391 int newY=(int)(currY+cellHeight/2.); 391 int newY=(int)(currY+cellHeight/2.);
392 QString numStr; 392 QString numStr;
393 if (newY < y+height) { 393 if (newY < y+height) {
394 p.drawLine(x+width/2, (int)newY, x+width, (int)newY); 394 p.drawLine(x+width/2, (int)newY, x+width, (int)newY);
395 // draw the time: 395 // draw the time:
396 if ( !KGlobal::locale()->use12Clock() ) { 396 if ( !KGlobal::locale()->use12Clock() ) {
397 numStr.setNum(curTime.hour()); 397 numStr.setNum(curTime.hour());
398 if (cellHeight > 30) { 398 if (cellHeight > 30) {
399 p.setFont(QFont("helvetica", 16, QFont::Bold)); 399 p.setFont(QFont("helvetica", 16, QFont::Bold));
400 } else { 400 } else {
401 p.setFont(QFont("helvetica", 12, QFont::Bold)); 401 p.setFont(QFont("helvetica", 12, QFont::Bold));
402 } 402 }
403 p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight, 403 p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight,
404 AlignTop|AlignRight, numStr); 404 AlignTop|AlignRight, numStr);
405 p.setFont(QFont("helvetica", 10, QFont::Normal)); 405 p.setFont(QFont("helvetica", 10, QFont::Normal));
406 p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3, 406 p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3,
407 AlignTop | AlignLeft, "00"); 407 AlignTop | AlignLeft, "00");
408 } else { 408 } else {
409 QTime time( curTime.hour(), 0 ); 409 QTime time( curTime.hour(), 0 );
410 numStr = KGlobal::locale()->formatTime( time ); 410 numStr = KGlobal::locale()->formatTime( time );
411 p.setFont(QFont("helvetica", 14, QFont::Bold)); 411 p.setFont(QFont("helvetica", 14, QFont::Bold));
412 p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3, 412 p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3,
413 AlignTop|AlignLeft, numStr); 413 AlignTop|AlignLeft, numStr);
414 } 414 }
415 currY+=cellHeight; 415 currY+=cellHeight;
416 } // enough space for half-hour line and time 416 } // enough space for half-hour line and time
417 if (curTime.secsTo(endTime)>3600) 417 if (curTime.secsTo(endTime)>3600)
418 curTime=curTime.addSecs(3600); 418 curTime=curTime.addSecs(3600);
419 else curTime=endTime; 419 else curTime=endTime;
420 } // currTime<endTime 420 } // currTime<endTime
421} 421}
422 422
423 423
424/////////////////////////////////////////////////////////////////////////////// 424///////////////////////////////////////////////////////////////////////////////
425 425
426/** prints the all-day box for the agenda print view. if expandable is set, 426/** prints the all-day box for the agenda print view. if expandable is set,
427 height is the cell height of a single cell, and the returned height will 427 height is the cell height of a single cell, and the returned height will
428 be the total height used for the all-day events. If !expandable, only one 428 be the total height used for the all-day events. If !expandable, only one
429 cell will be used, and multiple events are concatenated using ", ". 429 cell will be used, and multiple events are concatenated using ", ".
430*/ 430*/
431void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, 431void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList,
432 const QDate &qd, bool expandable, 432 const QDate &qd, bool expandable,
433 int x, int y, int width, int &height) 433 int x, int y, int width, int &height)
434{ 434{
435 Event::List::Iterator it, itold; 435 Event::List::Iterator it, itold;
436 436
437 int offset=y; 437 int offset=y;
438 438
439 //p.setBrush(QBrush(Dense7Pattern)); 439 //p.setBrush(QBrush(Dense7Pattern));
440 QPen oldPen(p.pen()); 440 QPen oldPen(p.pen());
441 QColor oldBgColor(p.backgroundColor()); 441 QColor oldBgColor(p.backgroundColor());
442 QBrush oldBrush(p.brush()); 442 QBrush oldBrush(p.brush());
443 QString multiDayStr; 443 QString multiDayStr;
444 444
445 it = eventList.begin(); 445 it = eventList.begin();
446#ifndef KORG_NOPLUGINS 446#ifndef KORG_NOPLUGINS
447 QString hstring(KOCore::self()->holiday(qd)); 447 QString hstring(KOCore::self()->holiday(qd));
448 if (!hstring.isEmpty()) { 448 if (!hstring.isEmpty()) {
449 Event*holiday=new Event(); 449 Event*holiday=new Event();
450 holiday->setDtStart(qd); 450 holiday->setDtStart(qd);
451 holiday->setDtEnd(qd); 451 holiday->setDtEnd(qd);
452 holiday->setFloats(true); 452 holiday->setFloats(true);
453 holiday->setCategories(i18n("Holiday")); 453 holiday->setCategories(i18n("Holiday"));
454 eventList.prepend(holiday); 454 eventList.prepend(holiday);
455 } 455 }
456#endif 456#endif
457 Event *currEvent = 0; 457 Event *currEvent = 0;
458 // First, print all floating events 458 // First, print all floating events
459 while( it!=eventList.end() ) { 459 while( it!=eventList.end() ) {
460 currEvent=*it; 460 currEvent=*it;
461 itold=it; 461 itold=it;
462 ++it; 462 ++it;
463 if ( currEvent->doesFloat() ) { 463 if ( currEvent->doesFloat() ) {
464 // set the colors according to the categories 464 // set the colors according to the categories
465 QString text = currEvent->summary() ; 465 QString text = currEvent->summary() ;
466 if ( ! currEvent->location().isEmpty() ) 466 if ( ! currEvent->location().isEmpty() )
467 text += " ("+currEvent->location()+")"; 467 text += " ("+currEvent->location()+")";
468 if (expandable) { 468 if (expandable) {
469 if (mUseColors) 469 if (mUseColors)
470 setCategoryColors(p, currEvent); 470 setCategoryColors(p, currEvent);
471 471
472 p.drawRect( x, offset, width, height ); 472 p.drawRect( x, offset, width, height );
473 473
474 p.drawText( x+5, offset+5, width-10, height-10, 474 p.drawText( x+5, offset+5, width-10, height-10,
475 AlignCenter | AlignVCenter | AlignJustify | WordBreak, 475 AlignCenter | AlignVCenter | AlignJustify | WordBreak,
476 text ); 476 text );
477 // reset the colors 477 // reset the colors
478 p.setBrush( oldBrush ); 478 p.setBrush( oldBrush );
479 p.setPen( oldPen ); 479 p.setPen( oldPen );
480 p.setBackgroundColor(oldBgColor); 480 p.setBackgroundColor(oldBgColor);
481 481
482 offset += height; 482 offset += height;
483 } else { 483 } else {
484 //if (!multiDayStr.isEmpty()) multiDayStr+=", "; 484 //if (!multiDayStr.isEmpty()) multiDayStr+=", ";
485 multiDayStr += text+"\n"; 485 multiDayStr += text+"\n";
486 } 486 }
487 eventList.remove( itold ); 487 eventList.remove( itold );
488 } 488 }
489 } 489 }
490 490
491 if (!expandable) { 491 if (!expandable) {
492 p.drawRect(x, offset, width, height); 492 p.drawRect(x, offset, width, height);
493 if (!multiDayStr.isEmpty()) { 493 if (!multiDayStr.isEmpty()) {
494 // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) ); 494 // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) );
495 p.drawText( x+5, offset+5, width-10, height-10, 495 p.drawText( x+5, offset+5, width-10, height-10,
496 AlignLeft | AlignTop | AlignJustify , 496 AlignLeft | AlignTop | AlignJustify ,
497 multiDayStr); 497 multiDayStr);
498 } 498 }
499 } else { 499 } else {
500 height=offset-y; 500 height=offset-y;
501 } 501 }
502} 502}
503 503
504 504
505void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, 505void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events,
506 const QDate &qd, bool expandable, 506 const QDate &qd, bool expandable,
507 QTime &fromTime, QTime &toTime, 507 QTime &fromTime, QTime &toTime,
508 int x, int y, int width, int height ) 508 int x, int y, int width, int height )
509{ 509{
510 p.drawRect( x, y, width, height ); 510 p.drawRect( x, y, width, height );
511 511
512 Event *event; 512 Event *event;
513 513
514 if ( expandable ) { 514 if ( expandable ) {
515 // Adapt start/end times to include complete events 515 // Adapt start/end times to include complete events
516 Event::List::ConstIterator it; 516 Event::List::ConstIterator it;
517 for ( it = events.begin(); it != events.end(); ++it ) { 517 for ( it = events.begin(); it != events.end(); ++it ) {
518 event = *it; 518 event = *it;
519 if ( event->dtStart().time() < fromTime ) 519 if ( event->dtStart().time() < fromTime )
520 fromTime = event->dtStart().time(); 520 fromTime = event->dtStart().time();
521 if ( event->dtEnd().time() > toTime ) 521 if ( event->dtEnd().time() > toTime )
522 toTime = event->dtEnd().time(); 522 toTime = event->dtEnd().time();
523 } 523 }
524 } 524 }
525 525
526 // Show at least one hour 526 // Show at least one hour
527 if ( fromTime.secsTo( toTime ) < 3600 ) { 527 if ( fromTime.secsTo( toTime ) < 3600 ) {
528 fromTime = QTime( fromTime.hour(), 0, 0 ); 528 fromTime = QTime( fromTime.hour(), 0, 0 );
529 toTime = fromTime.addSecs( 3600 ); 529 toTime = fromTime.addSecs( 3600 );
530 } 530 }
531 531
532 // calculate the height of a cell and of a minute 532 // calculate the height of a cell and of a minute
533 int totalsecs = fromTime.secsTo( toTime ); 533 int totalsecs = fromTime.secsTo( toTime );
534 float minlen = height * 60. / totalsecs; 534 float minlen = height * 60. / totalsecs;
535 float cellHeight = 60. * minlen; 535 float cellHeight = 60. * minlen;
536 float currY = y; 536 float currY = y;
537 537
538 // print grid: 538 // print grid:
539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) ); 539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) );
540 currY += fromTime.secsTo( curTime ) * minlen / 60; 540 currY += fromTime.secsTo( curTime ) * minlen / 60;
541 541
542 while ( curTime < toTime && curTime.isValid() ) { 542 while ( curTime < toTime && curTime.isValid() ) {
543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) ); 543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) );
544 currY += cellHeight / 2; 544 currY += cellHeight / 2;
545 if ( ( currY > y ) && ( currY < y + height ) ) { 545 if ( ( currY > y ) && ( currY < y + height ) ) {
546 QPen oldPen( p.pen() ); 546 QPen oldPen( p.pen() );
547 p.setPen( QColor( 192, 192, 192 ) ); 547 p.setPen( QColor( 192, 192, 192 ) );
548 p.drawLine( x, int( currY ), x + width, int( currY ) ); 548 p.drawLine( x, int( currY ), x + width, int( currY ) );
549 p.setPen( oldPen ); 549 p.setPen( oldPen );
550 } // enough space for half-hour line 550 } // enough space for half-hour line
551 if ( curTime.secsTo( toTime ) > 3600 ) 551 if ( curTime.secsTo( toTime ) > 3600 )
552 curTime = curTime.addSecs( 3600 ); 552 curTime = curTime.addSecs( 3600 );
553 else curTime = toTime; 553 else curTime = toTime;
554 currY += cellHeight / 2; 554 currY += cellHeight / 2;
555 } 555 }
556 556
557 QDateTime startPrintDate = QDateTime( qd, fromTime ); 557 QDateTime startPrintDate = QDateTime( qd, fromTime );
558 QDateTime endPrintDate = QDateTime( qd, toTime ); 558 QDateTime endPrintDate = QDateTime( qd, toTime );
559 559
560 // Calculate horizontal positions and widths of events taking into account 560 // Calculate horizontal positions and widths of events taking into account
561 // overlapping events 561 // overlapping events
562 562
563 QPtrList<KOrg::CellItem> cells; 563 QPtrList<KOrg::CellItem> cells;
564 cells.setAutoDelete( true ); 564 cells.setAutoDelete( true );
565 565
566 Event::List::ConstIterator itEvents; 566 Event::List::ConstIterator itEvents;
567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { 567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
568 cells.append( new PrintCellItem( *itEvents, qd ) ); 568 cells.append( new PrintCellItem( *itEvents, qd ) );
569 } 569 }
570 570
571 QPtrListIterator<KOrg::CellItem> it1( cells ); 571 QPtrListIterator<KOrg::CellItem> it1( cells );
572 for( it1.toFirst(); it1.current(); ++it1 ) { 572 for( it1.toFirst(); it1.current(); ++it1 ) {
573 KOrg::CellItem *placeItem = it1.current(); 573 KOrg::CellItem *placeItem = it1.current();
574 574
575 KOrg::CellItem::placeItem( cells, placeItem ); 575 KOrg::CellItem::placeItem( cells, placeItem );
576 } 576 }
577 577
578 QPen oldPen = p.pen(); 578 QPen oldPen = p.pen();
579 QColor oldBgColor = p.backgroundColor(); 579 QColor oldBgColor = p.backgroundColor();
580 QBrush oldBrush = p.brush(); 580 QBrush oldBrush = p.brush();
581 581
582 p.setFont( QFont( "helvetica", 10 ) ); 582 p.setFont( QFont( "helvetica", 10 ) );
583 //p.setBrush( QBrush( Dense7Pattern ) ); 583 //p.setBrush( QBrush( Dense7Pattern ) );
584 584
585 for( it1.toFirst(); it1.current(); ++it1 ) { 585 for( it1.toFirst(); it1.current(); ++it1 ) {
586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() ); 586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() );
587 587
588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x, 588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x,
589 y, width ); 589 y, width );
590 590
591 p.setBrush( oldBrush ); 591 p.setBrush( oldBrush );
592 p.setPen( oldPen ); 592 p.setPen( oldPen );
593 p.setBackgroundColor( oldBgColor ); 593 p.setBackgroundColor( oldBgColor );
594 } 594 }
595 595
596 p.setBrush( QBrush( NoBrush ) ); 596 p.setBrush( QBrush( NoBrush ) );
597} 597}
598 598
599 599
600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, 600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p,
601 const QDate &qd, 601 const QDate &qd,
602 const QDateTime &startPrintDate, 602 const QDateTime &startPrintDate,
603 const QDateTime &endPrintDate, 603 const QDateTime &endPrintDate,
604 float minlen, int x, int y, int width ) 604 float minlen, int x, int y, int width )
605{ 605{
606 Event *event = item->event(); 606 Event *event = item->event();
607 607
608 // set the colors according to the categories 608 // set the colors according to the categories
609 if ( mUseColors ) setCategoryColors( p, event ); 609 if ( mUseColors ) setCategoryColors( p, event );
610 else p.setBrush( Qt::white ); 610 else p.setBrush( Qt::white );
611 // start/end of print area for event 611 // start/end of print area for event
612 QDateTime startTime = event->dtStart(); 612 QDateTime startTime = event->dtStart();
613 QDateTime endTime = event->dtEnd(); 613 QDateTime endTime = event->dtEnd();
614 if ( event->doesRecur() ) { 614 if ( event->doesRecur() ) {
615 startTime.setDate( qd ); 615 startTime.setDate( qd );
616 endTime.setDate( qd ); 616 endTime.setDate( qd );
617 } 617 }
618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) || 618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
619 ( endTime > startPrintDate && startTime < endPrintDate ) ) { 619 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
620 if ( startTime < startPrintDate ) startTime = startPrintDate; 620 if ( startTime < startPrintDate ) startTime = startPrintDate;
621 if ( endTime > endPrintDate ) endTime = endPrintDate; 621 if ( endTime > endPrintDate ) endTime = endPrintDate;
622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen ); 622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen );
623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) * 623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) *
624 minlen / 60. ); 624 minlen / 60. );
625 int currentWidth = width / item->subCells(); 625 int currentWidth = width / item->subCells();
626 int currentX = x + item->subCell() * currentWidth; 626 int currentX = x + item->subCell() * currentWidth;
627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ 627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+
628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ 628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+
629 " "+event->summary(); 629 " "+event->summary();
630 if ( !event->location().isEmpty() ) 630 if ( !event->location().isEmpty() )
631 text += " (" +event->location()+")"; 631 text += " (" +event->location()+")";
632 // p.save(); 632 // p.save();
633 QPen pe = p.pen(); 633 QPen pe = p.pen();
634 pe.setWidth( 2 ); 634 pe.setWidth( 2 );
635 p.setPen( pe ); 635 p.setPen( pe );
636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); 636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 );
637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, 637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3,
638 AlignLeft | AlignTop | AlignJustify | WordBreak, 638 AlignLeft | AlignTop | AlignJustify | WordBreak,
639 text); 639 text);
640 // p.restore(); 640 // p.restore();
641 } 641 }
642} 642}
643 643
644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, 644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd,
645 int x, int y, int width, int height, 645 int x, int y, int width, int height,
646 bool fullDate) 646 bool fullDate)
647{ 647{
648 QString dayNumStr; 648 QString dayNumStr;
649 QString ampm; 649 QString ampm;
650 const KLocale*local = KGlobal::locale(); 650 const KLocale*local = KGlobal::locale();
651 651
652 652
653 // This has to be localized 653 // This has to be localized
654 if (fullDate) { 654 if (fullDate) {
655 /*int index; 655 /*int index;
656 dayNumStr= qd.toString(); 656 dayNumStr= qd.toString();
657 index = dayNumStr.find(' '); 657 index = dayNumStr.find(' ');
658 dayNumStr.remove(0, index); 658 dayNumStr.remove(0, index);
659 index = dayNumStr.findRev(' '); 659 index = dayNumStr.findRev(' ');
660 dayNumStr.truncate(index);*/ 660 dayNumStr.truncate(index);*/
661 661
662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
663 dayNumStr = i18n("weekday month date", "%1 %2 %3") 663 dayNumStr = i18n("weekday month date", "%1 %2 %3")
664 .arg( calSys->weekDayName( qd ) ) 664 .arg( calSys->weekDayName( qd ) )
665 .arg( calSys->monthName( qd ) ) 665 .arg( calSys->monthName( qd ) )
666 .arg( qd.day() ); 666 .arg( qd.day() );
667// dayNumStr = local->formatDate(qd); 667// dayNumStr = local->formatDate(qd);
668 } else { 668 } else {
669 dayNumStr = QString::number( qd.day() ); 669 dayNumStr = QString::number( qd.day() );
670 } 670 }
671 671
672 p.eraseRect( x, y, width, height ); 672 p.eraseRect( x, y, width, height );
673 p.drawRect( x, y, width, height ); 673 p.drawRect( x, y, width, height );
674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); 674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) );
675 p.drawRect( x, y, width, mSubHeaderHeight ); 675 p.drawRect( x, y, width, mSubHeaderHeight );
676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); 676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) );
677 QString hstring; 677 QString hstring;
678#ifndef KORG_NOPLUGINS 678#ifndef KORG_NOPLUGINS
679 hstring=KOCore::self()->holiday(qd); 679 hstring=KOCore::self()->holiday(qd);
680#endif 680#endif
681 681
682 if (!hstring.isEmpty()) { 682 if (!hstring.isEmpty()) {
683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); 683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) );
684 684
685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, 685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter,
686 hstring ); 686 hstring );
687 } 687 }
688 p.setFont(QFont("helvetica", 10, QFont::Bold)); 688 p.setFont(QFont("helvetica", 10, QFont::Bold));
689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, 689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter,
690 dayNumStr); 690 dayNumStr);
691 Event::List eventList; 691 Event::List eventList;
692 eventList.fill( mCalendar->events( qd, true )); 692 eventList.fill( mCalendar->events( qd, true ));
693 Todo::List todos; 693 Todo::List todos;
694 todos.fill( mCalendar->todos( qd )); 694 todos.fill( mCalendar->todos( qd ));
695 QString outStr; 695 QString outStr;
696 p.setFont( QFont( "helvetica", 8 ) ); 696 p.setFont( QFont( "helvetica", 8 ) );
697 int lineSpacing = p.fontMetrics().lineSpacing(); 697 int lineSpacing = p.fontMetrics().lineSpacing();
698 698
699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry 699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry
700 Event::List::ConstIterator it; 700 Event::List::ConstIterator it;
701 int entryCount = eventList.count() +todos.count(); 701 int entryCount = eventList.count() +todos.count();
702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { 702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) {
703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { 703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) {
704 p.setFont( QFont( "helvetica", 7 ) ); 704 p.setFont( QFont( "helvetica", 7 ) );
705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) 705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY )
706 p.setFont( QFont( "helvetica", 6 ) ); 706 p.setFont( QFont( "helvetica", 6 ) );
707 } 707 }
708 lineSpacing = p.fontMetrics().lineSpacing()-1; 708 lineSpacing = p.fontMetrics().lineSpacing()-1;
709 } 709 }
710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); 710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY );
711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { 711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) {
712 Event *currEvent = *it; 712 Event *currEvent = *it;
713 if (currEvent->doesFloat() || currEvent->isMultiDay()) 713 if (currEvent->doesFloat() || currEvent->isMultiDay())
714 outStr = currEvent->summary(); 714 outStr = currEvent->summary();
715 715
716 else { 716 else {
717 if ( fullDate ) { 717 if ( fullDate ) {
718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ 718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+
719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ 719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+
720 " "+ currEvent->summary(); 720 " "+ currEvent->summary();
721 if ( ! currEvent->location().isEmpty() ) 721 if ( ! currEvent->location().isEmpty() )
722 outStr += " (" + currEvent->location()+")"; 722 outStr += " (" + currEvent->location()+")";
723 } else { 723 } else {
724 QTime t1 = currEvent->dtStart().time(); 724 QTime t1 = currEvent->dtStart().time();
725 725
726 outStr = local->formatTime(t1); 726 outStr = local->formatTime(t1);
727 outStr += " " + currEvent->summary(); 727 outStr += " " + currEvent->summary();
728 } 728 }
729 729
730 } // doesFloat 730 } // doesFloat
731 731
732 p.drawText(x+5, y+textY, width-10, lineSpacing, 732 p.drawText(x+5, y+textY, width-10, lineSpacing,
733 AlignLeft|AlignBottom, outStr); 733 AlignLeft|AlignBottom, outStr);
734 textY+=lineSpacing; 734 textY+=lineSpacing;
735 } 735 }
736 736
737 if ( textY<height ) { 737 if ( textY<height ) {
738 738
739 Todo::List::ConstIterator it2; 739 Todo::List::ConstIterator it2;
740 for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { 740 for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) {
741 Todo *todo = *it2; 741 Todo *todo = *it2;
742 QString text; 742 QString text;
743 if (todo->hasDueDate()) { 743 if (todo->hasDueDate()) {
744 if (!todo->doesFloat()) { 744 if (!todo->doesFloat()) {
745 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 745 text += KGlobal::locale()->formatTime(todo->dtDue().time());
746 text += " "; 746 text += " ";
747 } 747 }
748 } 748 }
749 text += i18n("To-Do: %1").arg(todo->summary()); 749 text += i18n("To-Do: %1").arg(todo->summary());
750 750
751 p.drawText(x+5, y+textY, width-10, lineSpacing, 751 p.drawText(x+5, y+textY, width-10, lineSpacing,
752 AlignLeft|AlignBottom, text); 752 AlignLeft|AlignBottom, text);
753 textY+=lineSpacing; 753 textY+=lineSpacing;
754 } 754 }
755 } 755 }
756} 756}
757 757
758 758
759/////////////////////////////////////////////////////////////////////////////// 759///////////////////////////////////////////////////////////////////////////////
760 760
761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, 761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd,
762 int x, int y, int width, int height) 762 int x, int y, int width, int height)
763{ 763{
764 QDate weekDate = qd; 764 QDate weekDate = qd;
765 bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); 765 bool portrait = ( mPrinter->orientation() == KPrinter::Portrait );
766 int cellWidth, cellHeight; 766 int cellWidth, cellHeight;
767 int vcells; 767 int vcells;
768 if (portrait) { 768 if (portrait) {
769 cellWidth = width/2; 769 cellWidth = width/2;
770 vcells=3; 770 vcells=3;
771 } else { 771 } else {
772 cellWidth = width/6; 772 cellWidth = width/6;
773 vcells=1; 773 vcells=1;
774 } 774 }
775 cellHeight = height/vcells; 775 cellHeight = height/vcells;
776 776
777 // correct begin of week 777 // correct begin of week
778 int weekdayCol = weekdayColumn( qd.dayOfWeek() ); 778 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
779 weekDate = qd.addDays( -weekdayCol ); 779 weekDate = qd.addDays( -weekdayCol );
780 780
781 for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { 781 for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) {
782 if (i<5) { 782 if (i<5) {
783 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), 783 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
784 cellWidth, cellHeight, true); 784 cellWidth, cellHeight, true);
785 } else if (i==5) { 785 } else if (i==5) {
786 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), 786 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
787 cellWidth, cellHeight/2, true); 787 cellWidth, cellHeight/2, true);
788 } else if (i==6) { 788 } else if (i==6) {
789 drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), 789 drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells),
790 y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); 790 y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true);
791 } 791 }
792 } // for i through all weekdays 792 } // for i through all weekdays
793} 793}
794 794
795 795
796void CalPrintBase::drawTimeTable(QPainter &p, 796void CalPrintBase::drawTimeTable(QPainter &p,
797 const QDate &fromDate, const QDate &toDate, 797 const QDate &fromDate, const QDate &toDate,
798 QTime &fromTime, QTime &toTime, 798 QTime &fromTime, QTime &toTime,
799 int x, int y, int width, int height) 799 int x, int y, int width, int height)
800{ 800{
801 // timeline is 1.5 hours: 801 // timeline is 1.5 hours:
802 int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); 802 int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) );
803 int timelineWidth = 60; 803 int timelineWidth = 60;
804 int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); 804 int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) );
805 int currY=y; 805 int currY=y;
806 int currX=x; 806 int currX=x;
807 807
808 drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); 808 drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight);
809 currY+=mSubHeaderHeight; 809 currY+=mSubHeaderHeight;
810 drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, 810 drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight,
811 timelineWidth, height-mSubHeaderHeight-alldayHeight ); 811 timelineWidth, height-mSubHeaderHeight-alldayHeight );
812 812
813 currX=x+timelineWidth; 813 currX=x+timelineWidth;
814 // draw each day 814 // draw each day
815 QDate curDate(fromDate); 815 QDate curDate(fromDate);
816 while (curDate<=toDate) {Event::List eventList; 816 while (curDate<=toDate) {Event::List eventList;
817 eventList.fill( mCalendar->events(curDate, true)); 817 eventList.fill( mCalendar->events(curDate, true));
818 drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); 818 drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight);
819 drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, 819 drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX,
820 currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); 820 currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight );
821 currX+=cellWidth; 821 currX+=cellWidth;
822 curDate=curDate.addDays(1); 822 curDate=curDate.addDays(1);
823 } 823 }
824 824
825} 825}
826 826
827 827
828/////////////////////////////////////////////////////////////////////////////// 828///////////////////////////////////////////////////////////////////////////////
829 829
830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, 830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers,
831 int x, int y, int width, int height) 831 int x, int y, int width, int height)
832{ 832{
833 833
834 int yoffset = mSubHeaderHeight; 834 int yoffset = mSubHeaderHeight;
835 int xoffset = 0; 835 int xoffset = 0;
836 836
837 QDate monthDate(QDate(qd.year(), qd.month(), 1)); 837 QDate monthDate(QDate(qd.year(), qd.month(), 1));
838 QDate monthFirst(monthDate); 838 QDate monthFirst(monthDate);
839 QDate monthLast(monthDate.addMonths(1).addDays(-1)); 839 QDate monthLast(monthDate.addMonths(1).addDays(-1));
840 840
841 841
842 int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); 842 int weekdayCol = weekdayColumn( monthDate.dayOfWeek() );
843 monthDate = monthDate.addDays(-weekdayCol); 843 monthDate = monthDate.addDays(-weekdayCol);
844 844
845 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; 845 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1;
846 int cellHeight = (height-yoffset) / rows; 846 int cellHeight = (height-yoffset) / rows;
847 847
848 if (weeknumbers) { 848 if (weeknumbers) {
849 QFont oldFont(p.font()); 849 QFont oldFont(p.font());
850 QFont newFont(p.font()); 850 QFont newFont(p.font());
851 newFont.setPointSize(7); 851 newFont.setPointSize(7);
852 p.setFont(newFont); 852 p.setFont(newFont);
853 xoffset += 18; 853 xoffset += 18;
854 QDate weekDate(monthDate); 854 QDate weekDate(monthDate);
855 for (int row = 0; row<rows; row++) { 855 for (int row = 0; row<rows; row++) {
856 int calWeek = weekDate.weekNumber(); 856 int calWeek = weekDate.weekNumber();
857 QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); 857 QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight);
858 p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); 858 p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) );
859 weekDate = weekDate.addDays(7); 859 weekDate = weekDate.addDays(7);
860 } 860 }
861 p.setFont(oldFont); 861 p.setFont(oldFont);
862 } 862 }
863 863
864 drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); 864 drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight );
865 int cellWidth = (width-xoffset) / 7; 865 int cellWidth = (width-xoffset) / 7;
866 866
867 QColor back = p.backgroundColor(); 867 QColor back = p.backgroundColor();
868 bool darkbg = false; 868 bool darkbg = false;
869 for (int row = 0; row < rows; row++) { 869 for (int row = 0; row < rows; row++) {
870 for (int col = 0; col < 7; col++) { 870 for (int col = 0; col < 7; col++) {
871 // show days from previous/next month with a grayed background 871 // show days from previous/next month with a grayed background
872 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { 872 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) {
873 p.setBackgroundColor( QColor( 240, 240, 240) ); 873 p.setBackgroundColor( QColor( 240, 240, 240) );
874 darkbg = true; 874 darkbg = true;
875 } 875 }
876 drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); 876 drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight);
877 if ( darkbg ) { 877 if ( darkbg ) {
878 p.setBackgroundColor( back ); 878 p.setBackgroundColor( back );
879 darkbg = false; 879 darkbg = false;
880 } 880 }
881 monthDate = monthDate.addDays(1); 881 monthDate = monthDate.addDays(1);
882 } 882 }
883 } 883 }
884} 884}
885 885
886 886
887/////////////////////////////////////////////////////////////////////////////// 887///////////////////////////////////////////////////////////////////////////////
888 888
889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, 889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos,
890 bool desc, int pospriority, int possummary, int posDueDt, int level, 890 bool desc, int pospriority, int possummary, int posDueDt, int level,
891 int x, int &y, int width, int &height, int pageHeight, 891 int x, int &y, int width, int &height, int pageHeight,
892 TodoParentStart *r ) 892 TodoParentStart *r )
893{ 893{
894 if ( !completed && item->isCompleted() ) 894 if ( !completed && item->isCompleted() )
895 return; 895 return;
896 QString outStr; 896 QString outStr;
897// int fontHeight = 10; 897// int fontHeight = 10;
898 const KLocale *local = KGlobal::locale(); 898 const KLocale *local = KGlobal::locale();
899 int priority=item->priority(); 899 int priority=item->priority();
900 int posdue=posDueDt; 900 int posdue=posDueDt;
901 if (posdue<0) posdue=x+width; 901 if (posdue<0) posdue=x+width;
902 QRect rect; 902 QRect rect;
903 TodoParentStart startpt; 903 TodoParentStart startpt;
904 // This list keeps all starting points of the parent todos so the connection 904 // This list keeps all starting points of the parent todos so the connection
905 // lines of the tree can easily be drawn (needed if a new page is started) 905 // lines of the tree can easily be drawn (needed if a new page is started)
906 static QPtrList<TodoParentStart> startPoints; 906 static QPtrList<TodoParentStart> startPoints;
907 if (level<1) { 907 if (level<1) {
908 startPoints.clear(); 908 startPoints.clear();
909 } 909 }
910 910
911 // size of item 911 // size of item
912 outStr=item->summary(); 912 outStr=item->summary();
913 if ( ! item->location().isEmpty() ) 913 if ( ! item->location().isEmpty() )
914 outStr += " ("+item->location()+")"; 914 outStr += " ("+item->location()+")";
915 if ( item->hasDueDate() && posDueDt>=0 ) { 915 if ( item->hasDueDate() && posDueDt>=0 ) {
916 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; 916 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]";
917 } 917 }
918 int left = possummary+(level*10); 918 int left = possummary+(level*10);
919 rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); 919 rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr);
920 if ( !item->description().isEmpty() && !desc ) { 920 if ( !item->description().isEmpty() && desc ) {
921 outStr = item->description(); 921 outStr = item->description();
922 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, 922 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1,
923 WordBreak, outStr ); 923 WordBreak, outStr );
924 } 924 }
925 // if too big make new page 925 // if too big make new page
926 if ( rect.bottom() > y+height) { 926 if ( rect.bottom() > y+height) {
927 // first draw the connection lines from parent todos: 927 // first draw the connection lines from parent todos:
928 if (level > 0 && connectSubTodos) { 928 if (level > 0 && connectSubTodos) {
929 TodoParentStart *rct; 929 TodoParentStart *rct;
930 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { 930 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) {
931 int start; 931 int start;
932 int center = rct->mRect.left() + (rct->mRect.width()/2); 932 int center = rct->mRect.left() + (rct->mRect.width()/2);
933 int to = p.viewport().bottom(); 933 int to = p.viewport().bottom();
934 934
935 // draw either from start point of parent or from top of the page 935 // draw either from start point of parent or from top of the page
936 if (rct->mSamePage) 936 if (rct->mSamePage)
937 start = rct->mRect.bottom() + 1; 937 start = rct->mRect.bottom() + 1;
938 else 938 else
939 start = p.viewport().top(); 939 start = p.viewport().top();
940 p.moveTo( center, start ); 940 p.moveTo( center, start );
941 p.lineTo( center, to ); 941 p.lineTo( center, to );
942 rct->mSamePage=false; 942 rct->mSamePage=false;
943 } 943 }
944 } 944 }
945 y=0; 945 y=0;
946 height=pageHeight-y; 946 height=pageHeight-y;
947 mPrinter->newPage(); 947 mPrinter->newPage();
948 } 948 }
949 949
950 // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up 950 // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up
951 //to the RH side of the parent item's priority 951 //to the RH side of the parent item's priority
952 if (r && pospriority >= 0 ) { 952 if (r && pospriority >= 0 ) {
953 pospriority = r->mRect.right() + 1; 953 pospriority = r->mRect.right() + 1;
954 } 954 }
955 955
956 // Priority 956 // Priority
957 outStr.setNum(priority); 957 outStr.setNum(priority);
958 rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr); 958 rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr);
959 // Make it a more reasonable size 959 // Make it a more reasonable size
960 rect.setWidth(19); 960 rect.setWidth(19);
961 rect.setHeight(19); 961 rect.setHeight(19);
962 if ( priority > 0 && pospriority>=0 ) { 962 if ( priority > 0 && pospriority>=0 ) {
963 p.drawText(rect, AlignCenter, outStr); 963 p.drawText(rect, AlignCenter, outStr);
964 p.drawRect(rect); 964 p.drawRect(rect);
965 // cross out the rectangle for completed items 965 // cross out the rectangle for completed items
966 if ( item->isCompleted() ) { 966 if ( item->isCompleted() ) {
967 p.drawLine( rect.topLeft(), rect.bottomRight() ); 967 p.drawLine( rect.topLeft(), rect.bottomRight() );
968 p.drawLine( rect.topRight(), rect.bottomLeft() ); 968 p.drawLine( rect.topRight(), rect.bottomLeft() );
969 } 969 }
970 } 970 }
971 startpt.mRect = rect; //save for later 971 startpt.mRect = rect; //save for later
972 972
973 // Connect the dots 973 // Connect the dots
974 if (level > 0 && connectSubTodos) { 974 if (level > 0 && connectSubTodos) {
975 int bottom; 975 int bottom;
976 int center( r->mRect.left() + (r->mRect.width()/2)+1 ); 976 int center( r->mRect.left() + (r->mRect.width()/2)+1 );
977 if (r->mSamePage ) 977 if (r->mSamePage )
978 bottom = r->mRect.bottom();//lutz + 1; 978 bottom = r->mRect.bottom();//lutz + 1;
979 else 979 else
980 bottom = 0; 980 bottom = 0;
981 int to( rect.top() + (rect.height()/2)+1 ); 981 int to( rect.top() + (rect.height()/2)+1 );
982 int endx( rect.left() ); 982 int endx( rect.left() );
983 p.moveTo(center, bottom); 983 p.moveTo(center, bottom);
984 p.lineTo(center, to); 984 p.lineTo(center, to);
985 p.lineTo(endx, to); 985 p.lineTo(endx, to);
986 } 986 }
987 987
988 // if completed, use strike out font 988 // if completed, use strike out font
989 QFont ft=p.font(); 989 QFont ft=p.font();
990 ft.setStrikeOut( item->isCompleted() ); 990 ft.setStrikeOut( item->isCompleted() );
991 p.setFont( ft ); 991 p.setFont( ft );
992 // summary 992 // summary
993 outStr=item->summary(); 993 outStr=item->summary();
994 if ( ! item->location().isEmpty() ) 994 if ( ! item->location().isEmpty() )
995 outStr += " ("+item->location()+")"; 995 outStr += " ("+item->location()+")";
996 if ( item->hasDueDate() && posDueDt>=0 ) { 996 if ( item->hasDueDate() && posDueDt>=0 ) {
997 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; 997 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]";
998 } 998 }
999 rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), 999 rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)),
1000 -1, WordBreak, outStr); 1000 -1, WordBreak, outStr);
1001 QRect newrect; 1001 QRect newrect;
1002 p.drawText( rect, WordBreak, outStr, -1, &newrect ); 1002 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1003 ft.setStrikeOut(false); 1003 ft.setStrikeOut(false);
1004 p.setFont(ft); 1004 p.setFont(ft);
1005 1005
1006 // due 1006 // due
1007 // if ( item->hasDueDate() && posDueDt>=0 ) { 1007 // if ( item->hasDueDate() && posDueDt>=0 ) {
1008// outStr = local->formatDate(item->dtDue().date(),true); 1008// outStr = local->formatDate(item->dtDue().date(),true);
1009// rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr); 1009// rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr);
1010// p.drawText(rect, AlignTop|AlignLeft, outStr); 1010// p.drawText(rect, AlignTop|AlignLeft, outStr);
1011// } 1011// }
1012 1012
1013 if ( !item->description().isEmpty() && desc ) { 1013 if ( !item->description().isEmpty() && desc ) {
1014 y=newrect.bottom() + 5; 1014 y=newrect.bottom() + 5;
1015 outStr = item->description(); 1015 outStr = item->description();
1016 rect = p.boundingRect( left+20, y, x+width-(left+10), -1, 1016 rect = p.boundingRect( left+20, y, x+width-(left+10), -1,
1017 WordBreak, outStr ); 1017 WordBreak, outStr );
1018 p.drawText( rect, WordBreak, outStr, -1, &newrect ); 1018 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1019 } 1019 }
1020 1020
1021 // Set the new line position 1021 // Set the new line position
1022 y=newrect.bottom() + 10; //set the line position 1022 y=newrect.bottom() + 10; //set the line position
1023 1023
1024 // If the item has subitems, we need to call ourselves recursively 1024 // If the item has subitems, we need to call ourselves recursively
1025 Incidence::List l;l.fill( item->relations()); 1025 Incidence::List l;l.fill( item->relations());
1026 Incidence::List::ConstIterator it; 1026 Incidence::List::ConstIterator it;
1027 startPoints.append( &startpt ); 1027 startPoints.append( &startpt );
1028 for( it = l.begin(); it != l.end(); ++it ) { 1028 for( it = l.begin(); it != l.end(); ++it ) {
1029 count++; 1029 count++;
1030 drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos, 1030 drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos,
1031 desc, pospriority, possummary, posDueDt, level+1, 1031 desc, pospriority, possummary, posDueDt, level+1,
1032 x, y, width, height, pageHeight, &startpt); 1032 x, y, width, height, pageHeight, &startpt);
1033 } 1033 }
1034 startPoints.remove(&startpt); 1034 startPoints.remove(&startpt);
1035} 1035}
1036 1036
1037int CalPrintBase::weekdayColumn( int weekday ) 1037int CalPrintBase::weekdayColumn( int weekday )
1038{ 1038{
1039 return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7; 1039 return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7;
1040} 1040}
1041 1041
1042void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, 1042void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd,
1043 const QDate &td ) 1043 const QDate &td )
1044{ 1044{
1045 QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek; 1045 QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek;
1046 1046
1047 mPrinter->setOrientation(KPrinter::Portrait); 1047 mPrinter->setOrientation(KPrinter::Portrait);
1048 1048
1049 int minus = 0; 1049 int minus = 0;
1050 if (KGlobal::locale()->weekStartsMonday()) { 1050 if (KGlobal::locale()->weekStartsMonday()) {
1051 // correct to monday 1051 // correct to monday
1052 fromWeek = fd.addDays(-(fd.dayOfWeek()-1)); 1052 fromWeek = fd.addDays(-(fd.dayOfWeek()-1));
1053 // correct to sunday 1053 // correct to sunday
1054 toWeek = td.addDays(7-fd.dayOfWeek()); 1054 toWeek = td.addDays(7-fd.dayOfWeek());
1055 minus = 1; 1055 minus = 1;
1056 } else { 1056 } else {
1057 // correct to sunday 1057 // correct to sunday
1058 fromWeek = fd.addDays(-(fd.dayOfWeek()%7)); 1058 fromWeek = fd.addDays(-(fd.dayOfWeek()%7));
1059 // correct to saturday 1059 // correct to saturday
1060 toWeek = td.addDays(6-td.dayOfWeek()); 1060 toWeek = td.addDays(6-td.dayOfWeek());
1061 } 1061 }
1062 1062
1063 fromDay = fd; 1063 fromDay = fd;
1064 curDay = fd; 1064 curDay = fd;
1065 toDay = td; 1065 toDay = td;
1066 p.setFont( QFont("Helvetica") ); 1066 p.setFont( QFont("Helvetica") );
1067 // the painter initially begins at 72 dpi per the Qt docs. 1067 // the painter initially begins at 72 dpi per the Qt docs.
1068 int pageWidth = p.viewport().width(); 1068 int pageWidth = p.viewport().width();
1069 int pageHeight = p.viewport().height(); 1069 int pageHeight = p.viewport().height();
1070 int margin=0; 1070 int margin=0;
1071 mHeaderHeight = 110; 1071 mHeaderHeight = 110;
1072 mSubHeaderHeight = 20; 1072 mSubHeaderHeight = 20;
1073 1073
1074 p.setViewport(margin, margin, 1074 p.setViewport(margin, margin,
1075 p.viewport().width()-margin, 1075 p.viewport().width()-margin,
1076 p.viewport().height()-margin); 1076 p.viewport().height()-margin);
1077 1077
1078 curWeek = fromWeek.addDays(6); 1078 curWeek = fromWeek.addDays(6);
1079 1079
1080 int columnWidth = int( pageWidth / 4.5 ); 1080 int columnWidth = int( pageWidth / 4.5 );
1081 1081
1082 do { 1082 do {
1083 1083
1084 // if ( (curDay.dayOfWeek()-1)%7 < 3 ) 1084 // if ( (curDay.dayOfWeek()-1)%7 < 3 )
1085 switch((curDay.dayOfWeek()-minus)%7){ 1085 switch((curDay.dayOfWeek()-minus)%7){
1086 case 0: 1086 case 0:
1087 drawSplitTimes( p, pageWidth, columnWidth, pageHeight ); 1087 drawSplitTimes( p, pageWidth, columnWidth, pageHeight );
1088 drawSplitDay( p, curDay, columnWidth, pageHeight, 1088 drawSplitDay( p, curDay, columnWidth, pageHeight,
1089 int( columnWidth * 0.5 ) ); 1089 int( columnWidth * 0.5 ) );
1090 break; 1090 break;
1091 case 1: 1091 case 1:
1092 drawSplitDay( p, curDay, columnWidth, pageHeight, 1092 drawSplitDay( p, curDay, columnWidth, pageHeight,
1093 int( columnWidth * 1.5 ) ); 1093 int( columnWidth * 1.5 ) );
1094 break; 1094 break;
1095 case 2: 1095 case 2:
1096 drawSplitDay( p, curDay, columnWidth, pageHeight, 1096 drawSplitDay( p, curDay, columnWidth, pageHeight,
1097 int( columnWidth * 2.5 ) ); 1097 int( columnWidth * 2.5 ) );
1098 break; 1098 break;
1099 case 3: 1099 case 3:
1100 drawSplitDay( p, curDay, columnWidth, pageHeight, 1100 drawSplitDay( p, curDay, columnWidth, pageHeight,
1101 int( columnWidth * 3.5 ) ); 1101 int( columnWidth * 3.5 ) );
1102 mPrinter->newPage(); 1102 mPrinter->newPage();
1103 break; 1103 break;
1104 case 4: 1104 case 4:
1105 drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth, 1105 drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth,
1106 pageHeight ); 1106 pageHeight );
1107 drawSplitDay( p, curDay, columnWidth, pageHeight, 1107 drawSplitDay( p, curDay, columnWidth, pageHeight,
1108 int( columnWidth * 0.5 ) ); 1108 int( columnWidth * 0.5 ) );
1109 drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek, 1109 drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek,
1110 curWeek, pageWidth, mHeaderHeight ); 1110 curWeek, pageWidth, mHeaderHeight );
1111 break; 1111 break;
1112 case 5: 1112 case 5:
1113 drawSplitDay( p, curDay, columnWidth, pageHeight, 1113 drawSplitDay( p, curDay, columnWidth, pageHeight,
1114 int( columnWidth * 1.5 ) ); 1114 int( columnWidth * 1.5 ) );
1115 break; 1115 break;
1116 case 6: 1116 case 6:
1117 drawSplitDay( p, curDay, columnWidth, pageHeight, 1117 drawSplitDay( p, curDay, columnWidth, pageHeight,
1118 int( columnWidth * 2.5 ) ); 1118 int( columnWidth * 2.5 ) );
1119 if ( curDay < toDay ) 1119 if ( curDay < toDay )
1120 mPrinter->newPage(); 1120 mPrinter->newPage();
1121 curWeek = curWeek.addDays( 7 ); 1121 curWeek = curWeek.addDays( 7 );
1122 break; 1122 break;
1123 } 1123 }
1124 curDay = curDay.addDays(1); 1124 curDay = curDay.addDays(1);
1125 1125
1126 } while (curDay <= toDay); 1126 } while (curDay <= toDay);
1127 1127
1128} 1128}
1129 1129
1130void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, 1130void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd,
1131 const QDate &td, 1131 const QDate &td,
1132 const QDate &, 1132 const QDate &,
1133 int width, int ) 1133 int width, int )
1134{ 1134{
1135 int tempStore = mSubHeaderHeight; 1135 int tempStore = mSubHeaderHeight;
1136 mSubHeaderHeight+= mSubHeaderHeight; 1136 mSubHeaderHeight+= mSubHeaderHeight;
1137 KLocale *local = KGlobal::locale(); 1137 KLocale *local = KGlobal::locale();
1138 QFont font("helvetica", 18, QFont::Bold); 1138 QFont font("helvetica", 18, QFont::Bold);
1139 QPen penA( black,0); 1139 QPen penA( black,0);
1140 QPen penB( black,3); 1140 QPen penB( black,3);
1141 p.setFont(font); 1141 p.setFont(font);
1142 int lineSpacing = p.fontMetrics().lineSpacing(); 1142 int lineSpacing = p.fontMetrics().lineSpacing();
1143 QString title; 1143 QString title;
1144 QString myOwner(mCalendar->getOwner()); 1144 QString myOwner(mCalendar->getOwner());
1145 if ( fd.month() == td.month() ) { 1145 if ( fd.month() == td.month() ) {
1146 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' 1146 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1147 + '-' + ' ' + QString::number(td.day()); 1147 + '-' + ' ' + QString::number(td.day());
1148 } else { 1148 } else {
1149 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' 1149 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1150 + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day()); 1150 + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day());
1151 } 1151 }
1152 1152
1153// Grrrrrrr! why can't I set the font to a serif font?!?!? 1153// Grrrrrrr! why can't I set the font to a serif font?!?!?
1154 QFont serifFont("Helvetica", 30); 1154 QFont serifFont("Helvetica", 30);
1155// serifFont.setFamily("Serif"); 1155// serifFont.setFamily("Serif");
1156// serifFont.setWeight(87); 1156// serifFont.setWeight(87);
1157// serifFont.setItalic(true); 1157// serifFont.setItalic(true);
1158 p.setFont(serifFont); 1158 p.setFont(serifFont);
1159 QFontInfo info(p.font()); 1159 QFontInfo info(p.font());
1160 1160
1161 lineSpacing = p.fontMetrics().lineSpacing(); 1161 lineSpacing = p.fontMetrics().lineSpacing();
1162 p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title ); 1162 p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title );
1163 1163
1164 title.truncate(0); 1164 title.truncate(0);
1165 1165
1166 p.setPen(penB ); 1166 p.setPen(penB );
1167 p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1); 1167 p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1);
1168 p.setPen(penA ); 1168 p.setPen(penA );
1169 1169
1170 p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE)); 1170 p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE));
1171 title += QString::number(fd.year()); 1171 title += QString::number(fd.year());
1172 p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title ); 1172 p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title );
1173 mSubHeaderHeight = tempStore ; 1173 mSubHeaderHeight = tempStore ;
1174} 1174}
1175 1175
1176void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, 1176void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width,
1177 int height, int offsetLeft ) 1177 int height, int offsetLeft )
1178{ 1178{
1179 int tempStore = mSubHeaderHeight; 1179 int tempStore = mSubHeaderHeight;
1180 mSubHeaderHeight+= mSubHeaderHeight; 1180 mSubHeaderHeight+= mSubHeaderHeight;
1181 int startHour = KOPrefs::instance()->mDayBegins; 1181 int startHour = KOPrefs::instance()->mDayBegins;
1182 int endHour = 20; 1182 int endHour = 20;
1183 int offset = mHeaderHeight + mSubHeaderHeight + 10; 1183 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1184 Event::List eventList; eventList.fill( mCalendar->events( qd, true )); 1184 Event::List eventList; eventList.fill( mCalendar->events( qd, true ));
1185 Event::List::Iterator it; 1185 Event::List::Iterator it;
1186 Event *currEvent; 1186 Event *currEvent;
1187 KLocale *local = KGlobal::locale(); 1187 KLocale *local = KGlobal::locale();
1188 QString dayName; 1188 QString dayName;
1189 1189
1190 dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day()); 1190 dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day());
1191 //p.setBrush(QBrush(black)); 1191 //p.setBrush(QBrush(black));
1192// width+1 to make sure there's a continuous, black bar across the top. 1192// width+1 to make sure there's a continuous, black bar across the top.
1193 p.setPen( QPen(Qt::black,2)); 1193 p.setPen( QPen(Qt::black,2));
1194 p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight); 1194 p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight);
1195 p.setPen( Qt::black); 1195 p.setPen( Qt::black);
1196 p.setFont(QFont("helvetica", 12, QFont::Bold, true)); 1196 p.setFont(QFont("helvetica", 12, QFont::Bold, true));
1197 p.drawText(offsetLeft, mHeaderHeight + 5, 1197 p.drawText(offsetLeft, mHeaderHeight + 5,
1198 width, mSubHeaderHeight, AlignHCenter | AlignVCenter, 1198 width, mSubHeaderHeight, AlignHCenter | AlignVCenter,
1199 dayName); 1199 dayName);
1200 1200
1201 p.setPen( QPen(Qt::black,2)); 1201 p.setPen( QPen(Qt::black,2));
1202 p.setFont(QFont("helvetica", 12)); 1202 p.setFont(QFont("helvetica", 12));
1203 p.setBrush(Qt::white); 1203 p.setBrush(Qt::white);
1204 it = eventList.begin(); 1204 it = eventList.begin();
1205 int allDays = 0; 1205 int allDays = 0;
1206 /* 1206 /*
1207 while( it != eventList.end() ) { 1207 while( it != eventList.end() ) {
1208 Event *currEvent = *it; 1208 Event *currEvent = *it;
1209 if ( currEvent->doesFloat() ) { 1209 if ( currEvent->doesFloat() ) {
1210 p.drawRect( offsetLeft, offset, width, 35 ); 1210 p.drawRect( offsetLeft, offset, width, 35 );
1211 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30, 1211 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30,
1212 AlignLeft | AlignTop, currEvent->summary() ); 1212 AlignLeft | AlignTop, currEvent->summary() );
1213 offset += 40; 1213 offset += 40;
1214 allDays++; 1214 allDays++;
1215 it = eventList.remove( it ); 1215 it = eventList.remove( it );
1216 } else { 1216 } else {
1217 ++it; 1217 ++it;
1218 } 1218 }
1219 } 1219 }
1220 */ 1220 */
1221 //p.setBrush(QBrush()); 1221 //p.setBrush(QBrush());
1222 int tmpEnd; 1222 int tmpEnd;
1223 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1223 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1224 Event *currEvent = *it; 1224 Event *currEvent = *it;
1225 tmpEnd = currEvent->dtEnd().time().hour(); 1225 tmpEnd = currEvent->dtEnd().time().hour();
1226 if (currEvent->dtEnd().time().minute() > 0) 1226 if (currEvent->dtEnd().time().minute() > 0)
1227 tmpEnd++; 1227 tmpEnd++;
1228 if (tmpEnd > endHour) 1228 if (tmpEnd > endHour)
1229 endHour = tmpEnd; 1229 endHour = tmpEnd;
1230 } 1230 }
1231 int hours = endHour - startHour; 1231 int hours = endHour - startHour;
1232 int cellHeight = (height-offset) / hours; // hour increments. 1232 int cellHeight = (height-offset) / hours; // hour increments.
1233 1233
1234 p.setFont(QFont("helvetica", 12)); 1234 p.setFont(QFont("helvetica", 12));
1235 //p.setBrush(QBrush(Dense7Pattern)); 1235 //p.setBrush(QBrush(Dense7Pattern));
1236 p.setBrush(Qt::white); 1236 p.setBrush(Qt::white);
1237 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1237 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1238 Event *currEvent = *it; 1238 Event *currEvent = *it;
1239 int startTime = currEvent->dtStart().time().hour(); 1239 int startTime = currEvent->dtStart().time().hour();
1240 int endTime = currEvent->dtEnd().time().hour(); 1240 int endTime = currEvent->dtEnd().time().hour();
1241 float minuteInc = cellHeight / 60.0; 1241 float minuteInc = cellHeight / 60.0;
1242 if ((startTime >= startHour) && (endTime <= (startHour + hours))) { 1242 if ((startTime >= startHour) && (endTime <= (startHour + hours))) {
1243 startTime -= startHour; 1243 startTime -= startHour;
1244 int startMinuteOff = (int) (minuteInc * 1244 int startMinuteOff = (int) (minuteInc *
1245 currEvent->dtStart().time().minute()); 1245 currEvent->dtStart().time().minute());
1246 QString text = currEvent->summary() ; 1246 QString text = currEvent->summary() ;
1247 if ( ! currEvent->location().isEmpty() ) 1247 if ( ! currEvent->location().isEmpty() )
1248 text += "\n("+currEvent->location()+")"; 1248 text += "\n("+currEvent->location()+")";
1249 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute()); 1249 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute());
1250 int cheight = (int) (minuteInc * 1250 int cheight = (int) (minuteInc *
1251 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 ); 1251 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 );
1252 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight, 1252 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight,
1253 width-4, cheight); 1253 width-4, cheight);
1254 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24, 1254 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24,
1255 cheight-10, AlignHCenter | AlignTop, text); 1255 cheight-10, AlignHCenter | AlignTop, text);
1256 } 1256 }
1257 } 1257 }
1258 p.setBrush(QBrush(NoBrush)); 1258 p.setBrush(QBrush(NoBrush));
1259 mSubHeaderHeight = tempStore ; 1259 mSubHeaderHeight = tempStore ;
1260} 1260}
1261 1261
1262void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, 1262void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth,
1263 int height ) 1263 int height )
1264{ 1264{
1265 int tempStore = mSubHeaderHeight; 1265 int tempStore = mSubHeaderHeight;
1266 mSubHeaderHeight+= mSubHeaderHeight; 1266 mSubHeaderHeight+= mSubHeaderHeight;
1267 int startHour = KOPrefs::instance()->mDayBegins; 1267 int startHour = KOPrefs::instance()->mDayBegins;
1268 int endHour = 20; 1268 int endHour = 20;
1269 int offset = mHeaderHeight + mSubHeaderHeight + 10; 1269 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1270 int hours = endHour - startHour; 1270 int hours = endHour - startHour;
1271 int cellHeight = (height-offset) / hours; // hour increments. 1271 int cellHeight = (height-offset) / hours; // hour increments.
1272 1272
1273 QString numStr; 1273 QString numStr;
1274 for (int i = 0; i < hours; i++) { 1274 for (int i = 0; i < hours; i++) {
1275 p.setPen(QPen(black,1)); 1275 p.setPen(QPen(black,1));
1276 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight); 1276 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight);
1277 p.setPen(QPen(gray,0)); 1277 p.setPen(QPen(gray,0));
1278 p.drawLine(37, offset+i*cellHeight+(cellHeight/2), 1278 p.drawLine(37, offset+i*cellHeight+(cellHeight/2),
1279 width, offset+i*cellHeight+(cellHeight/2)); 1279 width, offset+i*cellHeight+(cellHeight/2));
1280 p.setPen(QPen(black,0)); 1280 p.setPen(QPen(black,0));
1281 1281
1282 if ( !KGlobal::locale()->use12Clock() ) { 1282 if ( !KGlobal::locale()->use12Clock() ) {
1283 numStr.setNum(i+startHour); 1283 numStr.setNum(i+startHour);
1284 if (cellHeight > 40) { 1284 if (cellHeight > 40) {
1285 p.setFont(QFont("helvetica", 16, QFont::Bold)); 1285 p.setFont(QFont("helvetica", 16, QFont::Bold));
1286 } else { 1286 } else {
1287 p.setFont(QFont("helvetica", 14, QFont::Bold)); 1287 p.setFont(QFont("helvetica", 14, QFont::Bold));
1288 } 1288 }
1289 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2, 1289 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2,
1290 AlignTop|AlignRight, numStr); 1290 AlignTop|AlignRight, numStr);
1291 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1291 p.setFont(QFont("helvetica", 12, QFont::Bold));
1292 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2, 1292 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2,
1293 AlignTop | AlignLeft, "00"); 1293 AlignTop | AlignLeft, "00");
1294 } else { 1294 } else {
1295 QTime time( i + startHour, 0 ); 1295 QTime time( i + startHour, 0 );
1296 numStr = KGlobal::locale()->formatTime( time ); 1296 numStr = KGlobal::locale()->formatTime( time );
1297 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1297 p.setFont(QFont("helvetica", 12, QFont::Bold));
1298 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2, 1298 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2,
1299 AlignTop|AlignLeft, numStr); 1299 AlignTop|AlignLeft, numStr);
1300 } 1300 }
1301 } mSubHeaderHeight = tempStore ; 1301 } mSubHeaderHeight = tempStore ;
1302} 1302}
1303 1303
1304#endif 1304#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2de7f28..006a8dd 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2094 +1,2103 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.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
131int globalFlagBlockStartup; 131int globalFlagBlockStartup;
132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
133 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
134{ 134{
135 135
136 mClosed = false; 136 mClosed = false;
137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
138 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
139 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
140 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
141 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
142 mBlockAtStartup = true; 142 mBlockAtStartup = true;
143 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
144 setCaption("KOrganizer/Pi"); 144 setCaption("KOrganizer/Pi");
145 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
146 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
147 if ( p->mHourSize > 22 ) 147 if ( p->mHourSize > 22 )
148 p->mHourSize = 22; 148 p->mHourSize = 22;
149 QMainWindow::ToolBarDock tbd; 149 QMainWindow::ToolBarDock tbd;
150 if ( p->mToolBarHor ) { 150 if ( p->mToolBarHor ) {
151 if ( p->mToolBarUp ) 151 if ( p->mToolBarUp )
152 tbd = Bottom; 152 tbd = Bottom;
153 else 153 else
154 tbd = Top; 154 tbd = Top;
155 } 155 }
156 else { 156 else {
157 if ( p->mToolBarUp ) 157 if ( p->mToolBarUp )
158 tbd = Right; 158 tbd = Right;
159 else 159 else
160 tbd = Left; 160 tbd = Left;
161 } 161 }
162 if ( KOPrefs::instance()->mUseAppColors ) 162 if ( KOPrefs::instance()->mUseAppColors )
163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
164 globalFlagBlockStartup = 1; 164 globalFlagBlockStartup = 1;
165 iconToolBar = new QPEToolBar( this ); 165 iconToolBar = new QPEToolBar( this );
166 addToolBar (iconToolBar , tbd ); 166 addToolBar (iconToolBar , tbd );
167 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
169 splash->setAlignment ( AlignCenter ); 169 splash->setAlignment ( AlignCenter );
170 setCentralWidget( splash ); 170 setCentralWidget( splash );
171#ifndef DESKTOP_VERSION 171#ifndef DESKTOP_VERSION
172 showMaximized(); 172 showMaximized();
173#endif 173#endif
174 174
175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
176 setDefaultPreferences(); 176 setDefaultPreferences();
177 mCalendar = new CalendarLocal(); 177 mCalendar = new CalendarLocal();
178 mView = new CalendarView( mCalendar, this,"mCalendar " ); 178 mView = new CalendarView( mCalendar, this,"mCalendar " );
179 mView->hide(); 179 mView->hide();
180 //mView->resize(splash->size() ); 180 //mView->resize(splash->size() );
181 initActions(); 181 initActions();
182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
183 mSyncManager->setBlockSave(false); 183 mSyncManager->setBlockSave(false);
184 mView->setSyncManager(mSyncManager); 184 mView->setSyncManager(mSyncManager);
185#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 186 iconToolBar->show();
187 qApp->processEvents(); 187 qApp->processEvents();
188#endif 188#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 190 int vh = height() ;
191 int vw = width(); 191 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
195 } else { 195 } else {
196 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
197 } 197 }
198 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 201 mView->readSettings();
202 bool newFile = false; 202 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
208 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 209 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
212 qApp->processEvents(); 212 qApp->processEvents();
213 } else { 213 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 216 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
219 qApp->processEvents(); 219 qApp->processEvents();
220 } 220 }
221 } 221 }
222 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
223 newFile = true; 223 newFile = true;
224 } 224 }
225 225
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 230
231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
232 KOPrefs::instance()->setAllDefaults(); 232 KOPrefs::instance()->setAllDefaults();
233 int count = mView->addCategories(); 233 int count = mView->addCategories();
234 } 234 }
235 processIncidenceSelection( 0 ); 235 processIncidenceSelection( 0 );
236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
237 SLOT( processIncidenceSelection( Incidence * ) ) ); 237 SLOT( processIncidenceSelection( Incidence * ) ) );
238 connect( mView, SIGNAL( modifiedChanged( bool ) ), 238 connect( mView, SIGNAL( modifiedChanged( bool ) ),
239 SLOT( slotModifiedChanged( bool ) ) ); 239 SLOT( slotModifiedChanged( bool ) ) );
240 240
241 241
242 connect( mView, SIGNAL( tempDisableBR(bool) ), 242 connect( mView, SIGNAL( tempDisableBR(bool) ),
243 SLOT( disableBR(bool) ) ); 243 SLOT( disableBR(bool) ) );
244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
245 mView->setModified( false ); 245 mView->setModified( false );
246 mBlockAtStartup = false; 246 mBlockAtStartup = false;
247 mView->setModified( false ); 247 mView->setModified( false );
248 setCentralWidget( mView ); 248 setCentralWidget( mView );
249 globalFlagBlockStartup = 0; 249 globalFlagBlockStartup = 0;
250 mView->show(); 250 mView->show();
251 delete splash; 251 delete splash;
252 if ( newFile ) 252 if ( newFile )
253 mView->updateConfig(); 253 mView->updateConfig();
254 // qApp->processEvents(); 254 // qApp->processEvents();
255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
256 //fillSyncMenu(); 256 //fillSyncMenu();
257 257
258 258
259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
264 mSyncManager->setDefaultFileName( sentSyncFile()); 264 mSyncManager->setDefaultFileName( sentSyncFile());
265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
266 mSyncManager->fillSyncMenu(); 266 mSyncManager->fillSyncMenu();
267 267
268 268
269 269
270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
271 if ( showWarning ) { 271 if ( showWarning ) {
272 KMessageBox::information( this, 272 KMessageBox::information( this,
273 "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"); 273 "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");
274 qApp->processEvents(); 274 qApp->processEvents();
275 mView->dialogManager()->showSyncOptions(); 275 mView->dialogManager()->showSyncOptions();
276 } 276 }
277 277
278 //US listen for result adressed from Ka/Pi 278 //US listen for result adressed from Ka/Pi
279#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
281#endif 281#endif
282#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
283 infrared = 0; 283 infrared = 0;
284#endif 284#endif
285 updateWeek( mView->startDate() ); 285 updateWeek( mView->startDate() );
286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
287 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 287 SLOT( updateWeekNum( const KCal::DateList & ) ) );
288 mBRdisabled = false; 288 mBRdisabled = false;
289 //toggleBeamReceive(); 289 //toggleBeamReceive();
290} 290}
291MainWindow::~MainWindow() 291MainWindow::~MainWindow()
292{ 292{
293 //qDebug("MainWindow::~MainWindow() "); 293 //qDebug("MainWindow::~MainWindow() ");
294 //save toolbar location 294 //save toolbar location
295 delete mCalendar; 295 delete mCalendar;
296 delete mSyncManager; 296 delete mSyncManager;
297#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
298 if ( infrared ) 298 if ( infrared )
299 delete infrared; 299 delete infrared;
300#endif 300#endif
301 301
302 302
303} 303}
304 304
305void MainWindow::disableBR(bool b) 305void MainWindow::disableBR(bool b)
306{ 306{
307#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
308 if ( b ) { 308 if ( b ) {
309 if ( infrared ) { 309 if ( infrared ) {
310 toggleBeamReceive(); 310 toggleBeamReceive();
311 mBRdisabled = true; 311 mBRdisabled = true;
312 } 312 }
313 mBRdisabled = true; 313 mBRdisabled = true;
314 } else { 314 } else {
315 if ( mBRdisabled ) { 315 if ( mBRdisabled ) {
316 mBRdisabled = false; 316 mBRdisabled = false;
317 //makes no sense,because other cal ap is probably running 317 //makes no sense,because other cal ap is probably running
318 // toggleBeamReceive(); 318 // toggleBeamReceive();
319 } 319 }
320 } 320 }
321#endif 321#endif
322 322
323} 323}
324bool MainWindow::beamReceiveEnabled() 324bool MainWindow::beamReceiveEnabled()
325{ 325{
326#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
327 return ( infrared != 0 ); 327 return ( infrared != 0 );
328#endif 328#endif
329 return false; 329 return false;
330} 330}
331 331
332void MainWindow::toggleBeamReceive() 332void MainWindow::toggleBeamReceive()
333{ 333{
334 if ( mBRdisabled ) 334 if ( mBRdisabled )
335 return; 335 return;
336#ifndef DESKTOP_VERSION 336#ifndef DESKTOP_VERSION
337 if ( infrared ) { 337 if ( infrared ) {
338 qDebug("disable BeamReceive "); 338 qDebug("disable BeamReceive ");
339 delete infrared; 339 delete infrared;
340 infrared = 0; 340 infrared = 0;
341 brAction->setOn(false); 341 brAction->setOn(false);
342 return; 342 return;
343 } 343 }
344 qDebug("enable BeamReceive "); 344 qDebug("enable BeamReceive ");
345 brAction->setOn(true); 345 brAction->setOn(true);
346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
348#endif 348#endif
349} 349}
350void MainWindow::showMaximized () 350void MainWindow::showMaximized ()
351{ 351{
352#ifndef DESKTOP_VERSION 352#ifndef DESKTOP_VERSION
353 if ( ! globalFlagBlockStartup ) 353 if ( ! globalFlagBlockStartup )
354 if ( mClosed ) 354 if ( mClosed )
355 mView->goToday(); 355 mView->goToday();
356#endif 356#endif
357 QWidget::showMaximized () ; 357 QWidget::showMaximized () ;
358 mClosed = false; 358 mClosed = false;
359} 359}
360void MainWindow::closeEvent( QCloseEvent* ce ) 360void MainWindow::closeEvent( QCloseEvent* ce )
361{ 361{
362 362
363 363
364 364
365 if ( ! KOPrefs::instance()->mAskForQuit ) { 365 if ( ! KOPrefs::instance()->mAskForQuit ) {
366 saveOnClose(); 366 saveOnClose();
367 mClosed = true; 367 mClosed = true;
368 ce->accept(); 368 ce->accept();
369 return; 369 return;
370 370
371 } 371 }
372 372
373 switch( QMessageBox::information( this, "KO/Pi", 373 switch( QMessageBox::information( this, "KO/Pi",
374 i18n("Do you really want\nto close KO/Pi?"), 374 i18n("Do you really want\nto close KO/Pi?"),
375 i18n("Close"), i18n("No"), 375 i18n("Close"), i18n("No"),
376 0, 0 ) ) { 376 0, 0 ) ) {
377 case 0: 377 case 0:
378 saveOnClose(); 378 saveOnClose();
379 mClosed = true; 379 mClosed = true;
380 ce->accept(); 380 ce->accept();
381 break; 381 break;
382 case 1: 382 case 1:
383 ce->ignore(); 383 ce->ignore();
384 break; 384 break;
385 case 2: 385 case 2:
386 386
387 default: 387 default:
388 break; 388 break;
389 } 389 }
390 390
391 391
392} 392}
393 393
394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
395{ 395{
396 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
398 //QString datamess; 398 //QString datamess;
399 //qDebug("message "); 399 //qDebug("message ");
400 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 400 qDebug("KO: QCOP message received: %s ", cmsg.data() );
401 401
402 if ( cmsg == "setDocument(QString)" ) { 402 if ( cmsg == "setDocument(QString)" ) {
403 QDataStream stream( data, IO_ReadOnly ); 403 QDataStream stream( data, IO_ReadOnly );
404 QString fileName; 404 QString fileName;
405 stream >> fileName; 405 stream >> fileName;
406 //qDebug("filename %s ", fileName.latin1()); 406 //qDebug("filename %s ", fileName.latin1());
407 showMaximized(); 407 showMaximized();
408 raise(); 408 raise();
409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
410 mSyncManager->slotSyncMenu( 1002 ); 410 mSyncManager->slotSyncMenu( 1002 );
411 return; 411 return;
412 } 412 }
413 413
414 if ( cmsg == "-writeFile" ) { 414 if ( cmsg == "-writeFile" ) {
415 // I made from the "-writeFile" an "-writeAlarm" 415 // I made from the "-writeFile" an "-writeAlarm"
416 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
417 mCalendar->checkAlarmForIncidence( 0, true); 417 mCalendar->checkAlarmForIncidence( 0, true);
418 showMaximized(); 418 showMaximized();
419 raise(); 419 raise();
420 return; 420 return;
421 421
422 } 422 }
423 if ( cmsg == "-writeFileSilent" ) { 423 if ( cmsg == "-writeFileSilent" ) {
424 // I made from the "-writeFile" an "-writeAlarm" 424 // I made from the "-writeFile" an "-writeAlarm"
425 // mView->viewManager()->showWhatsNextView(); 425 // mView->viewManager()->showWhatsNextView();
426 mCalendar->checkAlarmForIncidence( 0, true); 426 mCalendar->checkAlarmForIncidence( 0, true);
427 //showMaximized(); 427 //showMaximized();
428 //raise(); 428 //raise();
429 hide(); 429 hide();
430 return; 430 return;
431 } 431 }
432 if ( cmsg == "-newCountdown" ) { 432 if ( cmsg == "-newCountdown" ) {
433 qDebug("newCountdown "); 433 qDebug("newCountdown ");
434 434
435 } 435 }
436 QString msg ; 436 QString msg ;
437 QString allmsg = cmsg; 437 QString allmsg = cmsg;
438 while ( allmsg.length() > 0 ) { 438 while ( allmsg.length() > 0 ) {
439 int nextC = allmsg.find( "-", 1 ); 439 int nextC = allmsg.find( "-", 1 );
440 if ( nextC == -1 ) { 440 if ( nextC == -1 ) {
441 msg = allmsg; 441 msg = allmsg;
442 allmsg = ""; 442 allmsg = "";
443 } else{ 443 } else{
444 msg = allmsg.left( nextC ); 444 msg = allmsg.left( nextC );
445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
446 } 446 }
447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
448 if ( msg == "-newEvent" ) { 448 if ( msg == "-newEvent" ) {
449 mView->newEvent(); 449 mView->newEvent();
450 } 450 }
451 if ( msg == "-newTodo" ) { 451 if ( msg == "-newTodo" ) {
452 mView->newTodo(); 452 mView->newTodo();
453 453
454 } 454 }
455 if ( msg == "-showWN" ) { 455 if ( msg == "-showWN" ) {
456 mView->viewManager()->showWhatsNextView(); 456 mView->viewManager()->showWhatsNextView();
457 } 457 }
458 if ( msg == "-showTodo" ) { 458 if ( msg == "-showTodo" ) {
459 mView->viewManager()->showTodoView(); 459 mView->viewManager()->showTodoView();
460 } 460 }
461 if ( msg == "-showList" ) { 461 if ( msg == "-showList" ) {
462 mView->viewManager()->showListView(); 462 mView->viewManager()->showListView();
463 } 463 }
464 else if ( msg == "-showDay" ) { 464 else if ( msg == "-showDay" ) {
465 mView->viewManager()->showDayView(); 465 mView->viewManager()->showDayView();
466 } 466 }
467 else if ( msg == "-showWWeek" ) { 467 else if ( msg == "-showWWeek" ) {
468 mView->viewManager()->showWorkWeekView(); 468 mView->viewManager()->showWorkWeekView();
469 } 469 }
470 else if ( msg == "-ringSync" ) { 470 else if ( msg == "-ringSync" ) {
471 mSyncManager->multiSync( false ); 471 mSyncManager->multiSync( false );
472 } 472 }
473 else if ( msg == "-showWeek" ) { 473 else if ( msg == "-showWeek" ) {
474 mView->viewManager()->showWeekView(); 474 mView->viewManager()->showWeekView();
475 } 475 }
476 else if ( msg == "-showTodo" ) { 476 else if ( msg == "-showTodo" ) {
477 mView->viewManager()->showTodoView(); 477 mView->viewManager()->showTodoView();
478 } 478 }
479 else if ( msg == "-showJournal" ) { 479 else if ( msg == "-showJournal" ) {
480 mView->dateNavigator()->selectDates( 1 ); 480 mView->dateNavigator()->selectDates( 1 );
481 mView->dateNavigator()->selectToday(); 481 mView->dateNavigator()->selectToday();
482 mView->viewManager()->showJournalView(); 482 mView->viewManager()->showJournalView();
483 } 483 }
484 else if ( msg == "-showKO" ) { 484 else if ( msg == "-showKO" ) {
485 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
486 } 486 }
487 else if ( msg == "-showWNext" || msg == "nextView()" ) { 487 else if ( msg == "-showWNext" || msg == "nextView()" ) {
488 mView->viewManager()->showWhatsNextView(); 488 mView->viewManager()->showWhatsNextView();
489 } 489 }
490 else if ( msg == "-showNextXView" ) { 490 else if ( msg == "-showNextXView" ) {
491 mView->viewManager()->showNextXView(); 491 mView->viewManager()->showNextXView();
492 } 492 }
493 493
494 494
495 } 495 }
496 496
497 showMaximized(); 497 showMaximized();
498 raise(); 498 raise();
499} 499}
500 500
501QPixmap MainWindow::loadPixmap( QString name ) 501QPixmap MainWindow::loadPixmap( QString name )
502{ 502{
503 return SmallIcon( name ); 503 return SmallIcon( name );
504 504
505} 505}
506void MainWindow::initActions() 506void MainWindow::initActions()
507{ 507{
508 //KOPrefs::instance()->mShowFullMenu 508 //KOPrefs::instance()->mShowFullMenu
509 iconToolBar->clear(); 509 iconToolBar->clear();
510 KOPrefs *p = KOPrefs::instance(); 510 KOPrefs *p = KOPrefs::instance();
511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
512 512
513 QPopupMenu *viewMenu = new QPopupMenu( this ); 513 QPopupMenu *viewMenu = new QPopupMenu( this );
514 QPopupMenu *actionMenu = new QPopupMenu( this ); 514 QPopupMenu *actionMenu = new QPopupMenu( this );
515 QPopupMenu *importMenu = new QPopupMenu( this ); 515 QPopupMenu *importMenu = new QPopupMenu( this );
516 selectFilterMenu = new QPopupMenu( this ); 516 selectFilterMenu = new QPopupMenu( this );
517 selectFilterMenu->setCheckable( true ); 517 selectFilterMenu->setCheckable( true );
518 syncMenu = new QPopupMenu( this ); 518 syncMenu = new QPopupMenu( this );
519 configureAgendaMenu = new QPopupMenu( this ); 519 configureAgendaMenu = new QPopupMenu( this );
520 configureToolBarMenu = new QPopupMenu( this ); 520 configureToolBarMenu = new QPopupMenu( this );
521 QPopupMenu *helpMenu = new QPopupMenu( this ); 521 QPopupMenu *helpMenu = new QPopupMenu( this );
522 if ( KOPrefs::instance()->mShowFullMenu ) { 522 if ( KOPrefs::instance()->mShowFullMenu ) {
523 QMenuBar *menuBar1; 523 QMenuBar *menuBar1;
524 menuBar1 = menuBar(); 524 menuBar1 = menuBar();
525 menuBar1->insertItem( i18n("File"), importMenu ); 525 menuBar1->insertItem( i18n("File"), importMenu );
526 menuBar1->insertItem( i18n("View"), viewMenu ); 526 menuBar1->insertItem( i18n("View"), viewMenu );
527 menuBar1->insertItem( i18n("Actions"), actionMenu ); 527 menuBar1->insertItem( i18n("Actions"), actionMenu );
528#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
529 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 529 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
530 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 530 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
531#else 531#else
532 menuBar1->insertItem( i18n("Sync"), syncMenu ); 532 menuBar1->insertItem( i18n("Sync"), syncMenu );
533 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 533 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
534#endif 534#endif
535 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 535 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
536 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 536 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
537 menuBar1->insertItem( i18n("Help"), helpMenu ); 537 menuBar1->insertItem( i18n("Help"), helpMenu );
538 } else { 538 } else {
539 QPEMenuBar *menuBar1; 539 QPEMenuBar *menuBar1;
540 menuBar1 = new QPEMenuBar( iconToolBar ); 540 menuBar1 = new QPEMenuBar( iconToolBar );
541 QPopupMenu *menuBar = new QPopupMenu( this ); 541 QPopupMenu *menuBar = new QPopupMenu( this );
542 menuBar1->insertItem( i18n("ME"), menuBar); 542 menuBar1->insertItem( i18n("ME"), menuBar);
543 menuBar->insertItem( i18n("File"), importMenu ); 543 menuBar->insertItem( i18n("File"), importMenu );
544 menuBar->insertItem( i18n("View"), viewMenu ); 544 menuBar->insertItem( i18n("View"), viewMenu );
545 menuBar->insertItem( i18n("Actions"), actionMenu ); 545 menuBar->insertItem( i18n("Actions"), actionMenu );
546 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 546 menuBar->insertItem( i18n("Synchronize"), syncMenu );
547 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 547 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
548 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 548 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
549 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 549 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
550 menuBar->insertItem( i18n("Help"), helpMenu ); 550 menuBar->insertItem( i18n("Help"), helpMenu );
551 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 551 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
552 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 552 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
553 } 553 }
554 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 554 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
555 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 555 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
556 QIconSet icon; 556 QIconSet icon;
557 int pixWid = 22, pixHei = 22; 557 int pixWid = 22, pixHei = 22;
558 QString pathString = ""; 558 QString pathString = "";
559 if ( !p->mToolBarMiniIcons ) { 559 if ( !p->mToolBarMiniIcons ) {
560 if ( QApplication::desktop()->width() < 480 ) { 560 if ( QApplication::desktop()->width() < 480 ) {
561 pathString += "icons16/"; 561 pathString += "icons16/";
562 pixWid = 18; pixHei = 16; 562 pixWid = 18; pixHei = 16;
563 } 563 }
564 } else { 564 } else {
565 pathString += "iconsmini/"; 565 pathString += "iconsmini/";
566 pixWid = 18; pixHei = 16; 566 pixWid = 18; pixHei = 16;
567 } 567 }
568 mWeekBgColor = iconToolBar->backgroundColor(); 568 mWeekBgColor = iconToolBar->backgroundColor();
569 mWeekPixmap.resize( pixWid , pixHei ); 569 mWeekPixmap.resize( pixWid , pixHei );
570 mWeekPixmap.fill( mWeekBgColor ); 570 mWeekPixmap.fill( mWeekBgColor );
571 icon = mWeekPixmap; 571 icon = mWeekPixmap;
572 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 572 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
573 if ( p-> mShowIconWeekNum ) 573 if ( p-> mShowIconWeekNum )
574 mWeekAction->addTo( iconToolBar ); 574 mWeekAction->addTo( iconToolBar );
575 mWeekFont = font(); 575 mWeekFont = font();
576 576
577 int fontPoint = mWeekFont.pointSize(); 577 int fontPoint = mWeekFont.pointSize();
578 QFontMetrics f( mWeekFont ); 578 QFontMetrics f( mWeekFont );
579 int fontWid = f.width( "30" ); 579 int fontWid = f.width( "30" );
580 while ( fontWid > pixWid ) { 580 while ( fontWid > pixWid ) {
581 --fontPoint; 581 --fontPoint;
582 mWeekFont.setPointSize( fontPoint ); 582 mWeekFont.setPointSize( fontPoint );
583 QFontMetrics f( mWeekFont ); 583 QFontMetrics f( mWeekFont );
584 fontWid = f.width( "30" ); 584 fontWid = f.width( "30" );
585 qDebug("dec-- "); 585 qDebug("dec-- ");
586 } 586 }
587 587
588 connect( mWeekAction, SIGNAL( activated() ), 588 connect( mWeekAction, SIGNAL( activated() ),
589 this, SLOT( weekAction() ) ); 589 this, SLOT( weekAction() ) );
590 590
591 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 591 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
592 592
593 //#endif 593 //#endif
594 // ****************** 594 // ******************
595 QAction *action; 595 QAction *action;
596 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 596 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
597 configureToolBarMenu->setCheckable( true ); 597 configureToolBarMenu->setCheckable( true );
598 598
599 599
600 configureAgendaMenu->setCheckable( true ); 600 configureAgendaMenu->setCheckable( true );
601 int iii ; 601 int iii ;
602 for ( iii = 1;iii<= 10 ;++iii ){ 602 for ( iii = 1;iii<= 10 ;++iii ){
603 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 603 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
604 } 604 }
605 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 605 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
606 606
607 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 607 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
608 this, SLOT( showConfigureAgenda( ) ) ); 608 this, SLOT( showConfigureAgenda( ) ) );
609 609
610 icon = loadPixmap( pathString + "configure" ); 610 icon = loadPixmap( pathString + "configure" );
611 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 611 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
612 action->addTo( actionMenu ); 612 action->addTo( actionMenu );
613 connect( action, SIGNAL( activated() ), 613 connect( action, SIGNAL( activated() ),
614 mView, SLOT( edit_options() ) ); 614 mView, SLOT( edit_options() ) );
615 actionMenu->insertSeparator(); 615 actionMenu->insertSeparator();
616 616
617 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 617 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
618 action->addTo( actionMenu ); 618 action->addTo( actionMenu );
619 connect( action, SIGNAL( activated() ), 619 connect( action, SIGNAL( activated() ),
620 mView, SLOT( undo_delete() ) ); 620 mView, SLOT( undo_delete() ) );
621 actionMenu->insertSeparator(); 621 actionMenu->insertSeparator();
622 622
623 icon = loadPixmap( pathString + "newevent" ); 623 icon = loadPixmap( pathString + "newevent" );
624 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 624 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
625 configureToolBarMenu->insertSeparator(); 625 configureToolBarMenu->insertSeparator();
626 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 626 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
627 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 627 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
628 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 628 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
629 ne_action->addTo( actionMenu ); 629 ne_action->addTo( actionMenu );
630 connect( ne_action, SIGNAL( activated() ), 630 connect( ne_action, SIGNAL( activated() ),
631 mView, SLOT( newEvent() ) ); 631 mView, SLOT( newEvent() ) );
632 icon = loadPixmap( pathString + "newtodo" ); 632 icon = loadPixmap( pathString + "newtodo" );
633 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 633 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
634 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 634 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
635 nt_action->addTo( actionMenu ); 635 nt_action->addTo( actionMenu );
636 connect( nt_action, SIGNAL( activated() ), 636 connect( nt_action, SIGNAL( activated() ),
637 mView, SLOT( newTodo() ) ); 637 mView, SLOT( newTodo() ) );
638 638
639 icon = loadPixmap( pathString + "today" ); 639 icon = loadPixmap( pathString + "today" );
640 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 640 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
641 today_action->addTo( viewMenu ); 641 today_action->addTo( viewMenu );
642 connect( today_action, SIGNAL( activated() ), 642 connect( today_action, SIGNAL( activated() ),
643 mView, SLOT( goToday() ) ); 643 mView, SLOT( goToday() ) );
644 viewMenu->insertSeparator(); 644 viewMenu->insertSeparator();
645 645
646 icon = loadPixmap( pathString + "navi" ); 646 icon = loadPixmap( pathString + "navi" );
647 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 647 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
648 action->addTo( viewMenu ); 648 action->addTo( viewMenu );
649 connect( action, SIGNAL( activated() ), 649 connect( action, SIGNAL( activated() ),
650 mView, SLOT( toggleDateNavigatorWidget() ) ); 650 mView, SLOT( toggleDateNavigatorWidget() ) );
651 mToggleNav = action ; 651 mToggleNav = action ;
652 icon = loadPixmap( pathString + "filter" ); 652 icon = loadPixmap( pathString + "filter" );
653 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 653 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
654 action->addTo( viewMenu ); 654 action->addTo( viewMenu );
655 connect( action, SIGNAL( activated() ), 655 connect( action, SIGNAL( activated() ),
656 mView, SLOT( toggleFilter() ) ); 656 mView, SLOT( toggleFilter() ) );
657 mToggleFilter = action; 657 mToggleFilter = action;
658 icon = loadPixmap( pathString + "allday" ); 658 icon = loadPixmap( pathString + "allday" );
659 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 659 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
660 action->addTo( viewMenu ); 660 action->addTo( viewMenu );
661 connect( action, SIGNAL( activated() ), 661 connect( action, SIGNAL( activated() ),
662 mView, SLOT( toggleAllDaySize() ) ); 662 mView, SLOT( toggleAllDaySize() ) );
663 mToggleAllday = action; 663 mToggleAllday = action;
664 664
665 665
666 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 666 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
667 mToggleNav, SLOT( setEnabled ( bool ) ) ); 667 mToggleNav, SLOT( setEnabled ( bool ) ) );
668 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 668 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
669 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 669 mToggleFilter, SLOT( setEnabled ( bool ) ) );
670 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 670 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
671 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 671 mToggleAllday, SLOT( setEnabled ( bool ) ) );
672 672
673 viewMenu->insertSeparator(); 673 viewMenu->insertSeparator();
674 icon = loadPixmap( pathString + "picker" ); 674 icon = loadPixmap( pathString + "picker" );
675 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 675 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
676 action->addTo( viewMenu ); 676 action->addTo( viewMenu );
677 connect( action, SIGNAL( activated() ), 677 connect( action, SIGNAL( activated() ),
678 mView, SLOT( showDatePicker() ) ); 678 mView, SLOT( showDatePicker() ) );
679 action->addTo( iconToolBar ); 679 action->addTo( iconToolBar );
680 viewMenu->insertSeparator(); 680 viewMenu->insertSeparator();
681 icon = loadPixmap( pathString + "list" ); 681 icon = loadPixmap( pathString + "list" );
682 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 682 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
683 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 683 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
684 showlist_action->addTo( viewMenu ); 684 showlist_action->addTo( viewMenu );
685 connect( showlist_action, SIGNAL( activated() ), 685 connect( showlist_action, SIGNAL( activated() ),
686 mView->viewManager(), SLOT( showListView() ) ); 686 mView->viewManager(), SLOT( showListView() ) );
687 687
688 688
689 icon = loadPixmap( pathString + "day" ); 689 icon = loadPixmap( pathString + "day" );
690 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 690 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
691 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 691 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
692 day1_action->addTo( viewMenu ); 692 day1_action->addTo( viewMenu );
693 // action->addTo( toolBar ); 693 // action->addTo( toolBar );
694 connect( day1_action, SIGNAL( activated() ), 694 connect( day1_action, SIGNAL( activated() ),
695 mView->viewManager(), SLOT( showDayView() ) ); 695 mView->viewManager(), SLOT( showDayView() ) );
696 696
697 icon = loadPixmap( pathString + "workweek" ); 697 icon = loadPixmap( pathString + "workweek" );
698 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 698 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
699 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 699 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
700 day5_action->addTo( viewMenu ); 700 day5_action->addTo( viewMenu );
701 connect( day5_action, SIGNAL( activated() ), 701 connect( day5_action, SIGNAL( activated() ),
702 mView->viewManager(), SLOT( showWorkWeekView() ) ); 702 mView->viewManager(), SLOT( showWorkWeekView() ) );
703 703
704 icon = loadPixmap( pathString + "week" ); 704 icon = loadPixmap( pathString + "week" );
705 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 705 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
706 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 706 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
707 day7_action->addTo( viewMenu ); 707 day7_action->addTo( viewMenu );
708 connect( day7_action, SIGNAL( activated() ), 708 connect( day7_action, SIGNAL( activated() ),
709 mView->viewManager(), SLOT( showWeekView() ) ); 709 mView->viewManager(), SLOT( showWeekView() ) );
710 710
711 icon = loadPixmap( pathString + "workweek2" ); 711 icon = loadPixmap( pathString + "workweek2" );
712 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 712 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
713 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 713 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
714 day6_action->addTo( viewMenu ); 714 day6_action->addTo( viewMenu );
715 connect( day6_action, SIGNAL( activated() ), 715 connect( day6_action, SIGNAL( activated() ),
716 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 716 mView->viewManager(), SLOT( showMonthViewWeek() ) );
717 717
718 icon = loadPixmap( pathString + "month" ); 718 icon = loadPixmap( pathString + "month" );
719 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 719 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
720 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 720 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
721 month_action->addTo( viewMenu ); 721 month_action->addTo( viewMenu );
722 connect( month_action, SIGNAL( activated() ), 722 connect( month_action, SIGNAL( activated() ),
723 mView->viewManager(), SLOT( showMonthView() ) ); 723 mView->viewManager(), SLOT( showMonthView() ) );
724 724
725 icon = loadPixmap( pathString + "todo" ); 725 icon = loadPixmap( pathString + "todo" );
726 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 726 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
727 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 727 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
728 todoview_action->addTo( viewMenu ); 728 todoview_action->addTo( viewMenu );
729 connect( todoview_action, SIGNAL( activated() ), 729 connect( todoview_action, SIGNAL( activated() ),
730 mView->viewManager(), SLOT( showTodoView() ) ); 730 mView->viewManager(), SLOT( showTodoView() ) );
731 731
732 icon = loadPixmap( pathString + "journal" ); 732 icon = loadPixmap( pathString + "journal" );
733 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 733 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
734 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 734 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
735 viewjournal_action->addTo( viewMenu ); 735 viewjournal_action->addTo( viewMenu );
736 connect( viewjournal_action, SIGNAL( activated() ), 736 connect( viewjournal_action, SIGNAL( activated() ),
737 mView->viewManager(), SLOT( showJournalView() ) ); 737 mView->viewManager(), SLOT( showJournalView() ) );
738 738
739 icon = loadPixmap( pathString + "xdays" ); 739 icon = loadPixmap( pathString + "xdays" );
740 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 740 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
741 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 741 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
742 xdays_action->addTo( viewMenu ); 742 xdays_action->addTo( viewMenu );
743 connect( xdays_action, SIGNAL( activated() ), 743 connect( xdays_action, SIGNAL( activated() ),
744 mView->viewManager(), SLOT( showNextXView() ) ); 744 mView->viewManager(), SLOT( showNextXView() ) );
745 745
746 icon = loadPixmap( pathString + "whatsnext" ); 746 icon = loadPixmap( pathString + "whatsnext" );
747 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 747 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
748 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 748 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
749 whatsnext_action->addTo( viewMenu ); 749 whatsnext_action->addTo( viewMenu );
750 connect( whatsnext_action, SIGNAL( activated() ), 750 connect( whatsnext_action, SIGNAL( activated() ),
751 mView->viewManager(), SLOT( showWhatsNextView() ) ); 751 mView->viewManager(), SLOT( showWhatsNextView() ) );
752 752
753#if 0 753#if 0
754 action = new QAction( "view_timespan", "Time Span", 0, this ); 754 action = new QAction( "view_timespan", "Time Span", 0, this );
755 action->addTo( viewMenu ); 755 action->addTo( viewMenu );
756 connect( action, SIGNAL( activated() ), 756 connect( action, SIGNAL( activated() ),
757 mView->viewManager(), SLOT( showTimeSpanView() ) ); 757 mView->viewManager(), SLOT( showTimeSpanView() ) );
758#endif 758#endif
759 759
760 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 760 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
761 this ); 761 this );
762 mNewSubTodoAction->addTo( actionMenu ); 762 mNewSubTodoAction->addTo( actionMenu );
763 connect( mNewSubTodoAction, SIGNAL( activated() ), 763 connect( mNewSubTodoAction, SIGNAL( activated() ),
764 mView, SLOT( newSubTodo() ) ); 764 mView, SLOT( newSubTodo() ) );
765 765
766 actionMenu->insertSeparator(); 766 actionMenu->insertSeparator();
767 767
768 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 768 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
769 mShowAction->addTo( actionMenu ); 769 mShowAction->addTo( actionMenu );
770 connect( mShowAction, SIGNAL( activated() ), 770 connect( mShowAction, SIGNAL( activated() ),
771 mView, SLOT( showIncidence() ) ); 771 mView, SLOT( showIncidence() ) );
772 772
773 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 773 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
774 mEditAction->addTo( actionMenu ); 774 mEditAction->addTo( actionMenu );
775 connect( mEditAction, SIGNAL( activated() ), 775 connect( mEditAction, SIGNAL( activated() ),
776 mView, SLOT( editIncidence() ) ); 776 mView, SLOT( editIncidence() ) );
777 777
778 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 778 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
779 mDeleteAction->addTo( actionMenu ); 779 mDeleteAction->addTo( actionMenu );
780 connect( mDeleteAction, SIGNAL( activated() ), 780 connect( mDeleteAction, SIGNAL( activated() ),
781 mView, SLOT( deleteIncidence() ) ); 781 mView, SLOT( deleteIncidence() ) );
782 782
783 783
784 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 784 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
785 mCloneAction->addTo( actionMenu ); 785 mCloneAction->addTo( actionMenu );
786 connect( mCloneAction, SIGNAL( activated() ), 786 connect( mCloneAction, SIGNAL( activated() ),
787 mView, SLOT( cloneIncidence() ) ); 787 mView, SLOT( cloneIncidence() ) );
788 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 788 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
789 mMoveAction->addTo( actionMenu ); 789 mMoveAction->addTo( actionMenu );
790 connect( mMoveAction, SIGNAL( activated() ), 790 connect( mMoveAction, SIGNAL( activated() ),
791 mView, SLOT( moveIncidence() ) ); 791 mView, SLOT( moveIncidence() ) );
792 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 792 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
793 mBeamAction->addTo( actionMenu ); 793 mBeamAction->addTo( actionMenu );
794 connect( mBeamAction, SIGNAL( activated() ), 794 connect( mBeamAction, SIGNAL( activated() ),
795 mView, SLOT( beamIncidence() ) ); 795 mView, SLOT( beamIncidence() ) );
796 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 796 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
797 mCancelAction->addTo( actionMenu ); 797 mCancelAction->addTo( actionMenu );
798 connect( mCancelAction, SIGNAL( activated() ), 798 connect( mCancelAction, SIGNAL( activated() ),
799 mView, SLOT( toggleCancelIncidence() ) ); 799 mView, SLOT( toggleCancelIncidence() ) );
800 800
801 actionMenu->insertSeparator(); 801 actionMenu->insertSeparator();
802 802
803 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 803 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
804 this ); 804 this );
805 action->addTo( actionMenu ); 805 action->addTo( actionMenu );
806 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 806 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
807 807
808 icon = loadPixmap( pathString + "search" ); 808 icon = loadPixmap( pathString + "search" );
809 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 809 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
810 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 810 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
811 search_action->addTo( actionMenu ); 811 search_action->addTo( actionMenu );
812 connect( search_action, SIGNAL( activated() ), 812 connect( search_action, SIGNAL( activated() ),
813 mView->dialogManager(), SLOT( showSearchDialog() ) ); 813 mView->dialogManager(), SLOT( showSearchDialog() ) );
814 814
815 815
816 816
817 if ( KOPrefs::instance()->mShowFullMenu ) { 817 if ( KOPrefs::instance()->mShowFullMenu ) {
818 actionMenu->insertSeparator(); 818 actionMenu->insertSeparator();
819 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 819 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
820 820
821 } 821 }
822 // actionMenu->insertSeparator(); 822 // actionMenu->insertSeparator();
823 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 823 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
824 this ); 824 this );
825 action->addTo( importMenu ); 825 action->addTo( importMenu );
826 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 826 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
827 action = new QAction( "import_quick", i18n("Import last file"), 0, 827 action = new QAction( "import_quick", i18n("Import last file"), 0,
828 this ); 828 this );
829 action->addTo( importMenu ); 829 action->addTo( importMenu );
830 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 830 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
831 importMenu->insertSeparator(); 831 importMenu->insertSeparator();
832 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 832 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
833 this ); 833 this );
834 action->addTo( importMenu ); 834 action->addTo( importMenu );
835 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 835 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
836#ifndef DESKTOP_VERSION 836 //#ifndef DESKTOP_VERSION
837 importMenu->insertSeparator(); 837 importMenu->insertSeparator();
838 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 838 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
839 this ); 839 this );
840 action->addTo( importMenu ); 840 action->addTo( importMenu );
841 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 841 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
842#else 842 //#else
843#ifdef _OL_IMPORT_ 843#ifdef _OL_IMPORT_
844 importMenu->insertSeparator(); 844 importMenu->insertSeparator();
845 action = new QAction( "import_ol", i18n("Import from OL"), 0, 845 action = new QAction( "import_ol", i18n("Import from OL"), 0,
846 this ); 846 this );
847 action->addTo( importMenu ); 847 action->addTo( importMenu );
848 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 848 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
849#endif 849#endif
850#endif 850 //#endif
851 851
852 importMenu->insertSeparator(); 852 importMenu->insertSeparator();
853 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 853 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
854 this ); 854 this );
855 action->addTo( importMenu ); 855 action->addTo( importMenu );
856 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 856 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
857 857
858 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 858 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
859 this ); 859 this );
860 action->addTo( importMenu ); 860 action->addTo( importMenu );
861 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 861 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
862 862
863 importMenu->insertSeparator(); 863 importMenu->insertSeparator();
864 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 864 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
865 this ); 865 this );
866 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 866 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
867 867
868 868
869 //LR 869 //LR
870 QPopupMenu *ex2phone = new QPopupMenu( this ); 870 QPopupMenu *ex2phone = new QPopupMenu( this );
871 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 871 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
872 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 872 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
873 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 873 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
874 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 874 importMenu->insertItem( i18n("Export to phone"), ex2phone );
875 875
876 importMenu->insertSeparator(); 876 importMenu->insertSeparator();
877 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 877 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
878 this ); 878 this );
879 action->addTo( importMenu ); 879 action->addTo( importMenu );
880 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 880 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
881#ifndef DESKTOP_VERSION 881#ifndef DESKTOP_VERSION
882 importMenu->insertSeparator(); 882 importMenu->insertSeparator();
883 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 883 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
884 this ); 884 this );
885 brAction->addTo( importMenu ); 885 brAction->addTo( importMenu );
886 brAction->setToggleAction (true ) ; 886 brAction->setToggleAction (true ) ;
887 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 887 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
888 888
889 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 889 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
890 this ); 890 this );
891 action->addTo( importMenu ); 891 action->addTo( importMenu );
892 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 892 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
893 893
894 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 894 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
895 this ); 895 this );
896 action->addTo( importMenu ); 896 action->addTo( importMenu );
897 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 897 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
898#else 898#else
899 importMenu->insertSeparator(); 899 importMenu->insertSeparator();
900 icon = loadPixmap( pathString + "print" ); 900 icon = loadPixmap( pathString + "print" );
901 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 901 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
902 action->addTo( importMenu ); 902 action->addTo( importMenu );
903 connect( action, SIGNAL( activated() ), 903 connect( action, SIGNAL( activated() ),
904 this, SLOT( printCal() ) ); 904 this, SLOT( printCal() ) );
905 905
906 icon = loadPixmap( pathString + "print" ); 906 icon = loadPixmap( pathString + "print" );
907 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 907 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
908 action->addTo( importMenu ); 908 action->addTo( importMenu );
909 connect( action, SIGNAL( activated() ), 909 connect( action, SIGNAL( activated() ),
910 this, SLOT( printSel() ) ); 910 this, SLOT( printSel() ) );
911 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 911 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
912 action->addTo( importMenu ); 912 action->addTo( importMenu );
913 connect( action, SIGNAL( activated() ), 913 connect( action, SIGNAL( activated() ),
914 mView->viewManager(), SIGNAL( printWNV() ) ); 914 mView->viewManager(), SIGNAL( printWNV() ) );
915#endif 915#endif
916 importMenu->insertSeparator(); 916 importMenu->insertSeparator();
917 action = new QAction( "beam all", i18n("Save"), 0, 917 action = new QAction( "beam all", i18n("Save"), 0,
918 this ); 918 this );
919 action->addTo( importMenu ); 919 action->addTo( importMenu );
920 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 920 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
921 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 921 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
922 this ); 922 this );
923 action->addTo( importMenu ); 923 action->addTo( importMenu );
924 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 924 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
925 925
926 //menuBar->insertItem( "Configure",configureMenu ); 926 //menuBar->insertItem( "Configure",configureMenu );
927 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 927 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
928 icon = loadPixmap( "korganizer/korganizer" ); 928 icon = loadPixmap( "korganizer/korganizer" );
929 929
930 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 930 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
931 action->addTo( helpMenu ); 931 action->addTo( helpMenu );
932 connect( action, SIGNAL( activated() ), 932 connect( action, SIGNAL( activated() ),
933 SLOT( whatsNew() ) ); 933 SLOT( whatsNew() ) );
934 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 934 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
935 action->addTo( helpMenu ); 935 action->addTo( helpMenu );
936 connect( action, SIGNAL( activated() ), 936 connect( action, SIGNAL( activated() ),
937 SLOT( features() ) ); 937 SLOT( features() ) );
938 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 938 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
939 action->addTo( helpMenu ); 939 action->addTo( helpMenu );
940 connect( action, SIGNAL( activated() ), 940 connect( action, SIGNAL( activated() ),
941 SLOT( keyBindings() ) ); 941 SLOT( keyBindings() ) );
942 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 942 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
943 action->addTo( helpMenu ); 943 action->addTo( helpMenu );
944 connect( action, SIGNAL( activated() ), 944 connect( action, SIGNAL( activated() ),
945 SLOT( synchowto() ) ); 945 SLOT( synchowto() ) );
946 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 946 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
947 action->addTo( helpMenu ); 947 action->addTo( helpMenu );
948 connect( action, SIGNAL( activated() ), 948 connect( action, SIGNAL( activated() ),
949 SLOT( kdesynchowto() ) ); 949 SLOT( kdesynchowto() ) );
950 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 950 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
951 action->addTo( helpMenu ); 951 action->addTo( helpMenu );
952 connect( action, SIGNAL( activated() ), 952 connect( action, SIGNAL( activated() ),
953 SLOT( multisynchowto() ) ); 953 SLOT( multisynchowto() ) );
954 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 954 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
955 action->addTo( helpMenu ); 955 action->addTo( helpMenu );
956 connect( action, SIGNAL( activated() ), 956 connect( action, SIGNAL( activated() ),
957 SLOT( aboutAutoSaving() ) ); 957 SLOT( aboutAutoSaving() ) );
958 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 958 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
959 action->addTo( helpMenu ); 959 action->addTo( helpMenu );
960 connect( action, SIGNAL( activated() ), 960 connect( action, SIGNAL( activated() ),
961 SLOT( aboutKnownBugs() ) ); 961 SLOT( aboutKnownBugs() ) );
962 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 962 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
963 action->addTo( helpMenu ); 963 action->addTo( helpMenu );
964 connect( action, SIGNAL( activated() ), 964 connect( action, SIGNAL( activated() ),
965 SLOT( usertrans() ) ); 965 SLOT( usertrans() ) );
966 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 966 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
967 action->addTo( helpMenu ); 967 action->addTo( helpMenu );
968 connect( action, SIGNAL( activated() ), 968 connect( action, SIGNAL( activated() ),
969 SLOT( faq() ) ); 969 SLOT( faq() ) );
970 action = new QAction( "licence", i18n("Licence..."), 0, this ); 970 action = new QAction( "licence", i18n("Licence..."), 0, this );
971 action->addTo( helpMenu ); 971 action->addTo( helpMenu );
972 connect( action, SIGNAL( activated() ), 972 connect( action, SIGNAL( activated() ),
973 SLOT( licence() ) ); 973 SLOT( licence() ) );
974 action = new QAction( "about", i18n("About..."), 0, this ); 974 action = new QAction( "about", i18n("About..."), 0, this );
975 action->addTo( helpMenu ); 975 action->addTo( helpMenu );
976 connect( action, SIGNAL( activated() ), 976 connect( action, SIGNAL( activated() ),
977 SLOT( about() ) ); 977 SLOT( about() ) );
978 //menuBar->insertSeparator(); 978 //menuBar->insertSeparator();
979 979
980 // ****************************************************** 980 // ******************************************************
981 // menubar icons 981 // menubar icons
982 982
983 983
984 iconToolBar->setHorizontalStretchable (true ); 984 iconToolBar->setHorizontalStretchable (true );
985 //menuBar->insertItem( iconToolBar ); 985 //menuBar->insertItem( iconToolBar );
986 //xdays_action 986 //xdays_action
987 if (p-> mShowIconNewEvent) 987 if (p-> mShowIconNewEvent)
988 ne_action->addTo( iconToolBar ); 988 ne_action->addTo( iconToolBar );
989 if (p->mShowIconNewTodo ) 989 if (p->mShowIconNewTodo )
990 nt_action->addTo( iconToolBar ); 990 nt_action->addTo( iconToolBar );
991 if (p-> mShowIconSearch) 991 if (p-> mShowIconSearch)
992 search_action->addTo( iconToolBar ); 992 search_action->addTo( iconToolBar );
993 if (p-> mShowIconNext) 993 if (p-> mShowIconNext)
994 whatsnext_action->addTo( iconToolBar ); 994 whatsnext_action->addTo( iconToolBar );
995 if (p-> mShowIconNextDays) 995 if (p-> mShowIconNextDays)
996 xdays_action->addTo( iconToolBar ); 996 xdays_action->addTo( iconToolBar );
997 if (p-> mShowIconList) 997 if (p-> mShowIconList)
998 showlist_action->addTo( iconToolBar ); 998 showlist_action->addTo( iconToolBar );
999 if (p-> mShowIconDay1) 999 if (p-> mShowIconDay1)
1000 day1_action->addTo( iconToolBar ); 1000 day1_action->addTo( iconToolBar );
1001 if (p-> mShowIconDay5) 1001 if (p-> mShowIconDay5)
1002 day5_action->addTo( iconToolBar ); 1002 day5_action->addTo( iconToolBar );
1003 if (p-> mShowIconDay7) 1003 if (p-> mShowIconDay7)
1004 day7_action->addTo( iconToolBar ); 1004 day7_action->addTo( iconToolBar );
1005 if (p-> mShowIconDay6) 1005 if (p-> mShowIconDay6)
1006 day6_action->addTo( iconToolBar ); 1006 day6_action->addTo( iconToolBar );
1007 if (p-> mShowIconMonth) 1007 if (p-> mShowIconMonth)
1008 month_action->addTo( iconToolBar ); 1008 month_action->addTo( iconToolBar );
1009 if (p-> mShowIconTodoview) 1009 if (p-> mShowIconTodoview)
1010 todoview_action->addTo( iconToolBar ); 1010 todoview_action->addTo( iconToolBar );
1011 if (p-> mShowIconJournal) 1011 if (p-> mShowIconJournal)
1012 viewjournal_action->addTo( iconToolBar ); 1012 viewjournal_action->addTo( iconToolBar );
1013 icon = loadPixmap( pathString + "2leftarrowB" ); 1013 icon = loadPixmap( pathString + "2leftarrowB" );
1014 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 1014 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
1015 if (p-> mShowIconBackFast) { 1015 if (p-> mShowIconBackFast) {
1016 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1016 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1017 connect( action, SIGNAL( activated() ), 1017 connect( action, SIGNAL( activated() ),
1018 mView, SLOT( goPreviousMonth() ) ); 1018 mView, SLOT( goPreviousMonth() ) );
1019 action->addTo( iconToolBar ); 1019 action->addTo( iconToolBar );
1020 } 1020 }
1021 icon = loadPixmap( pathString + "1leftarrowB" ); 1021 icon = loadPixmap( pathString + "1leftarrowB" );
1022 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 1022 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
1023 if (p-> mShowIconBack) { 1023 if (p-> mShowIconBack) {
1024 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1024 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1025 connect( action, SIGNAL( activated() ), 1025 connect( action, SIGNAL( activated() ),
1026 mView, SLOT( goPrevious() ) ); 1026 mView, SLOT( goPrevious() ) );
1027 action->addTo( iconToolBar ); 1027 action->addTo( iconToolBar );
1028 } 1028 }
1029 icon = loadPixmap( pathString + "today" ); 1029 icon = loadPixmap( pathString + "today" );
1030 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1030 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1031 if (p-> mShowIconToday) 1031 if (p-> mShowIconToday)
1032 today_action->addTo( iconToolBar ); 1032 today_action->addTo( iconToolBar );
1033 icon = loadPixmap( pathString + "1rightarrowB" ); 1033 icon = loadPixmap( pathString + "1rightarrowB" );
1034 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1034 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1035 if (p-> mShowIconForward) { 1035 if (p-> mShowIconForward) {
1036 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1036 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1037 connect( action, SIGNAL( activated() ), 1037 connect( action, SIGNAL( activated() ),
1038 mView, SLOT( goNext() ) ); 1038 mView, SLOT( goNext() ) );
1039 action->addTo( iconToolBar ); 1039 action->addTo( iconToolBar );
1040 } 1040 }
1041 icon = loadPixmap( pathString + "2rightarrowB" ); 1041 icon = loadPixmap( pathString + "2rightarrowB" );
1042 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1042 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1043 if (p-> mShowIconForwardFast) { 1043 if (p-> mShowIconForwardFast) {
1044 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1044 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1045 connect( action, SIGNAL( activated() ), 1045 connect( action, SIGNAL( activated() ),
1046 mView, SLOT( goNextMonth() ) ); 1046 mView, SLOT( goNextMonth() ) );
1047 action->addTo( iconToolBar ); 1047 action->addTo( iconToolBar );
1048 } 1048 }
1049 1049
1050 1050
1051 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1051 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1052 1052
1053 if (p-> mShowIconNewEvent) 1053 if (p-> mShowIconNewEvent)
1054 configureToolBarMenu->setItemChecked( 10, true ); 1054 configureToolBarMenu->setItemChecked( 10, true );
1055 if (p->mShowIconNewTodo ) 1055 if (p->mShowIconNewTodo )
1056 configureToolBarMenu->setItemChecked( 20, true ); 1056 configureToolBarMenu->setItemChecked( 20, true );
1057 if (p-> mShowIconSearch) 1057 if (p-> mShowIconSearch)
1058 configureToolBarMenu->setItemChecked( 120, true ); 1058 configureToolBarMenu->setItemChecked( 120, true );
1059 if (p-> mShowIconList) 1059 if (p-> mShowIconList)
1060 configureToolBarMenu->setItemChecked( 30, true ); 1060 configureToolBarMenu->setItemChecked( 30, true );
1061 if (p-> mShowIconDay1) 1061 if (p-> mShowIconDay1)
1062 configureToolBarMenu->setItemChecked( 40, true ); 1062 configureToolBarMenu->setItemChecked( 40, true );
1063 if (p-> mShowIconDay5) 1063 if (p-> mShowIconDay5)
1064 configureToolBarMenu->setItemChecked( 50, true ); 1064 configureToolBarMenu->setItemChecked( 50, true );
1065 if (p-> mShowIconDay6) 1065 if (p-> mShowIconDay6)
1066 configureToolBarMenu->setItemChecked( 75, true ); 1066 configureToolBarMenu->setItemChecked( 75, true );
1067 if (p-> mShowIconDay7) 1067 if (p-> mShowIconDay7)
1068 configureToolBarMenu->setItemChecked( 60, true ); 1068 configureToolBarMenu->setItemChecked( 60, true );
1069 if (p-> mShowIconMonth) 1069 if (p-> mShowIconMonth)
1070 configureToolBarMenu->setItemChecked( 70, true ); 1070 configureToolBarMenu->setItemChecked( 70, true );
1071 if (p-> mShowIconTodoview) 1071 if (p-> mShowIconTodoview)
1072 configureToolBarMenu->setItemChecked( 80, true ); 1072 configureToolBarMenu->setItemChecked( 80, true );
1073 if (p-> mShowIconBackFast) 1073 if (p-> mShowIconBackFast)
1074 configureToolBarMenu->setItemChecked( 200, true ); 1074 configureToolBarMenu->setItemChecked( 200, true );
1075 if (p-> mShowIconBack) 1075 if (p-> mShowIconBack)
1076 configureToolBarMenu->setItemChecked( 210, true ); 1076 configureToolBarMenu->setItemChecked( 210, true );
1077 if (p-> mShowIconToday) 1077 if (p-> mShowIconToday)
1078 configureToolBarMenu->setItemChecked( 130, true ); 1078 configureToolBarMenu->setItemChecked( 130, true );
1079 if (p-> mShowIconForward) 1079 if (p-> mShowIconForward)
1080 configureToolBarMenu->setItemChecked( 220, true ); 1080 configureToolBarMenu->setItemChecked( 220, true );
1081 if (p-> mShowIconForwardFast) 1081 if (p-> mShowIconForwardFast)
1082 configureToolBarMenu->setItemChecked( 230, true ); 1082 configureToolBarMenu->setItemChecked( 230, true );
1083 if (p-> mShowIconNextDays) 1083 if (p-> mShowIconNextDays)
1084 configureToolBarMenu->setItemChecked( 100, true ); 1084 configureToolBarMenu->setItemChecked( 100, true );
1085 if (p-> mShowIconNext) 1085 if (p-> mShowIconNext)
1086 configureToolBarMenu->setItemChecked( 110, true ); 1086 configureToolBarMenu->setItemChecked( 110, true );
1087 if (p-> mShowIconJournal) 1087 if (p-> mShowIconJournal)
1088 configureToolBarMenu->setItemChecked( 90, true ); 1088 configureToolBarMenu->setItemChecked( 90, true );
1089 if (p-> mShowIconWhatsThis) 1089 if (p-> mShowIconWhatsThis)
1090 configureToolBarMenu->setItemChecked( 300, true ); 1090 configureToolBarMenu->setItemChecked( 300, true );
1091 if (p-> mShowIconWeekNum) 1091 if (p-> mShowIconWeekNum)
1092 configureToolBarMenu->setItemChecked( 400, true ); 1092 configureToolBarMenu->setItemChecked( 400, true );
1093 QLabel* dummy = new QLabel( iconToolBar ); 1093 QLabel* dummy = new QLabel( iconToolBar );
1094 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1094 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1095 if (!p-> mShowIconStretch) 1095 if (!p-> mShowIconStretch)
1096 iconToolBar->setStretchableWidget ( dummy ) ; 1096 iconToolBar->setStretchableWidget ( dummy ) ;
1097 else 1097 else
1098 configureToolBarMenu->setItemChecked( 5, true ); 1098 configureToolBarMenu->setItemChecked( 5, true );
1099 if (p-> mShowIconWhatsThis) 1099 if (p-> mShowIconWhatsThis)
1100 QWhatsThis::whatsThisButton ( iconToolBar ); 1100 QWhatsThis::whatsThisButton ( iconToolBar );
1101 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1101 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1102 configureAgenda( p->mHourSize ); 1102 configureAgenda( p->mHourSize );
1103 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1103 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1104} 1104}
1105 1105
1106void MainWindow::exportToPhone( int mode ) 1106void MainWindow::exportToPhone( int mode )
1107{ 1107{
1108 1108
1109 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1109 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1110 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1110 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1111 KOex2phonePrefs ex2phone; 1111 KOex2phonePrefs ex2phone;
1112 1112
1113 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1113 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1114 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1114 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1115 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1115 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1116 if ( mode == 1 ) 1116 if ( mode == 1 )
1117 ex2phone.setCaption(i18n("Export complete calendar")); 1117 ex2phone.setCaption(i18n("Export complete calendar"));
1118 if ( mode == 2 ) 1118 if ( mode == 2 )
1119 ex2phone.setCaption(i18n("Export filtered calendar")); 1119 ex2phone.setCaption(i18n("Export filtered calendar"));
1120 1120
1121 if ( !ex2phone.exec() ) { 1121 if ( !ex2phone.exec() ) {
1122 return; 1122 return;
1123 } 1123 }
1124 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1124 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1125 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1125 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1126 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1126 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1127 1127
1128 int inFuture = 0; 1128 int inFuture = 0;
1129 if ( ex2phone.mWriteBackFuture->isChecked() ) 1129 if ( ex2phone.mWriteBackFuture->isChecked() )
1130 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1130 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1131 QPtrList<Incidence> delSel; 1131 QPtrList<Incidence> delSel;
1132 if ( mode == 1 ) 1132 if ( mode == 1 )
1133 delSel = mCalendar->rawIncidences(); 1133 delSel = mCalendar->rawIncidences();
1134 if ( mode == 2 ) 1134 if ( mode == 2 )
1135 delSel = mCalendar->incidences(); 1135 delSel = mCalendar->incidences();
1136 CalendarLocal* cal = new CalendarLocal(); 1136 CalendarLocal* cal = new CalendarLocal();
1137 cal->setLocalTime(); 1137 cal->setLocalTime();
1138 Incidence *incidence = delSel.first(); 1138 Incidence *incidence = delSel.first();
1139 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1139 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1140 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1140 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1141 while ( incidence ) { 1141 while ( incidence ) {
1142 if ( incidence->type() != "Journal" ) { 1142 if ( incidence->type() != "Journal" ) {
1143 bool add = true; 1143 bool add = true;
1144 if ( inFuture ) { 1144 if ( inFuture ) {
1145 QDateTime dt; 1145 QDateTime dt;
1146 if ( incidence->type() == "Todo" ) { 1146 if ( incidence->type() == "Todo" ) {
1147 Todo * t = (Todo*)incidence; 1147 Todo * t = (Todo*)incidence;
1148 if ( t->hasDueDate() ) 1148 if ( t->hasDueDate() )
1149 dt = t->dtDue(); 1149 dt = t->dtDue();
1150 else 1150 else
1151 dt = cur.addSecs( 62 ); 1151 dt = cur.addSecs( 62 );
1152 } 1152 }
1153 else { 1153 else {
1154 bool ok; 1154 bool ok;
1155 dt = incidence->getNextOccurence( cur, &ok ); 1155 dt = incidence->getNextOccurence( cur, &ok );
1156 if ( !ok ) 1156 if ( !ok )
1157 dt = cur.addSecs( -62 ); 1157 dt = cur.addSecs( -62 );
1158 } 1158 }
1159 if ( dt < cur || dt > end ) { 1159 if ( dt < cur || dt > end ) {
1160 add = false; 1160 add = false;
1161 } 1161 }
1162 } 1162 }
1163 if ( add ) { 1163 if ( add ) {
1164 Incidence *in = incidence->clone(); 1164 Incidence *in = incidence->clone();
1165 cal->addIncidence( in ); 1165 cal->addIncidence( in );
1166 } 1166 }
1167 } 1167 }
1168 incidence = delSel.next(); 1168 incidence = delSel.next();
1169 } 1169 }
1170 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1170 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1171 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1171 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1172 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1172 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1173 1173
1174 setCaption( i18n("Writing to phone...")); 1174 setCaption( i18n("Writing to phone..."));
1175 if ( PhoneFormat::writeToPhone( cal ) ) 1175 if ( PhoneFormat::writeToPhone( cal ) )
1176 setCaption( i18n("Export to phone successful!")); 1176 setCaption( i18n("Export to phone successful!"));
1177 else 1177 else
1178 setCaption( i18n("Error exporting to phone!")); 1178 setCaption( i18n("Error exporting to phone!"));
1179 delete cal; 1179 delete cal;
1180} 1180}
1181 1181
1182 1182
1183void MainWindow::setDefaultPreferences() 1183void MainWindow::setDefaultPreferences()
1184{ 1184{
1185 KOPrefs *p = KOPrefs::instance(); 1185 KOPrefs *p = KOPrefs::instance();
1186 1186
1187 p->mCompactDialogs = true; 1187 p->mCompactDialogs = true;
1188 p->mConfirm = true; 1188 p->mConfirm = true;
1189 // p->mEnableQuickTodo = false; 1189 // p->mEnableQuickTodo = false;
1190 1190
1191} 1191}
1192 1192
1193QString MainWindow::resourcePath() 1193QString MainWindow::resourcePath()
1194{ 1194{
1195 return KGlobal::iconLoader()->iconPath(); 1195 return KGlobal::iconLoader()->iconPath();
1196} 1196}
1197 1197
1198void MainWindow::displayText( QString text ,QString cap ) 1198void MainWindow::displayText( QString text ,QString cap )
1199{ 1199{
1200 QDialog dia( this, "name", true ); ; 1200 QDialog dia( this, "name", true ); ;
1201 dia.setCaption( cap ); 1201 dia.setCaption( cap );
1202 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1202 QVBoxLayout* lay = new QVBoxLayout( &dia );
1203 lay->setSpacing( 3 ); 1203 lay->setSpacing( 3 );
1204 lay->setMargin( 3 ); 1204 lay->setMargin( 3 );
1205 QTextBrowser tb ( &dia ); 1205 QTextBrowser tb ( &dia );
1206 lay->addWidget( &tb ); 1206 lay->addWidget( &tb );
1207 tb.setText( text ); 1207 tb.setText( text );
1208#ifdef DESKTOP_VERSION 1208#ifdef DESKTOP_VERSION
1209 dia.resize( 640, 480); 1209 dia.resize( 640, 480);
1210#else 1210#else
1211 dia.showMaximized(); 1211 dia.showMaximized();
1212#endif 1212#endif
1213 dia.exec(); 1213 dia.exec();
1214} 1214}
1215 1215
1216void MainWindow::features() 1216void MainWindow::features()
1217{ 1217{
1218 1218
1219 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1219 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1220} 1220}
1221 1221
1222void MainWindow::usertrans() 1222void MainWindow::usertrans()
1223{ 1223{
1224 1224
1225 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1225 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1226} 1226}
1227 1227
1228void MainWindow::kdesynchowto() 1228void MainWindow::kdesynchowto()
1229{ 1229{
1230 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1230 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1231} 1231}
1232void MainWindow::multisynchowto() 1232void MainWindow::multisynchowto()
1233{ 1233{
1234 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1234 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1235} 1235}
1236void MainWindow::synchowto() 1236void MainWindow::synchowto()
1237{ 1237{
1238 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1238 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1239} 1239}
1240void MainWindow::faq() 1240void MainWindow::faq()
1241{ 1241{
1242 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1242 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1243 1243
1244} 1244}
1245void MainWindow::whatsNew() 1245void MainWindow::whatsNew()
1246{ 1246{
1247 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1247 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1248 1248
1249} 1249}
1250void MainWindow::licence() 1250void MainWindow::licence()
1251{ 1251{
1252 KApplication::showLicence(); 1252 KApplication::showLicence();
1253 1253
1254} 1254}
1255void MainWindow::about() 1255void MainWindow::about()
1256{ 1256{
1257 QString version; 1257 QString version;
1258#include <../version> 1258#include <../version>
1259 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1259 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1260 i18n("KOrganizer/Platform-independent\n") + 1260 i18n("KOrganizer/Platform-independent\n") +
1261 "(KO/Pi) " + version + " - " + 1261 "(KO/Pi) " + version + " - " +
1262 1262
1263#ifdef DESKTOP_VERSION 1263#ifdef DESKTOP_VERSION
1264 i18n("Desktop Edition\n") + 1264 i18n("Desktop Edition\n") +
1265#else 1265#else
1266 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1266 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1267#endif 1267#endif
1268 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.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1268 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.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1269} 1269}
1270void MainWindow::keyBindings() 1270void MainWindow::keyBindings()
1271{ 1271{
1272 QString cap = i18n("KO/Pi Keys + Colors"); 1272 QString cap = i18n("KO/Pi Keys + Colors");
1273 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1273 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1274 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1274 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1275 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1275 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1276 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1276 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1277 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1277 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1278 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1278 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1279 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1279 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1280 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1280 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1281 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1281 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1282 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1282 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1283 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1283 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1284 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1284 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1285 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1285 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1286 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1286 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1287 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1287 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1288 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1288 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1289 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1289 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1290 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1290 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1291 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1291 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1292 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1292 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1293 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1293 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1294 i18n("<p><h3>In agenda view:</h3></p>\n") + 1294 i18n("<p><h3>In agenda view:</h3></p>\n") +
1295 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1295 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1296 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1296 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1297 i18n("<p><h3>In todo view:</h3></p>\n") + 1297 i18n("<p><h3>In todo view:</h3></p>\n") +
1298 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1298 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1299 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1299 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1300 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1300 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1301 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1301 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1302 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1302 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1303 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1303 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1304 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1304 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1305 i18n("<p><h3>In list view:</h3></p>\n") + 1305 i18n("<p><h3>In list view:</h3></p>\n") +
1306 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1306 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1307 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1307 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1308 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1308 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1309 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1309 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1310 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1310 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1311 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1311 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1312 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1312 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1313 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1313 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1314 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1314 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1315 i18n("<p><b>E</b>: Edit item</p>\n") + 1315 i18n("<p><b>E</b>: Edit item</p>\n") +
1316 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1316 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1317 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1317 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1318 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1318 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1319 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1319 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1320 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1320 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1321 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1321 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1322 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1322 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1323 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1323 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1324 i18n("<p><b>White</b>: Item readonly</p>\n"); 1324 i18n("<p><b>White</b>: Item readonly</p>\n");
1325 displayText( text, cap); 1325 displayText( text, cap);
1326} 1326}
1327void MainWindow::aboutAutoSaving() 1327void MainWindow::aboutAutoSaving()
1328{ 1328{
1329 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"); 1329 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");
1330 1330
1331 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1331 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1332 1332
1333} 1333}
1334void MainWindow::aboutKnownBugs() 1334void MainWindow::aboutKnownBugs()
1335{ 1335{
1336 QMessageBox* msg; 1336 QMessageBox* msg;
1337 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1337 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1338 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")+ 1338 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")+
1339 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1339 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1340 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1340 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1341 i18n("\nor report them in the bugtracker on\n") + 1341 i18n("\nor report them in the bugtracker on\n") +
1342 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1342 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1343 QMessageBox::NoIcon, 1343 QMessageBox::NoIcon,
1344 QMessageBox::Ok, 1344 QMessageBox::Ok,
1345 QMessageBox::NoButton, 1345 QMessageBox::NoButton,
1346 QMessageBox::NoButton); 1346 QMessageBox::NoButton);
1347 msg->exec(); 1347 msg->exec();
1348 delete msg; 1348 delete msg;
1349 1349
1350} 1350}
1351 1351
1352QString MainWindow::defaultFileName() 1352QString MainWindow::defaultFileName()
1353{ 1353{
1354 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1354 return locateLocal( "data", "korganizer/mycalendar.ics" );
1355} 1355}
1356QString MainWindow::syncFileName() 1356QString MainWindow::syncFileName()
1357{ 1357{
1358#ifdef DESKTOP_VERSION 1358#ifdef DESKTOP_VERSION
1359 return locateLocal( "tmp", "synccalendar.ics" ); 1359 return locateLocal( "tmp", "synccalendar.ics" );
1360#else 1360#else
1361 return QString( "/tmp/synccalendar.ics" ); 1361 return QString( "/tmp/synccalendar.ics" );
1362#endif 1362#endif
1363} 1363}
1364void MainWindow::updateWeek(QDate seda) 1364void MainWindow::updateWeek(QDate seda)
1365{ 1365{
1366 int weekNum = 0; 1366 int weekNum = 0;
1367 QDate d = QDate ( seda.year(), 1,1); 1367 QDate d = QDate ( seda.year(), 1,1);
1368 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1368 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1369 if ( seda.addDays(6).year() != seda.year() ) { 1369 if ( seda.addDays(6).year() != seda.year() ) {
1370 if ( seda.year() != d.year() ) { 1370 if ( seda.year() != d.year() ) {
1371 if ( d.dayOfWeek() > 4 ) 1371 if ( d.dayOfWeek() > 4 )
1372 d = QDate ( seda.year(), 1,1); 1372 d = QDate ( seda.year(), 1,1);
1373 else 1373 else
1374 weekNum = 1; 1374 weekNum = 1;
1375 } else { 1375 } else {
1376 QDate dd( seda.year()+1, 1,1); 1376 QDate dd( seda.year()+1, 1,1);
1377 if ( dd.dayOfWeek() <= 4 ) 1377 if ( dd.dayOfWeek() <= 4 )
1378 weekNum = 1; 1378 weekNum = 1;
1379 } 1379 }
1380 } 1380 }
1381 if ( weekNum == 0 ){ 1381 if ( weekNum == 0 ){
1382 int dow = d.dayOfWeek(); 1382 int dow = d.dayOfWeek();
1383 if ( dow <= 4 ) 1383 if ( dow <= 4 )
1384 d = d.addDays( 1-dow ); 1384 d = d.addDays( 1-dow );
1385 else // 5,6,7 1385 else // 5,6,7
1386 d = d.addDays( 8-dow ); 1386 d = d.addDays( 8-dow );
1387 // we have the first week of the year.we are on monday 1387 // we have the first week of the year.we are on monday
1388 weekNum = d.daysTo( seda ) / 7 +1; 1388 weekNum = d.daysTo( seda ) / 7 +1;
1389 } 1389 }
1390 1390
1391 mWeekPixmap.fill( mWeekBgColor ); 1391 mWeekPixmap.fill( mWeekBgColor );
1392 QPainter p ( &mWeekPixmap ); 1392 QPainter p ( &mWeekPixmap );
1393 p.setFont( mWeekFont ); 1393 p.setFont( mWeekFont );
1394 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1394 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1395 p.end(); 1395 p.end();
1396 QIconSet icon3 ( mWeekPixmap ); 1396 QIconSet icon3 ( mWeekPixmap );
1397 mWeekAction->setIconSet ( icon3 ); 1397 mWeekAction->setIconSet ( icon3 );
1398 1398
1399} 1399}
1400void MainWindow::updateWeekNum(const DateList &selectedDates) 1400void MainWindow::updateWeekNum(const DateList &selectedDates)
1401{ 1401{
1402 updateWeek( selectedDates.first() ); 1402 updateWeek( selectedDates.first() );
1403} 1403}
1404void MainWindow::processIncidenceSelection( Incidence *incidence ) 1404void MainWindow::processIncidenceSelection( Incidence *incidence )
1405{ 1405{
1406 1406
1407 if ( !incidence ) { 1407 if ( !incidence ) {
1408 enableIncidenceActions( false ); 1408 enableIncidenceActions( false );
1409 1409
1410 mNewSubTodoAction->setEnabled( false ); 1410 mNewSubTodoAction->setEnabled( false );
1411 setCaptionToDates(); 1411 setCaptionToDates();
1412 return; 1412 return;
1413 1413
1414 } 1414 }
1415 1415
1416 //KGlobal::locale()->formatDateTime(nextA, true); 1416 //KGlobal::locale()->formatDateTime(nextA, true);
1417 QString startString = ""; 1417 QString startString = "";
1418 if ( incidence->type() != "Todo" ) { 1418 if ( incidence->type() != "Todo" ) {
1419 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1419 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1420 if ( incidence->doesFloat() ) { 1420 if ( incidence->doesFloat() ) {
1421 startString += ": "+incidence->dtStartDateStr( true ); 1421 startString += ": "+incidence->dtStartDateStr( true );
1422 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1422 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1423 1423
1424 } else { 1424 } else {
1425 startString = ": "+incidence->dtStartStr(true); 1425 startString = ": "+incidence->dtStartStr(true);
1426 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1426 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1427 1427
1428 } 1428 }
1429 1429
1430 } else { 1430 } else {
1431 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1431 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1432 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1432 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1433 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1433 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1434 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1434 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1435 bool ok; 1435 bool ok;
1436 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1436 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1437 if ( ok ) { 1437 if ( ok ) {
1438 int years = noc.date().year() - incidence->dtStart().date().year(); 1438 int years = noc.date().year() - incidence->dtStart().date().year();
1439 startString += i18n(" (%1 y.)"). arg( years ); 1439 startString += i18n(" (%1 y.)"). arg( years );
1440 } 1440 }
1441 } 1441 }
1442 else 1442 else
1443 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1443 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1444 } 1444 }
1445 1445
1446 } 1446 }
1447 else 1447 else
1448 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1448 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1449 if ( !incidence->location().isEmpty() ) 1449 if ( !incidence->location().isEmpty() )
1450 startString += " (" +incidence->location()+")"; 1450 startString += " (" +incidence->location()+")";
1451 setCaption( incidence->summary()+startString); 1451 setCaption( incidence->summary()+startString);
1452 1452
1453 enableIncidenceActions( true ); 1453 enableIncidenceActions( true );
1454 1454
1455 if ( incidence->type() == "Event" ) { 1455 if ( incidence->type() == "Event" ) {
1456 mShowAction->setText( i18n("Show Event...") ); 1456 mShowAction->setText( i18n("Show Event...") );
1457 mEditAction->setText( i18n("Edit Event...") ); 1457 mEditAction->setText( i18n("Edit Event...") );
1458 mDeleteAction->setText( i18n("Delete Event...") ); 1458 mDeleteAction->setText( i18n("Delete Event...") );
1459 1459
1460 mNewSubTodoAction->setEnabled( false ); 1460 mNewSubTodoAction->setEnabled( false );
1461 } else if ( incidence->type() == "Todo" ) { 1461 } else if ( incidence->type() == "Todo" ) {
1462 mShowAction->setText( i18n("Show Todo...") ); 1462 mShowAction->setText( i18n("Show Todo...") );
1463 mEditAction->setText( i18n("Edit Todo...") ); 1463 mEditAction->setText( i18n("Edit Todo...") );
1464 mDeleteAction->setText( i18n("Delete Todo...") ); 1464 mDeleteAction->setText( i18n("Delete Todo...") );
1465 1465
1466 mNewSubTodoAction->setEnabled( true ); 1466 mNewSubTodoAction->setEnabled( true );
1467 } else { 1467 } else {
1468 mShowAction->setText( i18n("Show...") ); 1468 mShowAction->setText( i18n("Show...") );
1469 mShowAction->setText( i18n("Edit...") ); 1469 mShowAction->setText( i18n("Edit...") );
1470 mShowAction->setText( i18n("Delete...") ); 1470 mShowAction->setText( i18n("Delete...") );
1471 1471
1472 mNewSubTodoAction->setEnabled( false ); 1472 mNewSubTodoAction->setEnabled( false );
1473 } 1473 }
1474} 1474}
1475 1475
1476void MainWindow::enableIncidenceActions( bool enabled ) 1476void MainWindow::enableIncidenceActions( bool enabled )
1477{ 1477{
1478 mShowAction->setEnabled( enabled ); 1478 mShowAction->setEnabled( enabled );
1479 mEditAction->setEnabled( enabled ); 1479 mEditAction->setEnabled( enabled );
1480 mDeleteAction->setEnabled( enabled ); 1480 mDeleteAction->setEnabled( enabled );
1481 1481
1482 mCloneAction->setEnabled( enabled ); 1482 mCloneAction->setEnabled( enabled );
1483 mMoveAction->setEnabled( enabled ); 1483 mMoveAction->setEnabled( enabled );
1484 mBeamAction->setEnabled( enabled ); 1484 mBeamAction->setEnabled( enabled );
1485 mCancelAction->setEnabled( enabled ); 1485 mCancelAction->setEnabled( enabled );
1486} 1486}
1487 1487
1488void MainWindow::importOL() 1488void MainWindow::importOL()
1489{ 1489{
1490#ifdef _OL_IMPORT_ 1490#ifdef _OL_IMPORT_
1491 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1491 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1492 id->exec(); 1492 id->exec();
1493 delete id; 1493 delete id;
1494 mView->updateView(); 1494 mView->updateView();
1495#endif 1495#endif
1496} 1496}
1497void MainWindow::importBday() 1497void MainWindow::importBday()
1498{ 1498{
1499 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1499 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1500 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1500 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1501 i18n("Import!"), i18n("Cancel"), 0, 1501 i18n("Import!"), i18n("Cancel"), 0,
1502 0, 1 ); 1502 0, 1 );
1503 if ( result == 0 ) { 1503 if ( result == 0 ) {
1504 mView->importBday(); 1504 mView->importBday();
1505 1505
1506 } 1506 }
1507 1507
1508 1508
1509} 1509}
1510void MainWindow::importQtopia() 1510void MainWindow::importQtopia()
1511{ 1511{
1512#ifndef DESKTOP_VERSION 1512 //#ifndef DESKTOP_VERSION
1513 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1513 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");
1514 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"), 1514#ifdef DESKTOP_VERSION
1515 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");
1516#endif
1517 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1515 i18n("Import!"), i18n("Cancel"), 0, 1518 i18n("Import!"), i18n("Cancel"), 0,
1516 0, 1 ); 1519 0, 1 );
1517 if ( result == 0 ) { 1520 if ( result == 0 ) {
1521#ifndef DESKTOP_VERSION
1518 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1522 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1519 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1523 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1520 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1524 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1525#else
1526 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1527 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1528 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1529#endif
1521 mView->importQtopia( categories, datebook, todolist ); 1530 mView->importQtopia( categories, datebook, todolist );
1522 } 1531 }
1523#else 1532#if 0
1524 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1533 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1525 i18n("Not supported \non desktop!\n"), 1534 i18n("Not supported \non desktop!\n"),
1526 i18n("Ok"), i18n("Cancel"), 0, 1535 i18n("Ok"), i18n("Cancel"), 0,
1527 0, 1 ); 1536 0, 1 );
1528 1537
1529#endif 1538#endif
1530} 1539}
1531 1540
1532void MainWindow::saveOnClose() 1541void MainWindow::saveOnClose()
1533{ 1542{
1534 KOPrefs *p = KOPrefs::instance(); 1543 KOPrefs *p = KOPrefs::instance();
1535 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1544 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1536 p->mToolBarUp = iconToolBar->x() > width()/2 || 1545 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1537 iconToolBar->y() > height()/2; 1546 iconToolBar->y() > height()/2;
1538 mView->writeSettings(); 1547 mView->writeSettings();
1539 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1548 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1540 save(); 1549 save();
1541} 1550}
1542void MainWindow::slotModifiedChanged( bool changed ) 1551void MainWindow::slotModifiedChanged( bool changed )
1543{ 1552{
1544 if ( mBlockAtStartup ) 1553 if ( mBlockAtStartup )
1545 return; 1554 return;
1546 1555
1547 int msec; 1556 int msec;
1548 // we store the changes after 1 minute, 1557 // we store the changes after 1 minute,
1549 // and for safety reasons after 10 minutes again 1558 // and for safety reasons after 10 minutes again
1550 if ( !mSyncManager->blockSave() ) 1559 if ( !mSyncManager->blockSave() )
1551 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1560 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1552 else 1561 else
1553 msec = 1000 * 600; 1562 msec = 1000 * 600;
1554 mSaveTimer.start( msec, true ); // 1 minute 1563 mSaveTimer.start( msec, true ); // 1 minute
1555 qDebug("KO: Saving File in %d secs!", msec/1000); 1564 qDebug("KO: Saving File in %d secs!", msec/1000);
1556 mCalendarModifiedFlag = true; 1565 mCalendarModifiedFlag = true;
1557} 1566}
1558void MainWindow::saveStopTimer() 1567void MainWindow::saveStopTimer()
1559{ 1568{
1560 mSaveTimer.stop(); 1569 mSaveTimer.stop();
1561 if (mSaveTimer.isActive() ) 1570 if (mSaveTimer.isActive() )
1562 qDebug("ti active "); 1571 qDebug("ti active ");
1563 else 1572 else
1564 qDebug("KO: Save timer stopped"); 1573 qDebug("KO: Save timer stopped");
1565} 1574}
1566void MainWindow::save() 1575void MainWindow::save()
1567{ 1576{
1568 if ( !mCalendarModifiedFlag ) { 1577 if ( !mCalendarModifiedFlag ) {
1569 qDebug("KO: Calendar not modified. Nothing saved."); 1578 qDebug("KO: Calendar not modified. Nothing saved.");
1570 return; 1579 return;
1571 } 1580 }
1572 if ( mSyncManager->blockSave() ) 1581 if ( mSyncManager->blockSave() )
1573 return; 1582 return;
1574 mSyncManager->setBlockSave(true); 1583 mSyncManager->setBlockSave(true);
1575 if ( mView->checkFileVersion( defaultFileName()) ) { 1584 if ( mView->checkFileVersion( defaultFileName()) ) {
1576 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1585 QTime neededSaveTime = QDateTime::currentDateTime().time();
1577 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1586 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1578 qDebug("KO: Start saving data to file!"); 1587 qDebug("KO: Start saving data to file!");
1579 mView->saveCalendar( defaultFileName() ); 1588 mView->saveCalendar( defaultFileName() );
1580 mCalendarModifiedFlag = false; 1589 mCalendarModifiedFlag = false;
1581 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1590 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1582 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1591 qDebug("KO: Needed %d ms for saving.",msNeeded );
1583 QString savemes; 1592 QString savemes;
1584 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1593 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1585 setCaption(savemes); 1594 setCaption(savemes);
1586 } else 1595 } else
1587 setCaption(i18n("Saving cancelled!")); 1596 setCaption(i18n("Saving cancelled!"));
1588 mSyncManager->setBlockSave( false ); 1597 mSyncManager->setBlockSave( false );
1589} 1598}
1590 1599
1591void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1600void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1592{ 1601{
1593 if ( !e->isAutoRepeat() ) { 1602 if ( !e->isAutoRepeat() ) {
1594 mFlagKeyPressed = false; 1603 mFlagKeyPressed = false;
1595 } 1604 }
1596} 1605}
1597void MainWindow::keyPressEvent ( QKeyEvent * e ) 1606void MainWindow::keyPressEvent ( QKeyEvent * e )
1598{ 1607{
1599 qApp->processEvents(); 1608 qApp->processEvents();
1600 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1609 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1601 e->ignore(); 1610 e->ignore();
1602 // qDebug(" ignore %d",e->isAutoRepeat() ); 1611 // qDebug(" ignore %d",e->isAutoRepeat() );
1603 return; 1612 return;
1604 } 1613 }
1605 if (! e->isAutoRepeat() ) 1614 if (! e->isAutoRepeat() )
1606 mFlagKeyPressed = true; 1615 mFlagKeyPressed = true;
1607 KOPrefs *p = KOPrefs::instance(); 1616 KOPrefs *p = KOPrefs::instance();
1608 bool showSelectedDates = false; 1617 bool showSelectedDates = false;
1609 int size; 1618 int size;
1610 int pro = 0; 1619 int pro = 0;
1611 //qDebug("MainWindow::keyPressEvent "); 1620 //qDebug("MainWindow::keyPressEvent ");
1612 switch ( e->key() ) { 1621 switch ( e->key() ) {
1613 case Qt::Key_Right: 1622 case Qt::Key_Right:
1614 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1623 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1615 mView->goNextMonth(); 1624 mView->goNextMonth();
1616 else 1625 else
1617 mView->goNext(); 1626 mView->goNext();
1618 showSelectedDates = true; 1627 showSelectedDates = true;
1619 break; 1628 break;
1620 case Qt::Key_Left: 1629 case Qt::Key_Left:
1621 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1630 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1622 mView->goPreviousMonth(); 1631 mView->goPreviousMonth();
1623 else 1632 else
1624 mView->goPrevious(); 1633 mView->goPrevious();
1625 showSelectedDates = true; 1634 showSelectedDates = true;
1626 break; 1635 break;
1627 case Qt::Key_Down: 1636 case Qt::Key_Down:
1628 mView->viewManager()->agendaView()->scrollOneHourDown(); 1637 mView->viewManager()->agendaView()->scrollOneHourDown();
1629 break; 1638 break;
1630 case Qt::Key_Up: 1639 case Qt::Key_Up:
1631 mView->viewManager()->agendaView()->scrollOneHourUp(); 1640 mView->viewManager()->agendaView()->scrollOneHourUp();
1632 break; 1641 break;
1633 case Qt::Key_K: 1642 case Qt::Key_K:
1634 mView->viewManager()->showMonthViewWeek(); 1643 mView->viewManager()->showMonthViewWeek();
1635 break; 1644 break;
1636 case Qt::Key_I: 1645 case Qt::Key_I:
1637 mView->showIncidence(); 1646 mView->showIncidence();
1638 break; 1647 break;
1639 case Qt::Key_Delete: 1648 case Qt::Key_Delete:
1640 case Qt::Key_Backspace: 1649 case Qt::Key_Backspace:
1641 mView->deleteIncidence(); 1650 mView->deleteIncidence();
1642 break; 1651 break;
1643 case Qt::Key_D: 1652 case Qt::Key_D:
1644 mView->viewManager()->showDayView(); 1653 mView->viewManager()->showDayView();
1645 showSelectedDates = true; 1654 showSelectedDates = true;
1646 break; 1655 break;
1647 case Qt::Key_O: 1656 case Qt::Key_O:
1648 mView->toggleFilerEnabled( ); 1657 mView->toggleFilerEnabled( );
1649 break; 1658 break;
1650 case Qt::Key_0: 1659 case Qt::Key_0:
1651 case Qt::Key_1: 1660 case Qt::Key_1:
1652 case Qt::Key_2: 1661 case Qt::Key_2:
1653 case Qt::Key_3: 1662 case Qt::Key_3:
1654 case Qt::Key_4: 1663 case Qt::Key_4:
1655 case Qt::Key_5: 1664 case Qt::Key_5:
1656 case Qt::Key_6: 1665 case Qt::Key_6:
1657 case Qt::Key_7: 1666 case Qt::Key_7:
1658 case Qt::Key_8: 1667 case Qt::Key_8:
1659 case Qt::Key_9: 1668 case Qt::Key_9:
1660 pro = e->key()-48; 1669 pro = e->key()-48;
1661 if ( pro == 0 ) 1670 if ( pro == 0 )
1662 pro = 10; 1671 pro = 10;
1663 if ( e->state() == Qt::ControlButton) 1672 if ( e->state() == Qt::ControlButton)
1664 pro += 10; 1673 pro += 10;
1665 break; 1674 break;
1666 case Qt::Key_M: 1675 case Qt::Key_M:
1667 mView->viewManager()->showMonthView(); 1676 mView->viewManager()->showMonthView();
1668 showSelectedDates = true; 1677 showSelectedDates = true;
1669 break; 1678 break;
1670 case Qt::Key_Insert: 1679 case Qt::Key_Insert:
1671 mView->newEvent(); 1680 mView->newEvent();
1672 break; 1681 break;
1673 case Qt::Key_S : 1682 case Qt::Key_S :
1674 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1683 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1675 mView->newSubTodo(); 1684 mView->newSubTodo();
1676 else 1685 else
1677 mView->dialogManager()->showSearchDialog(); 1686 mView->dialogManager()->showSearchDialog();
1678 break; 1687 break;
1679 case Qt::Key_Y : 1688 case Qt::Key_Y :
1680 case Qt::Key_Z : 1689 case Qt::Key_Z :
1681 mView->viewManager()->showWorkWeekView(); 1690 mView->viewManager()->showWorkWeekView();
1682 showSelectedDates = true; 1691 showSelectedDates = true;
1683 break; 1692 break;
1684 case Qt::Key_U : 1693 case Qt::Key_U :
1685 mView->viewManager()->showWeekView(); 1694 mView->viewManager()->showWeekView();
1686 showSelectedDates = true; 1695 showSelectedDates = true;
1687 break; 1696 break;
1688 case Qt::Key_H : 1697 case Qt::Key_H :
1689 keyBindings(); 1698 keyBindings();
1690 break; 1699 break;
1691 case Qt::Key_W: 1700 case Qt::Key_W:
1692 mView->viewManager()->showWhatsNextView(); 1701 mView->viewManager()->showWhatsNextView();
1693 break; 1702 break;
1694 case Qt::Key_L: 1703 case Qt::Key_L:
1695 mView->viewManager()->showListView(); 1704 mView->viewManager()->showListView();
1696 break; 1705 break;
1697 case Qt::Key_N: 1706 case Qt::Key_N:
1698 mView->viewManager()->showNextXView(); 1707 mView->viewManager()->showNextXView();
1699 showSelectedDates = true; 1708 showSelectedDates = true;
1700 break; 1709 break;
1701 case Qt::Key_V: 1710 case Qt::Key_V:
1702 mView->viewManager()->showTodoView(); 1711 mView->viewManager()->showTodoView();
1703 break; 1712 break;
1704 case Qt::Key_C: 1713 case Qt::Key_C:
1705 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1714 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1706 break; 1715 break;
1707 case Qt::Key_P: 1716 case Qt::Key_P:
1708 mView->showDatePicker( ); 1717 mView->showDatePicker( );
1709 break; 1718 break;
1710 case Qt::Key_F: 1719 case Qt::Key_F:
1711 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1720 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1712 mView->editFilters(); 1721 mView->editFilters();
1713 else 1722 else
1714 mView->toggleFilter(); 1723 mView->toggleFilter();
1715 break; 1724 break;
1716 case Qt::Key_X: 1725 case Qt::Key_X:
1717 mView->toggleDateNavigatorWidget(); 1726 mView->toggleDateNavigatorWidget();
1718 break; 1727 break;
1719 case Qt::Key_Space: 1728 case Qt::Key_Space:
1720 mView->toggleExpand(); 1729 mView->toggleExpand();
1721 break; 1730 break;
1722 case Qt::Key_A: 1731 case Qt::Key_A:
1723 mView->toggleAllDaySize(); 1732 mView->toggleAllDaySize();
1724 break; 1733 break;
1725 case Qt::Key_T: 1734 case Qt::Key_T:
1726 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1735 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1727 mView->newTodo(); 1736 mView->newTodo();
1728 else { 1737 else {
1729 mView->goToday(); 1738 mView->goToday();
1730 showSelectedDates = true; 1739 showSelectedDates = true;
1731 } 1740 }
1732 break; 1741 break;
1733 case Qt::Key_J: 1742 case Qt::Key_J:
1734 mView->viewManager()->showJournalView(); 1743 mView->viewManager()->showJournalView();
1735 break; 1744 break;
1736 case Qt::Key_B: 1745 case Qt::Key_B:
1737 mView->editIncidenceDescription();; 1746 mView->editIncidenceDescription();;
1738 break; 1747 break;
1739 // case Qt::Key_Return: 1748 // case Qt::Key_Return:
1740 case Qt::Key_E: 1749 case Qt::Key_E:
1741 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1750 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1742 mView->newEvent(); 1751 mView->newEvent();
1743 else 1752 else
1744 mView->editIncidence(); 1753 mView->editIncidence();
1745 break; 1754 break;
1746 case Qt::Key_Plus: 1755 case Qt::Key_Plus:
1747 size = p->mHourSize +2; 1756 size = p->mHourSize +2;
1748 if ( size <= 22 ) 1757 if ( size <= 22 )
1749 configureAgenda( size ); 1758 configureAgenda( size );
1750 break; 1759 break;
1751 case Qt::Key_Minus: 1760 case Qt::Key_Minus:
1752 size = p->mHourSize - 2; 1761 size = p->mHourSize - 2;
1753 if ( size >= 4 ) 1762 if ( size >= 4 )
1754 configureAgenda( size ); 1763 configureAgenda( size );
1755 break; 1764 break;
1756 1765
1757 1766
1758 default: 1767 default:
1759 e->ignore(); 1768 e->ignore();
1760 } 1769 }
1761 if ( pro > 0 ) { 1770 if ( pro > 0 ) {
1762 mView->selectFilter( pro-1 ); 1771 mView->selectFilter( pro-1 );
1763 } 1772 }
1764 if ( showSelectedDates ) { 1773 if ( showSelectedDates ) {
1765 ;// setCaptionToDates(); 1774 ;// setCaptionToDates();
1766 } 1775 }
1767 1776
1768} 1777}
1769 1778
1770void MainWindow::fillFilterMenu() 1779void MainWindow::fillFilterMenu()
1771{ 1780{
1772 selectFilterMenu->clear(); 1781 selectFilterMenu->clear();
1773 bool disable = false; 1782 bool disable = false;
1774 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1783 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1775 selectFilterMenu->insertSeparator(); 1784 selectFilterMenu->insertSeparator();
1776 if ( mView->filterView()->filtersEnabled() ) { 1785 if ( mView->filterView()->filtersEnabled() ) {
1777 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1786 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1778 } 1787 }
1779 else { 1788 else {
1780 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1789 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1781 disable = true; 1790 disable = true;
1782 } 1791 }
1783 selectFilterMenu->insertSeparator(); 1792 selectFilterMenu->insertSeparator();
1784 QPtrList<CalFilter> fili = mView->filters(); 1793 QPtrList<CalFilter> fili = mView->filters();
1785 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1794 CalFilter *curfilter = mView->filterView()->selectedFilter();
1786 CalFilter *filter = fili.first(); 1795 CalFilter *filter = fili.first();
1787 int iii = 2; 1796 int iii = 2;
1788 while(filter) { 1797 while(filter) {
1789 selectFilterMenu->insertItem( filter->name(), iii ); 1798 selectFilterMenu->insertItem( filter->name(), iii );
1790 if ( filter == curfilter) 1799 if ( filter == curfilter)
1791 selectFilterMenu->setItemChecked( iii, true ); 1800 selectFilterMenu->setItemChecked( iii, true );
1792 if ( disable ) 1801 if ( disable )
1793 selectFilterMenu->setItemEnabled( iii, false ); 1802 selectFilterMenu->setItemEnabled( iii, false );
1794 filter = fili.next(); 1803 filter = fili.next();
1795 ++iii; 1804 ++iii;
1796 } 1805 }
1797} 1806}
1798void MainWindow::selectFilter( int fil ) 1807void MainWindow::selectFilter( int fil )
1799{ 1808{
1800 if ( fil == 0 ) { 1809 if ( fil == 0 ) {
1801 mView->editFilters( ); 1810 mView->editFilters( );
1802 } else if ( fil == 1 ){ 1811 } else if ( fil == 1 ){
1803 mView->toggleFilerEnabled( ); 1812 mView->toggleFilerEnabled( );
1804 } else { 1813 } else {
1805 mView->selectFilter( fil-2 ); 1814 mView->selectFilter( fil-2 );
1806 } 1815 }
1807} 1816}
1808void MainWindow::configureToolBar( int item ) 1817void MainWindow::configureToolBar( int item )
1809{ 1818{
1810 1819
1811 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1820 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1812 KOPrefs *p = KOPrefs::instance(); 1821 KOPrefs *p = KOPrefs::instance();
1813 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1822 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1814 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1823 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1815 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1824 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1816 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1825 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1817 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1826 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1818 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1827 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1819 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1828 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1820 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 1829 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
1821 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1830 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1822 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1831 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1823 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1832 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1824 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1833 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1825 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1834 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1826 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1835 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1827 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1836 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1828 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1837 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1829 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1838 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1830 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1839 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1831 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1840 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1832 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1841 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1833 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 1842 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
1834 // initActions(); 1843 // initActions();
1835} 1844}
1836 1845
1837void MainWindow::setCaptionToDates() 1846void MainWindow::setCaptionToDates()
1838{ 1847{
1839 QString selDates; 1848 QString selDates;
1840 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1849 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1841 if (mView->startDate() < mView->endDate() ) 1850 if (mView->startDate() < mView->endDate() )
1842 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1851 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1843 else { 1852 else {
1844 QString addString; 1853 QString addString;
1845 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1854 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1846 addString = i18n("Today"); 1855 addString = i18n("Today");
1847 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1856 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1848 addString = i18n("Tomorrow"); 1857 addString = i18n("Tomorrow");
1849 if ( !addString.isEmpty() ) 1858 if ( !addString.isEmpty() )
1850 selDates = addString+", "+selDates ; 1859 selDates = addString+", "+selDates ;
1851 } 1860 }
1852 setCaption( i18n("Dates: ") + selDates ); 1861 setCaption( i18n("Dates: ") + selDates );
1853 1862
1854} 1863}
1855void MainWindow::showConfigureAgenda( ) 1864void MainWindow::showConfigureAgenda( )
1856{ 1865{
1857 int iii; 1866 int iii;
1858 for ( iii = 1;iii<= 10 ;++iii ){ 1867 for ( iii = 1;iii<= 10 ;++iii ){
1859 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1868 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1860 } 1869 }
1861 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1870 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1862} 1871}
1863void MainWindow::configureAgenda( int item ) 1872void MainWindow::configureAgenda( int item )
1864{ 1873{
1865 if ( KOPrefs::instance()->mHourSize == item ) 1874 if ( KOPrefs::instance()->mHourSize == item )
1866 return; 1875 return;
1867 KOPrefs::instance()->mHourSize=item; 1876 KOPrefs::instance()->mHourSize=item;
1868 mView->viewManager()->agendaView()->updateConfig(); 1877 mView->viewManager()->agendaView()->updateConfig();
1869} 1878}
1870 1879
1871void MainWindow::saveCalendar() 1880void MainWindow::saveCalendar()
1872{ 1881{
1873 QString fn = KOPrefs::instance()->mLastSaveFile; 1882 QString fn = KOPrefs::instance()->mLastSaveFile;
1874 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1883 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1875 1884
1876 if ( fn == "" ) 1885 if ( fn == "" )
1877 return; 1886 return;
1878 QFileInfo info; 1887 QFileInfo info;
1879 info.setFile( fn ); 1888 info.setFile( fn );
1880 QString mes; 1889 QString mes;
1881 bool createbup = true; 1890 bool createbup = true;
1882 if ( info. exists() ) { 1891 if ( info. exists() ) {
1883 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1892 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1884 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1893 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1885 i18n("Overwrite!"), i18n("Cancel"), 0, 1894 i18n("Overwrite!"), i18n("Cancel"), 0,
1886 0, 1 ); 1895 0, 1 );
1887 if ( result != 0 ) { 1896 if ( result != 0 ) {
1888 createbup = false; 1897 createbup = false;
1889 } 1898 }
1890 } 1899 }
1891 if ( createbup ) { 1900 if ( createbup ) {
1892 mView->saveCalendar( fn ); 1901 mView->saveCalendar( fn );
1893 mes = i18n("KO/Pi:Saved %1").arg(fn); 1902 mes = i18n("KO/Pi:Saved %1").arg(fn);
1894 KOPrefs::instance()->mLastSaveFile = fn; 1903 KOPrefs::instance()->mLastSaveFile = fn;
1895 setCaption(mes); 1904 setCaption(mes);
1896 } 1905 }
1897} 1906}
1898void MainWindow::loadCalendar() 1907void MainWindow::loadCalendar()
1899{ 1908{
1900 1909
1901 QString fn = KOPrefs::instance()->mLastLoadFile; 1910 QString fn = KOPrefs::instance()->mLastLoadFile;
1902 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1911 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1903 1912
1904 if ( fn == "" ) 1913 if ( fn == "" )
1905 return; 1914 return;
1906 QFileInfo info; 1915 QFileInfo info;
1907 info.setFile( fn ); 1916 info.setFile( fn );
1908 QString mess; 1917 QString mess;
1909 bool loadbup = true; 1918 bool loadbup = true;
1910 if ( info. exists() ) { 1919 if ( info. exists() ) {
1911 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1920 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1912 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1921 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1913 mess, 1922 mess,
1914 i18n("Load!"), i18n("Cancel"), 0, 1923 i18n("Load!"), i18n("Cancel"), 0,
1915 0, 1 ); 1924 0, 1 );
1916 if ( result != 0 ) { 1925 if ( result != 0 ) {
1917 loadbup = false; 1926 loadbup = false;
1918 } 1927 }
1919 } else { 1928 } else {
1920 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1929 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1921 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1930 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1922 0, 1 ); 1931 0, 1 );
1923 1932
1924 return; 1933 return;
1925 } 1934 }
1926 if ( loadbup ) { 1935 if ( loadbup ) {
1927 mView->openCalendar( fn ); 1936 mView->openCalendar( fn );
1928 KOPrefs::instance()->mLastLoadFile = fn; 1937 KOPrefs::instance()->mLastLoadFile = fn;
1929 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1938 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1930 setCaption(mess); 1939 setCaption(mess);
1931 } 1940 }
1932 1941
1933} 1942}
1934void MainWindow::quickImportIcal() 1943void MainWindow::quickImportIcal()
1935{ 1944{
1936 importFile( KOPrefs::instance()->mLastImportFile, false ); 1945 importFile( KOPrefs::instance()->mLastImportFile, false );
1937} 1946}
1938void MainWindow::importFile( QString fn, bool quick ) 1947void MainWindow::importFile( QString fn, bool quick )
1939{ 1948{
1940 QFileInfo info; 1949 QFileInfo info;
1941 info.setFile( fn ); 1950 info.setFile( fn );
1942 QString mess; 1951 QString mess;
1943 bool loadbup = true; 1952 bool loadbup = true;
1944 if ( !info. exists() ) { 1953 if ( !info. exists() ) {
1945 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1954 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1946 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1955 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1947 mess ); 1956 mess );
1948 return; 1957 return;
1949 } 1958 }
1950 int result = 0; 1959 int result = 0;
1951 if ( !quick ) { 1960 if ( !quick ) {
1952 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 )); 1961 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 ));
1953 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1962 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1954 mess, 1963 mess,
1955 "Import", "Cancel", 0, 1964 "Import", "Cancel", 0,
1956 0, 1 ); 1965 0, 1 );
1957 } 1966 }
1958 if ( result == 0 ) { 1967 if ( result == 0 ) {
1959 if ( mView->openCalendar( fn, true )) { 1968 if ( mView->openCalendar( fn, true )) {
1960 KOPrefs::instance()->mLastImportFile = fn; 1969 KOPrefs::instance()->mLastImportFile = fn;
1961 setCaption(i18n("Imported file successfully")); 1970 setCaption(i18n("Imported file successfully"));
1962 } else { 1971 } else {
1963 setCaption(i18n("Error importing file")); 1972 setCaption(i18n("Error importing file"));
1964 } 1973 }
1965 } 1974 }
1966} 1975}
1967 1976
1968void MainWindow::importIcal() 1977void MainWindow::importIcal()
1969{ 1978{
1970 1979
1971 QString fn =KOPrefs::instance()->mLastImportFile; 1980 QString fn =KOPrefs::instance()->mLastImportFile;
1972 1981
1973 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1982 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1974 if ( fn == "" ) 1983 if ( fn == "" )
1975 return; 1984 return;
1976 importFile( fn, true ); 1985 importFile( fn, true );
1977 1986
1978} 1987}
1979 1988
1980void MainWindow::exportVCalendar() 1989void MainWindow::exportVCalendar()
1981{ 1990{
1982 QString fn = KOPrefs::instance()->mLastVcalFile; 1991 QString fn = KOPrefs::instance()->mLastVcalFile;
1983 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1992 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1984 if ( fn == "" ) 1993 if ( fn == "" )
1985 return; 1994 return;
1986 QFileInfo info; 1995 QFileInfo info;
1987 info.setFile( fn ); 1996 info.setFile( fn );
1988 QString mes; 1997 QString mes;
1989 bool createbup = true; 1998 bool createbup = true;
1990 if ( info. exists() ) { 1999 if ( info. exists() ) {
1991 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2000 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1992 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2001 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1993 i18n("Overwrite!"), i18n("Cancel"), 0, 2002 i18n("Overwrite!"), i18n("Cancel"), 0,
1994 0, 1 ); 2003 0, 1 );
1995 if ( result != 0 ) { 2004 if ( result != 0 ) {
1996 createbup = false; 2005 createbup = false;
1997 } 2006 }
1998 } 2007 }
1999 if ( createbup ) { 2008 if ( createbup ) {
2000 if ( mView->exportVCalendar( fn ) ) { 2009 if ( mView->exportVCalendar( fn ) ) {
2001 KOPrefs::instance()->mLastVcalFile = fn; 2010 KOPrefs::instance()->mLastVcalFile = fn;
2002 if ( fn.length() > 20 ) 2011 if ( fn.length() > 20 )
2003 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2012 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2004 else 2013 else
2005 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2014 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2006 setCaption(mes); 2015 setCaption(mes);
2007 } 2016 }
2008 } 2017 }
2009 2018
2010} 2019}
2011QString MainWindow::sentSyncFile() 2020QString MainWindow::sentSyncFile()
2012{ 2021{
2013#ifdef DESKTOP_VERSION 2022#ifdef DESKTOP_VERSION
2014 return locateLocal( "tmp", "copysynccal.ics" ); 2023 return locateLocal( "tmp", "copysynccal.ics" );
2015#else 2024#else
2016 return QString( "/tmp/copysynccal.ics" ); 2025 return QString( "/tmp/copysynccal.ics" );
2017#endif 2026#endif
2018} 2027}
2019 2028
2020void MainWindow::syncFileRequest() 2029void MainWindow::syncFileRequest()
2021{ 2030{
2022 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2031 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2023 mSyncManager->slotSyncMenu( 999 ); 2032 mSyncManager->slotSyncMenu( 999 );
2024 } 2033 }
2025 2034
2026 setCaption(i18n("Saving Data to temp file ..." )); 2035 setCaption(i18n("Saving Data to temp file ..." ));
2027 mView->saveCalendar( sentSyncFile() ); 2036 mView->saveCalendar( sentSyncFile() );
2028 setCaption(i18n("Data saved to temp file!" )); 2037 setCaption(i18n("Data saved to temp file!" ));
2029 2038
2030} 2039}
2031void MainWindow::getFile( bool success ) 2040void MainWindow::getFile( bool success )
2032{ 2041{
2033 if ( ! success ) { 2042 if ( ! success ) {
2034 setCaption( i18n("Error receiving file. Nothing changed!") ); 2043 setCaption( i18n("Error receiving file. Nothing changed!") );
2035 return; 2044 return;
2036 } 2045 }
2037 mView->openCalendar( sentSyncFile() ); 2046 mView->openCalendar( sentSyncFile() );
2038 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2047 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2039 mSyncManager->slotSyncMenu( 999 ); 2048 mSyncManager->slotSyncMenu( 999 );
2040 } 2049 }
2041 setCaption( i18n("Pi-Sync successful!") ); 2050 setCaption( i18n("Pi-Sync successful!") );
2042} 2051}
2043 2052
2044void MainWindow::printSel( ) 2053void MainWindow::printSel( )
2045{ 2054{
2046 mView->viewManager()->agendaView()->agenda()->printSelection(); 2055 mView->viewManager()->agendaView()->agenda()->printSelection();
2047} 2056}
2048 2057
2049void MainWindow::printCal() 2058void MainWindow::printCal()
2050{ 2059{
2051 mView->print();//mCp->showDialog(); 2060 mView->print();//mCp->showDialog();
2052} 2061}
2053 2062
2054 2063
2055#include "libkdepim/kdatepicker.h" 2064#include "libkdepim/kdatepicker.h"
2056#include <kdatetbl.h> 2065#include <kdatetbl.h>
2057void MainWindow::weekAction() 2066void MainWindow::weekAction()
2058{ 2067{
2059 int month; 2068 int month;
2060 KPopupFrame* popup = new KPopupFrame(this); 2069 KPopupFrame* popup = new KPopupFrame(this);
2061 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2070 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2062 // ----- 2071 // -----
2063 picker->resize(picker->sizeHint()); 2072 picker->resize(picker->sizeHint());
2064 popup->setMainWidget(picker); 2073 popup->setMainWidget(picker);
2065 picker->setFocus(); 2074 picker->setFocus();
2066 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2075 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2067 int x = 0; 2076 int x = 0;
2068 int y = iconToolBar->height(); 2077 int y = iconToolBar->height();
2069 int dX = 0; 2078 int dX = 0;
2070 int dY = 0; 2079 int dY = 0;
2071 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2080 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2072 if ( iconToolBar->y() > height()/2 ) { 2081 if ( iconToolBar->y() > height()/2 ) {
2073 dY = picker->sizeHint().height()+8; 2082 dY = picker->sizeHint().height()+8;
2074 y = 0; 2083 y = 0;
2075 } 2084 }
2076 } else { 2085 } else {
2077 if ( iconToolBar->x() > width()/2 ) { // right side 2086 if ( iconToolBar->x() > width()/2 ) { // right side
2078 x=0; 2087 x=0;
2079 dX= picker->sizeHint().width()+8; 2088 dX= picker->sizeHint().width()+8;
2080 y = 0; 2089 y = 0;
2081 } else { 2090 } else {
2082 x= iconToolBar->width(); 2091 x= iconToolBar->width();
2083 y = 0; 2092 y = 0;
2084 } 2093 }
2085 } 2094 }
2086 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2095 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2087 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2096 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2088 { 2097 {
2089 month = picker->getResult(); 2098 month = picker->getResult();
2090 emit selectWeek ( month ); 2099 emit selectWeek ( month );
2091 //qDebug("weekSelected %d ", month); 2100 //qDebug("weekSelected %d ", month);
2092 } 2101 }
2093 delete popup; 2102 delete popup;
2094} 2103}