-rw-r--r-- | korganizer/koagendaview.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f811fba..488d9d4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -67,25 +67,25 @@ | |||
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; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | #define IDLETIMEOUT 3 | |
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::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); |
@@ -564,27 +564,50 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
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()) ); | ||
577 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | ||
576 | 578 | ||
579 | mIdleTimer = new QTimer ( this );; | ||
580 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | ||
581 | } | ||
582 | void KOAgendaView::slotIdleTimeout() | ||
583 | { | ||
584 | qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | ||
585 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | ||
586 | mIdleTimer->stop(); | ||
587 | bool isActice = topLevelWidget()->isActiveWindow(); | ||
588 | qDebug("KO: Active Window %d ", isActice); | ||
589 | // we do nothing if we wake up from a suspend | ||
590 | if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) { | ||
591 | qDebug("KO: Wakeup from suspend "); | ||
592 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | ||
593 | return; | ||
594 | } | ||
595 | qDebug("KO: Downsizing Pixmaps "); | ||
596 | mAgenda->shrinkPixmap(); | ||
597 | mAllDayAgenda->shrinkPixmap(); | ||
598 | KOAgendaItem::paintPix()->resize( 20,20); | ||
599 | KOAgendaItem::paintPixAllday()->resize( 20,20); | ||
600 | |||
577 | } | 601 | } |
578 | |||
579 | void KOAgendaView::toggleAllDay() | 602 | void KOAgendaView::toggleAllDay() |
580 | { | 603 | { |
581 | if ( mSplitterAgenda->firstHandle() ) | 604 | if ( mSplitterAgenda->firstHandle() ) |
582 | mSplitterAgenda->firstHandle()->toggle(); | 605 | mSplitterAgenda->firstHandle()->toggle(); |
583 | } | 606 | } |
584 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 607 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
585 | { | 608 | { |
586 | calendar()->addIncidence( inc ); | 609 | calendar()->addIncidence( inc ); |
587 | 610 | ||
588 | if ( incOld ) { | 611 | if ( incOld ) { |
589 | if ( incOld->typeID() == todoID ) | 612 | if ( incOld->typeID() == todoID ) |
590 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 613 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
@@ -1289,24 +1312,26 @@ void KOAgendaView::fillAgenda() | |||
1289 | 1312 | ||
1290 | if ( globalFlagBlockAgenda == 2 ) { | 1313 | if ( globalFlagBlockAgenda == 2 ) { |
1291 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1314 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1292 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1315 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1293 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1316 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1294 | setStartHour( QTime::currentTime ().hour() ); | 1317 | setStartHour( QTime::currentTime ().hour() ); |
1295 | } | 1318 | } |
1296 | qApp->processEvents(); | 1319 | qApp->processEvents(); |
1297 | globalFlagBlockAgenda = 0; | 1320 | globalFlagBlockAgenda = 0; |
1298 | mAllDayAgenda->drawContentsToPainter(); | 1321 | mAllDayAgenda->drawContentsToPainter(); |
1299 | mAgenda->drawContentsToPainter(); | 1322 | mAgenda->drawContentsToPainter(); |
1300 | repaintAgenda(); | 1323 | repaintAgenda(); |
1324 | mIdleTimer->start ( IDLETIMEOUT *1000 ); | ||
1325 | mIdleStart = QDateTime::currentDateTime(); | ||
1301 | onlyOne = false; | 1326 | onlyOne = false; |
1302 | } | 1327 | } |
1303 | void KOAgendaView::repaintAgenda() | 1328 | void KOAgendaView::repaintAgenda() |
1304 | { | 1329 | { |
1305 | mAgenda->viewport()->repaint( false ); | 1330 | mAgenda->viewport()->repaint( false ); |
1306 | mAllDayAgenda->viewport()->repaint( false ); | 1331 | mAllDayAgenda->viewport()->repaint( false ); |
1307 | mAgenda->finishUpdate(); | 1332 | mAgenda->finishUpdate(); |
1308 | mAllDayAgenda->finishUpdate(); | 1333 | mAllDayAgenda->finishUpdate(); |
1309 | } | 1334 | } |
1310 | 1335 | ||
1311 | 1336 | ||
1312 | void KOAgendaView::clearView() | 1337 | void KOAgendaView::clearView() |
@@ -1332,25 +1357,25 @@ void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | |||
1332 | #endif | 1357 | #endif |
1333 | } | 1358 | } |
1334 | 1359 | ||
1335 | // void KOAgendaView::updateMovedTodo() | 1360 | // void KOAgendaView::updateMovedTodo() |
1336 | // { | 1361 | // { |
1337 | // // updateConfig(); | 1362 | // // updateConfig(); |
1338 | // // emit updateTodoViews(); | 1363 | // // emit updateTodoViews(); |
1339 | // } | 1364 | // } |
1340 | 1365 | ||
1341 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1366 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1342 | { | 1367 | { |
1343 | if ( d >= mSelectedDates.count() ) { | 1368 | if ( d >= mSelectedDates.count() ) { |
1344 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1369 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); |
1345 | 1370 | ||
1346 | } else { | 1371 | } else { |
1347 | QDate day = mSelectedDates[d]; | 1372 | QDate day = mSelectedDates[d]; |
1348 | emit showDateView(mode , day ); | 1373 | emit showDateView(mode , day ); |
1349 | } | 1374 | } |
1350 | 1375 | ||
1351 | } | 1376 | } |
1352 | void KOAgendaView::newEvent(int gx, int gy) | 1377 | void KOAgendaView::newEvent(int gx, int gy) |
1353 | { | 1378 | { |
1354 | if (!mSelectedDates.count()) return; | 1379 | if (!mSelectedDates.count()) return; |
1355 | 1380 | ||
1356 | QDate day = mSelectedDates[gx]; | 1381 | QDate day = mSelectedDates[gx]; |