-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 @@ -51,24 +51,25 @@ #include <libkcal/todo.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif //extern bool globalFlagBlockPainting; 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) { setLineWidth(0); setMargin(0); setBackgroundColor(Qt::red); minutes = new QTimer(this); connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); minutes->start(0, true); mTimeBox = new QLabel(this); mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); @@ -169,24 +170,25 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, { mAllAgendaPopup = 0; mColumns = columns; mRows = rows; mGridSpacingY = rowSize; mAllDayMode = false; #ifndef DESKTOP_VERSION //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 all-day events. */ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { mAllAgendaPopup = 0; blockResize = false; mColumns = columns; @@ -308,26 +310,42 @@ void KOAgenda::init() connect(verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(checkScrollBoundaries(int))); // Create the Marcus Bains line. if(mAllDayMode) mMarcusBains = 0; else { mMarcusBains = new MarcusBains(this); 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() ) { mUnusedItems.append( item ); //item->hide(); } mItems.clear(); mSelectedItem = 0; clearSelection(); } @@ -913,24 +931,25 @@ void KOAgenda::performItemAction(QPoint viewportPos) KOAgendaItem *moveItem = mActionItem->firstMultiItem(); bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); if (!moveItem) moveItem = mActionItem; while (moveItem) { int dy; if (isMultiItem) dy = 0; else dy = gy - mCurrentCellY; moveItem->moveRelative(gx - mCurrentCellX,dy); 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) { if (mCurrentCellY <= mActionItem->cellYBottom()) { mActionItem->expandTop(gy - mCurrentCellY); mActionItem->resize(mActionItem->width(), mGridSpacingY * mActionItem->cellHeight()); int x,y; gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); //moveChild(mActionItem,childX(mActionItem),y); QScrollView::moveChild( mActionItem,childX(mActionItem),y ); @@ -1235,24 +1254,31 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) // for ( item=conflictItems.first(); item != 0; // item=conflictItems.next() ) { // //item->updateItem(); // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); // } // placeItem->updateItem(); } 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 "); if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) ;//drawContentsToPainter(); QPaintDevice* pd = p->device(); p->end(); int vx, vy; int selectionX = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - mSelectionCellX) * mGridSpacingX : @@ -1907,31 +1933,31 @@ void KOAgenda::computeSizes() item->resize(subCellWidth,item->height()); moveChild(item,(KOGlobals::self()->reverseLayout() ? (mColumns - 1 - item->cellX()) * mGridSpacingX : item->cellX() * mGridSpacingX) + item->subCell() * subCellWidth,childY(item)); } } int cw = contentsWidth(); 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 ); } } checkScrollBoundaries(); marcus_bains(); drawContentsToPainter(); viewport()->repaint(false); } void KOAgenda::scrollUp() { diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index de6acac..5d813b2 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -66,24 +66,25 @@ class MarcusBains : public QFrame { class KOAgenda : public QScrollView { Q_OBJECT public: enum MouseActionType { NOP, MOVE, SELECT, RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 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; virtual bool eventFilter ( QObject *, QEvent * ); void contentsToGrid (int x, int y, int& gx, int& gy); void gridToContents (int gx, int gy, int& x, int& y); int timeToY (const QTime &time); QTime gyToTime (int y); @@ -116,26 +117,28 @@ class KOAgenda : public QScrollView void checkScrollBoundaries(); void setHolidayMask(QMemArray<bool> *); void setDateList(const DateList &selectedDates); DateList dateList() const; void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); void finishUpdate(); 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 ); void moveChild( QWidget *, int, int ); void scrollUp(); void scrollDown(); void updateTodo( Todo * t, int , bool ); void popupAlarm(); void checkScrollBoundaries(int); @@ -161,24 +164,25 @@ class KOAgenda : public QScrollView void deleteIncidenceSignal(Incidence *); void showIncidencePopupSignal(Incidence *); void itemModified(KOAgendaItem *item, int ); void incidenceSelected(Incidence *); void lowerYChanged(int); void upperYChanged(int); void startDragSignal(Incidence *); void addToCalSignal(Incidence *, Incidence *); void resizedSignal(); + void updateViewSignal(); protected: KOEventPopupMenu * mAllAgendaPopup; QPainter mPixPainter; QPixmap mPaintPixmap; QPixmap mHighlightPixmap; void drawContents(QPainter *p,int cx, int cy, int cw, int ch); virtual void resizeEvent ( QResizeEvent * ); /** Handles mouse events. Called from eventFilter */ virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 8675ff6..303a92a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -487,36 +487,33 @@ QPixmap * KOAgendaItem::paintPixAllday() if ( ! mPaintPixA ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height()/5; mPaintPixA = new QPixmap(w,h); } return mPaintPixA ; } 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 yy = mCellYTop * ( height() / cellHeight() ); int xx = x(); if ( xPaintCoord != xx || yPaintCoord != yy || wPaintCoord != width() || hPaintCoord != height()) { xPaintCoord= xx; yPaintCoord = yy; wPaintCoord = width(); 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 @@ #include "koagendaview.h" //#include "koagendaview.moc" //extern bool globalFlagBlockPainting; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; 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) { myPix.resize( 1, 1 ); mRows = rows; mRedrawNeeded = true; setMinimumHeight( 20 ); mCellHeight = KOPrefs::instance()->mHourSize*4; enableClipper(true); @@ -564,27 +564,50 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAgenda, SIGNAL( resizedSignal() ), SLOT( updateConfig( ) ) ); connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), SLOT( addToCalSlot(Incidence * , Incidence *) ) ); // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); //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(); } void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) { calendar()->addIncidence( inc ); if ( incOld ) { if ( incOld->typeID() == todoID ) emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); @@ -1289,24 +1312,26 @@ void KOAgendaView::fillAgenda() if ( globalFlagBlockAgenda == 2 ) { if ( KOPrefs::instance()->mSetTimeToDayStartAt ) setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) setStartHour( QTime::currentTime ().hour() ); } qApp->processEvents(); globalFlagBlockAgenda = 0; mAllDayAgenda->drawContentsToPainter(); mAgenda->drawContentsToPainter(); repaintAgenda(); + mIdleTimer->start ( IDLETIMEOUT *1000 ); + mIdleStart = QDateTime::currentDateTime(); onlyOne = false; } void KOAgendaView::repaintAgenda() { mAgenda->viewport()->repaint( false ); mAllDayAgenda->viewport()->repaint( false ); mAgenda->finishUpdate(); mAllDayAgenda->finishUpdate(); } void KOAgendaView::clearView() @@ -1332,25 +1357,25 @@ void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, #endif } // void KOAgendaView::updateMovedTodo() // { // // updateConfig(); // // emit updateTodoViews(); // } 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 ); } } void KOAgendaView::newEvent(int gx, int gy) { if (!mSelectedDates.count()) return; QDate day = mSelectedDates[gx]; diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index a1cf308..effd7a3 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -201,68 +201,71 @@ class KOAgendaView : public KOEventView { void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); void slotShowDateView( int, int ); + void fillAgenda(); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void selectWeekNum( int ); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: KOAgendaButton* getNewDaylabel(); bool mBlockUpdating; int mUpcomingWidth; /** 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(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ 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); //void updateMovedTodo(); void updateEventIndicatorTop(int newY); void updateEventIndicatorBottom(int newY); /** Updates data for selected timespan */ void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); /** 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; QFrame *mAllDayFrame; KOAgenda *mAllDayAgenda; KOAgenda *mAgenda; TimeLabels *mTimeLabels; QWidget *mDummyAllDayLeft; KDGanttMinimizeSplitter* mSplitterAgenda; QPushButton *mExpandButton; |