summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -15,97 +15,97 @@
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)
@@ -285,96 +285,97 @@ void KOAgenda::init()
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 )
@@ -393,96 +394,105 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
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
@@ -1222,153 +1232,160 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
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);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 5d813b2..0e3aed8 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -30,97 +30,97 @@
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();
@@ -129,96 +129,97 @@ class KOAgenda : public QScrollView
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();
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 488d9d4..1b21a71 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -31,97 +31,97 @@
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";
@@ -530,111 +530,120 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
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 )
@@ -1276,98 +1285,97 @@ void KOAgendaView::fillAgenda()
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 );
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index effd7a3..4b7ef5b 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -166,96 +166,97 @@ class KOAgendaView : public KOEventView {
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;