-rw-r--r-- | korganizer/koagenda.cpp | 30 | ||||
-rw-r--r-- | korganizer/koagenda.h | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 5 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 31 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 5 |
5 files changed, 65 insertions, 10 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0280c74..c339b57 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -59,8 +59,9 @@ extern int globalFlagBlockAgenda; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockStartup; +bool KOAgenda::mInvalidPixmap = false; //////////////////////////////////////////////////////////////////////////// MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) : QFrame(_agenda->viewport(),name), agenda(_agenda) { @@ -177,8 +178,9 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); + connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); } /* Create an agenda widget with columns columns and one row. This is used for @@ -316,10 +318,26 @@ void KOAgenda::init() addChild(mMarcusBains); } mPopupKind = 0; mPopupItem = 0; + mInvalidPixmap = false; + } +void KOAgenda::shrinkPixmap() +{ + mPaintPixmap.resize( 20,20); + mInvalidPixmap = true; +} +void KOAgenda::slotContentMove(int,int) +{ + if ( mActionType == NOP ) + slotClearSelection(); + if ( mSelectedItem && !mActionItem ) { + deselectItem(); + emit incidenceSelected( 0 ); + } +} void KOAgenda::clear() { KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { @@ -921,8 +939,9 @@ void KOAgenda::performItemAction(QPoint viewportPos) int x,y; gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); moveItem->resize(mGridSpacingX * moveItem->cellWidth(), mGridSpacingY * moveItem->cellHeight()); + moveItem->raise(); moveChild(moveItem,x,y); moveItem = moveItem->nextMultiItem(); } } else if (mActionType == RESIZETOP) { @@ -1243,8 +1262,15 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) { if ( globalFlagBlockAgenda ) return; + + if ( mInvalidPixmap ) { + mInvalidPixmap = false; + qDebug("InvalidPixmap "); + QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); + return; + } if ( ! mAllDayMode ) { // currently not working for //qDebug("KOAgenda::drawContents "); @@ -1915,15 +1941,15 @@ void KOAgenda::computeSizes() int ch = contentsHeight(); if ( mAllDayMode ) { QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { - //qDebug("paintPixAll->resize "); + qDebug("paintPixAll->resize "); paintPixAll->resize( cw, ch ); } } else { QPixmap* paintPix = KOAgendaItem::paintPix(); if ( paintPix->width() < cw || paintPix->height() < ch ) { - //qDebug("paintPix->resize "); + qDebug("paintPix->resize "); paintPix->resize( cw , ch ); } } diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index de6acac..5d813b2 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -74,8 +74,9 @@ class KOAgenda : public QScrollView const char * name=0, WFlags f=0 ); KOAgenda ( int columns, QWidget * parent=0, const char * name=0, WFlags f=0 ); virtual ~KOAgenda(); + static bool mInvalidPixmap; Incidence *selectedIncidence() const; QDate selectedIncidenceDate() const; @@ -124,10 +125,12 @@ class KOAgenda : public QScrollView void printSelection(); void storePosition(); void restorePosition(); void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } + void shrinkPixmap(); public slots: + void slotContentMove(int,int); void categoryChanged(Incidence * inc); void slotClearSelection(); void popupMenu(); void newItem( int ); @@ -169,8 +172,9 @@ class KOAgenda : public QScrollView void startDragSignal(Incidence *); void addToCalSignal(Incidence *, Incidence *); void resizedSignal(); + void updateViewSignal(); protected: KOEventPopupMenu * mAllAgendaPopup; QPainter mPixPainter; diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 8675ff6..303a92a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -495,20 +495,17 @@ QPixmap * KOAgendaItem::paintPixAllday() void KOAgendaItem::repaintItem() { globalFlagBlockAgendaItemPaint = 0; globalFlagBlockAgenda = 0; - //qDebug("AAA "); repaint( false ); - //qDebug("BBB "); } void KOAgendaItem::paintEvent ( QPaintEvent *e ) { - qDebug("CCC "); + if ( globalFlagBlockAgendaItemPaint ) return; if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) return; - qDebug("DDD "); int yy; if ( mAllDay ) yy = y(); else diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f811fba..488d9d4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -75,9 +75,9 @@ extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockLabel; using namespace KOrg; - +#define IDLETIMEOUT 3 TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { @@ -572,11 +572,34 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); - + connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); + connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); + + mIdleTimer = new QTimer ( this );; + connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); +} +void KOAgendaView::slotIdleTimeout() +{ + qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); + int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); + mIdleTimer->stop(); + bool isActice = topLevelWidget()->isActiveWindow(); + qDebug("KO: Active Window %d ", isActice); + // we do nothing if we wake up from a suspend + if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) { + qDebug("KO: Wakeup from suspend "); + mIdleTimer->start( IDLETIMEOUT * 1000 ); + return; } + qDebug("KO: Downsizing Pixmaps "); + mAgenda->shrinkPixmap(); + mAllDayAgenda->shrinkPixmap(); + KOAgendaItem::paintPix()->resize( 20,20); + KOAgendaItem::paintPixAllday()->resize( 20,20); +} void KOAgendaView::toggleAllDay() { if ( mSplitterAgenda->firstHandle() ) mSplitterAgenda->firstHandle()->toggle(); @@ -1297,8 +1320,10 @@ void KOAgendaView::fillAgenda() globalFlagBlockAgenda = 0; mAllDayAgenda->drawContentsToPainter(); mAgenda->drawContentsToPainter(); repaintAgenda(); + mIdleTimer->start ( IDLETIMEOUT *1000 ); + mIdleStart = QDateTime::currentDateTime(); onlyOne = false; } void KOAgendaView::repaintAgenda() { @@ -1340,9 +1365,9 @@ void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, void KOAgendaView::slotShowDateView( int mode , int d ) { if ( d >= mSelectedDates.count() ) { - qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); + qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); } else { QDate day = mSelectedDates[d]; emit showDateView(mode , day ); diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index a1cf308..effd7a3 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -209,8 +209,9 @@ class KOAgendaView : public KOEventView { void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); void slotShowDateView( int, int ); + void fillAgenda(); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); @@ -227,9 +228,8 @@ class KOAgendaView : public KOEventView { /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ - void fillAgenda(); /** Create labels for the selected dates. */ void createDayLabels(); @@ -238,8 +238,9 @@ class KOAgendaView : public KOEventView { */ void setHolidayMasks(); protected slots: + void slotIdleTimeout(); void categoryChanged( Incidence * ); void slotDaylabelClicked( int ); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); @@ -253,8 +254,10 @@ class KOAgendaView : public KOEventView { /** Updates data for selected timespan for all day event*/ void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); private: + QTimer* mIdleTimer; + QDateTime mIdleStart; // view widgets QFrame *mDayLabels; QHBox *mDayLabelsFrame; QBoxLayout *mLayoutDayLabels; |