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
@@ -39,49 +39,49 @@
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{
@@ -309,48 +309,49 @@ void KOAgenda::init()
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;
@@ -417,48 +418,57 @@ void KOAgenda::popupMenu()
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 ");
@@ -1246,105 +1256,112 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
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);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 5d813b2..0e3aed8 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -54,49 +54,49 @@ class MarcusBains : public QFrame {
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
@@ -153,48 +153,49 @@ class KOAgenda : public QScrollView
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
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 488d9d4..1b21a71 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -55,49 +55,49 @@
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;
@@ -554,63 +554,72 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
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 }
@@ -1300,50 +1309,49 @@ void KOAgendaView::fillAgenda()
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,
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index effd7a3..4b7ef5b 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -190,48 +190,49 @@ class KOAgendaView : public KOEventView {
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.