summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-28 23:39:37 (UTC)
committer zautrix <zautrix>2005-03-28 23:39:37 (UTC)
commit4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (unidiff)
tree6815e055d6cb35d56d43f036261f5be9d2a9c350 /korganizer
parent4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff)
downloadkdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2
montview sunday fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp18
-rw-r--r--korganizer/komonthview.cpp25
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/mainwindow.cpp28
4 files changed, 24 insertions, 49 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 38bddc2..2fca49e 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -69,402 +69,400 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
74 74
75 // get the day of the week on the first day 75 // get the day of the week on the first day
76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
77 m_fstDayOfWk = dayone.dayOfWeek(); 77 m_fstDayOfWk = dayone.dayOfWeek();
78 78
79 int i; 79 int i;
80 80
81 // Set up the heading fields. 81 // Set up the heading fields.
82 for( i = 0; i < 7; i++ ) { 82 for( i = 0; i < 7; i++ ) {
83 headings[i] = new QLabel("",this); 83 headings[i] = new QLabel("",this);
84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
85 headings[i]->setAlignment(AlignCenter); 85 headings[i]->setAlignment(AlignCenter);
86 headings[i]->installEventFilter(this); 86 headings[i]->installEventFilter(this);
87 87
88 topLayout->addWidget(headings[i],1,i+1); 88 topLayout->addWidget(headings[i],1,i+1);
89 } 89 }
90 90
91 // Create the weeknumber labels 91 // Create the weeknumber labels
92 for( i = 0; i < 6; i++ ) { 92 for( i = 0; i < 6; i++ ) {
93 weeknos[i] = new QLabel(this); 93 weeknos[i] = new QLabel(this);
94 weeknos[i]->setAlignment(AlignCenter); 94 weeknos[i]->setAlignment(AlignCenter);
95 //weeknos[i]->setFont(QFont("Arial", 10)); 95 //weeknos[i]->setFont(QFont("Arial", 10));
96 if(!m_bShowWeekNums) { 96 if(!m_bShowWeekNums) {
97 weeknos[i]->hide(); 97 weeknos[i]->hide();
98 } 98 }
99 weeknos[i]->installEventFilter(this); 99 weeknos[i]->installEventFilter(this);
100 100
101 topLayout->addWidget(weeknos[i],i+2,0); 101 topLayout->addWidget(weeknos[i],i+2,0);
102 } 102 }
103 103
104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
106 daymatrix->setLineWidth(1); 106 daymatrix->setLineWidth(1);
107 107
108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
109 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 109 SIGNAL( datesSelected( const KCal::DateList & ) ) );
110 110
111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
112 SIGNAL( eventDropped( Event * ) ) ); 112 SIGNAL( eventDropped( Event * ) ) );
113 113
114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
115 115
116 // read settings from configuration file. 116 // read settings from configuration file.
117 updateConfig(); 117 updateConfig();
118 enableRollover(FollowMonth); 118 enableRollover(FollowMonth);
119 mySizeHint = sizeHintTwoButtons(); 119 mySizeHint = sizeHintTwoButtons();
120 myFullSizeHint = sizeHintTwoButtons( 4 ); 120 myFullSizeHint = sizeHintTwoButtons( 4 );
121 mFontChanged = false; 121 mFontChanged = false;
122 //resize ( 3,3 ); 122 //resize ( 3,3 );
123 123
124} 124}
125void KDateNavigator::changeFont ( QFont fo ) 125void KDateNavigator::changeFont ( QFont fo )
126{ 126{
127 setFont( fo ); 127 setFont( fo );
128 mNavigatorBar->resetFont( fo ); 128 mNavigatorBar->resetFont( fo );
129} 129}
130QFont KDateNavigator::yourFontHint( QSize si , bool *b) 130QFont KDateNavigator::yourFontHint( QSize si , bool *b)
131{ 131{
132 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 132 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
133 *b = false; 133 *b = false;
134 int fontPoint = fo.pointSize(); 134 int fontPoint = fo.pointSize();
135 while ( fontPoint > 5 ) { 135 while ( fontPoint > 5 ) {
136 --fontPoint; 136 --fontPoint;
137 fo.setPointSize( fontPoint ); 137 fo.setPointSize( fontPoint );
138 setFont( fo ); 138 setFont( fo );
139 mFontChanged = true; 139 mFontChanged = true;
140 mNavigatorBar->resetFont( fo ); 140 mNavigatorBar->resetFont( fo );
141 QSize sh = sizeHintTwoButtons( 2 ); 141 QSize sh = sizeHintTwoButtons( 2 );
142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
143 if ( si.width() > sh.width() && si.height() > sh.height()) { 143 if ( si.width() > sh.width() && si.height() > sh.height()) {
144 if ( si.width() / sh.width() == 1 ) { 144 if ( si.width() / sh.width() == 1 ) {
145 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 145 if ( si.width() < sizeHintTwoButtons( 4 ).width())
146 continue; 146 continue;
147 } 147 }
148 *b = true; 148 *b = true;
149 //qDebug("fooooooooooooooooooooooouuuuund "); 149 //qDebug("fooooooooooooooooooooooouuuuund ");
150 break; 150 break;
151 } 151 }
152 } 152 }
153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
154 return fo; 154 return fo;
155} 155}
156QSize KDateNavigator::sizeHint() const 156QSize KDateNavigator::sizeHint() const
157{ 157{
158 QFontMetrics fm ( font() ); 158 QFontMetrics fm ( font() );
159 QSize day = daymatrix->sizeHint(); 159 QSize day = daymatrix->sizeHint();
160 QSize nav = mNavigatorBar->sizeHint(); 160 QSize nav = mNavigatorBar->sizeHint();
161 int wid = fm.width( "30") + day.width()+3; 161 int wid = fm.width( "30") + day.width()+3;
162 int hei = fm.height() +day.height()+nav.height()+2; 162 int hei = fm.height() +day.height()+nav.height()+2;
163 if ( wid < nav.width() ) 163 if ( wid < nav.width() )
164 wid = nav.width() ; 164 wid = nav.width() ;
165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
166 return QSize ( wid, hei ); 166 return QSize ( wid, hei );
167} 167}
168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const 168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
169{ 169{
170 QFontMetrics fm ( font() ); 170 QFontMetrics fm ( font() );
171 QSize day = daymatrix->sizeHint(); 171 QSize day = daymatrix->sizeHint();
172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); 172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
173 int wid = fm.width( "30") + day.width()+3; 173 int wid = fm.width( "30") + day.width()+3;
174 int hei = fm.height() +day.height()+nav.height()+2; 174 int hei = fm.height() +day.height()+nav.height()+2;
175 if ( wid < nav.width() ) 175 if ( wid < nav.width() )
176 wid = nav.width() ; 176 wid = nav.width() ;
177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
178 return QSize ( wid, hei ); 178 return QSize ( wid, hei );
179} 179}
180void KDateNavigator::slotMonthSelected( int m ) 180void KDateNavigator::slotMonthSelected( int m )
181{ 181{
182 if ( m_MthYr.month() <= mMonthSignalOffset) 182 if ( m_MthYr.month() <= mMonthSignalOffset)
183 m += 12; 183 m += 12;
184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
185 emit monthSelected( m - mMonthSignalOffset ); 185 emit monthSelected( m - mMonthSignalOffset );
186 186
187} 187}
188void KDateNavigator::setCalendar( Calendar *cal ) 188void KDateNavigator::setCalendar( Calendar *cal )
189{ 189{
190 daymatrix->setCalendar( cal ); 190 daymatrix->setCalendar( cal );
191} 191}
192 192
193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
194{ 194{
195 m_MthYr = date; 195 m_MthYr = date;
196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); 196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
197 197
198 updateDates(); 198 updateDates();
199 updateView(); 199 updateView();
200 200
201 KCal::DateList dates; 201 KCal::DateList dates;
202 dates.append( date ); 202 dates.append( date );
203 mNavigatorBar->selectDates( dates ); 203 mNavigatorBar->selectDates( dates );
204 204
205 daymatrix->clearSelection(); 205 daymatrix->clearSelection();
206 if ( doRepaint ) 206 if ( doRepaint )
207 daymatrix->repaint( false ); 207 daymatrix->repaint( false );
208} 208}
209 209
210void KDateNavigator::enableRollover(RolloverType r) 210void KDateNavigator::enableRollover(RolloverType r)
211{ 211{
212 switch(r) 212 switch(r)
213 { 213 {
214 case None : 214 case None :
215 if (updateTimer) 215 if (updateTimer)
216 { 216 {
217 updateTimer->stop(); 217 updateTimer->stop();
218 delete updateTimer; 218 delete updateTimer;
219 updateTimer=0L; 219 updateTimer=0L;
220 } 220 }
221 break; 221 break;
222 case FollowDay : 222 case FollowDay :
223 case FollowMonth : 223 case FollowMonth :
224 if (!updateTimer) 224 if (!updateTimer)
225 { 225 {
226 updateTimer = new QTimer(this); 226 updateTimer = new QTimer(this);
227 QObject::connect(updateTimer,SIGNAL(timeout()), 227 QObject::connect(updateTimer,SIGNAL(timeout()),
228 this,SLOT(possiblyPastMidnight())); 228 this,SLOT(possiblyPastMidnight()));
229 } 229 }
230 updateTimer->start(0,true); 230 updateTimer->start(0,true);
231 lastDayChecked = QDate::currentDate(); 231 lastDayChecked = QDate::currentDate();
232 } 232 }
233 updateRollover=r; 233 updateRollover=r;
234} 234}
235 235
236 236
237KDateNavigator::~KDateNavigator() 237KDateNavigator::~KDateNavigator()
238{ 238{
239} 239}
240 240
241 241
242void KDateNavigator::passedMidnight() 242void KDateNavigator::passedMidnight()
243{ 243{
244 QDate today = QDate::currentDate(); 244 QDate today = QDate::currentDate();
245 bool emitMonth = false; 245 bool emitMonth = false;
246 246
247 if (today.month() != lastDayChecked.month()) 247 if (today.month() != lastDayChecked.month())
248 { 248 {
249 if (updateRollover==FollowMonth && 249 if (updateRollover==FollowMonth &&
250 daymatrix->isEndOfMonth()) { 250 daymatrix->isEndOfMonth()) {
251 goNextMonth(); 251 goNextMonth();
252 emitMonth=true; 252 emitMonth=true;
253 } 253 }
254 } 254 }
255 daymatrix->recalculateToday(); 255 daymatrix->recalculateToday();
256 daymatrix->repaint( false ); 256 daymatrix->repaint( false );
257 emit dayPassed(today); 257 emit dayPassed(today);
258 if (emitMonth) { emit monthPassed(today); } 258 if (emitMonth) { emit monthPassed(today); }
259} 259}
260 260
261/* slot */ void KDateNavigator::possiblyPastMidnight() 261/* slot */ void KDateNavigator::possiblyPastMidnight()
262{ 262{
263 if (lastDayChecked!=QDate::currentDate()) 263 if (lastDayChecked!=QDate::currentDate())
264 { 264 {
265 passedMidnight(); 265 passedMidnight();
266 lastDayChecked=QDate::currentDate(); 266 lastDayChecked=QDate::currentDate();
267 } 267 }
268 // Set the timer to go off 1 second after midnight 268 // Set the timer to go off 1 second after midnight
269 // or after 8 minutes, whichever comes first. 269 // or after 8 minutes, whichever comes first.
270 if (updateTimer) 270 if (updateTimer)
271 { 271 {
272 QTime now = QTime::currentTime(); 272 QTime now = QTime::currentTime();
273 QTime midnight = QTime(23,59,59); 273 QTime midnight = QTime(23,59,59);
274 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 274 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
275 275
276 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 276 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
277 //.arg(now.toString()).arg(midnight.toString())); 277 //.arg(now.toString()).arg(midnight.toString()));
278 278
279 updateTimer->stop(); 279 updateTimer->stop();
280 updateTimer->start(msecsWait,true); 280 updateTimer->start(msecsWait,true);
281 } 281 }
282} 282}
283 283
284void KDateNavigator::updateDates() 284void KDateNavigator::updateDates()
285{ 285{
286 // Find the first day of the week of the current month. 286 // Find the first day of the week of the current month.
287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
290 //int di = d1 - d2 + 1; 290 //int di = d1 - d2 + 1;
291 dayone = dayone.addDays( -d2 + 1 ); 291 dayone = dayone.addDays( -d2 + 1 );
292 292
293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
294 294
295 // If month begins on Monday and Monday is first day of week, 295 // If month begins on Monday and Monday is first day of week,
296 // month should begin on second line. Sunday doesn't have this problem. 296 // month should begin on second line. Sunday doesn't have this problem.
297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
299 299
300 // update the matrix dates 300 // update the matrix dates
301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
302 302
303 303
304 daymatrix->updateView(dayone.addDays(index)); 304 daymatrix->updateView(dayone.addDays(index));
305//each updateDates is followed by an updateView -> repaint is issued there ! 305//each updateDates is followed by an updateView -> repaint is issued there !
306// daymatrix->repaint(); 306// daymatrix->repaint();
307} 307}
308 308
309void KDateNavigator::updateDayMatrix() 309void KDateNavigator::updateDayMatrix()
310{ 310{
311 daymatrix->updateView(); 311 daymatrix->updateView();
312 //daymatrix->repaint(); 312 //daymatrix->repaint();
313} 313}
314 314
315 315
316void KDateNavigator::updateView() 316void KDateNavigator::updateView()
317{ 317{
318 318
319 setUpdatesEnabled( false ); 319 setUpdatesEnabled( false );
320 320
321 int i; 321 int i;
322 322
323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
324 daymatrix->updateView(); 324 daymatrix->updateView();
325 325 int sub = 4;
326 if ( ! KGlobal::locale()->weekStartsMonday() )
327 --sub;
326 // set the week numbers. 328 // set the week numbers.
327 for(i = 0; i < 6; i++) { 329 for(i = 0; i < 6; i++) {
328 QString weeknum;
329 // remember, according to ISO 8601, the first week of the year is the 330 // remember, according to ISO 8601, the first week of the year is the
330 // first week that contains a thursday. Thus we must subtract off 4, 331 // first week that contains a thursday. Thus we must subtract off 4,
331 // not just 1. 332 // not just 1.
332 333
333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 334 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 335 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub)));
335 336 int weekNo;
336 int add = 0;
337 if ( ! KGlobal::locale()->weekStartsMonday() )
338 ++add;
339 if (dayOfYear % 7 != 0) 337 if (dayOfYear % 7 != 0)
340 weeknum.setNum(dayOfYear / 7 + 1+add); 338 weekNo = (dayOfYear / 7 + 1);
341 else 339 else
342 weeknum.setNum(dayOfYear / 7 +add); 340 weekNo = (dayOfYear / 7);
343 weeknos[i]->setText(weeknum); 341 weeknos[i]->setText(QString::number( weekNo ));
344 } 342 }
345 343
346 setUpdatesEnabled( true ); 344 setUpdatesEnabled( true );
347// kdDebug() << "updateView() -> repaint()" << endl; 345// kdDebug() << "updateView() -> repaint()" << endl;
348 repaint(); 346 repaint();
349 // daymatrix->repaint(); 347 // daymatrix->repaint();
350} 348}
351 349
352void KDateNavigator::updateConfig() 350void KDateNavigator::updateConfig()
353{ 351{
354 int day; 352 int day;
355 for(int i=0; i<7; i++) { 353 for(int i=0; i<7; i++) {
356 // take the first letter of the day name to be the abbreviation 354 // take the first letter of the day name to be the abbreviation
357 if (KGlobal::locale()->weekStartsMonday()) { 355 if (KGlobal::locale()->weekStartsMonday()) {
358 day = i+1; 356 day = i+1;
359 } else { 357 } else {
360 if (i==0) day = 7; 358 if (i==0) day = 7;
361 else day = i; 359 else day = i;
362 } 360 }
363 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 361 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
364 true ); 362 true );
365 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 363 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
366 headings[i]->setText( dayName ); 364 headings[i]->setText( dayName );
367 } 365 }
368 updateDates(); 366 updateDates();
369 updateView(); 367 updateView();
370} 368}
371 369
372void KDateNavigator::setShowWeekNums(bool enabled) 370void KDateNavigator::setShowWeekNums(bool enabled)
373{ 371{
374 qDebug("KDateNavigator::setShowWeekNums***************************** "); 372 qDebug("KDateNavigator::setShowWeekNums***************************** ");
375 m_bShowWeekNums = enabled; 373 m_bShowWeekNums = enabled;
376 for(int i=0; i<6; i++) { 374 for(int i=0; i<6; i++) {
377 if(enabled) 375 if(enabled)
378 weeknos[i]->show(); 376 weeknos[i]->show();
379 else 377 else
380 weeknos[i]->hide(); 378 weeknos[i]->hide();
381 } 379 }
382 resize(size()); 380 resize(size());
383} 381}
384 382
385void KDateNavigator::selectDates(const DateList& dateList) 383void KDateNavigator::selectDates(const DateList& dateList)
386{ 384{
387 385
388 if (dateList.count() > 0) { 386 if (dateList.count() > 0) {
389 mNavigatorBar->selectDates( dateList ); 387 mNavigatorBar->selectDates( dateList );
390 mSelectedDates = dateList; 388 mSelectedDates = dateList;
391 389
392 // set our record of the month and year that this datetbl is 390 // set our record of the month and year that this datetbl is
393 // displaying. 391 // displaying.
394 m_MthYr = mSelectedDates.first(); 392 m_MthYr = mSelectedDates.first();
395 393
396 394
397 // set our record of the first day of the week of the current 395 // set our record of the first day of the week of the current
398 // month. This needs to be done before calling dayToIndex, since it 396 // month. This needs to be done before calling dayToIndex, since it
399 // relies on this information being up to date. 397 // relies on this information being up to date.
400 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 398 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
401 m_fstDayOfWk = dayone.dayOfWeek(); 399 m_fstDayOfWk = dayone.dayOfWeek();
402 400
403 updateDates(); 401 updateDates();
404 402
405 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 403 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
406 404
407 updateView(); 405 updateView();
408 } 406 }
409} 407}
410 408
411int KDateNavigator::dayNum(int row, int col) 409int KDateNavigator::dayNum(int row, int col)
412{ 410{
413 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 411 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
414} 412}
415 413
416int KDateNavigator::dayToIndex(int dayNum) 414int KDateNavigator::dayToIndex(int dayNum)
417{ 415{
418 int row, col; 416 int row, col;
419 417
420 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 418 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
421 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 419 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
422 row++; 420 row++;
423 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 421 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
424 return row * 7 + col; 422 return row * 7 + col;
425} 423}
426 424
427void KDateNavigator::wheelEvent (QWheelEvent *e) 425void KDateNavigator::wheelEvent (QWheelEvent *e)
428{ 426{
429 if(e->delta()>0) emit goPrevious(); 427 if(e->delta()>0) emit goPrevious();
430 else emit goNext(); 428 else emit goNext();
431 429
432 e->accept(); 430 e->accept();
433} 431}
434 432
435bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 433bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
436{ 434{
437 if (e->type() == QEvent::MouseButtonPress) { 435 if (e->type() == QEvent::MouseButtonPress) {
438 int i; 436 int i;
439 for(i=0;i<6;++i) { 437 for(i=0;i<6;++i) {
440 if (o == weeknos[i]) { 438 if (o == weeknos[i]) {
441 QDate weekstart = daymatrix->getDate(i*7); 439 QDate weekstart = daymatrix->getDate(i*7);
442 emit weekClicked(weekstart); 440 emit weekClicked(weekstart);
443 break; 441 break;
444 } 442 }
445 } 443 }
446 for(i=0;i<7;++i) { 444 for(i=0;i<7;++i) {
447 if (o == headings[i]) { 445 if (o == headings[i]) {
448 KCal::DateList selDays; 446 KCal::DateList selDays;
449 QDate date = daymatrix->getDate(14); 447 QDate date = daymatrix->getDate(14);
450 emit showMonth(date ); 448 emit showMonth(date );
451#if 0 449#if 0
452 int dio = date.daysInMonth(); 450 int dio = date.daysInMonth();
453 int j; 451 int j;
454 int ye = date.year(); 452 int ye = date.year();
455 int mo = date.month(); 453 int mo = date.month();
456 for ( j = 1; j <= dio; ++j ) { 454 for ( j = 1; j <= dio; ++j ) {
457 selDays.append( QDate( ye, mo, j ) ); 455 selDays.append( QDate( ye, mo, j ) );
458 } 456 }
459 emit datesSelected( selDays ); 457 emit datesSelected( selDays );
460#endif 458#endif
461 break; 459 break;
462 } 460 }
463 } 461 }
464 return true; 462 return true;
465 } else { 463 } else {
466 return false; 464 return false;
467 } 465 }
468} 466}
469 467
470//#include "kdatenavigator.moc" 468//#include "kdatenavigator.moc"
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9085775..d825493 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -748,824 +748,823 @@ void MonthViewCell::finishUpdateCell()
748 mAvailItemList.append( item ); 748 mAvailItemList.append( item );
749 takeItem ( item ); 749 takeItem ( item );
750 } 750 }
751 751
752 752
753#ifdef DESKTOP_VERSION 753#ifdef DESKTOP_VERSION
754 if (mToolTip.count() > 0 ) { 754 if (mToolTip.count() > 0 ) {
755 mToolTip.sort(); 755 mToolTip.sort();
756 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 756 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
757 } 757 }
758#endif 758#endif
759 sort(); 759 sort();
760 //setMyPalette(); 760 //setMyPalette();
761 setMyPalette(); 761 setMyPalette();
762 762
763 resizeEvent( 0 ); 763 resizeEvent( 0 );
764 764
765} 765}
766void MonthViewCell::updateCell() 766void MonthViewCell::updateCell()
767{ 767{
768 //qDebug("MonthViewCell::updateCell() "); 768 //qDebug("MonthViewCell::updateCell() ");
769 if ( !mMonthView->isUpdatePossible() ) 769 if ( !mMonthView->isUpdatePossible() )
770 return; 770 return;
771 startUpdateCell(); 771 startUpdateCell();
772 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 772 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
773 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 773 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
774 Event *event; 774 Event *event;
775 for( event = events.first(); event; event = events.next() ) { // for event 775 for( event = events.first(); event; event = events.next() ) { // for event
776 insertEvent(event); 776 insertEvent(event);
777 } 777 }
778 // insert due todos 778 // insert due todos
779 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 779 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
780 Todo *todo; 780 Todo *todo;
781 for(todo = todos.first(); todo; todo = todos.next()) { 781 for(todo = todos.first(); todo; todo = todos.next()) {
782 insertTodo( todo ); 782 insertTodo( todo );
783 } 783 }
784 finishUpdateCell(); 784 finishUpdateCell();
785 // if ( isVisible()) 785 // if ( isVisible())
786 //qApp->processEvents(); 786 //qApp->processEvents();
787} 787}
788 788
789void MonthViewCell::updateConfig( bool bigFont ) // = false 789void MonthViewCell::updateConfig( bool bigFont ) // = false
790{ 790{
791 791
792 if ( bigFont ) { 792 if ( bigFont ) {
793 QFont fo = KOPrefs::instance()->mMonthViewFont; 793 QFont fo = KOPrefs::instance()->mMonthViewFont;
794 int ps = fo.pointSize() + 2; 794 int ps = fo.pointSize() + 2;
795 if ( ps < 18 ) 795 if ( ps < 18 )
796 ps += 2; 796 ps += 2;
797 fo.setPointSize( ps ); 797 fo.setPointSize( ps );
798 setFont( fo ); 798 setFont( fo );
799 } else 799 } else
800 setFont( KOPrefs::instance()->mMonthViewFont ); 800 setFont( KOPrefs::instance()->mMonthViewFont );
801 801
802 QFontMetrics fm( font() ); 802 QFontMetrics fm( font() );
803 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 803 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
804 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 804 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
805 mHolidayPalette = mStandardPalette; 805 mHolidayPalette = mStandardPalette;
806 mPrimaryPalette = mStandardPalette; 806 mPrimaryPalette = mStandardPalette;
807 mNonPrimaryPalette = mStandardPalette; 807 mNonPrimaryPalette = mStandardPalette;
808 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 808 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
809 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 809 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
810 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 810 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
811 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 811 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
812 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 812 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
813 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 813 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
814 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 814 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
815 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 815 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
816 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 816 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
817 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 817 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
818 } 818 }
819 //updateCell(); 819 //updateCell();
820} 820}
821 821
822void MonthViewCell::enableScrollBars( bool enabled ) 822void MonthViewCell::enableScrollBars( bool enabled )
823{ 823{
824 if ( enabled ) { 824 if ( enabled ) {
825 QListBoxItem *fi = firstItem (); 825 QListBoxItem *fi = firstItem ();
826 if (fi ) { 826 if (fi ) {
827 int ihei = fi->height( this ); 827 int ihei = fi->height( this );
828 int hei = numRows () * ihei; 828 int hei = numRows () * ihei;
829 if ( hei < height() - horizontalScrollBar()->height () ) { 829 if ( hei < height() - horizontalScrollBar()->height () ) {
830 setVScrollBarMode(QScrollView::AlwaysOff); 830 setVScrollBarMode(QScrollView::AlwaysOff);
831 } 831 }
832 else 832 else
833 setVScrollBarMode(QScrollView::Auto); 833 setVScrollBarMode(QScrollView::Auto);
834 if ( ihei *3 > height() ) 834 if ( ihei *3 > height() )
835 setHScrollBarMode(QScrollView::AlwaysOff); 835 setHScrollBarMode(QScrollView::AlwaysOff);
836 else 836 else
837 setHScrollBarMode(QScrollView::Auto); 837 setHScrollBarMode(QScrollView::Auto);
838 } else { 838 } else {
839 setVScrollBarMode(QScrollView::Auto); 839 setVScrollBarMode(QScrollView::Auto);
840 setHScrollBarMode(QScrollView::Auto); 840 setHScrollBarMode(QScrollView::Auto);
841 } 841 }
842 } else { 842 } else {
843 setVScrollBarMode(QScrollView::AlwaysOff); 843 setVScrollBarMode(QScrollView::AlwaysOff);
844 setHScrollBarMode(QScrollView::AlwaysOff); 844 setHScrollBarMode(QScrollView::AlwaysOff);
845 } 845 }
846} 846}
847 847
848Incidence *MonthViewCell::selectedIncidence() 848Incidence *MonthViewCell::selectedIncidence()
849{ 849{
850 int index = currentItem(); 850 int index = currentItem();
851 if ( index < 0 ) return 0; 851 if ( index < 0 ) return 0;
852 852
853 MonthViewItem *mitem = 853 MonthViewItem *mitem =
854 static_cast<MonthViewItem *>( item( index ) ); 854 static_cast<MonthViewItem *>( item( index ) );
855 855
856 if ( !mitem ) return 0; 856 if ( !mitem ) return 0;
857 857
858 return mitem->incidence(); 858 return mitem->incidence();
859} 859}
860 860
861QDate MonthViewCell::selectedIncidenceDate() 861QDate MonthViewCell::selectedIncidenceDate()
862{ 862{
863 QDate qd; 863 QDate qd;
864 int index = currentItem(); 864 int index = currentItem();
865 if ( index < 0 ) return qd; 865 if ( index < 0 ) return qd;
866 866
867 MonthViewItem *mitem = 867 MonthViewItem *mitem =
868 static_cast<MonthViewItem *>( item( index ) ); 868 static_cast<MonthViewItem *>( item( index ) );
869 869
870 if ( !mitem ) return qd; 870 if ( !mitem ) return qd;
871 871
872 return mitem->incidenceDate(); 872 return mitem->incidenceDate();
873} 873}
874 874
875void MonthViewCell::deselect() 875void MonthViewCell::deselect()
876{ 876{
877 clearSelection(); 877 clearSelection();
878 enableScrollBars( false ); 878 enableScrollBars( false );
879 // updateCell(); 879 // updateCell();
880} 880}
881void MonthViewCell::select() 881void MonthViewCell::select()
882{ 882{
883 ;// updateCell(); 883 ;// updateCell();
884} 884}
885 885
886void MonthViewCell::resizeEvent ( QResizeEvent * e ) 886void MonthViewCell::resizeEvent ( QResizeEvent * e )
887{ 887{
888 if ( !mMonthView->isUpdatePossible() ) 888 if ( !mMonthView->isUpdatePossible() )
889 return; 889 return;
890 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 890 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
891 deselect(); 891 deselect();
892 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 892 mLabel->setMaximumHeight( height() - lineWidth()*2 );
893 893
894 QString text; 894 QString text;
895 mLabel->setText( text ); 895 mLabel->setText( text );
896 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 896 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
897 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 897 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
898 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 898 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
899 mLabel->resize( mLabelBigSize ); 899 mLabel->resize( mLabelBigSize );
900 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 900 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
901 } else { 901 } else {
902 mLabel->resize( mLabelSize ); 902 mLabel->resize( mLabelSize );
903 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 903 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
904 } 904 }
905 mLabel->setText( text ); 905 mLabel->setText( text );
906 906
907 int size = height() - mLabel->height() - lineWidth()-1; 907 int size = height() - mLabel->height() - lineWidth()-1;
908 //qDebug("LW %d ", lineWidth()); 908 //qDebug("LW %d ", lineWidth());
909 if ( size > 0 ) 909 if ( size > 0 )
910 verticalScrollBar()->setMaximumHeight( size ); 910 verticalScrollBar()->setMaximumHeight( size );
911 size = width() - mLabel->width() -lineWidth()-1; 911 size = width() - mLabel->width() -lineWidth()-1;
912 if ( size > 0 ) 912 if ( size > 0 )
913 horizontalScrollBar()->setMaximumWidth( size ); 913 horizontalScrollBar()->setMaximumWidth( size );
914 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 914 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
915 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 915 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
916 // mItemList->resize ( width(), height () ); 916 // mItemList->resize ( width(), height () );
917 if ( e ) 917 if ( e )
918 KNoScrollListBox::resizeEvent ( e ); 918 KNoScrollListBox::resizeEvent ( e );
919} 919}
920 920
921void MonthViewCell::defaultAction( QListBoxItem *item ) 921void MonthViewCell::defaultAction( QListBoxItem *item )
922{ 922{
923 if ( !item ) return; 923 if ( !item ) return;
924 924
925 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 925 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
926 Incidence *incidence = eventItem->incidence(); 926 Incidence *incidence = eventItem->incidence();
927 if ( incidence ) mMonthView->defaultAction( incidence ); 927 if ( incidence ) mMonthView->defaultAction( incidence );
928} 928}
929void MonthViewCell::showDay() 929void MonthViewCell::showDay()
930{ 930{
931 emit showDaySignal( date() ); 931 emit showDaySignal( date() );
932} 932}
933void MonthViewCell::newEvent() 933void MonthViewCell::newEvent()
934{ 934{
935 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 935 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
936 emit newEventSignal( dt ); 936 emit newEventSignal( dt );
937} 937}
938void MonthViewCell::cellClicked( QListBoxItem *item ) 938void MonthViewCell::cellClicked( QListBoxItem *item )
939{ 939{
940 static QListBoxItem * lastClicked = 0; 940 static QListBoxItem * lastClicked = 0;
941 if ( item == 0 ) { 941 if ( item == 0 ) {
942 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 942 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
943 emit newEventSignal( dt ); 943 emit newEventSignal( dt );
944 return; 944 return;
945 } 945 }
946 /* 946 /*
947 if ( lastClicked ) 947 if ( lastClicked )
948 if ( ! item ) { 948 if ( ! item ) {
949 if ( lastClicked->listBox() != item->listBox() ) 949 if ( lastClicked->listBox() != item->listBox() )
950 lastClicked->listBox()->clearSelection(); 950 lastClicked->listBox()->clearSelection();
951 } 951 }
952 */ 952 */
953 953
954 mMonthView->setSelectedCell( this ); 954 mMonthView->setSelectedCell( this );
955 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 955 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
956 select(); 956 select();
957} 957}
958 958
959void MonthViewCell::contextMenu( QListBoxItem *item ) 959void MonthViewCell::contextMenu( QListBoxItem *item )
960{ 960{
961 if ( !item ) return; 961 if ( !item ) return;
962 962
963 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 963 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
964 Incidence *incidence = eventItem->incidence(); 964 Incidence *incidence = eventItem->incidence();
965 if ( incidence ) mMonthView->showContextMenu( incidence ); 965 if ( incidence ) mMonthView->showContextMenu( incidence );
966} 966}
967 967
968void MonthViewCell::selection( QListBoxItem *item ) 968void MonthViewCell::selection( QListBoxItem *item )
969{ 969{
970 if ( !item ) return; 970 if ( !item ) return;
971 971
972 mMonthView->setSelectedCell( this ); 972 mMonthView->setSelectedCell( this );
973} 973}
974 974
975 975
976// ******************************************************************************* 976// *******************************************************************************
977// ******************************************************************************* 977// *******************************************************************************
978// ******************************************************************************* 978// *******************************************************************************
979 979
980 980
981KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 981KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
982 : KOEventView( calendar, parent, name ), 982 : KOEventView( calendar, parent, name ),
983 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 983 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
984 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 984 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
985{ 985{
986 mShortDayLabelsM = false; 986 mShortDayLabelsM = false;
987 mShortDayLabelsW = false; 987 mShortDayLabelsW = false;
988 skipResize = false; 988 skipResize = false;
989 clPending = true; 989 clPending = true;
990 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 990 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
991 mWidStack = new QWidgetStack( this ); 991 mWidStack = new QWidgetStack( this );
992 QVBoxLayout* hb = new QVBoxLayout( this ); 992 QVBoxLayout* hb = new QVBoxLayout( this );
993 mMonthView = new QWidget( mWidStack ); 993 mMonthView = new QWidget( mWidStack );
994 mWeekView = new QWidget( mWidStack ); 994 mWeekView = new QWidget( mWidStack );
995#if QT_VERSION >= 0x030000 995#if QT_VERSION >= 0x030000
996 mWidStack->addWidget(mMonthView ); 996 mWidStack->addWidget(mMonthView );
997 mWidStack->addWidget(mWeekView ); 997 mWidStack->addWidget(mWeekView );
998#else 998#else
999 mWidStack->addWidget( mMonthView, 1 ); 999 mWidStack->addWidget( mMonthView, 1 );
1000 mWidStack->addWidget( mWeekView , 1 ); 1000 mWidStack->addWidget( mWeekView , 1 );
1001#endif 1001#endif
1002 hb->addWidget( mNavigatorBar ); 1002 hb->addWidget( mNavigatorBar );
1003 hb->addWidget( mWidStack ); 1003 hb->addWidget( mWidStack );
1004 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1005 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1004 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1006 if ( mShowWeekView )
1007 mWeekStartsMonday = true;
1008 updatePossible = false; 1005 updatePossible = false;
1009 //updatePossible = true; 1006 //updatePossible = true;
1010 mCells.setAutoDelete( true ); 1007 mCells.setAutoDelete( true );
1011 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1008 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1012 mDayLabels.resize( mDaysPerWeek ); 1009 mDayLabels.resize( mDaysPerWeek );
1013 mDayLabelsW.resize( mDaysPerWeek ); 1010 mDayLabelsW.resize( mDaysPerWeek );
1014 QFont bfont = font(); 1011 QFont bfont = font();
1015 if ( QApplication::desktop()->width() < 650 ) { 1012 if ( QApplication::desktop()->width() < 650 ) {
1016 bfont.setPointSize( bfont.pointSize() - 2 ); 1013 bfont.setPointSize( bfont.pointSize() - 2 );
1017 } 1014 }
1018 bfont.setBold( true ); 1015 bfont.setBold( true );
1019 int i; 1016 int i;
1020 1017
1021 for( i = 0; i < mDaysPerWeek; i++ ) { 1018 for( i = 0; i < mDaysPerWeek; i++ ) {
1022 QLabel *label = new QLabel( mMonthView ); 1019 QLabel *label = new QLabel( mMonthView );
1023 label->setFont(bfont); 1020 label->setFont(bfont);
1024 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1021 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1025 label->setLineWidth(1); 1022 label->setLineWidth(1);
1026 label->setAlignment(AlignCenter); 1023 label->setAlignment(AlignCenter);
1027 mDayLabels.insert( i, label ); 1024 mDayLabels.insert( i, label );
1028 label = new QLabel( mWeekView ); 1025 label = new QLabel( mWeekView );
1029 label->setFont(bfont); 1026 label->setFont(bfont);
1030 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1027 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1031 label->setLineWidth(1); 1028 label->setLineWidth(1);
1032 label->setAlignment(AlignCenter); 1029 label->setAlignment(AlignCenter);
1033 mDayLabelsW.insert( i, label ); 1030 mDayLabelsW.insert( i, label );
1034 } 1031 }
1035 1032
1036 bfont.setBold( false ); 1033 bfont.setBold( false );
1037 mWeekLabels.resize( mNumWeeks+1 ); 1034 mWeekLabels.resize( mNumWeeks+1 );
1038 mWeekLabelsW.resize( 2 ); 1035 mWeekLabelsW.resize( 2 );
1039 for( i = 0; i < mNumWeeks+1; i++ ) { 1036 for( i = 0; i < mNumWeeks+1; i++ ) {
1040 KOWeekButton *label = new KOWeekButton( mMonthView ); 1037 KOWeekButton *label = new KOWeekButton( mMonthView );
1041 label->setFocusPolicy(NoFocus); 1038 label->setFocusPolicy(NoFocus);
1042 label->setFont(bfont); 1039 label->setFont(bfont);
1043 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1040 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1044 label->setFlat(true); 1041 label->setFlat(true);
1045 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1042 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1046 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1043 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1047 //label->setLineWidth(1); 1044 //label->setLineWidth(1);
1048 //label->setAlignment(AlignCenter); 1045 //label->setAlignment(AlignCenter);
1049 mWeekLabels.insert( i, label ); 1046 mWeekLabels.insert( i, label );
1050 } 1047 }
1051 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1048 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1052 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1049 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1053 1050
1054 for( i = 0; i < 1+1; i++ ) { 1051 for( i = 0; i < 1+1; i++ ) {
1055 KOWeekButton *label = new KOWeekButton( mWeekView ); 1052 KOWeekButton *label = new KOWeekButton( mWeekView );
1056 label->setFocusPolicy(NoFocus); 1053 label->setFocusPolicy(NoFocus);
1057 label->setFont(bfont); 1054 label->setFont(bfont);
1058 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1055 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1059 label->setFlat(true); 1056 label->setFlat(true);
1060 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1057 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1061 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1058 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1062 //label->setLineWidth(1); 1059 //label->setLineWidth(1);
1063 //label->setAlignment(AlignCenter); 1060 //label->setAlignment(AlignCenter);
1064 mWeekLabelsW.insert( i, label ); 1061 mWeekLabelsW.insert( i, label );
1065 } 1062 }
1066 mWeekLabelsW[1]->setText( i18n("W")); 1063 mWeekLabelsW[1]->setText( i18n("W"));
1067 1064
1068 1065
1069 int row, col; 1066 int row, col;
1070 mCells.resize( mNumCells ); 1067 mCells.resize( mNumCells );
1071 for( row = 0; row < mNumWeeks; ++row ) { 1068 for( row = 0; row < mNumWeeks; ++row ) {
1072 for( col = 0; col < mDaysPerWeek; ++col ) { 1069 for( col = 0; col < mDaysPerWeek; ++col ) {
1073 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1070 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1074 mCells.insert( row * mDaysPerWeek + col, cell ); 1071 mCells.insert( row * mDaysPerWeek + col, cell );
1075 1072
1076 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1073 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1077 SLOT( defaultAction( Incidence * ) ) ); 1074 SLOT( defaultAction( Incidence * ) ) );
1078 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1075 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1079 SIGNAL( newEventSignal( QDateTime ) ) ); 1076 SIGNAL( newEventSignal( QDateTime ) ) );
1080 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1077 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1081 SIGNAL( showDaySignal( QDate ) ) ); 1078 SIGNAL( showDaySignal( QDate ) ) );
1082 } 1079 }
1083 } 1080 }
1084 mCellsW.resize( mDaysPerWeek ); 1081 mCellsW.resize( mDaysPerWeek );
1085 for( col = 0; col < mDaysPerWeek; ++col ) { 1082 for( col = 0; col < mDaysPerWeek; ++col ) {
1086 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1083 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1087 mCellsW.insert( col, cell ); 1084 mCellsW.insert( col, cell );
1088 1085
1089 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1086 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1090 SLOT( defaultAction( Incidence * ) ) ); 1087 SLOT( defaultAction( Incidence * ) ) );
1091 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1088 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1092 SIGNAL( newEventSignal( QDateTime ) ) ); 1089 SIGNAL( newEventSignal( QDateTime ) ) );
1093 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1090 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1094 SIGNAL( showDaySignal( QDate ) ) ); 1091 SIGNAL( showDaySignal( QDate ) ) );
1095 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1092 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1096 } 1093 }
1097 1094
1098 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1095 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1099 mContextMenu = eventPopup(); 1096 mContextMenu = eventPopup();
1100 // updateConfig(); //useless here... 1097 // updateConfig(); //useless here...
1101 // ... but we need mWidthLongDayLabel computed 1098 // ... but we need mWidthLongDayLabel computed
1102 QFontMetrics fontmetric(mDayLabels[0]->font()); 1099 QFontMetrics fontmetric(mDayLabels[0]->font());
1103 mWidthLongDayLabel = 0; 1100 mWidthLongDayLabel = 0;
1104 for (int i = 0; i < 7; i++) { 1101 for (int i = 0; i < 7; i++) {
1105 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1102 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1106 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1103 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1107 } 1104 }
1108 1105
1109 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1106 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1110 1107
1111#if 0 1108#if 0
1112 if ( mShowWeekView ) 1109 if ( mShowWeekView )
1113 mWidStack->raiseWidget( mWeekView ); 1110 mWidStack->raiseWidget( mWeekView );
1114 else 1111 else
1115 mWidStack->raiseWidget( mMonthView ); 1112 mWidStack->raiseWidget( mMonthView );
1116#endif 1113#endif
1117 1114
1118 emit incidenceSelected( 0 ); 1115 emit incidenceSelected( 0 );
1119 1116
1120 mComputeLayoutTimer = new QTimer( this ); 1117 mComputeLayoutTimer = new QTimer( this );
1121 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1118 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1122 1119
1123 1120
1124#ifndef DESKTOP_VERSION 1121#ifndef DESKTOP_VERSION
1125 resize( QApplication::desktop()->size() ); 1122 resize( QApplication::desktop()->size() );
1126#else 1123#else
1127 resize(640, 480 ); 1124 resize(640, 480 );
1128 updatePossible = true; 1125 updatePossible = true;
1129#endif 1126#endif
1130 computeLayout(); 1127 computeLayout();
1131 1128
1132 if ( mShowWeekView ) 1129 if ( mShowWeekView )
1133 mWidStack->raiseWidget( mWeekView ); 1130 mWidStack->raiseWidget( mWeekView );
1134 else 1131 else
1135 mWidStack->raiseWidget( mMonthView ); 1132 mWidStack->raiseWidget( mMonthView );
1136} 1133}
1137 1134
1138KOMonthView::~KOMonthView() 1135KOMonthView::~KOMonthView()
1139{ 1136{
1140 delete mContextMenu; 1137 delete mContextMenu;
1141} 1138}
1142 1139
1143void KOMonthView::selectInternalWeekNum ( int n ) 1140void KOMonthView::selectInternalWeekNum ( int n )
1144{ 1141{
1145 switchView(); 1142 switchView();
1146 if ( !KOPrefs::instance()->mMonthViewWeek ) 1143 if ( !KOPrefs::instance()->mMonthViewWeek )
1147 emit selectMonth (); 1144 emit selectMonth ();
1148 else 1145 else
1149 emit selectWeekNum ( n ); 1146 emit selectWeekNum ( n );
1150} 1147}
1151 1148
1152int KOMonthView::currentWeek() 1149int KOMonthView::currentWeek()
1153{ 1150{
1154 if ( mShowWeekView ) 1151 if ( mShowWeekView )
1155 return mWeekLabelsW[0]->getWeekNum(); 1152 return mWeekLabelsW[0]->getWeekNum();
1156 return mWeekLabels[0]->getWeekNum(); 1153 return mWeekLabels[0]->getWeekNum();
1157} 1154}
1158void KOMonthView::switchView() 1155void KOMonthView::switchView()
1159{ 1156{
1160 if ( selectedCell( ) ) 1157 if ( selectedCell( ) )
1161 selectedCell()->deselect(); 1158 selectedCell()->deselect();
1162 mShowWeekView = !mShowWeekView; 1159 mShowWeekView = !mShowWeekView;
1163 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1160 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1164 if ( clPending ) { 1161 if ( clPending ) {
1165 computeLayout(); 1162 computeLayout();
1166 updateConfig(); 1163 updateConfig();
1167 } 1164 }
1168 if ( mShowWeekView ) 1165 if ( mShowWeekView )
1169 mWidStack->raiseWidget( mWeekView ); 1166 mWidStack->raiseWidget( mWeekView );
1170 else 1167 else
1171 mWidStack->raiseWidget( mMonthView ); 1168 mWidStack->raiseWidget( mMonthView );
1172 clPending = false; 1169 clPending = false;
1173} 1170}
1174 1171
1175int KOMonthView::maxDatesHint() 1172int KOMonthView::maxDatesHint()
1176{ 1173{
1177 return mNumCells; 1174 return mNumCells;
1178} 1175}
1179 1176
1180int KOMonthView::currentDateCount() 1177int KOMonthView::currentDateCount()
1181{ 1178{
1182 return mNumCells; 1179 return mNumCells;
1183} 1180}
1184 1181
1185QPtrList<Incidence> KOMonthView::selectedIncidences() 1182QPtrList<Incidence> KOMonthView::selectedIncidences()
1186{ 1183{
1187 QPtrList<Incidence> selected; 1184 QPtrList<Incidence> selected;
1188 1185
1189 if ( mSelectedCell ) { 1186 if ( mSelectedCell ) {
1190 Incidence *incidence = mSelectedCell->selectedIncidence(); 1187 Incidence *incidence = mSelectedCell->selectedIncidence();
1191 if ( incidence ) selected.append( incidence ); 1188 if ( incidence ) selected.append( incidence );
1192 } 1189 }
1193 1190
1194 return selected; 1191 return selected;
1195} 1192}
1196 1193
1197DateList KOMonthView::selectedDates() 1194DateList KOMonthView::selectedDates()
1198{ 1195{
1199 DateList selected; 1196 DateList selected;
1200 1197
1201 if ( mSelectedCell ) { 1198 if ( mSelectedCell ) {
1202 QDate qd = mSelectedCell->selectedIncidenceDate(); 1199 QDate qd = mSelectedCell->selectedIncidenceDate();
1203 if ( qd.isValid() ) selected.append( qd ); 1200 if ( qd.isValid() ) selected.append( qd );
1204 } 1201 }
1205 1202
1206 return selected; 1203 return selected;
1207} 1204}
1208 1205
1209void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1206void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1210 const QDate &td) 1207 const QDate &td)
1211{ 1208{
1212#ifndef KORG_NOPRINTER 1209#ifndef KORG_NOPRINTER
1213 calPrinter->preview(CalPrinter::Month, fd, td); 1210 calPrinter->preview(CalPrinter::Month, fd, td);
1214#endif 1211#endif
1215} 1212}
1216 1213
1217void KOMonthView::updateConfig() 1214void KOMonthView::updateConfig()
1218{ 1215{
1219 1216
1220 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1217 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1221 1218
1222 if ( mShowWeekView ) { 1219 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1223 mWeekStartsMonday = true; 1220 mWeekStartsMonday = true;
1224 } 1221 }
1225 QFontMetrics fontmetric(mDayLabels[0]->font()); 1222 QFontMetrics fontmetric(mDayLabels[0]->font());
1226 mWidthLongDayLabel = 0; 1223 mWidthLongDayLabel = 0;
1227 1224
1228 for (int i = 0; i < 7; i++) { 1225 for (int i = 0; i < 7; i++) {
1229 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1226 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1230 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1227 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1231 } 1228 }
1232 bool temp = mShowSatSunComp ; 1229 bool temp = mShowSatSunComp ;
1233 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1230 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1234 if ( ! mShowWeekView ) { 1231 if ( ! mShowWeekView ) {
1235 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1232 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1236 computeLayout(); 1233 computeLayout();
1237 } 1234 }
1238 updateDayLabels(); 1235 updateDayLabels();
1239 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1236 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1240 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1237 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1241 //resizeEvent( 0 ); 1238 //resizeEvent( 0 );
1242 for (uint i = 0; i < mCells.count(); ++i) { 1239 for (uint i = 0; i < mCells.count(); ++i) {
1243 mCells[i]->updateConfig(); 1240 mCells[i]->updateConfig();
1244 } 1241 }
1245 1242
1246 for (uint i = 0; i < mCellsW.count(); ++i) { 1243 for (uint i = 0; i < mCellsW.count(); ++i) {
1247 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1244 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1248 } 1245 }
1249#ifdef DESKTOP_VERSION 1246#ifdef DESKTOP_VERSION
1250 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1247 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1251#endif 1248#endif
1252 updateView(); 1249 updateView();
1253} 1250}
1254 1251
1255void KOMonthView::updateDayLabels() 1252void KOMonthView::updateDayLabels()
1256{ 1253{
1257 1254
1258 QPtrVector<QLabel> *mDayLabelsT; 1255 QPtrVector<QLabel> *mDayLabelsT;
1259 1256
1260 mDayLabelsT = &mDayLabelsW; 1257 mDayLabelsT = &mDayLabelsW;
1261 for (int i = 0; i < 7; i++) { 1258 for (int i = 0; i < 7; i++) {
1262 if (mWeekStartsMonday) { 1259 {
1263 bool show = mShortDayLabelsW; 1260 bool show = mShortDayLabelsW;
1264 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1261 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1265 show = true; 1262 show = true;
1266 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1263 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1267 } else {
1268 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1269 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1270
1271 } 1264 }
1272 } 1265 }
1273 mDayLabelsT = &mDayLabels; 1266 mDayLabelsT = &mDayLabels;
1274 for (int i = 0; i < 7; i++) { 1267 for (int i = 0; i < 7; i++) {
1275 if (mWeekStartsMonday) { 1268 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1276 bool show = mShortDayLabelsM; 1269 bool show = mShortDayLabelsM;
1277 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1270 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1278 show = true; 1271 show = true;
1279 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1272 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1280 } else { 1273 } else {
1281 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1274 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1282 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1275 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1283 1276
1284 } 1277 }
1285 } 1278 }
1286 1279
1287} 1280}
1288 1281
1289void KOMonthView::showDates(const QDate &start, const QDate &) 1282void KOMonthView::showDates(const QDate &start, const QDate &)
1290{ 1283{
1291 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1284 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1292 1285
1293 QPtrVector<MonthViewCell> *cells; 1286 QPtrVector<MonthViewCell> *cells;
1294 QPtrVector<QLabel> *dayLabels; 1287 QPtrVector<QLabel> *dayLabels;
1295 QPtrVector<KOWeekButton> *weekLabels; 1288 QPtrVector<KOWeekButton> *weekLabels;
1296 int weekNum = 6; 1289 int weekNum = 6;
1290 mStartDate = start;
1297 if ( mShowWeekView ) { 1291 if ( mShowWeekView ) {
1298 weekNum = 1; 1292 weekNum = 1;
1299 cells = &mCellsW; 1293 cells = &mCellsW;
1300 dayLabels = &mDayLabelsW; 1294 dayLabels = &mDayLabelsW;
1301 weekLabels = &mWeekLabelsW; 1295 weekLabels = &mWeekLabelsW;
1296 if ( !KGlobal::locale()->weekStartsMonday() ) {
1297 mStartDate = mStartDate.addDays( 1 );
1298 }
1302 } else { 1299 } else {
1303 cells = &mCells; 1300 cells = &mCells;
1304 dayLabels = &mDayLabels; 1301 dayLabels = &mDayLabels;
1305 weekLabels = &mWeekLabels; 1302 weekLabels = &mWeekLabels;
1306 } 1303 }
1307 1304
1308 mStartDate = start; 1305 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1309 1306
1307 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1308 mWeekStartsMonday = true;
1309 }
1310 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1310 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1311 1311
1312 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1312 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1313 mStartDate = mStartDate.addDays( -1 ); 1313 mStartDate = mStartDate.addDays( -1 );
1314 } 1314 }
1315
1316 bool primary = false; 1315 bool primary = false;
1317 uint i; 1316 uint i;
1318 for( i = 0; i < (*cells).size(); ++i ) { 1317 for( i = 0; i < (*cells).size(); ++i ) {
1319 QDate date = mStartDate.addDays( i ); 1318 QDate date = mStartDate.addDays( i );
1320 (*cells)[i]->setDate( date ); 1319 (*cells)[i]->setDate( date );
1321 1320
1322#ifndef KORG_NOPLUGINS 1321#ifndef KORG_NOPLUGINS
1323 // add holiday, if present 1322 // add holiday, if present
1324 QString hstring(KOCore::self()->holiday(date)); 1323 QString hstring(KOCore::self()->holiday(date));
1325 (*cells)[i]->setHoliday( hstring ); 1324 (*cells)[i]->setHoliday( hstring );
1326#endif 1325#endif
1327 1326
1328 } 1327 }
1329 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1328 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1330 for( i = 0; i < weekNum; ++i ) { 1329 for( i = 0; i < weekNum; ++i ) {
1331 int wno; 1330 int wno;
1332 // remember, according to ISO 8601, the first week of the year is the 1331 // remember, according to ISO 8601, the first week of the year is the
1333 // first week that contains a thursday. Thus we must subtract off 4, 1332 // first week that contains a thursday. Thus we must subtract off 4,
1334 // not just 1. 1333 // not just 1.
1335 int dayOfYear = date.dayOfYear(); 1334 int dayOfYear = date.dayOfYear();
1336 if (dayOfYear % 7 != 0) 1335 if (dayOfYear % 7 != 0)
1337 wno = dayOfYear / 7 + 1; 1336 wno = dayOfYear / 7 + 1;
1338 else 1337 else
1339 wno =dayOfYear / 7; 1338 wno =dayOfYear / 7;
1340 (*weekLabels)[i]->setWeekNum( wno ); 1339 (*weekLabels)[i]->setWeekNum( wno );
1341 date = date.addDays( 7 ); 1340 date = date.addDays( 7 );
1342 } 1341 }
1343 updateView(); 1342 updateView();
1344} 1343}
1345 1344
1346void KOMonthView::showEvents(QPtrList<Event>) 1345void KOMonthView::showEvents(QPtrList<Event>)
1347{ 1346{
1348 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1347 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1349} 1348}
1350 1349
1351void KOMonthView::changeEventDisplay(Event *, int) 1350void KOMonthView::changeEventDisplay(Event *, int)
1352{ 1351{
1353 // this should be re-written to be much more efficient, but this 1352 // this should be re-written to be much more efficient, but this
1354 // quick-and-dirty-hack gets the job done for right now. 1353 // quick-and-dirty-hack gets the job done for right now.
1355 updateView(); 1354 updateView();
1356} 1355}
1357 1356
1358void KOMonthView::updateView() 1357void KOMonthView::updateView()
1359{ 1358{
1360 1359
1361 if ( !updatePossible ) 1360 if ( !updatePossible )
1362 return; 1361 return;
1363 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1362 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1364 //QTime ti; 1363 //QTime ti;
1365 //ti.start(); 1364 //ti.start();
1366 clearSelection(); 1365 clearSelection();
1367 QPtrVector<MonthViewCell> *cells; 1366 QPtrVector<MonthViewCell> *cells;
1368 if ( mShowWeekView ) { 1367 if ( mShowWeekView ) {
1369 cells = &mCellsW; 1368 cells = &mCellsW;
1370 } else { 1369 } else {
1371 cells = &mCells; 1370 cells = &mCells;
1372 } 1371 }
1373#if 1 1372#if 1
1374 int i; 1373 int i;
1375 int timeSpan = (*cells).size()-1; 1374 int timeSpan = (*cells).size()-1;
1376 if ( KOPrefs::instance()->mMonthViewWeek ) 1375 if ( KOPrefs::instance()->mMonthViewWeek )
1377 timeSpan = 6; 1376 timeSpan = 6;
1378 for( i = 0; i < timeSpan + 1; ++i ) { 1377 for( i = 0; i < timeSpan + 1; ++i ) {
1379 (*cells)[i]->startUpdateCell(); 1378 (*cells)[i]->startUpdateCell();
1380 } 1379 }
1381 1380
1382 QPtrList<Event> events = calendar()->events(); 1381 QPtrList<Event> events = calendar()->events();
1383 Event *event; 1382 Event *event;
1384 QDateTime dt; 1383 QDateTime dt;
1385 bool ok; 1384 bool ok;
1386 QDate endDate = mStartDate.addDays( timeSpan ); 1385 QDate endDate = mStartDate.addDays( timeSpan );
1387 for( event = events.first(); event; event = events.next() ) { // for event 1386 for( event = events.first(); event; event = events.next() ) { // for event
1388 if ( event->doesRecur() ) { 1387 if ( event->doesRecur() ) {
1389 bool last; 1388 bool last;
1390 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1389 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1391 QDateTime incidenceEnd; 1390 QDateTime incidenceEnd;
1392 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1391 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1393 bool invalid = false; 1392 bool invalid = false;
1394 while( true ) { 1393 while( true ) {
1395 if ( incidenceStart.isValid() ) { 1394 if ( incidenceStart.isValid() ) {
1396 incidenceEnd = incidenceStart.addDays( eventlen ); 1395 incidenceEnd = incidenceStart.addDays( eventlen );
1397 int st = incidenceStart.date().daysTo( endDate ); 1396 int st = incidenceStart.date().daysTo( endDate );
1398 if ( st >= 0 ) { // start before timeend 1397 if ( st >= 0 ) { // start before timeend
1399 int end = mStartDate.daysTo( incidenceEnd.date() ); 1398 int end = mStartDate.daysTo( incidenceEnd.date() );
1400 if ( end >= 0 ) { // end after timestart --- got one! 1399 if ( end >= 0 ) { // end after timestart --- got one!
1401 //normalize 1400 //normalize
1402 st = timeSpan - st; 1401 st = timeSpan - st;
1403 if ( st < 0 ) st = 0; 1402 if ( st < 0 ) st = 0;
1404 if ( end > timeSpan ) end = timeSpan; 1403 if ( end > timeSpan ) end = timeSpan;
1405 int iii; 1404 int iii;
1406 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1405 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1407 for ( iii = st;iii<= end;++iii) 1406 for ( iii = st;iii<= end;++iii)
1408 (*cells)[iii]->insertEvent( event ); 1407 (*cells)[iii]->insertEvent( event );
1409 } 1408 }
1410 } 1409 }
1411 } else { 1410 } else {
1412 if ( invalid ) 1411 if ( invalid )
1413 break; 1412 break;
1414 invalid = true; 1413 invalid = true;
1415 //qDebug("invalid %s", event->summary().latin1()); 1414 //qDebug("invalid %s", event->summary().latin1());
1416 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1415 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1417 } 1416 }
1418 if ( last ) 1417 if ( last )
1419 break; 1418 break;
1420 bool ok; 1419 bool ok;
1421 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1420 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1422 if ( ! ok ) 1421 if ( ! ok )
1423 break; 1422 break;
1424 if ( incidenceStart.date() > endDate ) 1423 if ( incidenceStart.date() > endDate )
1425 break; 1424 break;
1426 } 1425 }
1427 } else { // no recur 1426 } else { // no recur
1428 int st = event->dtStart().date().daysTo( endDate ); 1427 int st = event->dtStart().date().daysTo( endDate );
1429 if ( st >= 0 ) { // start before timeend 1428 if ( st >= 0 ) { // start before timeend
1430 int end = mStartDate.daysTo( event->dtEnd().date() ); 1429 int end = mStartDate.daysTo( event->dtEnd().date() );
1431 if ( end >= 0 ) { // end after timestart --- got one! 1430 if ( end >= 0 ) { // end after timestart --- got one!
1432 //normalize 1431 //normalize
1433 st = timeSpan - st; 1432 st = timeSpan - st;
1434 if ( st < 0 ) st = 0; 1433 if ( st < 0 ) st = 0;
1435 if ( end > timeSpan ) end = timeSpan; 1434 if ( end > timeSpan ) end = timeSpan;
1436 int iii; 1435 int iii;
1437 for ( iii = st;iii<= end;++iii) 1436 for ( iii = st;iii<= end;++iii)
1438 (*cells)[iii]->insertEvent( event ); 1437 (*cells)[iii]->insertEvent( event );
1439 } 1438 }
1440 } 1439 }
1441 } 1440 }
1442 } 1441 }
1443 // insert due todos 1442 // insert due todos
1444 QPtrList<Todo> todos = calendar()->todos( ); 1443 QPtrList<Todo> todos = calendar()->todos( );
1445 Todo *todo; 1444 Todo *todo;
1446 for(todo = todos.first(); todo; todo = todos.next()) { 1445 for(todo = todos.first(); todo; todo = todos.next()) {
1447 //insertTodo( todo ); 1446 //insertTodo( todo );
1448 if ( todo->hasDueDate() ) { 1447 if ( todo->hasDueDate() ) {
1449 int day = mStartDate.daysTo( todo->dtDue().date() ); 1448 int day = mStartDate.daysTo( todo->dtDue().date() );
1450 if ( day >= 0 && day < timeSpan + 1) { 1449 if ( day >= 0 && day < timeSpan + 1) {
1451 (*cells)[day]->insertTodo( todo ); 1450 (*cells)[day]->insertTodo( todo );
1452 } 1451 }
1453 } 1452 }
1454 } 1453 }
1455 1454
1456 for( i = 0; i < timeSpan+1; ++i ) { 1455 for( i = 0; i < timeSpan+1; ++i ) {
1457 (*cells)[i]->finishUpdateCell(); 1456 (*cells)[i]->finishUpdateCell();
1458 } 1457 }
1459 processSelectionChange(); 1458 processSelectionChange();
1460 //qApp->processEvents(); 1459 //qApp->processEvents();
1461 for( i = 0; i < timeSpan+1; ++i ) { 1460 for( i = 0; i < timeSpan+1; ++i ) {
1462 (*cells)[i]->repaintfinishUpdateCell(); 1461 (*cells)[i]->repaintfinishUpdateCell();
1463 } 1462 }
1464 (*cells)[0]->setFocus(); 1463 (*cells)[0]->setFocus();
1465 1464
1466 1465
1467#else 1466#else
1468 // old code 1467 // old code
1469 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1468 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1470 int i; 1469 int i;
1471 for( i = 0; i < (*cells).count(); ++i ) { 1470 for( i = 0; i < (*cells).count(); ++i ) {
1472 (*cells)[i]->updateCell(); 1471 (*cells)[i]->updateCell();
1473 } 1472 }
1474 1473
1475 //qDebug("KOMonthView::updateView() "); 1474 //qDebug("KOMonthView::updateView() ");
1476 processSelectionChange(); 1475 processSelectionChange();
1477 // qDebug("---------------------------------------------------------------------+ "); 1476 // qDebug("---------------------------------------------------------------------+ ");
1478 (*cells)[0]->setFocus(); 1477 (*cells)[0]->setFocus();
1479#endif 1478#endif
1480 1479
1481 //qDebug("update time %d ", ti.elapsed()); 1480 //qDebug("update time %d ", ti.elapsed());
1482} 1481}
1483 1482
1484void KOMonthView::resizeEvent(QResizeEvent * e) 1483void KOMonthView::resizeEvent(QResizeEvent * e)
1485{ 1484{
1486 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1485 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1487 if ( isVisible() ) { 1486 if ( isVisible() ) {
1488 //qDebug("KOMonthView::isVisible "); 1487 //qDebug("KOMonthView::isVisible ");
1489 slotComputeLayout(); 1488 slotComputeLayout();
1490 } else 1489 } else
1491 mComputeLayoutTimer->start( 100 ); 1490 mComputeLayoutTimer->start( 100 );
1492} 1491}
1493 1492
1494void KOMonthView::slotComputeLayout() 1493void KOMonthView::slotComputeLayout()
1495{ 1494{
1496 mComputeLayoutTimer->stop(); 1495 mComputeLayoutTimer->stop();
1497 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1496 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1498 computeLayout(); 1497 computeLayout();
1499 clPending = true; 1498 clPending = true;
1500 if ( mShowWeekView ) 1499 if ( mShowWeekView )
1501 mCellsW[0]->setFocus(); 1500 mCellsW[0]->setFocus();
1502 else 1501 else
1503 mCells[0]->setFocus(); 1502 mCells[0]->setFocus();
1504 1503
1505} 1504}
1506void KOMonthView::computeLayoutWeek() 1505void KOMonthView::computeLayoutWeek()
1507{ 1506{
1508 static int lastWid = 0; 1507 static int lastWid = 0;
1509 static int lastHei = 0; 1508 static int lastHei = 0;
1510 int daysToShow; 1509 int daysToShow;
1511 bool combinedSatSun = false; 1510 bool combinedSatSun = false;
1512 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1511 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1513 daysToShow = 6; 1512 daysToShow = 6;
1514 combinedSatSun = true; 1513 combinedSatSun = true;
1515 } 1514 }
1516 int tWid = topLevelWidget()->size().width(); 1515 int tWid = topLevelWidget()->size().width();
1517 int tHei = topLevelWidget()->size().height(); 1516 int tHei = topLevelWidget()->size().height();
1518 1517
1519 int wid = width();//e 1518 int wid = width();//e
1520 int hei = height()-1-mNavigatorBar->height(); 1519 int hei = height()-1-mNavigatorBar->height();
1521 1520
1522 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1521 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1523 return; 1522 return;
1524 1523
1525 if ( lastWid == width() && lastHei == height() ) { 1524 if ( lastWid == width() && lastHei == height() ) {
1526 //qDebug("KOListWeekView::No compute layout needed "); 1525 //qDebug("KOListWeekView::No compute layout needed ");
1527 return; 1526 return;
1528 } 1527 }
1529 lastWid = width(); 1528 lastWid = width();
1530 lastHei = height(); 1529 lastHei = height();
1531 1530
1532 1531
1533 if ( wid < hei ) 1532 if ( wid < hei )
1534 daysToShow = 2; 1533 daysToShow = 2;
1535 else 1534 else
1536 daysToShow = 3; 1535 daysToShow = 3;
1537 mShowSatSunComp = true; 1536 mShowSatSunComp = true;
1538 combinedSatSun = true; 1537 combinedSatSun = true;
1539 1538
1540 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1539 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1541 QFontMetrics fm ( mWeekLabels[0]->font() ); 1540 QFontMetrics fm ( mWeekLabels[0]->font() );
1542 int weeklabelwid = fm.width( "888" ); 1541 int weeklabelwid = fm.width( "888" );
1543 wid -= weeklabelwid; 1542 wid -= weeklabelwid;
1544 1543
1545 int colWid = wid / daysToShow; 1544 int colWid = wid / daysToShow;
1546 int lastCol = wid - ( colWid*6 ); 1545 int lastCol = wid - ( colWid*6 );
1547 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1546 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1548 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1547 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1549 int colModulo = wid % daysToShow; 1548 int colModulo = wid % daysToShow;
1550 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1549 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1551 //qDebug("rowmod %d ", rowModulo); 1550 //qDebug("rowmod %d ", rowModulo);
1552 int i; 1551 int i;
1553 int x,y,w,h; 1552 int x,y,w,h;
1554 x= 0; 1553 x= 0;
1555 y= 0; 1554 y= 0;
1556 w = colWid; 1555 w = colWid;
1557 h = dayLabelHei ; 1556 h = dayLabelHei ;
1558 for ( i = 0; i < 7; i++) { 1557 for ( i = 0; i < 7; i++) {
1559 if ( i && !( i % daysToShow) && i < 6) { 1558 if ( i && !( i % daysToShow) && i < 6) {
1560 y += hei/(5-daysToShow); 1559 y += hei/(5-daysToShow);
1561 x = 0; 1560 x = 0;
1562 w = colWid; 1561 w = colWid;
1563 } 1562 }
1564 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1563 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1565 ++w; 1564 ++w;
1566 } 1565 }
1567 if ( i >= 5 ) { 1566 if ( i >= 5 ) {
1568 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1567 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1569 x -= (w/2 ); 1568 x -= (w/2 );
1570 } 1569 }
1571 else 1570 else
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a58f6b8..9e724c7 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -33,282 +33,282 @@
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class KOWeekButton : public QPushButton 47class KOWeekButton : public QPushButton
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 51 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
52 QPushButton( parent, name) 52 QPushButton( parent, name)
53 { 53 {
54 connect( this, SIGNAL( clicked() ), 54 connect( this, SIGNAL( clicked() ),
55 SLOT( bottonClicked() )); 55 SLOT( bottonClicked() ));
56 mNumber = -1; 56 mNumber = -1;
57 } 57 }
58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
59 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
60 signals: 60 signals:
61 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
62private: 62private:
63 int mNumber; 63 int mNumber;
64private slots : 64private slots :
65 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 65 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
66}; 66};
67 67
68class KNoScrollListBox: public QListBox 68class KNoScrollListBox: public QListBox
69{ 69{
70 Q_OBJECT 70 Q_OBJECT
71 public: 71 public:
72 KNoScrollListBox(QWidget *parent=0, const char *name=0); 72 KNoScrollListBox(QWidget *parent=0, const char *name=0);
73 ~KNoScrollListBox(); 73 ~KNoScrollListBox();
74 QString getWhatsThisText(QPoint p) ; 74 QString getWhatsThisText(QPoint p) ;
75 75
76 signals: 76 signals:
77 void shiftDown(); 77 void shiftDown();
78 void shiftUp(); 78 void shiftUp();
79 void rightClick(); 79 void rightClick();
80 80
81 protected slots: 81 protected slots:
82 void oneDown(); 82 void oneDown();
83 void keyPressEvent(QKeyEvent *); 83 void keyPressEvent(QKeyEvent *);
84 void keyReleaseEvent(QKeyEvent *); 84 void keyReleaseEvent(QKeyEvent *);
85 void mousePressEvent(QMouseEvent *); 85 void mousePressEvent(QMouseEvent *);
86 86
87 private: 87 private:
88 KNOWhatsThis * mWT; 88 KNOWhatsThis * mWT;
89}; 89};
90 90
91 91
92class MonthViewItem: public QListBoxItem 92class MonthViewItem: public QListBoxItem
93{ 93{
94 public: 94 public:
95 MonthViewItem( Incidence *, QDate qd, const QString & title ); 95 MonthViewItem( Incidence *, QDate qd, const QString & title );
96 void recycle( Incidence *incidence, QDate qd, const QString & s); 96 void recycle( Incidence *incidence, QDate qd, const QString & s);
97 void setRecur(bool on) { mRecur = on; } 97 void setRecur(bool on) { mRecur = on; }
98 void setAlarm(bool on) { mAlarm = on; } 98 void setAlarm(bool on) { mAlarm = on; }
99 void setReply(bool on) { mReply = on; } 99 void setReply(bool on) { mReply = on; }
100 void setMoreInfo(bool on) { mInfo = on; } 100 void setMoreInfo(bool on) { mInfo = on; }
101 void setMultiDay(int type) { mMultiday = type; } 101 void setMultiDay(int type) { mMultiday = type; }
102 void setBlockRepaint(bool on) { mblockRepaint = on; } 102 void setBlockRepaint(bool on) { mblockRepaint = on; }
103 103
104 104
105 void setPalette(const QPalette &p) { mPalette = p; } 105 void setPalette(const QPalette &p) { mPalette = p; }
106 QPalette palette() const { return mPalette; } 106 QPalette palette() const { return mPalette; }
107 107
108 Incidence *incidence() const { return mIncidence; } 108 Incidence *incidence() const { return mIncidence; }
109 QDate incidenceDate() { return mDate; } 109 QDate incidenceDate() { return mDate; }
110 110
111 protected: 111 protected:
112 virtual void paint(QPainter *); 112 virtual void paint(QPainter *);
113 virtual int height(const QListBox *) const; 113 virtual int height(const QListBox *) const;
114 virtual int width(const QListBox *) const; 114 virtual int width(const QListBox *) const;
115 115
116 private: 116 private:
117 bool mblockRepaint; 117 bool mblockRepaint;
118 int mMultiday; 118 int mMultiday;
119 bool mRecur; 119 bool mRecur;
120 bool mAlarm; 120 bool mAlarm;
121 bool mReply; 121 bool mReply;
122 bool mInfo; 122 bool mInfo;
123 123
124 QPalette mPalette; 124 QPalette mPalette;
125 QDate mDate; 125 QDate mDate;
126 126
127 Incidence *mIncidence; 127 Incidence *mIncidence;
128}; 128};
129 129
130 130
131class KOMonthView; 131class KOMonthView;
132 132
133class MonthViewCell : public KNoScrollListBox 133class MonthViewCell : public KNoScrollListBox
134{ 134{
135 Q_OBJECT 135 Q_OBJECT
136 public: 136 public:
137 MonthViewCell(KOMonthView *,QWidget* ); 137 MonthViewCell(KOMonthView *,QWidget* );
138 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 138 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
139 139
140 void setDate( const QDate & ); 140 void setDate( const QDate & );
141 QDate date() const; 141 QDate date() const;
142 142
143 void setPrimary( bool ); 143 void setPrimary( bool );
144 bool isPrimary() const; 144 bool isPrimary() const;
145 145
146 void setHoliday( bool ); 146 void setHoliday( bool );
147 void setHoliday( const QString & ); 147 void setHoliday( const QString & );
148 148
149 void updateCell(); 149 void updateCell();
150 void startUpdateCell(); 150 void startUpdateCell();
151 void finishUpdateCell(); 151 void finishUpdateCell();
152 void repaintfinishUpdateCell(); 152 void repaintfinishUpdateCell();
153 void insertEvent(Event *); 153 void insertEvent(Event *);
154 void insertTodo(Todo *); 154 void insertTodo(Todo *);
155 155
156 void updateConfig( bool bigFont = false ); 156 void updateConfig( bool bigFont = false );
157 157
158 void enableScrollBars( bool ); 158 void enableScrollBars( bool );
159 159
160 Incidence *selectedIncidence(); 160 Incidence *selectedIncidence();
161 QDate selectedIncidenceDate(); 161 QDate selectedIncidenceDate();
162 QPushButton * dateLabel() { return mLabel; } 162 QPushButton * dateLabel() { return mLabel; }
163 163
164 void deselect(); 164 void deselect();
165 void select(); 165 void select();
166 166
167#ifdef DESKTOP_VERSION 167#ifdef DESKTOP_VERSION
168 static QToolTipGroup *toolTipGroup(); 168 static QToolTipGroup *toolTipGroup();
169#endif 169#endif
170 signals: 170 signals:
171 void defaultAction( Incidence * ); 171 void defaultAction( Incidence * );
172 void newEventSignal( QDateTime ); 172 void newEventSignal( QDateTime );
173 void showDaySignal( QDate ); 173 void showDaySignal( QDate );
174 174
175 protected: 175 protected:
176 QStringList mToolTip; 176 QStringList mToolTip;
177 void resizeEvent( QResizeEvent * ); 177 void resizeEvent( QResizeEvent * );
178 178
179 179
180public slots: 180public slots:
181 void showDay(); 181 void showDay();
182 182
183 protected slots: 183 protected slots:
184 void defaultAction( QListBoxItem * ); 184 void defaultAction( QListBoxItem * );
185 void contextMenu( QListBoxItem * ); 185 void contextMenu( QListBoxItem * );
186 void selection( QListBoxItem * ); 186 void selection( QListBoxItem * );
187 void cellClicked( QListBoxItem * ); 187 void cellClicked( QListBoxItem * );
188 void newEvent(); 188 void newEvent();
189 189
190 private: 190 private:
191 MonthViewItem* mCurrentAvailItem; 191 MonthViewItem* mCurrentAvailItem;
192 QPtrList <MonthViewItem> mAvailItemList; 192 QPtrList <MonthViewItem> mAvailItemList;
193 KOMonthView *mMonthView; 193 KOMonthView *mMonthView;
194 int currentPalette; 194 int currentPalette;
195 195
196 QDate mDate; 196 QDate mDate;
197 bool mPrimary; 197 bool mPrimary;
198 bool mHoliday; 198 bool mHoliday;
199 QString mHolidayString; 199 QString mHolidayString;
200 200
201 //QLabel *mLabel; 201 //QLabel *mLabel;
202 QPushButton *mLabel; 202 QPushButton *mLabel;
203 //QListBox *mItemList; 203 //QListBox *mItemList;
204#ifdef DESKTOP_VERSION 204#ifdef DESKTOP_VERSION
205 static QToolTipGroup *mToolTipGroup; 205 static QToolTipGroup *mToolTipGroup;
206#endif 206#endif
207 QSize mLabelSize; 207 QSize mLabelSize;
208 QSize mLabelBigSize; 208 QSize mLabelBigSize;
209 QPalette mHolidayPalette; 209 QPalette mHolidayPalette;
210 QPalette mStandardPalette; 210 QPalette mStandardPalette;
211 QPalette mPrimaryPalette; 211 QPalette mPrimaryPalette;
212 QPalette mNonPrimaryPalette; 212 QPalette mNonPrimaryPalette;
213 void setMyPalette(); 213 void setMyPalette();
214 QPalette getPalette (); 214 QPalette getPalette ();
215 215
216}; 216};
217 217
218 218
219class KOMonthView: public KOEventView 219class KOMonthView: public KOEventView
220{ 220{
221 Q_OBJECT 221 Q_OBJECT
222 public: 222 public:
223 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 223 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
224 ~KOMonthView(); 224 ~KOMonthView();
225 225
226 /** Returns maximum number of days supported by the komonthview */ 226 /** Returns maximum number of days supported by the komonthview */
227 virtual int maxDatesHint(); 227 virtual int maxDatesHint();
228 228
229 /** Returns number of currently shown dates. */ 229 /** Returns number of currently shown dates. */
230 virtual int currentDateCount(); 230 virtual int currentDateCount();
231 231
232 /** returns the currently selected events */ 232 /** returns the currently selected events */
233 virtual QPtrList<Incidence> selectedIncidences(); 233 virtual QPtrList<Incidence> selectedIncidences();
234 234
235 /** returns dates of the currently selected events */ 235 /** returns dates of the currently selected events */
236 virtual DateList selectedDates(); 236 virtual DateList selectedDates();
237 237
238 virtual void printPreview(CalPrinter *calPrinter, 238 virtual void printPreview(CalPrinter *calPrinter,
239 const QDate &, const QDate &); 239 const QDate &, const QDate &);
240 bool isMonthView() { return !mShowWeekView; } 240 bool isMonthView() { return !mShowWeekView; }
241 bool isUpdatePossible() { return updatePossible; } 241 bool isUpdatePossible() { return updatePossible; }
242 242
243 MonthViewCell * selectedCell(); 243 MonthViewCell * selectedCell();
244 bool skipResize; 244 bool skipResize;
245 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 245 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
246 public slots: 246 public slots:
247 virtual void updateView(); 247 virtual void updateView();
248 virtual void updateConfig(); 248 virtual void updateConfig();
249 virtual void showDates(const QDate &start, const QDate &end); 249 virtual void showDates(const QDate &start, const QDate &end);
250 virtual void showEvents(QPtrList<Event> eventList); 250 virtual void showEvents(QPtrList<Event> eventList);
251 251
252 void changeEventDisplay(Event *, int); 252 void changeEventDisplay(Event *, int);
253 253
254 void clearSelection(); 254 void clearSelection();
255 255
256 void showContextMenu( Incidence * ); 256 void showContextMenu( Incidence * );
257 257
258 void setSelectedCell( MonthViewCell * ); 258 void setSelectedCell( MonthViewCell * );
259 void switchView(); 259 void switchView();
260 260
261 protected slots: 261 protected slots:
262 void slotComputeLayout(); 262 void slotComputeLayout();
263 void selectInternalWeekNum ( int ); 263 void selectInternalWeekNum ( int );
264 void processSelectionChange(); 264 void processSelectionChange();
265 signals: 265 signals:
266 void nextMonth(); 266 void nextMonth();
267 void prevMonth(); 267 void prevMonth();
268 void selectWeekNum ( int ); 268 void selectWeekNum ( int );
269 void selectMonth (); 269 void selectMonth ();
270 void showDaySignal( QDate ); 270 void showDaySignal( QDate );
271 protected: 271 protected:
272 void resizeEvent(QResizeEvent *); 272 void resizeEvent(QResizeEvent *);
273 void viewChanged(); 273 void viewChanged();
274 void updateDayLabels(); 274 void updateDayLabels();
275 275
276 private: 276 private:
277 QTimer* mComputeLayoutTimer; 277 QTimer* mComputeLayoutTimer;
278 NavigatorBar* mNavigatorBar; 278 NavigatorBar* mNavigatorBar;
279 int currentWeek(); 279 int currentWeek();
280 bool clPending; 280 bool clPending;
281 QWidgetStack * mWidStack; 281 QWidgetStack * mWidStack;
282 QWidget* mMonthView; 282 QWidget* mMonthView;
283 QWidget* mWeekView; 283 QWidget* mWeekView;
284 bool mShowWeekView; 284 bool mShowWeekView;
285 bool updatePossible; 285 bool updatePossible;
286 int mDaysPerWeek; 286 int mDaysPerWeek;
287 int mNumWeeks; 287 int mNumWeeks;
288 int mNumCells; 288 int mNumCells;
289 bool mWeekStartsMonday; 289 //bool mWeekStartsMonday;
290 bool mShowSatSunComp; 290 bool mShowSatSunComp;
291 void computeLayout(); 291 void computeLayout();
292 void computeLayoutWeek(); 292 void computeLayoutWeek();
293 293
294 QPtrVector<MonthViewCell> mCells; 294 QPtrVector<MonthViewCell> mCells;
295 QPtrVector<QLabel> mDayLabels; 295 QPtrVector<QLabel> mDayLabels;
296 QPtrVector<KOWeekButton> mWeekLabels; 296 QPtrVector<KOWeekButton> mWeekLabels;
297 QPtrVector<MonthViewCell> mCellsW; 297 QPtrVector<MonthViewCell> mCellsW;
298 QPtrVector<QLabel> mDayLabelsW; 298 QPtrVector<QLabel> mDayLabelsW;
299 QPtrVector<KOWeekButton> mWeekLabelsW; 299 QPtrVector<KOWeekButton> mWeekLabelsW;
300 300
301 bool mShortDayLabelsM; 301 bool mShortDayLabelsM;
302 bool mShortDayLabelsW; 302 bool mShortDayLabelsW;
303 int mWidthLongDayLabel; 303 int mWidthLongDayLabel;
304 304
305 QDate mStartDate; 305 QDate mStartDate;
306 306
307 MonthViewCell *mSelectedCell; 307 MonthViewCell *mSelectedCell;
308 308
309 KOEventPopupMenu *mContextMenu; 309 KOEventPopupMenu *mContextMenu;
310 void keyPressEvent ( QKeyEvent * ) ; 310 void keyPressEvent ( QKeyEvent * ) ;
311 311
312}; 312};
313 313
314#endif 314#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2da592b..8e52968 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1225,539 +1225,517 @@ void MainWindow::exportToPhone( int mode )
1225 1225
1226 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1226 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1227 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1227 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1228 KOex2phonePrefs ex2phone; 1228 KOex2phonePrefs ex2phone;
1229 1229
1230 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1230 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1231 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1231 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1232 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1232 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1233 if ( mode == 1 ) 1233 if ( mode == 1 )
1234 ex2phone.setCaption(i18n("Export complete calendar")); 1234 ex2phone.setCaption(i18n("Export complete calendar"));
1235 if ( mode == 2 ) 1235 if ( mode == 2 )
1236 ex2phone.setCaption(i18n("Export filtered calendar")); 1236 ex2phone.setCaption(i18n("Export filtered calendar"));
1237 1237
1238 if ( !ex2phone.exec() ) { 1238 if ( !ex2phone.exec() ) {
1239 return; 1239 return;
1240 } 1240 }
1241 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1241 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1242 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1242 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1243 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1243 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1244 1244
1245 int inFuture = 0; 1245 int inFuture = 0;
1246 if ( ex2phone.mWriteBackFuture->isChecked() ) 1246 if ( ex2phone.mWriteBackFuture->isChecked() )
1247 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1247 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1248 QPtrList<Incidence> delSel; 1248 QPtrList<Incidence> delSel;
1249 if ( mode == 1 ) 1249 if ( mode == 1 )
1250 delSel = mCalendar->rawIncidences(); 1250 delSel = mCalendar->rawIncidences();
1251 if ( mode == 2 ) 1251 if ( mode == 2 )
1252 delSel = mCalendar->incidences(); 1252 delSel = mCalendar->incidences();
1253 CalendarLocal* cal = new CalendarLocal(); 1253 CalendarLocal* cal = new CalendarLocal();
1254 cal->setLocalTime(); 1254 cal->setLocalTime();
1255 Incidence *incidence = delSel.first(); 1255 Incidence *incidence = delSel.first();
1256 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1256 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1257 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1257 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1258 while ( incidence ) { 1258 while ( incidence ) {
1259 if ( incidence->type() != "Journal" ) { 1259 if ( incidence->type() != "Journal" ) {
1260 bool add = true; 1260 bool add = true;
1261 if ( inFuture ) { 1261 if ( inFuture ) {
1262 QDateTime dt; 1262 QDateTime dt;
1263 if ( incidence->type() == "Todo" ) { 1263 if ( incidence->type() == "Todo" ) {
1264 Todo * t = (Todo*)incidence; 1264 Todo * t = (Todo*)incidence;
1265 if ( t->hasDueDate() ) 1265 if ( t->hasDueDate() )
1266 dt = t->dtDue(); 1266 dt = t->dtDue();
1267 else 1267 else
1268 dt = cur.addSecs( 62 ); 1268 dt = cur.addSecs( 62 );
1269 } 1269 }
1270 else { 1270 else {
1271 bool ok; 1271 bool ok;
1272 dt = incidence->getNextOccurence( cur, &ok ); 1272 dt = incidence->getNextOccurence( cur, &ok );
1273 if ( !ok ) 1273 if ( !ok )
1274 dt = cur.addSecs( -62 ); 1274 dt = cur.addSecs( -62 );
1275 } 1275 }
1276 if ( dt < cur || dt > end ) { 1276 if ( dt < cur || dt > end ) {
1277 add = false; 1277 add = false;
1278 } 1278 }
1279 } 1279 }
1280 if ( add ) { 1280 if ( add ) {
1281 Incidence *in = incidence->clone(); 1281 Incidence *in = incidence->clone();
1282 cal->addIncidence( in ); 1282 cal->addIncidence( in );
1283 } 1283 }
1284 } 1284 }
1285 incidence = delSel.next(); 1285 incidence = delSel.next();
1286 } 1286 }
1287 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1287 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1288 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1288 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1289 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1289 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1290 1290
1291 setCaption( i18n("Writing to phone...")); 1291 setCaption( i18n("Writing to phone..."));
1292 if ( PhoneFormat::writeToPhone( cal ) ) 1292 if ( PhoneFormat::writeToPhone( cal ) )
1293 setCaption( i18n("Export to phone successful!")); 1293 setCaption( i18n("Export to phone successful!"));
1294 else 1294 else
1295 setCaption( i18n("Error exporting to phone!")); 1295 setCaption( i18n("Error exporting to phone!"));
1296 delete cal; 1296 delete cal;
1297} 1297}
1298 1298
1299 1299
1300void MainWindow::setDefaultPreferences() 1300void MainWindow::setDefaultPreferences()
1301{ 1301{
1302 KOPrefs *p = KOPrefs::instance(); 1302 KOPrefs *p = KOPrefs::instance();
1303 1303
1304 p->mCompactDialogs = true; 1304 p->mCompactDialogs = true;
1305 p->mConfirm = true; 1305 p->mConfirm = true;
1306 // p->mEnableQuickTodo = false; 1306 // p->mEnableQuickTodo = false;
1307 1307
1308} 1308}
1309 1309
1310QString MainWindow::resourcePath() 1310QString MainWindow::resourcePath()
1311{ 1311{
1312 return KGlobal::iconLoader()->iconPath(); 1312 return KGlobal::iconLoader()->iconPath();
1313} 1313}
1314 1314
1315void MainWindow::displayText( QString text ,QString cap ) 1315void MainWindow::displayText( QString text ,QString cap )
1316{ 1316{
1317 QDialog dia( this, "name", true ); ; 1317 QDialog dia( this, "name", true ); ;
1318 dia.setCaption( cap ); 1318 dia.setCaption( cap );
1319 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1319 QVBoxLayout* lay = new QVBoxLayout( &dia );
1320 lay->setSpacing( 3 ); 1320 lay->setSpacing( 3 );
1321 lay->setMargin( 3 ); 1321 lay->setMargin( 3 );
1322 QTextBrowser tb ( &dia ); 1322 QTextBrowser tb ( &dia );
1323 lay->addWidget( &tb ); 1323 lay->addWidget( &tb );
1324 tb.setText( text ); 1324 tb.setText( text );
1325#ifdef DESKTOP_VERSION 1325#ifdef DESKTOP_VERSION
1326 dia.resize( 640, 480); 1326 dia.resize( 640, 480);
1327#else 1327#else
1328 dia.showMaximized(); 1328 dia.showMaximized();
1329#endif 1329#endif
1330 dia.exec(); 1330 dia.exec();
1331} 1331}
1332 1332
1333void MainWindow::features() 1333void MainWindow::features()
1334{ 1334{
1335 1335
1336 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1336 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1337} 1337}
1338 1338
1339void MainWindow::usertrans() 1339void MainWindow::usertrans()
1340{ 1340{
1341 1341
1342 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1342 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1343} 1343}
1344 1344
1345void MainWindow::kdesynchowto() 1345void MainWindow::kdesynchowto()
1346{ 1346{
1347 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1347 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1348} 1348}
1349void MainWindow::multisynchowto() 1349void MainWindow::multisynchowto()
1350{ 1350{
1351 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1351 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1352} 1352}
1353void MainWindow::synchowto() 1353void MainWindow::synchowto()
1354{ 1354{
1355 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1355 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1356} 1356}
1357void MainWindow::faq() 1357void MainWindow::faq()
1358{ 1358{
1359 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1359 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1360 1360
1361} 1361}
1362void MainWindow::whatsNew() 1362void MainWindow::whatsNew()
1363{ 1363{
1364 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1364 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1365 1365
1366} 1366}
1367void MainWindow::licence() 1367void MainWindow::licence()
1368{ 1368{
1369 KApplication::showLicence(); 1369 KApplication::showLicence();
1370 1370
1371} 1371}
1372void MainWindow::about() 1372void MainWindow::about()
1373{ 1373{
1374 QString version; 1374 QString version;
1375#include <../version> 1375#include <../version>
1376 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1376 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1377 i18n("KOrganizer/Platform-independent\n") + 1377 i18n("KOrganizer/Platform-independent\n") +
1378 "(KO/Pi) " + version + " - " + 1378 "(KO/Pi) " + version + " - " +
1379 1379
1380#ifdef DESKTOP_VERSION 1380#ifdef DESKTOP_VERSION
1381 i18n("Desktop Edition\n") + 1381 i18n("Desktop Edition\n") +
1382#else 1382#else
1383 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1383 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1384#endif 1384#endif
1385 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1385 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1386} 1386}
1387void MainWindow::keyBindings() 1387void MainWindow::keyBindings()
1388{ 1388{
1389 QString cap = i18n("KO/Pi Keys + Colors"); 1389 QString cap = i18n("KO/Pi Keys + Colors");
1390 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1390 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1391 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1391 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1392 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1392 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1393 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1393 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1394 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1394 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1395 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1395 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1396 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1396 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1397 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1397 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1398 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1398 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1399 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1399 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1400 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1400 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1401 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1401 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1402 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1402 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1403 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1403 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1404 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1404 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1405 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1405 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1406 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1406 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1407 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1407 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1408 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1408 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1409 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1409 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1410 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1410 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1411 i18n("<p><h3>In agenda view:</h3></p>\n") + 1411 i18n("<p><h3>In agenda view:</h3></p>\n") +
1412 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1412 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1413 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1413 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1414 i18n("<p><h3>In todo view:</h3></p>\n") + 1414 i18n("<p><h3>In todo view:</h3></p>\n") +
1415 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1415 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1416 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1416 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1417 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1417 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1418 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1418 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1419 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1419 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1420 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1420 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1421 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1421 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1422 i18n("<p><h3>In list view:</h3></p>\n") + 1422 i18n("<p><h3>In list view:</h3></p>\n") +
1423 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1423 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1424 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1424 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1425 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1425 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1426 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1426 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1427 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1427 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1428 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1428 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1429 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1429 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1430 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1430 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1431 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1431 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1432 i18n("<p><b>E</b>: Edit item</p>\n") + 1432 i18n("<p><b>E</b>: Edit item</p>\n") +
1433 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1433 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1434 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1434 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1435 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1435 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1436 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1436 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1437 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1437 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1438 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1438 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1439 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1439 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1440 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1440 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1441 i18n("<p><b>White</b>: Item readonly</p>\n"); 1441 i18n("<p><b>White</b>: Item readonly</p>\n");
1442 displayText( text, cap); 1442 displayText( text, cap);
1443} 1443}
1444void MainWindow::aboutAutoSaving() 1444void MainWindow::aboutAutoSaving()
1445{ 1445{
1446 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"); 1446 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");
1447 1447
1448 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1448 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1449 1449
1450} 1450}
1451void MainWindow::aboutKnownBugs() 1451void MainWindow::aboutKnownBugs()
1452{ 1452{
1453 QMessageBox* msg; 1453 QMessageBox* msg;
1454 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1454 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1455 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")+ 1455 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")+
1456 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1456 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1457 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1457 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1458 i18n("\nor report them in the bugtracker on\n") + 1458 i18n("\nor report them in the bugtracker on\n") +
1459 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1459 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1460 QMessageBox::NoIcon, 1460 QMessageBox::NoIcon,
1461 QMessageBox::Ok, 1461 QMessageBox::Ok,
1462 QMessageBox::NoButton, 1462 QMessageBox::NoButton,
1463 QMessageBox::NoButton); 1463 QMessageBox::NoButton);
1464 msg->exec(); 1464 msg->exec();
1465 delete msg; 1465 delete msg;
1466 1466
1467} 1467}
1468 1468
1469QString MainWindow::defaultFileName() 1469QString MainWindow::defaultFileName()
1470{ 1470{
1471 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1471 return locateLocal( "data", "korganizer/mycalendar.ics" );
1472} 1472}
1473QString MainWindow::syncFileName() 1473QString MainWindow::syncFileName()
1474{ 1474{
1475#ifdef DESKTOP_VERSION 1475#ifdef DESKTOP_VERSION
1476 return locateLocal( "tmp", "synccalendar.ics" ); 1476 return locateLocal( "tmp", "synccalendar.ics" );
1477#else 1477#else
1478 return QString( "/tmp/synccalendar.ics" ); 1478 return QString( "/tmp/synccalendar.ics" );
1479#endif 1479#endif
1480} 1480}
1481#include "koglobals.h"
1482#include <kcalendarsystem.h>
1481void MainWindow::updateWeek(QDate seda) 1483void MainWindow::updateWeek(QDate seda)
1482{ 1484{
1483 int weekNum = 0; 1485 int weekNum = KGlobal::locale()->weekNum ( seda );
1484 QDate d = QDate ( seda.year(), 1,1);
1485 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1486 if ( seda.addDays(6).year() != seda.year() ) {
1487 if ( seda.year() != d.year() ) {
1488 if ( d.dayOfWeek() > 4 )
1489 d = QDate ( seda.year(), 1,1);
1490 else
1491 weekNum = 1;
1492 } else {
1493 QDate dd( seda.year()+1, 1,1);
1494 if ( dd.dayOfWeek() <= 4 )
1495 weekNum = 1;
1496 }
1497 }
1498 if ( weekNum == 0 ){
1499 int dow = d.dayOfWeek();
1500 if ( dow <= 4 )
1501 d = d.addDays( 1-dow );
1502 else // 5,6,7
1503 d = d.addDays( 8-dow );
1504 // we have the first week of the year.we are on monday
1505 weekNum = d.daysTo( seda ) / 7 +1;
1506 }
1507
1508 mWeekPixmap.fill( mWeekBgColor ); 1486 mWeekPixmap.fill( mWeekBgColor );
1509 QPainter p ( &mWeekPixmap ); 1487 QPainter p ( &mWeekPixmap );
1510 p.setFont( mWeekFont ); 1488 p.setFont( mWeekFont );
1511 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1489 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1512 p.end(); 1490 p.end();
1513 QIconSet icon3 ( mWeekPixmap ); 1491 QIconSet icon3 ( mWeekPixmap );
1514 mWeekAction->setIconSet ( icon3 ); 1492 mWeekAction->setIconSet ( icon3 );
1515 1493
1516} 1494}
1517void MainWindow::updateWeekNum(const DateList &selectedDates) 1495void MainWindow::updateWeekNum(const DateList &selectedDates)
1518{ 1496{
1519 updateWeek( selectedDates.first() ); 1497 updateWeek( selectedDates.first() );
1520} 1498}
1521void MainWindow::processIncidenceSelection( Incidence *incidence ) 1499void MainWindow::processIncidenceSelection( Incidence *incidence )
1522{ 1500{
1523 1501
1524 if ( !incidence ) { 1502 if ( !incidence ) {
1525 enableIncidenceActions( false ); 1503 enableIncidenceActions( false );
1526 1504
1527 mNewSubTodoAction->setEnabled( false ); 1505 mNewSubTodoAction->setEnabled( false );
1528 setCaptionToDates(); 1506 setCaptionToDates();
1529 return; 1507 return;
1530 1508
1531 } 1509 }
1532 1510
1533 //KGlobal::locale()->formatDateTime(nextA, true); 1511 //KGlobal::locale()->formatDateTime(nextA, true);
1534 QString startString = ""; 1512 QString startString = "";
1535 if ( incidence->type() != "Todo" ) { 1513 if ( incidence->type() != "Todo" ) {
1536 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1514 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1537 if ( incidence->doesFloat() ) { 1515 if ( incidence->doesFloat() ) {
1538 startString += ": "+incidence->dtStartDateStr( true ); 1516 startString += ": "+incidence->dtStartDateStr( true );
1539 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1517 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1540 1518
1541 } else { 1519 } else {
1542 startString = ": "+incidence->dtStartStr(true); 1520 startString = ": "+incidence->dtStartStr(true);
1543 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1521 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1544 1522
1545 } 1523 }
1546 1524
1547 } else { 1525 } else {
1548 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1526 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1549 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1527 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1550 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1528 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1551 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1529 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1552 bool ok; 1530 bool ok;
1553 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1531 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1554 if ( ok ) { 1532 if ( ok ) {
1555 int years = noc.date().year() - incidence->dtStart().date().year(); 1533 int years = noc.date().year() - incidence->dtStart().date().year();
1556 startString += i18n(" (%1 y.)"). arg( years ); 1534 startString += i18n(" (%1 y.)"). arg( years );
1557 } 1535 }
1558 } 1536 }
1559 else 1537 else
1560 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1538 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1561 } 1539 }
1562 1540
1563 } 1541 }
1564 else 1542 else
1565 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1543 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1566 if ( !incidence->location().isEmpty() ) 1544 if ( !incidence->location().isEmpty() )
1567 startString += " (" +incidence->location()+")"; 1545 startString += " (" +incidence->location()+")";
1568 setCaption( incidence->summary()+startString); 1546 setCaption( incidence->summary()+startString);
1569 1547
1570 enableIncidenceActions( true ); 1548 enableIncidenceActions( true );
1571 1549
1572 if ( incidence->type() == "Event" ) { 1550 if ( incidence->type() == "Event" ) {
1573 mShowAction->setText( i18n("Show Event...") ); 1551 mShowAction->setText( i18n("Show Event...") );
1574 mEditAction->setText( i18n("Edit Event...") ); 1552 mEditAction->setText( i18n("Edit Event...") );
1575 mDeleteAction->setText( i18n("Delete Event...") ); 1553 mDeleteAction->setText( i18n("Delete Event...") );
1576 1554
1577 mNewSubTodoAction->setEnabled( false ); 1555 mNewSubTodoAction->setEnabled( false );
1578 } else if ( incidence->type() == "Todo" ) { 1556 } else if ( incidence->type() == "Todo" ) {
1579 mShowAction->setText( i18n("Show Todo...") ); 1557 mShowAction->setText( i18n("Show Todo...") );
1580 mEditAction->setText( i18n("Edit Todo...") ); 1558 mEditAction->setText( i18n("Edit Todo...") );
1581 mDeleteAction->setText( i18n("Delete Todo...") ); 1559 mDeleteAction->setText( i18n("Delete Todo...") );
1582 1560
1583 mNewSubTodoAction->setEnabled( true ); 1561 mNewSubTodoAction->setEnabled( true );
1584 } else { 1562 } else {
1585 mShowAction->setText( i18n("Show...") ); 1563 mShowAction->setText( i18n("Show...") );
1586 mShowAction->setText( i18n("Edit...") ); 1564 mShowAction->setText( i18n("Edit...") );
1587 mShowAction->setText( i18n("Delete...") ); 1565 mShowAction->setText( i18n("Delete...") );
1588 1566
1589 mNewSubTodoAction->setEnabled( false ); 1567 mNewSubTodoAction->setEnabled( false );
1590 } 1568 }
1591} 1569}
1592 1570
1593void MainWindow::enableIncidenceActions( bool enabled ) 1571void MainWindow::enableIncidenceActions( bool enabled )
1594{ 1572{
1595 mShowAction->setEnabled( enabled ); 1573 mShowAction->setEnabled( enabled );
1596 mEditAction->setEnabled( enabled ); 1574 mEditAction->setEnabled( enabled );
1597 mDeleteAction->setEnabled( enabled ); 1575 mDeleteAction->setEnabled( enabled );
1598 1576
1599 mCloneAction->setEnabled( enabled ); 1577 mCloneAction->setEnabled( enabled );
1600 mMoveAction->setEnabled( enabled ); 1578 mMoveAction->setEnabled( enabled );
1601 mBeamAction->setEnabled( enabled ); 1579 mBeamAction->setEnabled( enabled );
1602 mCancelAction->setEnabled( enabled ); 1580 mCancelAction->setEnabled( enabled );
1603} 1581}
1604 1582
1605void MainWindow::importOL() 1583void MainWindow::importOL()
1606{ 1584{
1607#ifdef _OL_IMPORT_ 1585#ifdef _OL_IMPORT_
1608 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1586 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1609 id->exec(); 1587 id->exec();
1610 delete id; 1588 delete id;
1611 mView->updateView(); 1589 mView->updateView();
1612#endif 1590#endif
1613} 1591}
1614void MainWindow::importBday() 1592void MainWindow::importBday()
1615{ 1593{
1616 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1594 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1617 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1595 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1618 i18n("Import!"), i18n("Cancel"), 0, 1596 i18n("Import!"), i18n("Cancel"), 0,
1619 0, 1 ); 1597 0, 1 );
1620 if ( result == 0 ) { 1598 if ( result == 0 ) {
1621 mView->importBday(); 1599 mView->importBday();
1622 1600
1623 } 1601 }
1624 1602
1625 1603
1626} 1604}
1627void MainWindow::importQtopia() 1605void MainWindow::importQtopia()
1628{ 1606{
1629 //#ifndef DESKTOP_VERSION 1607 //#ifndef DESKTOP_VERSION
1630 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"); 1608 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");
1631#ifdef DESKTOP_VERSION 1609#ifdef DESKTOP_VERSION
1632 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"); 1610 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");
1633#endif 1611#endif
1634 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1612 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1635 i18n("Import!"), i18n("Cancel"), 0, 1613 i18n("Import!"), i18n("Cancel"), 0,
1636 0, 1 ); 1614 0, 1 );
1637 if ( result == 0 ) { 1615 if ( result == 0 ) {
1638#ifndef DESKTOP_VERSION 1616#ifndef DESKTOP_VERSION
1639 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1617 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1640 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1618 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1641 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1619 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1642#else 1620#else
1643 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1621 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1644 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1622 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1645 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1623 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1646#endif 1624#endif
1647 mView->importQtopia( categories, datebook, todolist ); 1625 mView->importQtopia( categories, datebook, todolist );
1648 } 1626 }
1649#if 0 1627#if 0
1650 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1628 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1651 i18n("Not supported \non desktop!\n"), 1629 i18n("Not supported \non desktop!\n"),
1652 i18n("Ok"), i18n("Cancel"), 0, 1630 i18n("Ok"), i18n("Cancel"), 0,
1653 0, 1 ); 1631 0, 1 );
1654 1632
1655#endif 1633#endif
1656} 1634}
1657 1635
1658void MainWindow::saveOnClose() 1636void MainWindow::saveOnClose()
1659{ 1637{
1660 KOPrefs *p = KOPrefs::instance(); 1638 KOPrefs *p = KOPrefs::instance();
1661 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1639 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1662 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1640 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1663 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1641 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1664 if ( filterToolBar ) { 1642 if ( filterToolBar ) {
1665 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1643 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1666 } 1644 }
1667#ifdef DESKTOP_VERSION 1645#ifdef DESKTOP_VERSION
1668 1646
1669 QPoint myP; 1647 QPoint myP;
1670 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1648 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1671 if ( p->mToolBarHor ) 1649 if ( p->mToolBarHor )
1672 p->mToolBarUp = myP.y() > height()/2; 1650 p->mToolBarUp = myP.y() > height()/2;
1673 else 1651 else
1674 p->mToolBarUp = myP.x() > width()/2; 1652 p->mToolBarUp = myP.x() > width()/2;
1675 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1653 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1676 if ( p->mToolBarHorV ) 1654 if ( p->mToolBarHorV )
1677 p->mToolBarUpV = myP.y() > height()/2; 1655 p->mToolBarUpV = myP.y() > height()/2;
1678 else 1656 else
1679 p->mToolBarUpV = myP.x() > width()/2 ; 1657 p->mToolBarUpV = myP.x() > width()/2 ;
1680 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1658 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1681 if ( p->mToolBarHorN ) 1659 if ( p->mToolBarHorN )
1682 p->mToolBarUpN = myP.y() > height()/2; 1660 p->mToolBarUpN = myP.y() > height()/2;
1683 else 1661 else
1684 p->mToolBarUpN = myP.x() > width()/2 ; 1662 p->mToolBarUpN = myP.x() > width()/2 ;
1685 if ( filterToolBar ) { 1663 if ( filterToolBar ) {
1686 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1664 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1687 if ( p->mToolBarHorF ) 1665 if ( p->mToolBarHorF )
1688 p->mToolBarUpF = myP.y() > height()/2; 1666 p->mToolBarUpF = myP.y() > height()/2;
1689 else 1667 else
1690 p->mToolBarUpF = myP.x() > width()/2 ; 1668 p->mToolBarUpF = myP.x() > width()/2 ;
1691 } 1669 }
1692#else 1670#else
1693 if ( p->mToolBarHor ) 1671 if ( p->mToolBarHor )
1694 p->mToolBarUp = iconToolBar->y() > height()/2; 1672 p->mToolBarUp = iconToolBar->y() > height()/2;
1695 else 1673 else
1696 p->mToolBarUp = iconToolBar->x() > width()/2; 1674 p->mToolBarUp = iconToolBar->x() > width()/2;
1697 if ( p->mToolBarHorV ) 1675 if ( p->mToolBarHorV )
1698 p->mToolBarUpV = viewToolBar->y() > height()/2; 1676 p->mToolBarUpV = viewToolBar->y() > height()/2;
1699 else 1677 else
1700 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1678 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1701 1679
1702 if ( p->mToolBarHorN ) 1680 if ( p->mToolBarHorN )
1703 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1681 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1704 else 1682 else
1705 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1683 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1706 if ( filterToolBar ) { 1684 if ( filterToolBar ) {
1707 if ( p->mToolBarHorF ) 1685 if ( p->mToolBarHorF )
1708 p->mToolBarUpF = filterToolBar->y() > height()/2; 1686 p->mToolBarUpF = filterToolBar->y() > height()/2;
1709 else 1687 else
1710 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1688 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1711 } 1689 }
1712#endif 1690#endif
1713 1691
1714 1692
1715 mView->writeSettings(); 1693 mView->writeSettings();
1716 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1694 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1717 save(); 1695 save();
1718} 1696}
1719void MainWindow::slotModifiedChanged( bool changed ) 1697void MainWindow::slotModifiedChanged( bool changed )
1720{ 1698{
1721 if ( mBlockAtStartup ) 1699 if ( mBlockAtStartup )
1722 return; 1700 return;
1723 1701
1724 int msec; 1702 int msec;
1725 // we store the changes after 1 minute, 1703 // we store the changes after 1 minute,
1726 // and for safety reasons after 10 minutes again 1704 // and for safety reasons after 10 minutes again
1727 if ( !mSyncManager->blockSave() ) 1705 if ( !mSyncManager->blockSave() )
1728 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1706 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1729 else 1707 else
1730 msec = 1000 * 600; 1708 msec = 1000 * 600;
1731 mSaveTimer.start( msec, true ); // 1 minute 1709 mSaveTimer.start( msec, true ); // 1 minute
1732 qDebug("KO: Saving File in %d secs!", msec/1000); 1710 qDebug("KO: Saving File in %d secs!", msec/1000);
1733 mCalendarModifiedFlag = true; 1711 mCalendarModifiedFlag = true;
1734} 1712}
1735void MainWindow::saveStopTimer() 1713void MainWindow::saveStopTimer()
1736{ 1714{
1737 mSaveTimer.stop(); 1715 mSaveTimer.stop();
1738 if (mSaveTimer.isActive() ) 1716 if (mSaveTimer.isActive() )
1739 qDebug("ti active "); 1717 qDebug("ti active ");
1740 else 1718 else
1741 qDebug("KO: Save timer stopped"); 1719 qDebug("KO: Save timer stopped");
1742} 1720}
1743void MainWindow::save() 1721void MainWindow::save()
1744{ 1722{
1745 if ( !mCalendarModifiedFlag ) { 1723 if ( !mCalendarModifiedFlag ) {
1746 qDebug("KO: Calendar not modified. Nothing saved."); 1724 qDebug("KO: Calendar not modified. Nothing saved.");
1747 return; 1725 return;
1748 } 1726 }
1749 if ( mSyncManager->blockSave() ) 1727 if ( mSyncManager->blockSave() )
1750 return; 1728 return;
1751 mSyncManager->setBlockSave(true); 1729 mSyncManager->setBlockSave(true);
1752 if ( mView->checkFileVersion( defaultFileName()) ) { 1730 if ( mView->checkFileVersion( defaultFileName()) ) {
1753 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1731 QTime neededSaveTime = QDateTime::currentDateTime().time();
1754 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1732 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1755 qDebug("KO: Start saving data to file!"); 1733 qDebug("KO: Start saving data to file!");
1756 mView->saveCalendar( defaultFileName() ); 1734 mView->saveCalendar( defaultFileName() );
1757 mCalendarModifiedFlag = false; 1735 mCalendarModifiedFlag = false;
1758 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1736 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1759 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1737 qDebug("KO: Needed %d ms for saving.",msNeeded );
1760 QString savemes; 1738 QString savemes;
1761 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1739 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1762 setCaption(savemes); 1740 setCaption(savemes);
1763 } else 1741 } else