summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-05 08:37:52 (UTC)
committer zautrix <zautrix>2005-07-05 08:37:52 (UTC)
commit7e49703511de87f624cc8813b18ebbfcc01752cd (patch) (unidiff)
tree896918396dbf518f6358a066f93a04bd4185f535 /korganizer
parent28ca4c37fb0e131b2978584992840b3fdca21d3e (diff)
downloadkdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.zip
kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.gz
kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp35
-rw-r--r--korganizer/koagenda.h3
-rw-r--r--korganizer/koagendaview.cpp22
-rw-r--r--korganizer/koagendaview.h1
4 files changed, 44 insertions, 17 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index c339b57..662576f 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,159 +1,159 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63bool KOAgenda::mInvalidPixmap = false; 63
64//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{ 67{
68 setLineWidth(0); 68 setLineWidth(0);
69 setMargin(0); 69 setMargin(0);
70 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 71 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 73 minutes->start(0, true);
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
@@ -237,300 +237,310 @@ void KOAgenda::init()
237 pathString += "iconsmini/"; 237 pathString += "iconsmini/";
238 238
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
241 mNewItemPopup->insertSeparator ( ); 241 mNewItemPopup->insertSeparator ( );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
248#ifndef _WIN32_ 248#ifndef _WIN32_
249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
250 viewport()->setWFlags ( wflags); 250 viewport()->setWFlags ( wflags);
251#endif 251#endif
252 mGridSpacingX = 80; 252 mGridSpacingX = 80;
253 mResizeBorderWidth = 8; 253 mResizeBorderWidth = 8;
254 mScrollBorderWidth = 8; 254 mScrollBorderWidth = 8;
255 mScrollDelay = 30; 255 mScrollDelay = 30;
256 mScrollOffset = 10; 256 mScrollOffset = 10;
257 mPaintPixmap.resize( 20,20); 257 mPaintPixmap.resize( 20,20);
258 //enableClipper(true); 258 //enableClipper(true);
259 259
260 // Grab key strokes for keyboard navigation of agenda. Seems to have no 260 // Grab key strokes for keyboard navigation of agenda. Seems to have no
261 // effect. Has to be fixed. 261 // effect. Has to be fixed.
262 setFocusPolicy(WheelFocus); 262 setFocusPolicy(WheelFocus);
263 263
264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
267 267
268 mStartCellX = 0; 268 mStartCellX = 0;
269 mStartCellY = 0; 269 mStartCellY = 0;
270 mCurrentCellX = 0; 270 mCurrentCellX = 0;
271 mCurrentCellY = 0; 271 mCurrentCellY = 0;
272 272
273 mSelectionCellX = 0; 273 mSelectionCellX = 0;
274 mSelectionYTop = 0; 274 mSelectionYTop = 0;
275 mSelectionHeight = 0; 275 mSelectionHeight = 0;
276 276
277 mOldLowerScrollValue = -1; 277 mOldLowerScrollValue = -1;
278 mOldUpperScrollValue = -1; 278 mOldUpperScrollValue = -1;
279 279
280 mClickedItem = 0; 280 mClickedItem = 0;
281 281
282 mActionItem = 0; 282 mActionItem = 0;
283 mActionType = NOP; 283 mActionType = NOP;
284 mItemMoved = false; 284 mItemMoved = false;
285 285
286 mSelectedItem = 0; 286 mSelectedItem = 0;
287 287
288 // mItems.setAutoDelete(true); 288 // mItems.setAutoDelete(true);
289 289
290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
291 291
292 viewport()->update(); 292 viewport()->update();
293 293
294 setMinimumSize(30, 1); 294 setMinimumSize(30, 1);
295// setMaximumHeight(mGridSpacingY * mRows + 5); 295// setMaximumHeight(mGridSpacingY * mRows + 5);
296 296
297 // Disable horizontal scrollbar. This is a hack. The geometry should be 297 // Disable horizontal scrollbar. This is a hack. The geometry should be
298 // controlled in a way that the contents horizontally always fits. Then it is 298 // controlled in a way that the contents horizontally always fits. Then it is
299 // not necessary to turn off the scrollbar. 299 // not necessary to turn off the scrollbar.
300 setHScrollBarMode(AlwaysOff); 300 setHScrollBarMode(AlwaysOff);
301 if ( ! mAllDayMode ) 301 if ( ! mAllDayMode )
302 setVScrollBarMode(AlwaysOn); 302 setVScrollBarMode(AlwaysOn);
303 else 303 else
304 setVScrollBarMode(AlwaysOff); 304 setVScrollBarMode(AlwaysOff);
305 305
306 setStartHour(KOPrefs::instance()->mDayBegins); 306 setStartHour(KOPrefs::instance()->mDayBegins);
307 307
308 calculateWorkingHours(); 308 calculateWorkingHours();
309 309
310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
311 SLOT(checkScrollBoundaries(int))); 311 SLOT(checkScrollBoundaries(int)));
312 312
313 // Create the Marcus Bains line. 313 // Create the Marcus Bains line.
314 if(mAllDayMode) 314 if(mAllDayMode)
315 mMarcusBains = 0; 315 mMarcusBains = 0;
316 else { 316 else {
317 mMarcusBains = new MarcusBains(this); 317 mMarcusBains = new MarcusBains(this);
318 addChild(mMarcusBains); 318 addChild(mMarcusBains);
319 } 319 }
320 mPopupKind = 0; 320 mPopupKind = 0;
321 mPopupItem = 0; 321 mPopupItem = 0;
322 mInvalidPixmap = false; 322 mInvalidPixmap = false;
323 323
324} 324}
325 325
326void KOAgenda::shrinkPixmap() 326void KOAgenda::shrinkPixmap()
327{ 327{
328 mPaintPixmap.resize( 20,20); 328 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true; 329 mInvalidPixmap = true;
330} 330}
331void KOAgenda::slotContentMove(int,int) 331void KOAgenda::slotContentMove(int,int)
332{ 332{
333 emit sendPing();
333 if ( mActionType == NOP ) 334 if ( mActionType == NOP )
334 slotClearSelection(); 335 slotClearSelection();
335 if ( mSelectedItem && !mActionItem ) { 336 if ( mSelectedItem && !mActionItem ) {
336 deselectItem(); 337 deselectItem();
337 emit incidenceSelected( 0 ); 338 emit incidenceSelected( 0 );
338 } 339 }
339} 340}
340void KOAgenda::clear() 341void KOAgenda::clear()
341{ 342{
342 KOAgendaItem *item; 343 KOAgendaItem *item;
343 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 344 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
344 mUnusedItems.append( item ); 345 mUnusedItems.append( item );
345 //item->hide(); 346 //item->hide();
346 } 347 }
347 mItems.clear(); 348 mItems.clear();
348 mSelectedItem = 0; 349 mSelectedItem = 0;
349 clearSelection(); 350 clearSelection();
350} 351}
351 352
352void KOAgenda::clearSelection() 353void KOAgenda::clearSelection()
353{ 354{
354 mSelectionCellX = 0; 355 mSelectionCellX = 0;
355 mSelectionYTop = 0; 356 mSelectionYTop = 0;
356 mSelectionHeight = 0; 357 mSelectionHeight = 0;
357} 358}
358 359
359void KOAgenda::marcus_bains() 360void KOAgenda::marcus_bains()
360{ 361{
361 if(mMarcusBains) mMarcusBains->updateLocation(true); 362 if(mMarcusBains) mMarcusBains->updateLocation(true);
362} 363}
363 364
364 365
365void KOAgenda::changeColumns(int columns) 366void KOAgenda::changeColumns(int columns)
366{ 367{
367 if (columns == 0) { 368 if (columns == 0) {
368 qDebug("KOAgenda::changeColumns() called with argument 0 "); 369 qDebug("KOAgenda::changeColumns() called with argument 0 ");
369 return; 370 return;
370 } 371 }
371 clear(); 372 clear();
372 mColumns = columns; 373 mColumns = columns;
373 computeSizes(); 374 computeSizes();
374} 375}
375 376
376/* 377/*
377 This is the eventFilter function, which gets all events from the KOAgendaItems 378 This is the eventFilter function, which gets all events from the KOAgendaItems
378 contained in the agenda. It has to handle moving and resizing for all items. 379 contained in the agenda. It has to handle moving and resizing for all items.
379*/ 380*/
380bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 381bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
381{ 382{
382 // kdDebug() << "KOAgenda::eventFilter" << endl; 383 // kdDebug() << "KOAgenda::eventFilter" << endl;
383 switch(event->type()) { 384 switch(event->type()) {
384 case QEvent::MouseButtonPress: 385 case QEvent::MouseButtonPress:
385 case QEvent::MouseButtonDblClick: 386 case QEvent::MouseButtonDblClick:
386 case QEvent::MouseButtonRelease: 387 case QEvent::MouseButtonRelease:
387 case QEvent::MouseMove: 388 case QEvent::MouseMove:
388 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 389 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
389 390
390 case (QEvent::Leave): 391 case (QEvent::Leave):
391 if (!mActionItem) 392 if (!mActionItem)
392 setCursor(arrowCursor); 393 setCursor(arrowCursor);
393 return true; 394 return true;
394 395
395 default: 396 default:
396 return QScrollView::eventFilter(object,event); 397 return QScrollView::eventFilter(object,event);
397 } 398 }
398} 399}
399void KOAgenda::popupMenu() 400void KOAgenda::popupMenu()
400{ 401{
401 mPopupTimer->stop(); 402 mPopupTimer->stop();
402 if ( mPopupKind == 1 || mPopupKind == 3 ) { 403 if ( mPopupKind == 1 || mPopupKind == 3 ) {
403 if (mActionItem ) { 404 if (mActionItem ) {
404 endItemAction(); 405 endItemAction();
405 } 406 }
406 mLeftMouseDown = false; // no more leftMouse computation 407 mLeftMouseDown = false; // no more leftMouse computation
407 if (mPopupItem) { 408 if (mPopupItem) {
408 //mClickedItem = mPopupItem; 409 //mClickedItem = mPopupItem;
409 selectItem(mPopupItem); 410 selectItem(mPopupItem);
410 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 411 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
411 mAllAgendaPopup->installEventFilter( this ); 412 mAllAgendaPopup->installEventFilter( this );
412 emit showIncidencePopupSignal(mPopupItem->incidence()); 413 emit showIncidencePopupSignal(mPopupItem->incidence());
413 414
414 } 415 }
415 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 416 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
416 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 417 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
417 endSelectAction( false ); // do not emit new event signal 418 endSelectAction( false ); // do not emit new event signal
418 mLeftMouseDown = false; // no more leftMouse computation 419 mLeftMouseDown = false; // no more leftMouse computation
419 } 420 }
420 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 421 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
421 mNewItemPopup->installEventFilter( this ); 422 mNewItemPopup->installEventFilter( this );
422 mNewItemPopup->popup( mPopupPos); 423 mNewItemPopup->popup( mPopupPos);
423 424
424 } 425 }
425 mLeftMouseDown = false; 426 mLeftMouseDown = false;
426 mPopupItem = 0; 427 mPopupItem = 0;
427 mPopupKind = 0; 428 mPopupKind = 0;
428} 429}
429void KOAgenda::categoryChanged(Incidence * inc) 430void KOAgenda::categoryChanged(Incidence * inc)
430{ 431{
431 KOAgendaItem *item; 432 KOAgendaItem *item;
432 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 433 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
433 if ( item->incidence() == inc ) { 434 if ( item->incidence() == inc ) {
434 item->initColor (); 435 item->initColor ();
435 item->updateItem(); 436 item->updateItem();
436 } 437 }
437 } 438 }
438} 439}
439bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 440bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
440{ 441{
442
443 if ( mInvalidPixmap ) {
444 mInvalidPixmap = false;
445 qDebug("InvalidPixmap ");
446 computeSizes();
447 emit updateViewSignal();
448 return true;
449 }
450 emit sendPing();
441 static int startX = 0; 451 static int startX = 0;
442 static int startY = 0; 452 static int startY = 0;
443 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 453 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
444 static bool blockMoving = true; 454 static bool blockMoving = true;
445 455
446 //qDebug("KOAgenda::eventFilter_mous "); 456 //qDebug("KOAgenda::eventFilter_mous ");
447 if ( object == mNewItemPopup ) { 457 if ( object == mNewItemPopup ) {
448 //qDebug("mNewItemPopup "); 458 //qDebug("mNewItemPopup ");
449 if ( me->type() == QEvent::MouseButtonRelease ) { 459 if ( me->type() == QEvent::MouseButtonRelease ) {
450 mNewItemPopup->removeEventFilter( this ); 460 mNewItemPopup->removeEventFilter( this );
451 int dX = me->globalPos().x() - mPopupPos.x();; 461 int dX = me->globalPos().x() - mPopupPos.x();;
452 if ( dX < 0 ) 462 if ( dX < 0 )
453 dX = -dX; 463 dX = -dX;
454 int dY = me->globalPos().y() - mPopupPos.y(); 464 int dY = me->globalPos().y() - mPopupPos.y();
455 if ( dY < 0 ) 465 if ( dY < 0 )
456 dY = -dY; 466 dY = -dY;
457 if ( dX > blockmoveDist || dY > blockmoveDist ) { 467 if ( dX > blockmoveDist || dY > blockmoveDist ) {
458 mNewItemPopup->hide(); 468 mNewItemPopup->hide();
459 } 469 }
460 } 470 }
461 return true; 471 return true;
462 } 472 }
463 if ( object == mAllAgendaPopup ) { 473 if ( object == mAllAgendaPopup ) {
464 //qDebug(" mAllAgendaPopup "); 474 //qDebug(" mAllAgendaPopup ");
465 if ( me->type() == QEvent::MouseButtonRelease ) { 475 if ( me->type() == QEvent::MouseButtonRelease ) {
466 mAllAgendaPopup->removeEventFilter( this ); 476 mAllAgendaPopup->removeEventFilter( this );
467 int dX = me->globalPos().x() - mPopupPos.x();; 477 int dX = me->globalPos().x() - mPopupPos.x();;
468 if ( dX < 0 ) 478 if ( dX < 0 )
469 dX = -dX; 479 dX = -dX;
470 int dY = me->globalPos().y() - mPopupPos.y(); 480 int dY = me->globalPos().y() - mPopupPos.y();
471 if ( dY < 0 ) 481 if ( dY < 0 )
472 dY = -dY; 482 dY = -dY;
473 if ( dX > blockmoveDist || dY > blockmoveDist ) { 483 if ( dX > blockmoveDist || dY > blockmoveDist ) {
474 mAllAgendaPopup->hide(); 484 mAllAgendaPopup->hide();
475 } 485 }
476 } 486 }
477 return true; 487 return true;
478 } 488 }
479 QPoint viewportPos; 489 QPoint viewportPos;
480 if (object != viewport()) { 490 if (object != viewport()) {
481 blockmoveDist = blockmoveDist*2; 491 blockmoveDist = blockmoveDist*2;
482 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 492 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
483 } else { 493 } else {
484 viewportPos = me->pos(); 494 viewportPos = me->pos();
485 } 495 }
486 bool objIsNotViewport = (object != viewport()); 496 bool objIsNotViewport = (object != viewport());
487 bool leftButt = false; 497 bool leftButt = false;
488#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
489 leftButt = (me->button() == LeftButton); 499 leftButt = (me->button() == LeftButton);
490#endif 500#endif
491 switch (me->type()) { 501 switch (me->type()) {
492 case QEvent::MouseButtonPress: 502 case QEvent::MouseButtonPress:
493 if (me->button() == LeftButton) { 503 if (me->button() == LeftButton) {
494 mPopupTimer->start( 600 ); 504 mPopupTimer->start( 600 );
495 mLeftMouseDown = true; 505 mLeftMouseDown = true;
496 } 506 }
497 blockMoving = true; 507 blockMoving = true;
498 startX = viewportPos.x(); 508 startX = viewportPos.x();
499 startY = viewportPos.y(); 509 startY = viewportPos.y();
500 mPopupPos = me->globalPos(); 510 mPopupPos = me->globalPos();
501 if ( objIsNotViewport && !leftButt ) { 511 if ( objIsNotViewport && !leftButt ) {
502 KOAgendaItem * tempItem = (KOAgendaItem *)object; 512 KOAgendaItem * tempItem = (KOAgendaItem *)object;
503 if (mAllDayMode) { 513 if (mAllDayMode) {
504 if ( tempItem->height() > 10 ) { 514 if ( tempItem->height() > 10 ) {
505 int minV = tempItem->height()/4; 515 int minV = tempItem->height()/4;
506 if ( minV > (blockmoveDist/2)-2 ) { 516 if ( minV > (blockmoveDist/2)-2 ) {
507 if ( minV > blockmoveDist ) 517 if ( minV > blockmoveDist )
508 minV = blockmoveDist; 518 minV = blockmoveDist;
509 else 519 else
510 minV = (blockmoveDist/2); 520 minV = (blockmoveDist/2);
511 } 521 }
512 bool border = false; 522 bool border = false;
513 int diff = tempItem->y() - viewportPos.y(); 523 int diff = tempItem->y() - viewportPos.y();
514 if ( diff < 0 ) 524 if ( diff < 0 )
515 diff *= -1; 525 diff *= -1;
516 if ( diff < minV ) { 526 if ( diff < minV ) {
517 border = true; 527 border = true;
518 objIsNotViewport = false; 528 objIsNotViewport = false;
519 } 529 }
520 if ( ! border ) { 530 if ( ! border ) {
521 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 531 diff = tempItem->y() + tempItem->height()- viewportPos.y();
522 if ( diff < 0 ) 532 if ( diff < 0 )
523 diff *= -1; 533 diff *= -1;
524 if ( diff < minV ) { 534 if ( diff < minV ) {
525 border = true; 535 border = true;
526 objIsNotViewport = false; 536 objIsNotViewport = false;
527 } 537 }
528 } 538 }
529 } 539 }
530 } else { // not allday 540 } else { // not allday
531 if ( tempItem->width() > 10 ) { 541 if ( tempItem->width() > 10 ) {
532 int minH = tempItem->width()/4; 542 int minH = tempItem->width()/4;
533 if ( minH > (blockmoveDist/2)-2 ) { 543 if ( minH > (blockmoveDist/2)-2 ) {
534 if ( minH > blockmoveDist ) 544 if ( minH > blockmoveDist )
535 minH = blockmoveDist; 545 minH = blockmoveDist;
536 else 546 else
@@ -1174,249 +1184,256 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1174 1184
1175 if (conflictItems.count() > 0) { 1185 if (conflictItems.count() > 0) {
1176 // Look for unused sub cell and insert item 1186 // Look for unused sub cell and insert item
1177 int i; 1187 int i;
1178 for(i=0;i<maxSubCells;++i) { 1188 for(i=0;i<maxSubCells;++i) {
1179 if (!subCellDict.find(i)) { 1189 if (!subCellDict.find(i)) {
1180 placeItem->setSubCell(i); 1190 placeItem->setSubCell(i);
1181 break; 1191 break;
1182 } 1192 }
1183 } 1193 }
1184 if (i == maxSubCells) { 1194 if (i == maxSubCells) {
1185 placeItem->setSubCell(maxSubCells); 1195 placeItem->setSubCell(maxSubCells);
1186 maxSubCells++; // add new item to number of sub cells 1196 maxSubCells++; // add new item to number of sub cells
1187 } 1197 }
1188 1198
1189 // Prepare for sub cell geometry adjustment 1199 // Prepare for sub cell geometry adjustment
1190 int newSubCellWidth; 1200 int newSubCellWidth;
1191 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1201 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1192 else newSubCellWidth = mGridSpacingX / maxSubCells; 1202 else newSubCellWidth = mGridSpacingX / maxSubCells;
1193 conflictItems.append(placeItem); 1203 conflictItems.append(placeItem);
1194 1204
1195 1205
1196 // Adjust sub cell geometry of all direct conflict items 1206 // Adjust sub cell geometry of all direct conflict items
1197 for ( item=conflictItems.first(); item != 0; 1207 for ( item=conflictItems.first(); item != 0;
1198 item=conflictItems.next() ) { 1208 item=conflictItems.next() ) {
1199 item->setSubCells(maxSubCells); 1209 item->setSubCells(maxSubCells);
1200 if (mAllDayMode) { 1210 if (mAllDayMode) {
1201 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1211 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1202 } else { 1212 } else {
1203 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1213 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1204 } 1214 }
1205 int x,y; 1215 int x,y;
1206 gridToContents(item->cellX(),item->cellYTop(),x,y); 1216 gridToContents(item->cellX(),item->cellYTop(),x,y);
1207 if (mAllDayMode) { 1217 if (mAllDayMode) {
1208 y += item->subCell() * newSubCellWidth; 1218 y += item->subCell() * newSubCellWidth;
1209 } else { 1219 } else {
1210 x += item->subCell() * newSubCellWidth; 1220 x += item->subCell() * newSubCellWidth;
1211 } 1221 }
1212 moveChild(item,x,y); 1222 moveChild(item,x,y);
1213 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1223 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1214 //item->updateItem(); 1224 //item->updateItem();
1215 } 1225 }
1216 // Adjust sub cell geometry of all conflict items of all conflict items 1226 // Adjust sub cell geometry of all conflict items of all conflict items
1217 for ( item=conflictItems.first(); item != 0; 1227 for ( item=conflictItems.first(); item != 0;
1218 item=conflictItems.next() ) { 1228 item=conflictItems.next() ) {
1219 if ( placeItem != item ) { 1229 if ( placeItem != item ) {
1220 KOAgendaItem *item2; 1230 KOAgendaItem *item2;
1221 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1231 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1222 for ( item2=conflictItems2.first(); item2 != 0; 1232 for ( item2=conflictItems2.first(); item2 != 0;
1223 item2=conflictItems2.next() ) { 1233 item2=conflictItems2.next() ) {
1224 if ( item2->subCells() != maxSubCells) { 1234 if ( item2->subCells() != maxSubCells) {
1225 item2->setSubCells(maxSubCells); 1235 item2->setSubCells(maxSubCells);
1226 if (mAllDayMode) { 1236 if (mAllDayMode) {
1227 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1237 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1228 } else { 1238 } else {
1229 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1239 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1230 } 1240 }
1231 int x,y; 1241 int x,y;
1232 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1242 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1233 if (mAllDayMode) { 1243 if (mAllDayMode) {
1234 y += item2->subCell() * newSubCellWidth; 1244 y += item2->subCell() * newSubCellWidth;
1235 } else { 1245 } else {
1236 x += item2->subCell() * newSubCellWidth; 1246 x += item2->subCell() * newSubCellWidth;
1237 } 1247 }
1238 moveChild(item2,x,y); 1248 moveChild(item2,x,y);
1239 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1249 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1240 } 1250 }
1241 } 1251 }
1242 } 1252 }
1243 } 1253 }
1244 } else { 1254 } else {
1245 placeItem->setSubCell(0); 1255 placeItem->setSubCell(0);
1246 placeItem->setSubCells(1); 1256 placeItem->setSubCells(1);
1247 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1257 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1248 else placeItem->resize(mGridSpacingX,placeItem->height()); 1258 else placeItem->resize(mGridSpacingX,placeItem->height());
1249 int x,y; 1259 int x,y;
1250 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1260 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1251 moveChild(placeItem,x,y); 1261 moveChild(placeItem,x,y);
1252 } 1262 }
1253 placeItem->setConflictItems(conflictItems); 1263 placeItem->setConflictItems(conflictItems);
1254 // for ( item=conflictItems.first(); item != 0; 1264 // for ( item=conflictItems.first(); item != 0;
1255// item=conflictItems.next() ) { 1265// item=conflictItems.next() ) {
1256// //item->updateItem(); 1266// //item->updateItem();
1257// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1267// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1258// } 1268// }
1259// placeItem->updateItem(); 1269// placeItem->updateItem();
1260} 1270}
1261 1271
1262void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1272void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1263{ 1273{
1264 if ( globalFlagBlockAgenda ) 1274 if ( globalFlagBlockAgenda )
1265 return; 1275 return;
1266 1276
1267 if ( mInvalidPixmap ) { 1277 if ( mInvalidPixmap ) {
1268 mInvalidPixmap = false; 1278 mInvalidPixmap = false;
1269 qDebug("InvalidPixmap "); 1279 qDebug("InvalidPixmap ");
1270 QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); 1280 computeSizes();
1281 emit updateViewSignal();
1271 return; 1282 return;
1272 } 1283 }
1273 if ( ! mAllDayMode ) { 1284 if ( ! mAllDayMode ) {
1274 // currently not working for 1285 // currently not working for
1275 1286
1276 //qDebug("KOAgenda::drawContents "); 1287 //qDebug("KOAgenda::drawContents ");
1277 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1288#if 0
1278 ;//drawContentsToPainter(); 1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1279 1290 qDebug("WAU ");
1291 drawContentsToPainter();
1292 }
1293#endif
1280 QPaintDevice* pd = p->device(); 1294 QPaintDevice* pd = p->device();
1281 p->end(); 1295 p->end();
1282 int vx, vy; 1296 int vx, vy;
1283 int selectionX = KOGlobals::self()->reverseLayout() ? 1297 int selectionX = KOGlobals::self()->reverseLayout() ?
1284 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1298 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1285 mSelectionCellX * mGridSpacingX; 1299 mSelectionCellX * mGridSpacingX;
1286 contentsToViewport ( cx, cy, vx,vy); 1300 contentsToViewport ( cx, cy, vx,vy);
1287 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1301 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1288 1302
1289 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1303 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1290 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1304 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1291 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1305 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1292 1306
1293 int vxSel, vySel; 1307 int vxSel, vySel;
1294 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1308 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1295 int off = mSelectionHeight; 1309 int off = mSelectionHeight;
1296 if ( vySel < 0 ) 1310 if ( vySel < 0 )
1297 off += vySel; 1311 off += vySel;
1298 //qDebug("OFF %d %d %d", off,vySel, vy ); 1312 //qDebug("OFF %d %d %d", off,vySel, vy );
1299 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1313 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1300 } else { 1314 } else {
1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1315 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1302 } 1316 }
1303 } 1317 }
1304 if ( mSelectionHeight > 0 ) { 1318 if ( mSelectionHeight > 0 ) {
1305 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1319 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1306 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1320 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1307 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1321 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1308 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1322 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1309 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1323 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1310 int hei = mSelectionHeight; 1324 int hei = mSelectionHeight;
1311 int offset = 0; 1325 int offset = 0;
1312 while ( hei > 0 ) { 1326 while ( hei > 0 ) {
1313 int p_hei = 5; 1327 int p_hei = 5;
1314 if ( hei < 5 ) p_hei = hei; 1328 if ( hei < 5 ) p_hei = hei;
1315 hei -= 5; 1329 hei -= 5;
1316 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1330 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1317 offset += 5; 1331 offset += 5;
1318 } 1332 }
1319 } 1333 }
1320 } 1334 }
1321 p->begin( pd ); 1335 p->begin( pd );
1322 } else { 1336 } else {
1323 1337#if 0
1324 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1338 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1325 ;//drawContentsToPainter(); 1339 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1326 1340 qDebug("WAUWAU ");
1341 drawContentsToPainter();
1342 }
1343#endif
1327 QPaintDevice* pd = p->device(); 1344 QPaintDevice* pd = p->device();
1328 p->end(); 1345 p->end();
1329 int vx, vy; 1346 int vx, vy;
1330 int selectionX = KOGlobals::self()->reverseLayout() ? 1347 int selectionX = KOGlobals::self()->reverseLayout() ?
1331 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1348 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1332 mSelectionCellX * mGridSpacingX; 1349 mSelectionCellX * mGridSpacingX;
1333 contentsToViewport ( cx, cy, vx,vy); 1350 contentsToViewport ( cx, cy, vx,vy);
1334 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1351 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1335 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1352 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1336 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1353 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1337 1354
1338 if ( mSelectionHeight > 0 ) { 1355 if ( mSelectionHeight > 0 ) {
1339 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1356 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1340 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1357 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1341 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1358 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1342 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1359 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1343 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1360 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1344 int hei = mSelectionHeight; 1361 int hei = mSelectionHeight;
1345 int offset = 0; 1362 int offset = 0;
1346 while ( hei > 0 ) { 1363 while ( hei > 0 ) {
1347 int p_hei = 5; 1364 int p_hei = 5;
1348 if ( hei < 5 ) p_hei = hei; 1365 if ( hei < 5 ) p_hei = hei;
1349 hei -= 5; 1366 hei -= 5;
1350 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1367 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1351 offset += 5; 1368 offset += 5;
1352 } 1369 }
1353 } 1370 }
1354 } 1371 }
1355 p->begin( pd ); 1372 p->begin( pd );
1356 } 1373 }
1357 1374
1358} 1375}
1359 1376
1360void KOAgenda::finishUpdate() 1377void KOAgenda::finishUpdate()
1361{ 1378{
1362 1379
1363 KOAgendaItem *item; 1380 KOAgendaItem *item;
1364 globalFlagBlockAgendaItemPaint = 1; 1381 globalFlagBlockAgendaItemPaint = 1;
1365 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1382 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1366 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1383 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1367 if ( !item->checkLayout() ) { 1384 if ( !item->checkLayout() ) {
1368 //qDebug(" conflictitem found "); 1385 //qDebug(" conflictitem found ");
1369 int newSubCellWidth; 1386 int newSubCellWidth;
1370 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1387 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1371 else newSubCellWidth = mGridSpacingX / item->subCells(); 1388 else newSubCellWidth = mGridSpacingX / item->subCells();
1372 1389
1373 if (mAllDayMode) { 1390 if (mAllDayMode) {
1374 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1391 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1375 } else { 1392 } else {
1376 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1393 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1377 } 1394 }
1378 int x,y; 1395 int x,y;
1379 gridToContents(item->cellX(),item->cellYTop(),x,y); 1396 gridToContents(item->cellX(),item->cellYTop(),x,y);
1380 if (mAllDayMode) { 1397 if (mAllDayMode) {
1381 y += item->subCell() * newSubCellWidth; 1398 y += item->subCell() * newSubCellWidth;
1382 } else { 1399 } else {
1383 x += item->subCell() * newSubCellWidth; 1400 x += item->subCell() * newSubCellWidth;
1384 } 1401 }
1385 moveChild(item,x,y); 1402 moveChild(item,x,y);
1386 } 1403 }
1387 } 1404 }
1388 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1405 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1389 if ( !item->isVisible() ) 1406 if ( !item->isVisible() )
1390 item->show(); 1407 item->show();
1391 1408
1392 } 1409 }
1393 globalFlagBlockAgendaItemUpdate = 0; 1410 globalFlagBlockAgendaItemUpdate = 0;
1394 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1411 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1395 item->repaintMe( ); 1412 item->repaintMe( );
1396 } 1413 }
1397 globalFlagBlockAgendaItemUpdate = 1; 1414 globalFlagBlockAgendaItemUpdate = 1;
1398 qApp->processEvents(); 1415 qApp->processEvents();
1399 globalFlagBlockAgendaItemPaint = 0; 1416 globalFlagBlockAgendaItemPaint = 0;
1400 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1417 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1401 item->repaint( false ); 1418 item->repaint( false );
1402 } 1419 }
1403 1420
1404} 1421}
1405 1422
1406/* 1423/*
1407 Draw grid in the background of the agenda. 1424 Draw grid in the background of the agenda.
1408*/ 1425*/
1409void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1426void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1410{ 1427{
1411 1428
1412 1429
1413 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1430 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1414 return; 1431 return;
1415 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1432 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1416 return; 1433 return;
1417 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1434 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1418 if ( ch < 1 ) 1435 if ( ch < 1 )
1419 ch = 1; 1436 ch = 1;
1420 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1437 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1421 mPaintPixmap.resize( contentsWidth()+42, ch ); 1438 mPaintPixmap.resize( contentsWidth()+42, ch );
1422 } 1439 }
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 5d813b2..0e3aed8 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,272 +1,273 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 static bool mInvalidPixmap; 78 bool mInvalidPixmap;
79 79
80 Incidence *selectedIncidence() const; 80 Incidence *selectedIncidence() const;
81 QDate selectedIncidenceDate() const; 81 QDate selectedIncidenceDate() const;
82 82
83 virtual bool eventFilter ( QObject *, QEvent * ); 83 virtual bool eventFilter ( QObject *, QEvent * );
84 84
85 void contentsToGrid (int x, int y, int& gx, int& gy); 85 void contentsToGrid (int x, int y, int& gx, int& gy);
86 void gridToContents (int gx, int gy, int& x, int& y); 86 void gridToContents (int gx, int gy, int& x, int& y);
87 87
88 int timeToY (const QTime &time); 88 int timeToY (const QTime &time);
89 QTime gyToTime (int y); 89 QTime gyToTime (int y);
90 90
91 void setStartHour(int startHour); 91 void setStartHour(int startHour);
92 92
93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
96 int YTop,int YBottom); 96 int YTop,int YBottom);
97 97
98 void changeColumns(int columns); 98 void changeColumns(int columns);
99 99
100 int columns() { return mColumns; } 100 int columns() { return mColumns; }
101 int rows() { return mRows; } 101 int rows() { return mRows; }
102 102
103 int gridSpacingX() const { return mGridSpacingX; } 103 int gridSpacingX() const { return mGridSpacingX; }
104 int gridSpacingY() const { return mGridSpacingY; } 104 int gridSpacingY() const { return mGridSpacingY; }
105 105
106// virtual QSizePolicy sizePolicy() const; 106// virtual QSizePolicy sizePolicy() const;
107 107
108 void clear(); 108 void clear();
109 109
110 void clearSelection(); 110 void clearSelection();
111 void hideUnused(); 111 void hideUnused();
112 112
113 /** Calculates the minimum width */ 113 /** Calculates the minimum width */
114 virtual int minimumWidth() const; 114 virtual int minimumWidth() const;
115 /** Update configuration from preference settings */ 115 /** Update configuration from preference settings */
116 void updateConfig(); 116 void updateConfig();
117 117
118 void checkScrollBoundaries(); 118 void checkScrollBoundaries();
119 119
120 void setHolidayMask(QMemArray<bool> *); 120 void setHolidayMask(QMemArray<bool> *);
121 void setDateList(const DateList &selectedDates); 121 void setDateList(const DateList &selectedDates);
122 DateList dateList() const; 122 DateList dateList() const;
123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
124 void finishUpdate(); 124 void finishUpdate();
125 void printSelection(); 125 void printSelection();
126 void storePosition(); 126 void storePosition();
127 void restorePosition(); 127 void restorePosition();
128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
129 void shrinkPixmap(); 129 void shrinkPixmap();
130 130
131 public slots: 131 public slots:
132 void slotContentMove(int,int); 132 void slotContentMove(int,int);
133 void categoryChanged(Incidence * inc); 133 void categoryChanged(Incidence * inc);
134 void slotClearSelection(); 134 void slotClearSelection();
135 void popupMenu(); 135 void popupMenu();
136 void newItem( int ); 136 void newItem( int );
137 void moveChild( QWidget *, int, int ); 137 void moveChild( QWidget *, int, int );
138 void scrollUp(); 138 void scrollUp();
139 void scrollDown(); 139 void scrollDown();
140 void updateTodo( Todo * t, int , bool ); 140 void updateTodo( Todo * t, int , bool );
141 void popupAlarm(); 141 void popupAlarm();
142 142
143 void checkScrollBoundaries(int); 143 void checkScrollBoundaries(int);
144 144
145 /** Deselect selected items. This function does not emit any signals. */ 145 /** Deselect selected items. This function does not emit any signals. */
146 void deselectItem(); 146 void deselectItem();
147 /** Select item. If the argument is 0, the currently selected item gets 147 /** Select item. If the argument is 0, the currently selected item gets
148 deselected. This function emits the itemSelected(bool) signal to inform 148 deselected. This function emits the itemSelected(bool) signal to inform
149 about selection/deseelction of events. */ 149 about selection/deseelction of events. */
150 void selectItem(KOAgendaItem *); 150 void selectItem(KOAgendaItem *);
151 void finishResize(); 151 void finishResize();
152 152
153 signals: 153 signals:
154 void signalClearSelection(); 154 void signalClearSelection();
155 void showDateView( int, int); 155 void showDateView( int, int);
156 void newEventSignal(); 156 void newEventSignal();
157 void newEventSignal(int gx,int gy); 157 void newEventSignal(int gx,int gy);
158 void newTodoSignal(int gx,int gy); 158 void newTodoSignal(int gx,int gy);
159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
161 void newStartSelectSignal(); 161 void newStartSelectSignal();
162 void showIncidenceSignal(Incidence *); 162 void showIncidenceSignal(Incidence *);
163 void editIncidenceSignal(Incidence *); 163 void editIncidenceSignal(Incidence *);
164 void deleteIncidenceSignal(Incidence *); 164 void deleteIncidenceSignal(Incidence *);
165 void showIncidencePopupSignal(Incidence *); 165 void showIncidencePopupSignal(Incidence *);
166 166
167 void itemModified(KOAgendaItem *item, int ); 167 void itemModified(KOAgendaItem *item, int );
168 void incidenceSelected(Incidence *); 168 void incidenceSelected(Incidence *);
169 169
170 void lowerYChanged(int); 170 void lowerYChanged(int);
171 void upperYChanged(int); 171 void upperYChanged(int);
172 172
173 void startDragSignal(Incidence *); 173 void startDragSignal(Incidence *);
174 void addToCalSignal(Incidence *, Incidence *); 174 void addToCalSignal(Incidence *, Incidence *);
175 void resizedSignal(); 175 void resizedSignal();
176 void updateViewSignal(); 176 void updateViewSignal();
177 void sendPing();
177 178
178 protected: 179 protected:
179 KOEventPopupMenu * mAllAgendaPopup; 180 KOEventPopupMenu * mAllAgendaPopup;
180 QPainter mPixPainter; 181 QPainter mPixPainter;
181 QPixmap mPaintPixmap; 182 QPixmap mPaintPixmap;
182 QPixmap mHighlightPixmap; 183 QPixmap mHighlightPixmap;
183 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 184 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
184 virtual void resizeEvent ( QResizeEvent * ); 185 virtual void resizeEvent ( QResizeEvent * );
185 186
186 /** Handles mouse events. Called from eventFilter */ 187 /** Handles mouse events. Called from eventFilter */
187 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 188 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
188 189
189 /** Start selecting time span. */ 190 /** Start selecting time span. */
190 void startSelectAction(QPoint viewportPos); 191 void startSelectAction(QPoint viewportPos);
191 192
192 /** Select time span. */ 193 /** Select time span. */
193 void performSelectAction(QPoint viewportPos); 194 void performSelectAction(QPoint viewportPos);
194 195
195 /** Emd selecting time span. */ 196 /** Emd selecting time span. */
196 void endSelectAction( bool emitNewEvent = false ); 197 void endSelectAction( bool emitNewEvent = false );
197 198
198 /** Start moving/resizing agenda item */ 199 /** Start moving/resizing agenda item */
199 void startItemAction(QPoint viewportPos); 200 void startItemAction(QPoint viewportPos);
200 201
201 /** Move/resize agenda item */ 202 /** Move/resize agenda item */
202 void performItemAction(QPoint viewportPos); 203 void performItemAction(QPoint viewportPos);
203 204
204 /** End moving/resizing agenda item */ 205 /** End moving/resizing agenda item */
205 void endItemAction(); 206 void endItemAction();
206 207
207 /** Set cursor, when no item action is in progress */ 208 /** Set cursor, when no item action is in progress */
208 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 209 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
209 210
210 /** Place agenda item in agenda and adjust other cells if necessary */ 211 /** Place agenda item in agenda and adjust other cells if necessary */
211 void placeSubCells(KOAgendaItem *placeItem); 212 void placeSubCells(KOAgendaItem *placeItem);
212 213
213 /** Process the keyevent, including the ignored keyevents of eventwidgets. 214 /** Process the keyevent, including the ignored keyevents of eventwidgets.
214 * Implements pgup/pgdn and cursor key navigation in the view. 215 * Implements pgup/pgdn and cursor key navigation in the view.
215 */ 216 */
216 void keyPressEvent( QKeyEvent * ); 217 void keyPressEvent( QKeyEvent * );
217 218
218 void calculateWorkingHours(); 219 void calculateWorkingHours();
219 220
220 virtual void contentsMousePressEvent ( QMouseEvent * ); 221 virtual void contentsMousePressEvent ( QMouseEvent * );
221 222
222 private: 223 private:
223 void init(); 224 void init();
224 void marcus_bains(); 225 void marcus_bains();
225 bool mAllDayMode; 226 bool mAllDayMode;
226 bool blockResize; 227 bool blockResize;
227 bool mLeftMouseDown; 228 bool mLeftMouseDown;
228 KOAgendaItem *mPopupItem; 229 KOAgendaItem *mPopupItem;
229 QTimer* mPopupTimer; 230 QTimer* mPopupTimer;
230 int mPopupKind; 231 int mPopupKind;
231 QPoint mPopupPos; 232 QPoint mPopupPos;
232 QTimer mResizeTimer; 233 QTimer mResizeTimer;
233 double mContentPosition; 234 double mContentPosition;
234 235
235 // Width and height of agenda cells 236 // Width and height of agenda cells
236 int mGridSpacingX; 237 int mGridSpacingX;
237 int mGridSpacingY; 238 int mGridSpacingY;
238 239
239 // size of border, where mouse action will resize the KOAgendaItem 240 // size of border, where mouse action will resize the KOAgendaItem
240 int mResizeBorderWidth; 241 int mResizeBorderWidth;
241 242
242 // size of border, where mouse mve will cause a scroll of the agenda 243 // size of border, where mouse mve will cause a scroll of the agenda
243 int mScrollBorderWidth; 244 int mScrollBorderWidth;
244 int mScrollDelay; 245 int mScrollDelay;
245 int mScrollOffset; 246 int mScrollOffset;
246 247
247 QTimer mScrollUpTimer; 248 QTimer mScrollUpTimer;
248 QTimer mScrollDownTimer; 249 QTimer mScrollDownTimer;
249 250
250 // Number of Columns/Rows of agenda grid 251 // Number of Columns/Rows of agenda grid
251 int mColumns; 252 int mColumns;
252 int mRows; 253 int mRows;
253 254
254 // Cells to store Move and Resize coordiantes 255 // Cells to store Move and Resize coordiantes
255 int mStartCellX; 256 int mStartCellX;
256 int mStartCellY; 257 int mStartCellY;
257 int mCurrentCellX; 258 int mCurrentCellX;
258 int mCurrentCellY; 259 int mCurrentCellY;
259 260
260 // Working Hour coordiantes 261 // Working Hour coordiantes
261 bool mWorkingHoursEnable; 262 bool mWorkingHoursEnable;
262 int mWorkingHoursYTop; 263 int mWorkingHoursYTop;
263 int mWorkingHoursYBottom; 264 int mWorkingHoursYBottom;
264 265
265 // Selection 266 // Selection
266 int mSelectionCellX; 267 int mSelectionCellX;
267 int mSelectionYTop; 268 int mSelectionYTop;
268 int mSelectionHeight; 269 int mSelectionHeight;
269 270
270 // List of dates to be displayed 271 // List of dates to be displayed
271 DateList mSelectedDates; 272 DateList mSelectedDates;
272 273
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 488d9d4..1b21a71 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,175 +1,175 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79#define IDLETIMEOUT 3 79#define IDLETIMEOUT 15
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
@@ -482,207 +482,216 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); 576 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) );
577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); 577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) );
578 578
579 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) );
580 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) );
581
582
579 mIdleTimer = new QTimer ( this );; 583 mIdleTimer = new QTimer ( this );;
580 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); 584 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout()));
581} 585}
586void KOAgendaView::startIdleTimeout()
587{
588 mIdleStart = QDateTime::currentDateTime();
589 mIdleTimer->start( IDLETIMEOUT * 1000 );
590}
582void KOAgendaView::slotIdleTimeout() 591void KOAgendaView::slotIdleTimeout()
583{ 592{
584 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); 593 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) );
585 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); 594 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() );
586 mIdleTimer->stop(); 595 mIdleTimer->stop();
587 bool isActice = topLevelWidget()->isActiveWindow(); 596 bool isActice = topLevelWidget()->isActiveWindow();
588 qDebug("KO: Active Window %d ", isActice); 597 qDebug("KO: Active Window %d %d", isActice, isVisible());
589 // we do nothing if we wake up from a suspend 598 // we do nothing if we wake up from a suspend
590 if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) { 599 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) {
591 qDebug("KO: Wakeup from suspend "); 600 qDebug("KO: Wakeup from suspend ");
592 mIdleTimer->start( IDLETIMEOUT * 1000 ); 601 startIdleTimeout();
593 return; 602 return;
594 } 603 }
595 qDebug("KO: Downsizing Pixmaps "); 604 qDebug("KO: Downsizing Pixmaps ");
596 mAgenda->shrinkPixmap(); 605 mAgenda->shrinkPixmap();
597 mAllDayAgenda->shrinkPixmap(); 606 mAllDayAgenda->shrinkPixmap();
598 KOAgendaItem::paintPix()->resize( 20,20); 607 KOAgendaItem::paintPix()->resize( 20,20);
599 KOAgendaItem::paintPixAllday()->resize( 20,20); 608 KOAgendaItem::paintPixAllday()->resize( 20,20);
600 609
601} 610}
602void KOAgendaView::toggleAllDay() 611void KOAgendaView::toggleAllDay()
603{ 612{
604 if ( mSplitterAgenda->firstHandle() ) 613 if ( mSplitterAgenda->firstHandle() )
605 mSplitterAgenda->firstHandle()->toggle(); 614 mSplitterAgenda->firstHandle()->toggle();
606} 615}
607void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 616void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
608{ 617{
609 calendar()->addIncidence( inc ); 618 calendar()->addIncidence( inc );
610 619
611 if ( incOld ) { 620 if ( incOld ) {
612 if ( incOld->typeID() == todoID ) 621 if ( incOld->typeID() == todoID )
613 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 622 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
614 else 623 else
615 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 624 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
616 } 625 }
617 626
618} 627}
619void KOAgendaView::categoryChanged(Incidence * inc) 628void KOAgendaView::categoryChanged(Incidence * inc)
620{ 629{
621 mAgenda->categoryChanged( inc ); 630 mAgenda->categoryChanged( inc );
622 mAllDayAgenda->categoryChanged( inc ); 631 mAllDayAgenda->categoryChanged( inc );
623} 632}
624KOAgendaView::~KOAgendaView() 633KOAgendaView::~KOAgendaView()
625{ 634{
626 delete mAllAgendaPopup; 635 delete mAllAgendaPopup;
627 //delete mAllDayAgendaPopup; 636 //delete mAllDayAgendaPopup;
628 delete KOAgendaItem::paintPix(); 637 delete KOAgendaItem::paintPix();
629 delete KOAgendaItem::paintPixAllday(); 638 delete KOAgendaItem::paintPixAllday();
630} 639}
631void KOAgendaView::resizeEvent( QResizeEvent* e ) 640void KOAgendaView::resizeEvent( QResizeEvent* e )
632{ 641{
633 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 642 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
634 bool uc = false; 643 bool uc = false;
635 int ow = e->oldSize().width(); 644 int ow = e->oldSize().width();
636 int oh = e->oldSize().height(); 645 int oh = e->oldSize().height();
637 int w = e->size().width(); 646 int w = e->size().width();
638 int h = e->size().height(); 647 int h = e->size().height();
639 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 648 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
640 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 649 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
641 uc = true; 650 uc = true;
642 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 651 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
643 } 652 }
644 mUpcomingWidth = e->size().width() ; 653 mUpcomingWidth = e->size().width() ;
645 if ( mBlockUpdating || uc ) { 654 if ( mBlockUpdating || uc ) {
646 mBlockUpdating = false; 655 mBlockUpdating = false;
647 //mAgenda->setMinimumSize(800 , 600 ); 656 //mAgenda->setMinimumSize(800 , 600 );
648 //qDebug("mAgenda->resize+++++++++++++++ "); 657 //qDebug("mAgenda->resize+++++++++++++++ ");
649 updateConfig(); 658 updateConfig();
650 //qDebug("KOAgendaView::Updating now possible "); 659 //qDebug("KOAgendaView::Updating now possible ");
651 } else 660 } else
652 createDayLabels(); 661 createDayLabels();
653 //qDebug("resizeEvent end "); 662 //qDebug("resizeEvent end ");
654 663
655} 664}
656void KOAgendaView::slotDaylabelClicked( int num ) 665void KOAgendaView::slotDaylabelClicked( int num )
657{ 666{
658 667
659 QDate firstDate = mSelectedDates.first(); 668 QDate firstDate = mSelectedDates.first();
660 if ( num == -1 ) 669 if ( num == -1 )
661 emit showDateView( 6, firstDate ); 670 emit showDateView( 6, firstDate );
662 else if (num >= 0 ) { 671 else if (num >= 0 ) {
663 if ( mSelectedDates.count() == 1) 672 if ( mSelectedDates.count() == 1)
664 emit showDateView( 9, firstDate.addDays( num ) ); 673 emit showDateView( 9, firstDate.addDays( num ) );
665 else 674 else
666 emit showDateView( 3, firstDate.addDays( num ) ); 675 emit showDateView( 3, firstDate.addDays( num ) );
667 } 676 }
668 else 677 else
669 showDateView( 10, firstDate.addDays(1) ); 678 showDateView( 10, firstDate.addDays(1) );
670} 679}
671 680
672KOAgendaButton* KOAgendaView::getNewDaylabel() 681KOAgendaButton* KOAgendaView::getNewDaylabel()
673{ 682{
674 683
675 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 684 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
676 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 685 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
677 mDayLabelsList.append( dayLabel ); 686 mDayLabelsList.append( dayLabel );
678 mLayoutDayLabels->addWidget(dayLabel); 687 mLayoutDayLabels->addWidget(dayLabel);
679 return dayLabel ; 688 return dayLabel ;
680} 689}
681 690
682void KOAgendaView::createDayLabels() 691void KOAgendaView::createDayLabels()
683{ 692{
684 693
685 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 694 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
686 // qDebug(" KOAgendaView::createDayLabels() blocked "); 695 // qDebug(" KOAgendaView::createDayLabels() blocked ");
687 return; 696 return;
688 697
@@ -1228,194 +1237,193 @@ void KOAgendaView::fillAgenda()
1228 int secs = event->dtStart().secsTo( event->dtEnd() ); 1237 int secs = event->dtStart().secsTo( event->dtEnd() );
1229 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1238 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1230 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1239 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1231 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1240 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1232 1241
1233 } 1242 }
1234 } 1243 }
1235 int startY = mAgenda->timeToY(event->dtStart().time()); 1244 int startY = mAgenda->timeToY(event->dtStart().time());
1236 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1245 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1237 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1246 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1238 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1247 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1239 //qDebug("insert!!! "); 1248 //qDebug("insert!!! ");
1240 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1249 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1241 } 1250 }
1242 if (beginX == curCol) { 1251 if (beginX == curCol) {
1243 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1252 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1244 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1253 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1245 } else if (endX == curCol) { 1254 } else if (endX == curCol) {
1246 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1255 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1247 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1256 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1248 } else { 1257 } else {
1249 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1258 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1250 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1259 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1251 } 1260 }
1252 } else { 1261 } else {
1253 int startY = mAgenda->timeToY(event->dtStart().time()); 1262 int startY = mAgenda->timeToY(event->dtStart().time());
1254 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1263 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1255 if (endY < startY) endY = startY; 1264 if (endY < startY) endY = startY;
1256 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1265 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1257 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1266 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1258 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1267 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1259 } 1268 }
1260 } 1269 }
1261 // ---------- [display Todos -------------- 1270 // ---------- [display Todos --------------
1262 unsigned int numTodo; 1271 unsigned int numTodo;
1263 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1272 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1264 Todo *todo = todos.at(numTodo); 1273 Todo *todo = todos.at(numTodo);
1265 1274
1266 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1275 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1267 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1276 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1268 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1277 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1269 // Already completed items can be displayed on their original due date 1278 // Already completed items can be displayed on their original due date
1270 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1279 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1271 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1280 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1272 bool fillIn = false; 1281 bool fillIn = false;
1273 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1282 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1274 fillIn = true; 1283 fillIn = true;
1275 if ( ! fillIn && !todo->hasCompletedDate() ) 1284 if ( ! fillIn && !todo->hasCompletedDate() )
1276 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1285 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1277 if ( fillIn ) { 1286 if ( fillIn ) {
1278 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1287 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1279 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1288 if ( KOPrefs::instance()->mShowTodoInAgenda )
1280 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1289 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1281 } 1290 }
1282 else { 1291 else {
1283 QDateTime dt; 1292 QDateTime dt;
1284 if ( todo->hasCompletedDate() ) 1293 if ( todo->hasCompletedDate() )
1285 dt = todo->completed(); 1294 dt = todo->completed();
1286 else 1295 else
1287 dt = todo->dtDue();; 1296 dt = todo->dtDue();;
1288 1297
1289 1298
1290 int endY = mAgenda->timeToY(dt.time()) - 1; 1299 int endY = mAgenda->timeToY(dt.time()) - 1;
1291 int hi = (18/KOPrefs::instance()->mHourSize); 1300 int hi = (18/KOPrefs::instance()->mHourSize);
1292 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1301 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1293 int startY = endY -hi; 1302 int startY = endY -hi;
1294 1303
1295 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1304 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1296 1305
1297 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1306 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1298 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1307 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1299 } 1308 }
1300 } 1309 }
1301 } 1310 }
1302 // ---------- display Todos] -------------- 1311 // ---------- display Todos] --------------
1303 1312
1304 ++curCol; 1313 ++curCol;
1305 } 1314 }
1306 mAgenda->hideUnused(); 1315 mAgenda->hideUnused();
1307 mAllDayAgenda->hideUnused(); 1316 mAllDayAgenda->hideUnused();
1308 mAgenda->checkScrollBoundaries(); 1317 mAgenda->checkScrollBoundaries();
1309 deleteSelectedDateTime(); 1318 deleteSelectedDateTime();
1310 createDayLabels(); 1319 createDayLabels();
1311 emit incidenceSelected( 0 ); 1320 emit incidenceSelected( 0 );
1312 1321
1313 if ( globalFlagBlockAgenda == 2 ) { 1322 if ( globalFlagBlockAgenda == 2 ) {
1314 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1323 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1315 setStartHour( KOPrefs::instance()->mDayBegins ); 1324 setStartHour( KOPrefs::instance()->mDayBegins );
1316 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1325 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1317 setStartHour( QTime::currentTime ().hour() ); 1326 setStartHour( QTime::currentTime ().hour() );
1318 } 1327 }
1319 qApp->processEvents(); 1328 qApp->processEvents();
1320 globalFlagBlockAgenda = 0; 1329 globalFlagBlockAgenda = 0;
1321 mAllDayAgenda->drawContentsToPainter(); 1330 mAllDayAgenda->drawContentsToPainter();
1322 mAgenda->drawContentsToPainter(); 1331 mAgenda->drawContentsToPainter();
1323 repaintAgenda(); 1332 repaintAgenda();
1324 mIdleTimer->start ( IDLETIMEOUT *1000 ); 1333 startIdleTimeout();
1325 mIdleStart = QDateTime::currentDateTime();
1326 onlyOne = false; 1334 onlyOne = false;
1327} 1335}
1328void KOAgendaView::repaintAgenda() 1336void KOAgendaView::repaintAgenda()
1329{ 1337{
1330 mAgenda->viewport()->repaint( false ); 1338 mAgenda->viewport()->repaint( false );
1331 mAllDayAgenda->viewport()->repaint( false ); 1339 mAllDayAgenda->viewport()->repaint( false );
1332 mAgenda->finishUpdate(); 1340 mAgenda->finishUpdate();
1333 mAllDayAgenda->finishUpdate(); 1341 mAllDayAgenda->finishUpdate();
1334} 1342}
1335 1343
1336 1344
1337void KOAgendaView::clearView() 1345void KOAgendaView::clearView()
1338{ 1346{
1339 mAllDayAgenda->clear(); 1347 mAllDayAgenda->clear();
1340 mAgenda->clear(); 1348 mAgenda->clear();
1341} 1349}
1342void KOAgendaView::clearList() 1350void KOAgendaView::clearList()
1343{ 1351{
1344 clearView(); 1352 clearView();
1345 mAllDayAgenda->hideUnused(); 1353 mAllDayAgenda->hideUnused();
1346 mAgenda->hideUnused(); 1354 mAgenda->hideUnused();
1347} 1355}
1348 1356
1349void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1357void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1350 const QDate &td) 1358 const QDate &td)
1351{ 1359{
1352#ifndef KORG_NOPRINTER 1360#ifndef KORG_NOPRINTER
1353 if (fd == td) 1361 if (fd == td)
1354 calPrinter->preview(CalPrinter::Day, fd, td); 1362 calPrinter->preview(CalPrinter::Day, fd, td);
1355 else 1363 else
1356 calPrinter->preview(CalPrinter::Week, fd, td); 1364 calPrinter->preview(CalPrinter::Week, fd, td);
1357#endif 1365#endif
1358} 1366}
1359 1367
1360// void KOAgendaView::updateMovedTodo() 1368// void KOAgendaView::updateMovedTodo()
1361// { 1369// {
1362// // updateConfig(); 1370// // updateConfig();
1363// // emit updateTodoViews(); 1371// // emit updateTodoViews();
1364// } 1372// }
1365 1373
1366void KOAgendaView::slotShowDateView( int mode , int d ) 1374void KOAgendaView::slotShowDateView( int mode , int d )
1367{ 1375{
1368 if ( d >= mSelectedDates.count() ) { 1376 if ( d >= mSelectedDates.count() ) {
1369 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); 1377 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() );
1370 1378
1371 } else { 1379 } else {
1372 QDate day = mSelectedDates[d]; 1380 QDate day = mSelectedDates[d];
1373 emit showDateView(mode , day ); 1381 emit showDateView(mode , day );
1374 } 1382 }
1375 1383
1376} 1384}
1377void KOAgendaView::newEvent(int gx, int gy) 1385void KOAgendaView::newEvent(int gx, int gy)
1378{ 1386{
1379 if (!mSelectedDates.count()) return; 1387 if (!mSelectedDates.count()) return;
1380 1388
1381 QDate day = mSelectedDates[gx]; 1389 QDate day = mSelectedDates[gx];
1382 1390
1383 QTime time = mAgenda->gyToTime(gy); 1391 QTime time = mAgenda->gyToTime(gy);
1384 QDateTime dt(day,time); 1392 QDateTime dt(day,time);
1385 // if ( dt < QDateTime::currentDateTime () ) 1393 // if ( dt < QDateTime::currentDateTime () )
1386 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1394 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1387 emit newEventSignal(dt); 1395 emit newEventSignal(dt);
1388} 1396}
1389 1397
1390void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1398void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1391{ 1399{
1392 if (!mSelectedDates.count()) return; 1400 if (!mSelectedDates.count()) return;
1393 1401
1394 QDate dayStart = mSelectedDates[gxStart]; 1402 QDate dayStart = mSelectedDates[gxStart];
1395 QDate dayEnd = mSelectedDates[gxEnd]; 1403 QDate dayEnd = mSelectedDates[gxEnd];
1396 1404
1397 QTime timeStart = mAgenda->gyToTime(gyStart); 1405 QTime timeStart = mAgenda->gyToTime(gyStart);
1398 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1406 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1399 1407
1400 QDateTime dtStart(dayStart,timeStart); 1408 QDateTime dtStart(dayStart,timeStart);
1401 QDateTime dtEnd(dayEnd,timeEnd); 1409 QDateTime dtEnd(dayEnd,timeEnd);
1402 1410
1403 emit newEventSignal(dtStart,dtEnd); 1411 emit newEventSignal(dtStart,dtEnd);
1404} 1412}
1405 1413
1406void KOAgendaView::newEventAllDay(int gx, int ) 1414void KOAgendaView::newEventAllDay(int gx, int )
1407{ 1415{
1408 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1409 1417
1410 QDate day = mSelectedDates[gx]; 1418 QDate day = mSelectedDates[gx];
1411 1419
1412 emit newEventSignal(day); 1420 emit newEventSignal(day);
1413} 1421}
1414void KOAgendaView::newTodoAllDay(int gx, int ) 1422void KOAgendaView::newTodoAllDay(int gx, int )
1415{ 1423{
1416 if (!mSelectedDates.count()) return; 1424 if (!mSelectedDates.count()) return;
1417 1425
1418 QDateTime day (mSelectedDates[gx] ); 1426 QDateTime day (mSelectedDates[gx] );
1419 emit newTodoSignal(day, true); 1427 emit newTodoSignal(day, true);
1420} 1428}
1421void KOAgendaView::newTodo(int gx, int gy ) 1429void KOAgendaView::newTodo(int gx, int gy )
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index effd7a3..4b7ef5b 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -118,180 +118,181 @@ class EventIndicator : public QFrame {
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 void fillAgenda(); 213 void fillAgenda();
214 void startIdleTimeout();
214 215
215 signals: 216 signals:
216 void showDateView( int, QDate ); 217 void showDateView( int, QDate );
217 void newTodoSignal( QDateTime ,bool ); 218 void newTodoSignal( QDateTime ,bool );
218 void toggleExpand(); 219 void toggleExpand();
219 void selectWeekNum( int ); 220 void selectWeekNum( int );
220 void todoMoved( Todo *, int ); 221 void todoMoved( Todo *, int );
221 void incidenceChanged(Incidence * , int ); 222 void incidenceChanged(Incidence * , int );
222 // void cloneIncidenceSignal(Incidence *); 223 // void cloneIncidenceSignal(Incidence *);
223 224
224 protected: 225 protected:
225 KOAgendaButton* getNewDaylabel(); 226 KOAgendaButton* getNewDaylabel();
226 bool mBlockUpdating; 227 bool mBlockUpdating;
227 int mUpcomingWidth; 228 int mUpcomingWidth;
228 /** Fill agenda beginning with date startDate */ 229 /** Fill agenda beginning with date startDate */
229 void fillAgenda(const QDate &startDate); 230 void fillAgenda(const QDate &startDate);
230 void resizeEvent( QResizeEvent* e ); 231 void resizeEvent( QResizeEvent* e );
231 /** Fill agenda using the current set value for the start date */ 232 /** Fill agenda using the current set value for the start date */
232 233
233 /** Create labels for the selected dates. */ 234 /** Create labels for the selected dates. */
234 void createDayLabels(); 235 void createDayLabels();
235 236
236 /** 237 /**
237 Set the masks on the agenda widgets indicating, which days are holidays. 238 Set the masks on the agenda widgets indicating, which days are holidays.
238 */ 239 */
239 void setHolidayMasks(); 240 void setHolidayMasks();
240 241
241 protected slots: 242 protected slots:
242 void slotIdleTimeout(); 243 void slotIdleTimeout();
243 void categoryChanged( Incidence * ); 244 void categoryChanged( Incidence * );
244 void slotDaylabelClicked( int ); 245 void slotDaylabelClicked( int );
245 /** Update event belonging to agenda item */ 246 /** Update event belonging to agenda item */
246 void updateEventDates(KOAgendaItem *item, int mode = -1); 247 void updateEventDates(KOAgendaItem *item, int mode = -1);
247 //void updateMovedTodo(); 248 //void updateMovedTodo();
248 249
249 void updateEventIndicatorTop(int newY); 250 void updateEventIndicatorTop(int newY);
250 void updateEventIndicatorBottom(int newY); 251 void updateEventIndicatorBottom(int newY);
251 252
252 /** Updates data for selected timespan */ 253 /** Updates data for selected timespan */
253 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
254 /** Updates data for selected timespan for all day event*/ 255 /** Updates data for selected timespan for all day event*/
255 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 256 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
256 257
257 private: 258 private:
258 QTimer* mIdleTimer; 259 QTimer* mIdleTimer;
259 QDateTime mIdleStart; 260 QDateTime mIdleStart;
260 // view widgets 261 // view widgets
261 QFrame *mDayLabels; 262 QFrame *mDayLabels;
262 QHBox *mDayLabelsFrame; 263 QHBox *mDayLabelsFrame;
263 QBoxLayout *mLayoutDayLabels; 264 QBoxLayout *mLayoutDayLabels;
264 QFrame *mAllDayFrame; 265 QFrame *mAllDayFrame;
265 KOAgenda *mAllDayAgenda; 266 KOAgenda *mAllDayAgenda;
266 KOAgenda *mAgenda; 267 KOAgenda *mAgenda;
267 TimeLabels *mTimeLabels; 268 TimeLabels *mTimeLabels;
268 QWidget *mDummyAllDayLeft; 269 QWidget *mDummyAllDayLeft;
269 270
270 KDGanttMinimizeSplitter* mSplitterAgenda; 271 KDGanttMinimizeSplitter* mSplitterAgenda;
271 QPushButton *mExpandButton; 272 QPushButton *mExpandButton;
272 273
273 DateList mSelectedDates; // List of dates to be displayed 274 DateList mSelectedDates; // List of dates to be displayed
274 int mViewType; 275 int mViewType;
275 276
276 bool mWeekStartsMonday; 277 bool mWeekStartsMonday;
277 int mStartHour; 278 int mStartHour;
278 279
279 KOEventPopupMenu *mAllAgendaPopup; 280 KOEventPopupMenu *mAllAgendaPopup;
280 //KOEventPopupMenu *mAllDayAgendaPopup; 281 //KOEventPopupMenu *mAllDayAgendaPopup;
281 282
282 EventIndicator *mEventIndicatorTop; 283 EventIndicator *mEventIndicatorTop;
283 EventIndicator *mEventIndicatorBottom; 284 EventIndicator *mEventIndicatorBottom;
284 285
285 QMemArray<int> mMinY; 286 QMemArray<int> mMinY;
286 QMemArray<int> mMaxY; 287 QMemArray<int> mMaxY;
287 288
288 QMemArray<bool> mHolidayMask; 289 QMemArray<bool> mHolidayMask;
289 290
290 QPtrList<KOAgendaButton> mDayLabelsList; 291 QPtrList<KOAgendaButton> mDayLabelsList;
291 QDateTime mTimeSpanBegin; 292 QDateTime mTimeSpanBegin;
292 QDateTime mTimeSpanEnd; 293 QDateTime mTimeSpanEnd;
293 bool mTimeSpanInAllDay; 294 bool mTimeSpanInAllDay;
294 void keyPressEvent ( QKeyEvent * e ); 295 void keyPressEvent ( QKeyEvent * e );
295}; 296};
296 297
297#endif // KOAGENDAVIEW_H 298#endif // KOAGENDAVIEW_H