summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Unidiff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp169
1 files changed, 90 insertions, 79 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 1d4d6de..fe59787 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -16,67 +16,78 @@
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 <q3intdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <q3popupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <QDesktopWidget>
39//Added by qt3to4:
40#include <QResizeEvent>
41#include <QLabel>
42#include <QPixmap>
43#include <QMouseEvent>
44#include <QKeyEvent>
45#include <Q3MemArray>
46#include <QEvent>
47#include <Q3Frame>
48#include <Q3PtrList>
38 49
39#include <kdebug.h> 50#include <kdebug.h>
40#include <klocale.h> 51#include <klocale.h>
41#include <kiconloader.h> 52#include <kiconloader.h>
42#include <kglobal.h> 53#include <kglobal.h>
43 54
44#include "koagendaitem.h" 55#include "koagendaitem.h"
45#include "koprefs.h" 56#include "koprefs.h"
46#include "koglobals.h" 57#include "koglobals.h"
47 58
48#include "koagenda.h" 59#include "koagenda.h"
49 60
50#include <libkcal/event.h> 61#include <libkcal/event.h>
51#include <libkcal/todo.h> 62#include <libkcal/todo.h>
52 63
53#ifndef DESKTOP_VERSION 64#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 65#include <qpe/qpeapplication.h>
55#endif 66#endif
56 67
57//extern bool globalFlagBlockPainting; 68//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 69extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 70extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 71extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 72extern int globalFlagBlockStartup;
62 73
63 74
64//////////////////////////////////////////////////////////////////////////// 75////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 76MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 77 : Q3Frame(_agenda->viewport(),name), agenda(_agenda)
67{ 78{
68 setLineWidth(0); 79 setLineWidth(0);
69 setMargin(0); 80 setMargin(0);
70 setBackgroundColor(Qt::red); 81 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 82 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 83 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 84 minutes->start(0, true);
74 mTimeBox = new QLabel(this); 85 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 86 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 87 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 88 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 89 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 90 //mTimeBox->setAutoMask(true);
80 91
81 agenda->addChild(mTimeBox); 92 agenda->addChild(mTimeBox);
82 93
@@ -156,55 +167,55 @@ void MarcusBains::updateLocation(bool recalculate)
156 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 167 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
157 y-mTimeBox->height()); 168 y-mTimeBox->height());
158 mTimeBox->raise(); 169 mTimeBox->raise();
159 //mTimeBox->setAutoMask(true); 170 //mTimeBox->setAutoMask(true);
160 int secs = QTime::currentTime().second(); 171 int secs = QTime::currentTime().second();
161 minutes->start( (60 - secs +1)*1000 ,true); 172 minutes->start( (60 - secs +1)*1000 ,true);
162} 173}
163 174
164 175
165//////////////////////////////////////////////////////////////////////////// 176////////////////////////////////////////////////////////////////////////////
166 177
167 178
168/* 179/*
169 Create an agenda widget with rows rows and columns columns. 180 Create an agenda widget with rows rows and columns columns.
170*/ 181*/
171KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 182KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
172 const char *name,WFlags f) : 183 const char *name,Qt::WFlags f) :
173 QScrollView(parent,name,f) 184 Q3ScrollView(parent,name,f)
174{ 185{
175 186
176 mAllAgendaPopup = 0; 187 mAllAgendaPopup = 0;
177 mColumns = columns; 188 mColumns = columns;
178 mRows = rows; 189 mRows = rows;
179 mGridSpacingY = rowSize; 190 mGridSpacingY = rowSize;
180 mAllDayMode = false; 191 mAllDayMode = false;
181#ifndef DESKTOP_VERSION 192#ifndef DESKTOP_VERSION
182 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 193 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
183#endif 194#endif
184 mHolidayMask = 0; 195 mHolidayMask = 0;
185 init(); 196 init();
186 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); 197 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
187} 198}
188 199
189/* 200/*
190 Create an agenda widget with columns columns and one row. This is used for 201 Create an agenda widget with columns columns and one row. This is used for
191 all-day events. 202 all-day events.
192*/ 203*/
193KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 204KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,Qt::WFlags f) :
194 QScrollView(parent,name,f) 205 Q3ScrollView(parent,name,f)
195{ 206{
196 mAllAgendaPopup = 0; 207 mAllAgendaPopup = 0;
197 blockResize = false; 208 blockResize = false;
198 mColumns = columns; 209 mColumns = columns;
199 mRows = 1; 210 mRows = 1;
200 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 211 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
201 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 212 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
202 mAllDayMode = true; 213 mAllDayMode = true;
203#ifndef DESKTOP_VERSION 214#ifndef DESKTOP_VERSION
204 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 215 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
205#endif 216#endif
206 mHolidayMask = 0; 217 mHolidayMask = 0;
207 init(); 218 init();
208} 219}
209 220
210 221
@@ -218,65 +229,65 @@ Incidence *KOAgenda::selectedIncidence() const
218{ 229{
219 return (mSelectedItem ? mSelectedItem->incidence() : 0); 230 return (mSelectedItem ? mSelectedItem->incidence() : 0);
220} 231}
221 232
222 233
223QDate KOAgenda::selectedIncidenceDate() const 234QDate KOAgenda::selectedIncidenceDate() const
224{ 235{
225 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 236 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
226} 237}
227 238
228 239
229void KOAgenda::init() 240void KOAgenda::init()
230{ 241{
231 mPopupTimer = new QTimer(this); 242 mPopupTimer = new QTimer(this);
232 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 243 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
233 244
234 mNewItemPopup = new QPopupMenu( this ); 245 mNewItemPopup = new Q3PopupMenu( this );
235 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 246 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
236 QString pathString = ""; 247 QString pathString = "";
237 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 248 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
238 if ( QApplication::desktop()->width() < 480 ) 249 if ( QApplication::desktop()->width() < 480 )
239 pathString += "icons16/"; 250 pathString += "icons16/";
240 } else 251 } else
241 pathString += "iconsmini/"; 252 pathString += "iconsmini/";
242 253
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 254 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 255 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
245 mNewItemPopup->insertSeparator ( ); 256 mNewItemPopup->insertSeparator ( );
246 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 257 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"day" ), i18n("Day view"),3 );
247 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 258 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
248 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 259 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"week" ), i18n("Next week"),4 );
249 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 260 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
250 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 261 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"month" ), i18n("This month"),6 );
251 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 262 mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
252#ifndef _WIN32_ 263#ifndef _WIN32_
253 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 264 Qt::WindowFlags wflags = viewport()-> windowFlags() |Qt::WRepaintNoErase;//WResizeNoErase
254 viewport()->setWFlags ( wflags); 265 viewport()->setWindowFlags ( wflags);
255#endif 266#endif
256 mGridSpacingX = 80; 267 mGridSpacingX = 80;
257 mResizeBorderWidth = 8; 268 mResizeBorderWidth = 8;
258 mScrollBorderWidth = 8; 269 mScrollBorderWidth = 8;
259 mScrollDelay = 30; 270 mScrollDelay = 30;
260 mScrollOffset = 10; 271 mScrollOffset = 10;
261 mPaintPixmap.resize( 20,20); 272 mPaintPixmap.resize( 20,20);
262 //enableClipper(true); 273 //enableClipper(true);
263 274
264 // Grab key strokes for keyboard navigation of agenda. Seems to have no 275 // Grab key strokes for keyboard navigation of agenda. Seems to have no
265 // effect. Has to be fixed. 276 // effect. Has to be fixed.
266 setFocusPolicy(WheelFocus); 277 setFocusPolicy(Qt::WheelFocus);
267 278
268 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 279 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
269 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 280 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
270 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 281 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
271 282
272 mStartCellX = 0; 283 mStartCellX = 0;
273 mStartCellY = 0; 284 mStartCellY = 0;
274 mCurrentCellX = 0; 285 mCurrentCellX = 0;
275 mCurrentCellY = 0; 286 mCurrentCellY = 0;
276 287
277 mSelectionCellX = 0; 288 mSelectionCellX = 0;
278 mSelectionYTop = 0; 289 mSelectionYTop = 0;
279 mSelectionHeight = 0; 290 mSelectionHeight = 0;
280 291
281 mOldLowerScrollValue = -1; 292 mOldLowerScrollValue = -1;
282 mOldUpperScrollValue = -1; 293 mOldUpperScrollValue = -1;
@@ -382,37 +393,37 @@ void KOAgenda::changeColumns(int columns)
382/* 393/*
383 This is the eventFilter function, which gets all events from the KOAgendaItems 394 This is the eventFilter function, which gets all events from the KOAgendaItems
384 contained in the agenda. It has to handle moving and resizing for all items. 395 contained in the agenda. It has to handle moving and resizing for all items.
385*/ 396*/
386bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 397bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
387{ 398{
388 // kdDebug() << "KOAgenda::eventFilter" << endl; 399 // kdDebug() << "KOAgenda::eventFilter" << endl;
389 switch(event->type()) { 400 switch(event->type()) {
390 case QEvent::MouseButtonPress: 401 case QEvent::MouseButtonPress:
391 case QEvent::MouseButtonDblClick: 402 case QEvent::MouseButtonDblClick:
392 case QEvent::MouseButtonRelease: 403 case QEvent::MouseButtonRelease:
393 case QEvent::MouseMove: 404 case QEvent::MouseMove:
394 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 405 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
395 406
396 case (QEvent::Leave): 407 case (QEvent::Leave):
397 if (!mActionItem) 408 if (!mActionItem)
398 setCursor(arrowCursor); 409 setCursor(Qt::arrowCursor);
399 return true; 410 return true;
400 411
401 default: 412 default:
402 return QScrollView::eventFilter(object,event); 413 return Q3ScrollView::eventFilter(object,event);
403 } 414 }
404} 415}
405void KOAgenda::popupMenu() 416void KOAgenda::popupMenu()
406{ 417{
407 mPopupTimer->stop(); 418 mPopupTimer->stop();
408 if ( mPopupKind == 1 || mPopupKind == 3 ) { 419 if ( mPopupKind == 1 || mPopupKind == 3 ) {
409 if (mActionItem ) { 420 if (mActionItem ) {
410 endItemAction(); 421 endItemAction();
411 } 422 }
412 mLeftMouseDown = false; // no more leftMouse computation 423 mLeftMouseDown = false; // no more leftMouse computation
413 if (mPopupItem) { 424 if (mPopupItem) {
414 //mClickedItem = mPopupItem; 425 //mClickedItem = mPopupItem;
415 selectItem(mPopupItem); 426 selectItem(mPopupItem);
416 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 427 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
417 mAllAgendaPopup->installEventFilter( this ); 428 mAllAgendaPopup->installEventFilter( this );
418 emit showIncidencePopupSignal(mPopupItem->incidence()); 429 emit showIncidencePopupSignal(mPopupItem->incidence());
@@ -492,37 +503,37 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
492 if ( dX > blockmoveDist || dY > blockmoveDist ) { 503 if ( dX > blockmoveDist || dY > blockmoveDist ) {
493 mAllAgendaPopup->hide(); 504 mAllAgendaPopup->hide();
494 } 505 }
495 } 506 }
496 return true; 507 return true;
497 } 508 }
498 QPoint viewportPos; 509 QPoint viewportPos;
499 if (object != viewport()) { 510 if (object != viewport()) {
500 blockmoveDist = blockmoveDist*2; 511 blockmoveDist = blockmoveDist*2;
501 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 512 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
502 } else { 513 } else {
503 viewportPos = me->pos(); 514 viewportPos = me->pos();
504 } 515 }
505 bool objIsNotViewport = (object != viewport()); 516 bool objIsNotViewport = (object != viewport());
506 bool leftButt = false; 517 bool leftButt = false;
507#ifdef DESKTOP_VERSION 518#ifdef DESKTOP_VERSION
508 leftButt = (me->button() == LeftButton); 519 leftButt = (me->button() == Qt::LeftButton);
509#endif 520#endif
510 switch (me->type()) { 521 switch (me->type()) {
511 case QEvent::MouseButtonPress: 522 case QEvent::MouseButtonPress:
512 if (me->button() == LeftButton) { 523 if (me->button() == Qt::LeftButton) {
513 mPopupTimer->start( 600 ); 524 mPopupTimer->start( 600 );
514 mLeftMouseDown = true; 525 mLeftMouseDown = true;
515 } 526 }
516 blockMoving = true; 527 blockMoving = true;
517 startX = viewportPos.x(); 528 startX = viewportPos.x();
518 startY = viewportPos.y(); 529 startY = viewportPos.y();
519 mPopupPos = me->globalPos(); 530 mPopupPos = me->globalPos();
520 if ( objIsNotViewport && !leftButt ) { 531 if ( objIsNotViewport && !leftButt ) {
521 KOAgendaItem * tempItem = (KOAgendaItem *)object; 532 KOAgendaItem * tempItem = (KOAgendaItem *)object;
522 if (mAllDayMode) { 533 if (mAllDayMode) {
523 if ( tempItem->height() > 10 ) { 534 if ( tempItem->height() > 10 ) {
524 int minV = tempItem->height()/4; 535 int minV = tempItem->height()/4;
525 if ( minV > (blockmoveDist/2)-2 ) { 536 if ( minV > (blockmoveDist/2)-2 ) {
526 if ( minV > blockmoveDist ) 537 if ( minV > blockmoveDist )
527 minV = blockmoveDist; 538 minV = blockmoveDist;
528 else 539 else
@@ -565,104 +576,104 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
565 } 576 }
566 if ( ! border ) { 577 if ( ! border ) {
567 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 578 diff = tempItem->x() + tempItem->width() - viewportPos.x();
568 if ( diff < 0 ) 579 if ( diff < 0 )
569 diff *= -1; 580 diff *= -1;
570 if ( diff < minH ) { 581 if ( diff < minH ) {
571 border = true; 582 border = true;
572 objIsNotViewport = false; 583 objIsNotViewport = false;
573 } 584 }
574 } 585 }
575 } 586 }
576 } 587 }
577 } 588 }
578 if ( objIsNotViewport ) { 589 if ( objIsNotViewport ) {
579 mPopupItem = (KOAgendaItem *)object; 590 mPopupItem = (KOAgendaItem *)object;
580 mPopupKind = 1; 591 mPopupKind = 1;
581 if (me->button() == RightButton) { 592 if (me->button() == Qt::RightButton) {
582 mPopupKind = 3; 593 mPopupKind = 3;
583 popupMenu(); 594 popupMenu();
584 } else if (me->button() == LeftButton) { 595 } else if (me->button() == Qt::LeftButton) {
585 mActionItem = (KOAgendaItem *)object; 596 mActionItem = (KOAgendaItem *)object;
586 if (mActionItem) { 597 if (mActionItem) {
587 emit signalClearSelection(); 598 emit signalClearSelection();
588 slotClearSelection(); 599 slotClearSelection();
589 selectItem(mActionItem); 600 selectItem(mActionItem);
590 Incidence *incidence = mActionItem->incidence(); 601 Incidence *incidence = mActionItem->incidence();
591 if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { 602 if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) {
592 mActionItem = 0; 603 mActionItem = 0;
593 } else { 604 } else {
594 startItemAction(viewportPos); 605 startItemAction(viewportPos);
595 } 606 }
596 } 607 }
597 } 608 }
598 } else { // ---------- viewport() 609 } else { // ---------- viewport()
599 mPopupItem = 0; 610 mPopupItem = 0;
600 mPopupKind = 2; 611 mPopupKind = 2;
601 selectItem(0); 612 selectItem(0);
602 mActionItem = 0; 613 mActionItem = 0;
603 if (me->button() == RightButton) { 614 if (me->button() == Qt::RightButton) {
604 int x,y; 615 int x,y;
605 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 616 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
606 int gx,gy; 617 int gx,gy;
607 contentsToGrid(x,y,gx,gy); 618 contentsToGrid(x,y,gx,gy);
608 mCurrentCellX = gx; 619 mCurrentCellX = gx;
609 mCurrentCellY = gy; 620 mCurrentCellY = gy;
610 mStartCellX = gx; 621 mStartCellX = gx;
611 mStartCellY = gy; 622 mStartCellY = gy;
612 mPopupKind = 4; 623 mPopupKind = 4;
613 popupMenu(); 624 popupMenu();
614 } else if (me->button() == LeftButton) { 625 } else if (me->button() == Qt::LeftButton) {
615 setCursor(arrowCursor); 626 setCursor(Qt::arrowCursor);
616 startSelectAction(viewportPos); 627 startSelectAction(viewportPos);
617 } 628 }
618 } 629 }
619 break; 630 break;
620 631
621 case QEvent::MouseButtonRelease: 632 case QEvent::MouseButtonRelease:
622 if (me->button() == LeftButton ) { 633 if (me->button() == Qt::LeftButton ) {
623 mPopupTimer->stop(); 634 mPopupTimer->stop();
624 } 635 }
625 if (object != viewport()) { 636 if (object != viewport()) {
626 if (me->button() == LeftButton && mLeftMouseDown) { 637 if (me->button() == Qt::LeftButton && mLeftMouseDown) {
627 if (mActionItem) { 638 if (mActionItem) {
628 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 639 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
629 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 640 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
630 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 641 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
631 mScrollUpTimer.stop(); 642 mScrollUpTimer.stop();
632 mScrollDownTimer.stop(); 643 mScrollDownTimer.stop();
633 mActionItem->resetMove(); 644 mActionItem->resetMove();
634 placeSubCells( mActionItem ); 645 placeSubCells( mActionItem );
635 // emit startDragSignal( mActionItem->incidence() ); 646 // emit startDragSignal( mActionItem->incidence() );
636 setCursor( arrowCursor ); 647 setCursor( Qt::arrowCursor );
637 mActionItem = 0; 648 mActionItem = 0;
638 mActionType = NOP; 649 mActionType = NOP;
639 mItemMoved = 0; 650 mItemMoved = 0;
640 mLeftMouseDown = false; 651 mLeftMouseDown = false;
641 return true; 652 return true;
642 } 653 }
643 endItemAction(); 654 endItemAction();
644 } 655 }
645 } 656 }
646 657
647 } else { // ---------- viewport() 658 } else { // ---------- viewport()
648 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 659 if (me->button() == Qt::LeftButton && mLeftMouseDown ) { //left click
649 endSelectAction( true ); // emit new event signal 660 endSelectAction( true ); // emit new event signal
650 } 661 }
651 } 662 }
652 if (me->button() == LeftButton) 663 if (me->button() == Qt::LeftButton)
653 mLeftMouseDown = false; 664 mLeftMouseDown = false;
654 665
655 break; 666 break;
656 667
657 case QEvent::MouseMove: 668 case QEvent::MouseMove:
658 //qDebug("mm "); 669 //qDebug("mm ");
659 if ( !mLeftMouseDown ) 670 if ( !mLeftMouseDown )
660 return false; 671 return false;
661 if ( blockMoving ) { 672 if ( blockMoving ) {
662 int dX, dY; 673 int dX, dY;
663 dX = startX - viewportPos.x(); 674 dX = startX - viewportPos.x();
664 if ( dX < 0 ) 675 if ( dX < 0 )
665 dX = -dX; 676 dX = -dX;
666 dY = viewportPos.y() - startY; 677 dY = viewportPos.y() - startY;
667 if ( dY < 0 ) 678 if ( dY < 0 )
668 dY = -dY; 679 dY = -dY;
@@ -837,109 +848,109 @@ void KOAgenda::startItemAction(QPoint viewportPos)
837 int x,y; 848 int x,y;
838 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 849 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
839 int gx,gy; 850 int gx,gy;
840 contentsToGrid(x,y,gx,gy); 851 contentsToGrid(x,y,gx,gy);
841 852
842 mStartCellX = gx; 853 mStartCellX = gx;
843 mStartCellY = gy; 854 mStartCellY = gy;
844 mCurrentCellX = gx; 855 mCurrentCellX = gx;
845 mCurrentCellY = gy; 856 mCurrentCellY = gy;
846 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 857 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
847 858
848 if (mAllDayMode) { 859 if (mAllDayMode) {
849 int gridDistanceX = (x - gx * mGridSpacingX); 860 int gridDistanceX = (x - gx * mGridSpacingX);
850 if ( allowResize && gridDistanceX < mResizeBorderWidth && 861 if ( allowResize && gridDistanceX < mResizeBorderWidth &&
851 mActionItem->cellX() == mCurrentCellX) { 862 mActionItem->cellX() == mCurrentCellX) {
852 mActionType = RESIZELEFT; 863 mActionType = RESIZELEFT;
853 setCursor(sizeHorCursor); 864 setCursor(Qt::sizeHorCursor);
854 } else if ( allowResize && (mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 865 } else if ( allowResize && (mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
855 mActionItem->cellXWidth() == mCurrentCellX) { 866 mActionItem->cellXWidth() == mCurrentCellX) {
856 mActionType = RESIZERIGHT; 867 mActionType = RESIZERIGHT;
857 setCursor(sizeHorCursor); 868 setCursor(Qt::sizeHorCursor);
858 } else { 869 } else {
859 mActionType = MOVE; 870 mActionType = MOVE;
860 mActionItem->startMove(); 871 mActionItem->startMove();
861 setCursor(sizeAllCursor); 872 setCursor(Qt::sizeAllCursor);
862 } 873 }
863 } else { 874 } else {
864 int gridDistanceY = (y - gy * mGridSpacingY); 875 int gridDistanceY = (y - gy * mGridSpacingY);
865 if (allowResize && gridDistanceY < mResizeBorderWidth && 876 if (allowResize && gridDistanceY < mResizeBorderWidth &&
866 mActionItem->cellYTop() == mCurrentCellY && 877 mActionItem->cellYTop() == mCurrentCellY &&
867 !mActionItem->firstMultiItem()) { 878 !mActionItem->firstMultiItem()) {
868 mActionType = RESIZETOP; 879 mActionType = RESIZETOP;
869 setCursor(sizeVerCursor); 880 setCursor(Qt::sizeVerCursor);
870 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 881 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
871 mActionItem->cellYBottom() == mCurrentCellY && 882 mActionItem->cellYBottom() == mCurrentCellY &&
872 !mActionItem->lastMultiItem()) { 883 !mActionItem->lastMultiItem()) {
873 mActionType = RESIZEBOTTOM; 884 mActionType = RESIZEBOTTOM;
874 setCursor(sizeVerCursor); 885 setCursor(Qt::sizeVerCursor);
875 } else { 886 } else {
876 mActionType = MOVE; 887 mActionType = MOVE;
877 mActionItem->startMove(); 888 mActionItem->startMove();
878 setCursor(sizeAllCursor); 889 setCursor(Qt::sizeAllCursor);
879 } 890 }
880 } 891 }
881} 892}
882 893
883void KOAgenda::performItemAction(QPoint viewportPos) 894void KOAgenda::performItemAction(QPoint viewportPos)
884{ 895{
885// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 896// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
886// QPoint point = viewport()->mapToGlobal(viewportPos); 897// QPoint point = viewport()->mapToGlobal(viewportPos);
887// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 898// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
888// point = clipper()->mapFromGlobal(point); 899// point = clipper()->mapFromGlobal(point);
889// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 900// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
890// kdDebug() << "visible height: " << visibleHeight() << endl; 901// kdDebug() << "visible height: " << visibleHeight() << endl;
891 int x,y; 902 int x,y;
892 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 903 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
893// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 904// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
894 int gx,gy; 905 int gx,gy;
895 contentsToGrid(x,y,gx,gy); 906 contentsToGrid(x,y,gx,gy);
896 QPoint clipperPos = clipper()-> 907 QPoint clipperPos = clipper()->
897 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 908 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
898 909
899 // Cursor left active agenda area. 910 // Cursor left active agenda area.
900 // This starts a drag. 911 // This starts a drag.
901 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 912 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
902 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 913 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
903 if ( mActionType == MOVE ) { 914 if ( mActionType == MOVE ) {
904 mScrollUpTimer.stop(); 915 mScrollUpTimer.stop();
905 mScrollDownTimer.stop(); 916 mScrollDownTimer.stop();
906 mActionItem->resetMove(); 917 mActionItem->resetMove();
907 placeSubCells( mActionItem ); 918 placeSubCells( mActionItem );
908 // emit startDragSignal( mActionItem->incidence() ); 919 // emit startDragSignal( mActionItem->incidence() );
909 setCursor( arrowCursor ); 920 setCursor( Qt::arrowCursor );
910 mActionItem = 0; 921 mActionItem = 0;
911 mActionType = NOP; 922 mActionType = NOP;
912 mItemMoved = 0; 923 mItemMoved = 0;
913 return; 924 return;
914 } 925 }
915 } else { 926 } else {
916 switch ( mActionType ) { 927 switch ( mActionType ) {
917 case MOVE: 928 case MOVE:
918 setCursor( sizeAllCursor ); 929 setCursor( Qt::sizeAllCursor );
919 break; 930 break;
920 case RESIZETOP: 931 case RESIZETOP:
921 case RESIZEBOTTOM: 932 case RESIZEBOTTOM:
922 setCursor( sizeVerCursor ); 933 setCursor( Qt::sizeVerCursor );
923 break; 934 break;
924 case RESIZELEFT: 935 case RESIZELEFT:
925 case RESIZERIGHT: 936 case RESIZERIGHT:
926 setCursor( sizeHorCursor ); 937 setCursor( Qt::sizeHorCursor );
927 break; 938 break;
928 default: 939 default:
929 setCursor( arrowCursor ); 940 setCursor( Qt::arrowCursor );
930 } 941 }
931 } 942 }
932 943
933 // Scroll if item was moved to upper or lower end of agenda. 944 // Scroll if item was moved to upper or lower end of agenda.
934 if (clipperPos.y() < mScrollBorderWidth) { 945 if (clipperPos.y() < mScrollBorderWidth) {
935 mScrollUpTimer.start(mScrollDelay); 946 mScrollUpTimer.start(mScrollDelay);
936 } else if (visibleHeight() - clipperPos.y() < 947 } else if (visibleHeight() - clipperPos.y() <
937 mScrollBorderWidth) { 948 mScrollBorderWidth) {
938 mScrollDownTimer.start(mScrollDelay); 949 mScrollDownTimer.start(mScrollDelay);
939 } else { 950 } else {
940 mScrollUpTimer.stop(); 951 mScrollUpTimer.stop();
941 mScrollDownTimer.stop(); 952 mScrollDownTimer.stop();
942 } 953 }
943 954
944 // Move or resize item if necessary 955 // Move or resize item if necessary
945 if (mCurrentCellX != gx || mCurrentCellY != gy) { 956 if (mCurrentCellX != gx || mCurrentCellY != gy) {
@@ -958,33 +969,33 @@ void KOAgenda::performItemAction(QPoint viewportPos)
958 int x,y; 969 int x,y;
959 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 970 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
960 int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(), 971 int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(),
961 mGridSpacingY * moveItem->cellHeight()); 972 mGridSpacingY * moveItem->cellHeight());
962 moveItem->raise(); 973 moveItem->raise();
963 moveChild(moveItem,x+diff,y); 974 moveChild(moveItem,x+diff,y);
964 moveItem = moveItem->nextMultiItem(); 975 moveItem = moveItem->nextMultiItem();
965 } 976 }
966 } else if (mActionType == RESIZETOP) { 977 } else if (mActionType == RESIZETOP) {
967 if (mCurrentCellY <= mActionItem->cellYBottom()) { 978 if (mCurrentCellY <= mActionItem->cellYBottom()) {
968 mActionItem->expandTop(gy - mCurrentCellY); 979 mActionItem->expandTop(gy - mCurrentCellY);
969 mActionItem->resize(mActionItem->width(), 980 mActionItem->resize(mActionItem->width(),
970 mGridSpacingY * mActionItem->cellHeight()); 981 mGridSpacingY * mActionItem->cellHeight());
971 int x,y; 982 int x,y;
972 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 983 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
973 //moveChild(mActionItem,childX(mActionItem),y); 984 //moveChild(mActionItem,childX(mActionItem),y);
974 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 985 Q3ScrollView::moveChild( mActionItem,childX(mActionItem),y );
975 } 986 }
976 } else if (mActionType == RESIZEBOTTOM) { 987 } else if (mActionType == RESIZEBOTTOM) {
977 if (mCurrentCellY >= mActionItem->cellYTop()) { 988 if (mCurrentCellY >= mActionItem->cellYTop()) {
978 mActionItem->expandBottom(gy - mCurrentCellY); 989 mActionItem->expandBottom(gy - mCurrentCellY);
979 mActionItem->resize(mActionItem->width(), 990 mActionItem->resize(mActionItem->width(),
980 mGridSpacingY * mActionItem->cellHeight()); 991 mGridSpacingY * mActionItem->cellHeight());
981 } 992 }
982 } else if (mActionType == RESIZELEFT) { 993 } else if (mActionType == RESIZELEFT) {
983 if (mCurrentCellX <= mActionItem->cellXWidth()) { 994 if (mCurrentCellX <= mActionItem->cellXWidth()) {
984 mActionItem->expandLeft(gx - mCurrentCellX); 995 mActionItem->expandLeft(gx - mCurrentCellX);
985 int diff = mActionItem->resizeMe(mGridSpacingX , 996 int diff = mActionItem->resizeMe(mGridSpacingX ,
986 mGridSpacingX * mActionItem->cellWidth(), 997 mGridSpacingX * mActionItem->cellWidth(),
987 mActionItem->height()); 998 mActionItem->height());
988 int x,y; 999 int x,y;
989 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 1000 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
990 moveChild(mActionItem,x+diff,childY(mActionItem)); 1001 moveChild(mActionItem,x+diff,childY(mActionItem));
@@ -1006,33 +1017,33 @@ void KOAgenda::endItemAction()
1006 1017
1007 if ( mItemMoved ) { 1018 if ( mItemMoved ) {
1008 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 1019 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
1009 if ( !placeItem ) { 1020 if ( !placeItem ) {
1010 placeItem = mActionItem; 1021 placeItem = mActionItem;
1011 } 1022 }
1012 if ( placeItem->incidence()->doesRecur() ) { 1023 if ( placeItem->incidence()->doesRecur() ) {
1013 Incidence* oldInc = placeItem->incidence(); 1024 Incidence* oldInc = placeItem->incidence();
1014 placeItem->recreateIncidence(); 1025 placeItem->recreateIncidence();
1015 emit addToCalSignal(placeItem->incidence(), oldInc ); 1026 emit addToCalSignal(placeItem->incidence(), oldInc );
1016 } 1027 }
1017 int type = mActionType; 1028 int type = mActionType;
1018 if ( mAllDayMode ) 1029 if ( mAllDayMode )
1019 type = -1; 1030 type = -1;
1020 KOAgendaItem *modifiedItem = placeItem; 1031 KOAgendaItem *modifiedItem = placeItem;
1021 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1032 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1022 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1033 Q3PtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1023 KOAgendaItem *item; 1034 KOAgendaItem *item;
1024 1035
1025 if ( placeItem->incidence()->typeID() == todoID ) { 1036 if ( placeItem->incidence()->typeID() == todoID ) {
1026 mSelectedItem = 0; 1037 mSelectedItem = 0;
1027 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1038 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1028 modifiedItem->mLastMoveXPos = mCurrentCellX; 1039 modifiedItem->mLastMoveXPos = mCurrentCellX;
1029 emit itemModified( modifiedItem, mActionType ); 1040 emit itemModified( modifiedItem, mActionType );
1030 } 1041 }
1031 else { 1042 else {
1032 1043
1033 1044
1034 globalFlagBlockAgendaItemPaint = 1; 1045 globalFlagBlockAgendaItemPaint = 1;
1035 for ( item=oldconflictItems.first(); item != 0; 1046 for ( item=oldconflictItems.first(); item != 0;
1036 item=oldconflictItems.next() ) { 1047 item=oldconflictItems.next() ) {
1037 placeSubCells(item); 1048 placeSubCells(item);
1038 } 1049 }
@@ -1097,98 +1108,98 @@ void KOAgenda::endItemAction()
1097 item=oldconflictItems.next() ) { 1108 item=oldconflictItems.next() ) {
1098 globalFlagBlockAgendaItemUpdate = 0; 1109 globalFlagBlockAgendaItemUpdate = 0;
1099 item->paintMe(false); 1110 item->paintMe(false);
1100 globalFlagBlockAgendaItemUpdate = 1; 1111 globalFlagBlockAgendaItemUpdate = 1;
1101 item->repaint(false); 1112 item->repaint(false);
1102 } 1113 }
1103 */ 1114 */
1104 1115
1105 1116
1106 } 1117 }
1107 1118
1108 } 1119 }
1109 if ( mActionItem ) 1120 if ( mActionItem )
1110 emit incidenceSelected( mActionItem->incidence() ); 1121 emit incidenceSelected( mActionItem->incidence() );
1111 mScrollUpTimer.stop(); 1122 mScrollUpTimer.stop();
1112 mScrollDownTimer.stop(); 1123 mScrollDownTimer.stop();
1113 setCursor( arrowCursor ); 1124 setCursor( Qt::arrowCursor );
1114 mActionItem = 0; 1125 mActionItem = 0;
1115 mActionType = NOP; 1126 mActionType = NOP;
1116 mItemMoved = 0; 1127 mItemMoved = 0;
1117 1128
1118} 1129}
1119 1130
1120void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1131void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1121{ 1132{
1122// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1133// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1123// QPoint point = viewport()->mapToGlobal(viewportPos); 1134// QPoint point = viewport()->mapToGlobal(viewportPos);
1124// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1135// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1125// point = clipper()->mapFromGlobal(point); 1136// point = clipper()->mapFromGlobal(point);
1126// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1137// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1127 1138
1128 int x,y; 1139 int x,y;
1129 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1140 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1130// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1141// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1131 int gx,gy; 1142 int gx,gy;
1132 contentsToGrid(x,y,gx,gy); 1143 contentsToGrid(x,y,gx,gy);
1133 1144
1134 // Change cursor to resize cursor if appropriate 1145 // Change cursor to resize cursor if appropriate
1135 if (mAllDayMode) { 1146 if (mAllDayMode) {
1136 int gridDistanceX = (x - gx * mGridSpacingX); 1147 int gridDistanceX = (x - gx * mGridSpacingX);
1137 if (gridDistanceX < mResizeBorderWidth && 1148 if (gridDistanceX < mResizeBorderWidth &&
1138 moveItem->cellX() == gx) { 1149 moveItem->cellX() == gx) {
1139 setCursor(sizeHorCursor); 1150 setCursor(Qt::sizeHorCursor);
1140 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1151 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1141 moveItem->cellXWidth() == gx) { 1152 moveItem->cellXWidth() == gx) {
1142 setCursor(sizeHorCursor); 1153 setCursor(Qt::sizeHorCursor);
1143 } else { 1154 } else {
1144 setCursor(arrowCursor); 1155 setCursor(Qt::arrowCursor);
1145 } 1156 }
1146 } else { 1157 } else {
1147 int gridDistanceY = (y - gy * mGridSpacingY); 1158 int gridDistanceY = (y - gy * mGridSpacingY);
1148 if (gridDistanceY < mResizeBorderWidth && 1159 if (gridDistanceY < mResizeBorderWidth &&
1149 moveItem->cellYTop() == gy && 1160 moveItem->cellYTop() == gy &&
1150 !moveItem->firstMultiItem()) { 1161 !moveItem->firstMultiItem()) {
1151 setCursor(sizeVerCursor); 1162 setCursor(Qt::sizeVerCursor);
1152 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1163 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1153 moveItem->cellYBottom() == gy && 1164 moveItem->cellYBottom() == gy &&
1154 !moveItem->lastMultiItem()) { 1165 !moveItem->lastMultiItem()) {
1155 setCursor(sizeVerCursor); 1166 setCursor(Qt::sizeVerCursor);
1156 } else { 1167 } else {
1157 setCursor(arrowCursor); 1168 setCursor(Qt::arrowCursor);
1158 } 1169 }
1159 } 1170 }
1160} 1171}
1161 1172
1162 1173
1163/* 1174/*
1164 Place item in cell and take care that multiple items using the same cell do 1175 Place item in cell and take care that multiple items using the same cell do
1165 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1176 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1166 it can get in all cases. 1177 it can get in all cases.
1167 At the moment the method has a bug: When an item is placed only the sub cell 1178 At the moment the method has a bug: When an item is placed only the sub cell
1168 widths of the items are changed, which are within the Y region the item to 1179 widths of the items are changed, which are within the Y region the item to
1169 place spans. When the sub cell width change of one of this items affects a 1180 place spans. When the sub cell width change of one of this items affects a
1170 cell, where other items are, which do not overlap in Y with the item to place, 1181 cell, where other items are, which do not overlap in Y with the item to place,
1171 the display gets corrupted, although the corruption looks quite nice. 1182 the display gets corrupted, although the corruption looks quite nice.
1172*/ 1183*/
1173void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1184void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1174{ 1185{
1175 1186
1176 QPtrList<KOAgendaItem> conflictItems; 1187 Q3PtrList<KOAgendaItem> conflictItems;
1177 int maxSubCells = 0; 1188 int maxSubCells = 0;
1178 QIntDict<KOAgendaItem> subCellDict(7); 1189 Q3IntDict<KOAgendaItem> subCellDict(7);
1179 1190
1180 KOAgendaItem *item; 1191 KOAgendaItem *item;
1181 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1192 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1182 if (item != placeItem) { 1193 if (item != placeItem) {
1183 if (placeItem->cellX() <= item->cellXWidth() && 1194 if (placeItem->cellX() <= item->cellXWidth() &&
1184 placeItem->cellXWidth() >= item->cellX()) { 1195 placeItem->cellXWidth() >= item->cellX()) {
1185 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1196 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1186 (placeItem->cellYBottom() >= item->cellYTop())) { 1197 (placeItem->cellYBottom() >= item->cellYTop())) {
1187 conflictItems.append(item); 1198 conflictItems.append(item);
1188 if (item->subCells() > maxSubCells) 1199 if (item->subCells() > maxSubCells)
1189 maxSubCells = item->subCells(); 1200 maxSubCells = item->subCells();
1190 subCellDict.insert(item->subCell(),item); 1201 subCellDict.insert(item->subCell(),item);
1191 } 1202 }
1192 } 1203 }
1193 } 1204 }
1194 } 1205 }
@@ -1227,33 +1238,33 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1227 int x,y; 1238 int x,y;
1228 gridToContents(item->cellX(),item->cellYTop(),x,y); 1239 gridToContents(item->cellX(),item->cellYTop(),x,y);
1229 if (mAllDayMode) { 1240 if (mAllDayMode) {
1230 y += item->subCell() * newSubCellWidth; 1241 y += item->subCell() * newSubCellWidth;
1231 } else { 1242 } else {
1232 x += item->subCell() * newSubCellWidth; 1243 x += item->subCell() * newSubCellWidth;
1233 } 1244 }
1234 moveChild(item,x+diff,y); 1245 moveChild(item,x+diff,y);
1235 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1246 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1236 //item->updateItem(); 1247 //item->updateItem();
1237 } 1248 }
1238 // Adjust sub cell geometry of all conflict items of all conflict items 1249 // Adjust sub cell geometry of all conflict items of all conflict items
1239 for ( item=conflictItems.first(); item != 0; 1250 for ( item=conflictItems.first(); item != 0;
1240 item=conflictItems.next() ) { 1251 item=conflictItems.next() ) {
1241 if ( placeItem != item ) { 1252 if ( placeItem != item ) {
1242 KOAgendaItem *item2; 1253 KOAgendaItem *item2;
1243 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1254 Q3PtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1244 for ( item2=conflictItems2.first(); item2 != 0; 1255 for ( item2=conflictItems2.first(); item2 != 0;
1245 item2=conflictItems2.next() ) { 1256 item2=conflictItems2.next() ) {
1246 if ( item2->subCells() != maxSubCells) { 1257 if ( item2->subCells() != maxSubCells) {
1247 item2->setSubCells(maxSubCells); 1258 item2->setSubCells(maxSubCells);
1248 int diff = 0; 1259 int diff = 0;
1249 if (mAllDayMode) { 1260 if (mAllDayMode) {
1250 diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1261 diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1251 } else { 1262 } else {
1252 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1263 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1253 } 1264 }
1254 int x,y; 1265 int x,y;
1255 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1266 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1256 if (mAllDayMode) { 1267 if (mAllDayMode) {
1257 y += item2->subCell() * newSubCellWidth; 1268 y += item2->subCell() * newSubCellWidth;
1258 } else { 1269 } else {
1259 x += item2->subCell() * newSubCellWidth; 1270 x += item2->subCell() * newSubCellWidth;
@@ -1312,87 +1323,87 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1312 int selectionX = KOGlobals::self()->reverseLayout() ? 1323 int selectionX = KOGlobals::self()->reverseLayout() ?
1313 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1324 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1314 mSelectionCellX * mGridSpacingX; 1325 mSelectionCellX * mGridSpacingX;
1315 contentsToViewport ( cx, cy, vx,vy); 1326 contentsToViewport ( cx, cy, vx,vy);
1316 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1327 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1317 1328
1318 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1329 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1319 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1330 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1320 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1331 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1321 1332
1322 int vxSel, vySel; 1333 int vxSel, vySel;
1323 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1334 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1324 int off = mSelectionHeight; 1335 int off = mSelectionHeight;
1325 if ( vySel < 0 ) 1336 if ( vySel < 0 )
1326 off += vySel; 1337 off += vySel;
1327 //qDebug("OFF %d %d %d", off,vySel, vy ); 1338 //qDebug("OFF %d %d %d", off,vySel, vy );
1328 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1339 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,QPainter::CompositionMode_Source);
1329 } else { 1340 } else {
1330 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1341 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,QPainter::CompositionMode_Source);
1331 } 1342 }
1332 } 1343 }
1333 if ( mSelectionHeight > 0 ) { 1344 if ( mSelectionHeight > 0 ) {
1334 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1345 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1335 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1346 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1336 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1347 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1337 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1348 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1338 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1349 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1339 int hei = mSelectionHeight; 1350 int hei = mSelectionHeight;
1340 int offset = 0; 1351 int offset = 0;
1341 while ( hei > 0 ) { 1352 while ( hei > 0 ) {
1342 int p_hei = 5; 1353 int p_hei = 5;
1343 if ( hei < 5 ) p_hei = hei; 1354 if ( hei < 5 ) p_hei = hei;
1344 hei -= 5; 1355 hei -= 5;
1345 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1356 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,QPainter::CompositionMode_Source);
1346 offset += 5; 1357 offset += 5;
1347 } 1358 }
1348 } 1359 }
1349 } 1360 }
1350 p->begin( pd ); 1361 p->begin( pd );
1351 } else { 1362 } else {
1352#if 0 1363#if 0
1353 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); 1364 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1354 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1365 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1355 qDebug("WAUWAU "); 1366 qDebug("WAUWAU ");
1356 drawContentsToPainter(); 1367 drawContentsToPainter();
1357 } 1368 }
1358#endif 1369#endif
1359 QPaintDevice* pd = p->device(); 1370 QPaintDevice* pd = p->device();
1360 p->end(); 1371 p->end();
1361 int vx, vy; 1372 int vx, vy;
1362 int selectionX = KOGlobals::self()->reverseLayout() ? 1373 int selectionX = KOGlobals::self()->reverseLayout() ?
1363 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1374 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1364 mSelectionCellX * mGridSpacingX; 1375 mSelectionCellX * mGridSpacingX;
1365 contentsToViewport ( cx, cy, vx,vy); 1376 contentsToViewport ( cx, cy, vx,vy);
1366 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1377 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1367 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1378 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1368 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1379 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,QPainter::CompositionMode_Source);
1369 1380
1370 if ( mSelectionHeight > 0 ) { 1381 if ( mSelectionHeight > 0 ) {
1371 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1382 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1372 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1383 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1373 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1384 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1374 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1385 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1375 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1386 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1376 int hei = mSelectionHeight; 1387 int hei = mSelectionHeight;
1377 int offset = 0; 1388 int offset = 0;
1378 while ( hei > 0 ) { 1389 while ( hei > 0 ) {
1379 int p_hei = 5; 1390 int p_hei = 5;
1380 if ( hei < 5 ) p_hei = hei; 1391 if ( hei < 5 ) p_hei = hei;
1381 hei -= 5; 1392 hei -= 5;
1382 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1393 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,QPainter::CompositionMode_Source);
1383 offset += 5; 1394 offset += 5;
1384 } 1395 }
1385 } 1396 }
1386 } 1397 }
1387 p->begin( pd ); 1398 p->begin( pd );
1388 } 1399 }
1389 1400
1390} 1401}
1391 1402
1392void KOAgenda::finishUpdate() 1403void KOAgenda::finishUpdate()
1393{ 1404{
1394 1405
1395 KOAgendaItem *item; 1406 KOAgendaItem *item;
1396 globalFlagBlockAgendaItemPaint = 1; 1407 globalFlagBlockAgendaItemPaint = 1;
1397 // 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 1408 // 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
1398 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1409 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
@@ -1563,40 +1574,40 @@ void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// i
1563 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1574 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1564 } 1575 }
1565 */ 1576 */
1566 // Draw vertical lines of grid 1577 // Draw vertical lines of grid
1567 1578
1568 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1579 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1569 if ( mGridSpacingX > 0 ) { 1580 if ( mGridSpacingX > 0 ) {
1570 while (x < cx + cw) { 1581 while (x < cx + cw) {
1571 p->drawLine(x,cy,x,cy+ch); 1582 p->drawLine(x,cy,x,cy+ch);
1572 x+=mGridSpacingX; 1583 x+=mGridSpacingX;
1573 } 1584 }
1574 } 1585 }
1575 // Draw horizontal lines of grid 1586 // Draw horizontal lines of grid
1576 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1587 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1577 if ( lGridSpacingY > 0 ) { 1588 if ( lGridSpacingY > 0 ) {
1578 while (y < cy + ch) { 1589 while (y < cy + ch) {
1579 p->setPen( SolidLine ); 1590 p->setPen( Qt::SolidLine );
1580 p->drawLine(cx,y,cx+cw,y); 1591 p->drawLine(cx,y,cx+cw,y);
1581 y+=lGridSpacingY; 1592 y+=lGridSpacingY;
1582 p->setPen( DotLine ); 1593 p->setPen( Qt::DotLine );
1583 p->drawLine(cx,y,cx+cw,y); 1594 p->drawLine(cx,y,cx+cw,y);
1584 y+=lGridSpacingY; 1595 y+=lGridSpacingY;
1585 } 1596 }
1586 p->setPen( SolidLine ); 1597 p->setPen( Qt::SolidLine );
1587 } 1598 }
1588 mPixPainter.end() ; 1599 mPixPainter.end() ;
1589} 1600}
1590 1601
1591/* 1602/*
1592 Convert srcollview contents coordinates to agenda grid coordinates. 1603 Convert srcollview contents coordinates to agenda grid coordinates.
1593*/ 1604*/
1594void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1605void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1595{ 1606{
1596 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1607 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1597 x/mGridSpacingX; 1608 x/mGridSpacingX;
1598 gy = y/mGridSpacingY; 1609 gy = y/mGridSpacingY;
1599} 1610}
1600 1611
1601/* 1612/*
1602 Convert agenda grid coordinates to scrollview contents coordinates. 1613 Convert agenda grid coordinates to scrollview contents coordinates.
@@ -1704,95 +1715,95 @@ KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1704 1715
1705 1716
1706void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1717void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1707{ 1718{
1708 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1719 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1709 KOAgendaItem *item; 1720 KOAgendaItem *item;
1710 item = getItemForTodo ( todo ); 1721 item = getItemForTodo ( todo );
1711 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1722 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1712 if ( item ) { 1723 if ( item ) {
1713 blockSignals( true ); 1724 blockSignals( true );
1714 //qDebug("item found "); 1725 //qDebug("item found ");
1715 item->hide(); 1726 item->hide();
1716 item->setCellX(-2, -1 ); 1727 item->setCellX(-2, -1 );
1717 item->select(false); 1728 item->select(false);
1718 mUnusedItems.append( item ); 1729 mUnusedItems.append( item );
1719 mItems.remove( item ); 1730 mItems.remove( item );
1720 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1731 Q3PtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1721 KOAgendaItem *itemit; 1732 KOAgendaItem *itemit;
1722 //globalFlagBlockAgendaItemPaint = 1; 1733 //globalFlagBlockAgendaItemPaint = 1;
1723 for ( itemit=oldconflictItems.first(); itemit != 0; 1734 for ( itemit=oldconflictItems.first(); itemit != 0;
1724 itemit=oldconflictItems.next() ) { 1735 itemit=oldconflictItems.next() ) {
1725 if ( itemit != item ) 1736 if ( itemit != item )
1726 placeSubCells(itemit); 1737 placeSubCells(itemit);
1727 } 1738 }
1728 qApp->processEvents(); 1739 qApp->processEvents();
1729 //globalFlagBlockAgendaItemPaint = 0; 1740 //globalFlagBlockAgendaItemPaint = 0;
1730 for ( itemit=oldconflictItems.first(); itemit != 0; 1741 for ( itemit=oldconflictItems.first(); itemit != 0;
1731 itemit=oldconflictItems.next() ) { 1742 itemit=oldconflictItems.next() ) {
1732 globalFlagBlockAgendaItemUpdate = 0; 1743 globalFlagBlockAgendaItemUpdate = 0;
1733 if ( itemit != item ) 1744 if ( itemit != item )
1734 itemit->repaintMe(); 1745 itemit->repaintMe();
1735 globalFlagBlockAgendaItemUpdate = 1; 1746 globalFlagBlockAgendaItemUpdate = 1;
1736 //qDebug("sigleshot "); 1747 //qDebug("sigleshot ");
1737 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1748 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1738 //itemit->repaint( false ); repaintItem() 1749 //itemit->repaint( false ); repaintItem()
1739 } 1750 }
1740 blockSignals( false ); 1751 blockSignals( false );
1741 } 1752 }
1742 if ( remove ) { 1753 if ( remove ) {
1743 //qDebug("remove****************************************** "); 1754 //qDebug("remove****************************************** ");
1744 return; 1755 return;
1745 } 1756 }
1746 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1757 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1747 return; 1758 return;
1748 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1759 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1749 QDate currentDate = QDate::currentDate(); 1760 QDate currentDate = QDate::currentDate();
1750 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1761 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < (QDateTime)currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1751 QDateTime dt; 1762 QDateTime dt;
1752 if ( todo->hasCompletedDate() ) 1763 if ( todo->hasCompletedDate() )
1753 dt = todo->completed(); 1764 dt = todo->completed();
1754 else 1765 else
1755 dt = todo->dtDue(); 1766 dt = todo->dtDue();
1756 if ( overdue ) { 1767 if ( overdue ) {
1757 days += todo->dtDue().date().daysTo( currentDate ); 1768 days += todo->dtDue().date().daysTo( currentDate );
1758 } 1769 }
1759 else 1770 else
1760 currentDate = dt.date(); 1771 currentDate = dt.date();
1761 1772
1762 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1773 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1763 if ( ! mAllDayMode ) return; 1774 if ( ! mAllDayMode ) return;
1764 // aldayagenda 1775 // aldayagenda
1765 globalFlagBlockAgendaItemPaint = 1; 1776 globalFlagBlockAgendaItemPaint = 1;
1766 item = insertAllDayItem(todo, currentDate,days, days); 1777 item = insertAllDayItem(todo, currentDate,days, days);
1767 item->show(); 1778 item->show();
1768 1779
1769 } 1780 }
1770 else { 1781 else {
1771 if ( mAllDayMode ) return; 1782 if ( mAllDayMode ) return;
1772 // mAgenda 1783 // mAgenda
1773 globalFlagBlockAgendaItemPaint = 1; 1784 globalFlagBlockAgendaItemPaint = 1;
1774 int endY = timeToY(dt.time()) - 1; 1785 int endY = timeToY(dt.time()) - 1;
1775 int hi = 12/KOPrefs::instance()->mHourSize; 1786 int hi = 12/KOPrefs::instance()->mHourSize;
1776 int startY = endY - 1-hi; 1787 int startY = endY - 1-hi;
1777 item = insertItem(todo,currentDate,days,startY,endY); 1788 item = insertItem(todo,currentDate,days,startY,endY);
1778 item->show(); 1789 item->show();
1779 } 1790 }
1780 qApp->processEvents(); 1791 qApp->processEvents();
1781 globalFlagBlockAgendaItemPaint = 0; 1792 globalFlagBlockAgendaItemPaint = 0;
1782 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1793 Q3PtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1783 KOAgendaItem *itemit; 1794 KOAgendaItem *itemit;
1784 for ( itemit=oldconflictItems.first(); itemit != 0; 1795 for ( itemit=oldconflictItems.first(); itemit != 0;
1785 itemit=oldconflictItems.next() ) { 1796 itemit=oldconflictItems.next() ) {
1786 globalFlagBlockAgendaItemUpdate = 0; 1797 globalFlagBlockAgendaItemUpdate = 0;
1787 itemit->repaintMe(); 1798 itemit->repaintMe();
1788 globalFlagBlockAgendaItemUpdate = 1; 1799 globalFlagBlockAgendaItemUpdate = 1;
1789 itemit->repaint(); 1800 itemit->repaint();
1790 } 1801 }
1791 globalFlagBlockAgendaItemUpdate = 0; 1802 globalFlagBlockAgendaItemUpdate = 0;
1792 item->repaintMe(); 1803 item->repaintMe();
1793 globalFlagBlockAgendaItemUpdate = 1; 1804 globalFlagBlockAgendaItemUpdate = 1;
1794 item->repaint(); 1805 item->repaint();
1795} 1806}
1796/* 1807/*
1797 Insert KOAgendaItem into agenda. 1808 Insert KOAgendaItem into agenda.
1798*/ 1809*/
@@ -1854,33 +1865,33 @@ KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,i
1854} 1865}
1855 1866
1856 1867
1857void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1868void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1858 int YTop,int YBottom) 1869 int YTop,int YBottom)
1859{ 1870{
1860 if (mAllDayMode) { 1871 if (mAllDayMode) {
1861 ; 1872 ;
1862 return; 1873 return;
1863 } 1874 }
1864 1875
1865 int cellX,cellYTop,cellYBottom; 1876 int cellX,cellYTop,cellYBottom;
1866 QString newtext; 1877 QString newtext;
1867 int width = XEnd - XBegin + 1; 1878 int width = XEnd - XBegin + 1;
1868 int count = 0; 1879 int count = 0;
1869 KOAgendaItem *current = 0; 1880 KOAgendaItem *current = 0;
1870 QPtrList<KOAgendaItem> multiItems; 1881 Q3PtrList<KOAgendaItem> multiItems;
1871 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1882 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1872 if (cellX == XBegin) cellYTop = YTop; 1883 if (cellX == XBegin) cellYTop = YTop;
1873 else cellYTop = 0; 1884 else cellYTop = 0;
1874 if (cellX == XEnd) cellYBottom = YBottom; 1885 if (cellX == XEnd) cellYBottom = YBottom;
1875 else cellYBottom = rows() - 1; 1886 else cellYBottom = rows() - 1;
1876 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1887 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1877 newtext.append(event->summary()); 1888 newtext.append(event->summary());
1878 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1889 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1879 current->setText(newtext); 1890 current->setText(newtext);
1880 multiItems.append(current); 1891 multiItems.append(current);
1881 } 1892 }
1882 1893
1883 KOAgendaItem *next = 0; 1894 KOAgendaItem *next = 0;
1884 KOAgendaItem *last = multiItems.last(); 1895 KOAgendaItem *last = multiItems.last();
1885 KOAgendaItem *first = multiItems.first(); 1896 KOAgendaItem *first = multiItems.first();
1886 KOAgendaItem *setFirst,*setLast; 1897 KOAgendaItem *setFirst,*setLast;
@@ -1914,33 +1925,33 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1914void KOAgenda::finishResize ( ) 1925void KOAgenda::finishResize ( )
1915{ 1926{
1916 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1927 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1917 if ( globalFlagBlockAgenda == 0 ) { 1928 if ( globalFlagBlockAgenda == 0 ) {
1918 finishUpdate(); 1929 finishUpdate();
1919 //qDebug("finishUpdate() called "); 1930 //qDebug("finishUpdate() called ");
1920 } 1931 }
1921} 1932}
1922/* 1933/*
1923 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1934 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1924*/ 1935*/
1925void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1936void KOAgenda::resizeEvent ( QResizeEvent *ev )
1926{ 1937{
1927 mSelectionHeight = 0; 1938 mSelectionHeight = 0;
1928 mResizeTimer.start( 150 , true ); 1939 mResizeTimer.start( 150 , true );
1929 computeSizes(); 1940 computeSizes();
1930 QScrollView::resizeEvent( ev ); 1941 Q3ScrollView::resizeEvent( ev );
1931 return; 1942 return;
1932 1943
1933} 1944}
1934void KOAgenda::computeSizes() 1945void KOAgenda::computeSizes()
1935{ 1946{
1936 if ( globalFlagBlockStartup ) 1947 if ( globalFlagBlockStartup )
1937 return; 1948 return;
1938 int frameOffset = frameWidth() * 2 +1; 1949 int frameOffset = frameWidth() * 2 +1;
1939 if (mAllDayMode) { 1950 if (mAllDayMode) {
1940 mGridSpacingX = (width()-frameOffset) / mColumns; 1951 mGridSpacingX = (width()-frameOffset) / mColumns;
1941 mGridSpacingY = height() - 2 * frameWidth() - 1; 1952 mGridSpacingY = height() - 2 * frameWidth() - 1;
1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1953 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1943 // mGridSpacingY = height(); 1954 // mGridSpacingY = height();
1944 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1955 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1945 1956
1946 KOAgendaItem *item; 1957 KOAgendaItem *item;
@@ -2003,33 +2014,33 @@ void KOAgenda::scrollUp()
2003} 2014}
2004 2015
2005 2016
2006void KOAgenda::scrollDown() 2017void KOAgenda::scrollDown()
2007{ 2018{
2008 scrollBy(0,mScrollOffset); 2019 scrollBy(0,mScrollOffset);
2009} 2020}
2010 2021
2011void KOAgenda::popupAlarm() 2022void KOAgenda::popupAlarm()
2012{ 2023{
2013 if (!mClickedItem) { 2024 if (!mClickedItem) {
2014 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 2025 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
2015 return; 2026 return;
2016 } 2027 }
2017 // TODO: deal correctly with multiple alarms 2028 // TODO: deal correctly with multiple alarms
2018 Alarm* alarm; 2029 Alarm* alarm;
2019 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 2030 Q3PtrList<Alarm> list(mClickedItem->incidence()->alarms());
2020 for(alarm=list.first();alarm;alarm=list.next()) { 2031 for(alarm=list.first();alarm;alarm=list.next()) {
2021 alarm->toggleAlarm(); 2032 alarm->toggleAlarm();
2022 } 2033 }
2023 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2034 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2024 mClickedItem->paintMe( true ); 2035 mClickedItem->paintMe( true );
2025 mClickedItem->repaint( false ); 2036 mClickedItem->repaint( false );
2026} 2037}
2027 2038
2028/* 2039/*
2029 Calculates the minimum width 2040 Calculates the minimum width
2030*/ 2041*/
2031int KOAgenda::minimumWidth() const 2042int KOAgenda::minimumWidth() const
2032{ 2043{
2033 // TODO:: develop a way to dynamically determine the minimum width 2044 // TODO:: develop a way to dynamically determine the minimum width
2034 int min = 100; 2045 int min = 100;
2035 2046
@@ -2094,88 +2105,88 @@ void KOAgenda::selectItem(KOAgendaItem *item)
2094{ 2105{
2095 if ((KOAgendaItem *)mSelectedItem == item) return; 2106 if ((KOAgendaItem *)mSelectedItem == item) return;
2096 deselectItem(); 2107 deselectItem();
2097 if (item == 0) { 2108 if (item == 0) {
2098 emit incidenceSelected( 0 ); 2109 emit incidenceSelected( 0 );
2099 return; 2110 return;
2100 } 2111 }
2101 mSelectedItem = item; 2112 mSelectedItem = item;
2102 mSelectedItem->select(); 2113 mSelectedItem->select();
2103 emit incidenceSelected( mSelectedItem->incidence() ); 2114 emit incidenceSelected( mSelectedItem->incidence() );
2104} 2115}
2105 2116
2106// This function seems never be called. 2117// This function seems never be called.
2107void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2118void KOAgenda::keyPressEvent( QKeyEvent *kev )
2108{ 2119{
2109 switch(kev->key()) { 2120 switch(kev->key()) {
2110 case Key_PageDown: 2121 case Qt::Key_PageDown:
2111 verticalScrollBar()->addPage(); 2122 verticalScrollBar()->addPage();
2112 break; 2123 break;
2113 case Key_PageUp: 2124 case Qt::Key_PageUp:
2114 verticalScrollBar()->subtractPage(); 2125 verticalScrollBar()->subtractPage();
2115 break; 2126 break;
2116 case Key_Down: 2127 case Qt::Key_Down:
2117 verticalScrollBar()->addLine(); 2128 verticalScrollBar()->addLine();
2118 break; 2129 break;
2119 case Key_Up: 2130 case Qt::Key_Up:
2120 verticalScrollBar()->subtractLine(); 2131 verticalScrollBar()->subtractLine();
2121 break; 2132 break;
2122 default: 2133 default:
2123 ; 2134 ;
2124 } 2135 }
2125} 2136}
2126 2137
2127void KOAgenda::calculateWorkingHours() 2138void KOAgenda::calculateWorkingHours()
2128{ 2139{
2129// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2140// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2130 mWorkingHoursEnable = !mAllDayMode; 2141 mWorkingHoursEnable = !mAllDayMode;
2131 2142
2132 mWorkingHoursYTop = mGridSpacingY * 2143 mWorkingHoursYTop = mGridSpacingY *
2133 KOPrefs::instance()->mWorkingHoursStart * 4; 2144 KOPrefs::instance()->mWorkingHoursStart * 4;
2134 mWorkingHoursYBottom = mGridSpacingY * 2145 mWorkingHoursYBottom = mGridSpacingY *
2135 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2146 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2136} 2147}
2137 2148
2138 2149
2139DateList KOAgenda::dateList() const 2150DateList KOAgenda::dateList() const
2140{ 2151{
2141 return mSelectedDates; 2152 return mSelectedDates;
2142} 2153}
2143 2154
2144void KOAgenda::setDateList(const DateList &selectedDates) 2155void KOAgenda::setDateList(const DateList &selectedDates)
2145{ 2156{
2146 mSelectedDates = selectedDates; 2157 mSelectedDates = selectedDates;
2147} 2158}
2148 2159
2149void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2160void KOAgenda::setHolidayMask(Q3MemArray<bool> *mask)
2150{ 2161{
2151 mHolidayMask = mask; 2162 mHolidayMask = mask;
2152 2163
2153/* 2164/*
2154 kdDebug() << "HolidayMask: "; 2165 kdDebug() << "HolidayMask: ";
2155 for(uint i=0;i<mask->count();++i) { 2166 for(uint i=0;i<mask->count();++i) {
2156 kdDebug() << (mask->at(i) ? "*" : "o"); 2167 kdDebug() << (mask->at(i) ? "*" : "o");
2157 } 2168 }
2158 kdDebug() << endl; 2169 kdDebug() << endl;
2159*/ 2170*/
2160} 2171}
2161 2172
2162void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2173void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2163{ 2174{
2164 2175
2165 QScrollView::contentsMousePressEvent(event); 2176 Q3ScrollView::contentsMousePressEvent(event);
2166} 2177}
2167 2178
2168void KOAgenda::storePosition() 2179void KOAgenda::storePosition()
2169{ 2180{
2170 //mContentPosition 2181 //mContentPosition
2171 int max = mGridSpacingY*4*24; 2182 int max = mGridSpacingY*4*24;
2172 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2183 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2173 mContentPosition = 0; 2184 mContentPosition = 0;
2174 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2185 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2175 mContentPosition = -1.0; 2186 mContentPosition = -1.0;
2176 else 2187 else
2177 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2188 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2178 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2189 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2179 2190
2180} 2191}
2181void KOAgenda::restorePosition() 2192void KOAgenda::restorePosition()
@@ -2183,68 +2194,68 @@ void KOAgenda::restorePosition()
2183 int posY; 2194 int posY;
2184 int max = mGridSpacingY*4*24; 2195 int max = mGridSpacingY*4*24;
2185 if ( mContentPosition < 0 ) 2196 if ( mContentPosition < 0 )
2186 posY = max-viewport()->height(); 2197 posY = max-viewport()->height();
2187 else 2198 else
2188 if ( mContentPosition == 0 ) 2199 if ( mContentPosition == 0 )
2189 posY = 0; 2200 posY = 0;
2190 else 2201 else
2191 posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); 2202 posY = (int) ((max/mContentPosition)-(viewport()->height()/2));
2192 setContentsPos (0, posY ); 2203 setContentsPos (0, posY );
2193 //qDebug("posY %d hei %d", posY, max); 2204 //qDebug("posY %d hei %d", posY, max);
2194 2205
2195} 2206}
2196void KOAgenda::moveChild( QWidget *w, int x , int y ) 2207void KOAgenda::moveChild( QWidget *w, int x , int y )
2197{ 2208{
2198 ++x; 2209 ++x;
2199 QScrollView::moveChild( w, x , y ); 2210 Q3ScrollView::moveChild( w, x , y );
2200} 2211}
2201#include <qmessagebox.h> 2212#include <qmessagebox.h>
2202#ifdef DESKTOP_VERSION 2213#ifdef DESKTOP_VERSION
2203#include <qprinter.h> 2214#include <qprinter.h>
2204#include <qpainter.h> 2215#include <qpainter.h>
2205#include <qpaintdevicemetrics.h> 2216#include <q3paintdevicemetrics.h>
2206 2217
2207#endif 2218#endif
2208void KOAgenda::printSelection() 2219void KOAgenda::printSelection()
2209{ 2220{
2210#ifdef DESKTOP_VERSION 2221#ifdef DESKTOP_VERSION
2211 if ( mStartCellY == mCurrentCellY ) { 2222 if ( mStartCellY == mCurrentCellY ) {
2212 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2223 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2213 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2224 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2214 i18n("OK"), 0, 0, 2225 i18n("OK"), 0, 0,
2215 0, 1 ); 2226 0, 1 );
2216 return; 2227 return;
2217 } 2228 }
2218 2229
2219 float dx, dy; 2230 float dx, dy;
2220 int x,y,w,h; 2231 int x,y,w,h;
2221 x= 0; 2232 x= 0;
2222 w= contentsWidth()+2; 2233 w= contentsWidth()+2;
2223 // h= contentsHeight(); 2234 // h= contentsHeight();
2224 y = mGridSpacingY*mStartCellY; 2235 y = mGridSpacingY*mStartCellY;
2225 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2236 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2226 2237
2227 //return; 2238 //return;
2228 QPrinter* printer = new QPrinter(); 2239 QPrinter* printer = new QPrinter();
2229 if ( !printer->setup()) { 2240 if ( !printer->setup()) {
2230 delete printer; 2241 delete printer;
2231 return; 2242 return;
2232 } 2243 }
2233 QPainter p( printer ); 2244 QPainter p( printer );
2234 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2245 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( printer );
2235 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2246 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2236 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2247 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2237 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2248 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2238 // p.drawText( 0, 0, date ); 2249 // p.drawText( 0, 0, date );
2239 int offset = m.width()/8; 2250 int offset = m.width()/8;
2240 // compute the scale 2251 // compute the scale
2241 dx = ((float) m.width()-offset) / (float)w; 2252 dx = ((float) m.width()-offset) / (float)w;
2242 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2253 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2243 float scale; 2254 float scale;
2244 // scale to fit the width or height of the paper 2255 // scale to fit the width or height of the paper
2245 if ( dx < dy ) 2256 if ( dx < dy )
2246 scale = dx; 2257 scale = dx;
2247 else 2258 else
2248 scale = dy; 2259 scale = dy;
2249 // set the scale 2260 // set the scale
2250 p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date ); 2261 p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date );