From a08aff328d4393031d5ba7d622c2b05705a89d73 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 04 Jul 2007 11:23:42 +0000 Subject: initial public commit of qt4 port --- (limited to 'korganizer/koagenda.cpp') diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 1d4d6de..fe59787 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -29,12 +29,23 @@ #include #undef protected #endif -#include +#include #include #include -#include +#include #include #include +#include +//Added by qt3to4: +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -63,7 +74,7 @@ extern int globalFlagBlockStartup; //////////////////////////////////////////////////////////////////////////// MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) - : QFrame(_agenda->viewport(),name), agenda(_agenda) + : Q3Frame(_agenda->viewport(),name), agenda(_agenda) { setLineWidth(0); setMargin(0); @@ -169,8 +180,8 @@ void MarcusBains::updateLocation(bool recalculate) Create an agenda widget with rows rows and columns columns. */ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, - const char *name,WFlags f) : - QScrollView(parent,name,f) + const char *name,Qt::WFlags f) : + Q3ScrollView(parent,name,f) { mAllAgendaPopup = 0; @@ -190,8 +201,8 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 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) +KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,Qt::WFlags f) : + Q3ScrollView(parent,name,f) { mAllAgendaPopup = 0; blockResize = false; @@ -231,7 +242,7 @@ void KOAgenda::init() mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); - mNewItemPopup = new QPopupMenu( this ); + mNewItemPopup = new Q3PopupMenu( this ); connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { @@ -240,18 +251,18 @@ void KOAgenda::init() } else pathString += "iconsmini/"; - mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); mNewItemPopup->insertSeparator ( ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"day" ), i18n("Day view"),3 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"week" ), i18n("Next week"),4 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"month" ), i18n("This month"),6 ); + mNewItemPopup->insertItem ( (QIcon)SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); #ifndef _WIN32_ - int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase - viewport()->setWFlags ( wflags); + Qt::WindowFlags wflags = viewport()-> windowFlags() |Qt::WRepaintNoErase;//WResizeNoErase + viewport()->setWindowFlags ( wflags); #endif mGridSpacingX = 80; mResizeBorderWidth = 8; @@ -263,7 +274,7 @@ void KOAgenda::init() // Grab key strokes for keyboard navigation of agenda. Seems to have no // effect. Has to be fixed. - setFocusPolicy(WheelFocus); + setFocusPolicy(Qt::WheelFocus); connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); @@ -395,11 +406,11 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) case (QEvent::Leave): if (!mActionItem) - setCursor(arrowCursor); + setCursor(Qt::arrowCursor); return true; default: - return QScrollView::eventFilter(object,event); + return Q3ScrollView::eventFilter(object,event); } } void KOAgenda::popupMenu() @@ -505,11 +516,11 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) bool objIsNotViewport = (object != viewport()); bool leftButt = false; #ifdef DESKTOP_VERSION - leftButt = (me->button() == LeftButton); + leftButt = (me->button() == Qt::LeftButton); #endif switch (me->type()) { case QEvent::MouseButtonPress: - if (me->button() == LeftButton) { + if (me->button() == Qt::LeftButton) { mPopupTimer->start( 600 ); mLeftMouseDown = true; } @@ -578,10 +589,10 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) if ( objIsNotViewport ) { mPopupItem = (KOAgendaItem *)object; mPopupKind = 1; - if (me->button() == RightButton) { + if (me->button() == Qt::RightButton) { mPopupKind = 3; popupMenu(); - } else if (me->button() == LeftButton) { + } else if (me->button() == Qt::LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { emit signalClearSelection(); @@ -600,7 +611,7 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) mPopupKind = 2; selectItem(0); mActionItem = 0; - if (me->button() == RightButton) { + if (me->button() == Qt::RightButton) { int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; @@ -611,19 +622,19 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) mStartCellY = gy; mPopupKind = 4; popupMenu(); - } else if (me->button() == LeftButton) { - setCursor(arrowCursor); + } else if (me->button() == Qt::LeftButton) { + setCursor(Qt::arrowCursor); startSelectAction(viewportPos); } } break; case QEvent::MouseButtonRelease: - if (me->button() == LeftButton ) { + if (me->button() == Qt::LeftButton ) { mPopupTimer->stop(); } if (object != viewport()) { - if (me->button() == LeftButton && mLeftMouseDown) { + if (me->button() == Qt::LeftButton && mLeftMouseDown) { if (mActionItem) { QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); @@ -633,7 +644,7 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) mActionItem->resetMove(); placeSubCells( mActionItem ); // emit startDragSignal( mActionItem->incidence() ); - setCursor( arrowCursor ); + setCursor( Qt::arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; @@ -645,11 +656,11 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } } else { // ---------- viewport() - if (me->button() == LeftButton && mLeftMouseDown ) { //left click + if (me->button() == Qt::LeftButton && mLeftMouseDown ) { //left click endSelectAction( true ); // emit new event signal } } - if (me->button() == LeftButton) + if (me->button() == Qt::LeftButton) mLeftMouseDown = false; break; @@ -850,15 +861,15 @@ void KOAgenda::startItemAction(QPoint viewportPos) if ( allowResize && gridDistanceX < mResizeBorderWidth && mActionItem->cellX() == mCurrentCellX) { mActionType = RESIZELEFT; - setCursor(sizeHorCursor); + setCursor(Qt::sizeHorCursor); } else if ( allowResize && (mGridSpacingX - gridDistanceX) < mResizeBorderWidth && mActionItem->cellXWidth() == mCurrentCellX) { mActionType = RESIZERIGHT; - setCursor(sizeHorCursor); + setCursor(Qt::sizeHorCursor); } else { mActionType = MOVE; mActionItem->startMove(); - setCursor(sizeAllCursor); + setCursor(Qt::sizeAllCursor); } } else { int gridDistanceY = (y - gy * mGridSpacingY); @@ -866,16 +877,16 @@ void KOAgenda::startItemAction(QPoint viewportPos) mActionItem->cellYTop() == mCurrentCellY && !mActionItem->firstMultiItem()) { mActionType = RESIZETOP; - setCursor(sizeVerCursor); + setCursor(Qt::sizeVerCursor); } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && mActionItem->cellYBottom() == mCurrentCellY && !mActionItem->lastMultiItem()) { mActionType = RESIZEBOTTOM; - setCursor(sizeVerCursor); + setCursor(Qt::sizeVerCursor); } else { mActionType = MOVE; mActionItem->startMove(); - setCursor(sizeAllCursor); + setCursor(Qt::sizeAllCursor); } } } @@ -906,7 +917,7 @@ void KOAgenda::performItemAction(QPoint viewportPos) mActionItem->resetMove(); placeSubCells( mActionItem ); // emit startDragSignal( mActionItem->incidence() ); - setCursor( arrowCursor ); + setCursor( Qt::arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; @@ -915,18 +926,18 @@ void KOAgenda::performItemAction(QPoint viewportPos) } else { switch ( mActionType ) { case MOVE: - setCursor( sizeAllCursor ); + setCursor( Qt::sizeAllCursor ); break; case RESIZETOP: case RESIZEBOTTOM: - setCursor( sizeVerCursor ); + setCursor( Qt::sizeVerCursor ); break; case RESIZELEFT: case RESIZERIGHT: - setCursor( sizeHorCursor ); + setCursor( Qt::sizeHorCursor ); break; default: - setCursor( arrowCursor ); + setCursor( Qt::arrowCursor ); } } @@ -971,7 +982,7 @@ void KOAgenda::performItemAction(QPoint viewportPos) int x,y; gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); //moveChild(mActionItem,childX(mActionItem),y); - QScrollView::moveChild( mActionItem,childX(mActionItem),y ); + Q3ScrollView::moveChild( mActionItem,childX(mActionItem),y ); } } else if (mActionType == RESIZEBOTTOM) { if (mCurrentCellY >= mActionItem->cellYTop()) { @@ -1019,7 +1030,7 @@ void KOAgenda::endItemAction() type = -1; KOAgendaItem *modifiedItem = placeItem; //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); - QPtrList oldconflictItems ;//= placeItem->conflictItems(); + Q3PtrList oldconflictItems ;//= placeItem->conflictItems(); KOAgendaItem *item; if ( placeItem->incidence()->typeID() == todoID ) { @@ -1110,7 +1121,7 @@ void KOAgenda::endItemAction() emit incidenceSelected( mActionItem->incidence() ); mScrollUpTimer.stop(); mScrollDownTimer.stop(); - setCursor( arrowCursor ); + setCursor( Qt::arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; @@ -1136,25 +1147,25 @@ void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) int gridDistanceX = (x - gx * mGridSpacingX); if (gridDistanceX < mResizeBorderWidth && moveItem->cellX() == gx) { - setCursor(sizeHorCursor); + setCursor(Qt::sizeHorCursor); } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && moveItem->cellXWidth() == gx) { - setCursor(sizeHorCursor); + setCursor(Qt::sizeHorCursor); } else { - setCursor(arrowCursor); + setCursor(Qt::arrowCursor); } } else { int gridDistanceY = (y - gy * mGridSpacingY); if (gridDistanceY < mResizeBorderWidth && moveItem->cellYTop() == gy && !moveItem->firstMultiItem()) { - setCursor(sizeVerCursor); + setCursor(Qt::sizeVerCursor); } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && moveItem->cellYBottom() == gy && !moveItem->lastMultiItem()) { - setCursor(sizeVerCursor); + setCursor(Qt::sizeVerCursor); } else { - setCursor(arrowCursor); + setCursor(Qt::arrowCursor); } } } @@ -1173,9 +1184,9 @@ void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) void KOAgenda::placeSubCells(KOAgendaItem *placeItem) { - QPtrList conflictItems; + Q3PtrList conflictItems; int maxSubCells = 0; - QIntDict subCellDict(7); + Q3IntDict subCellDict(7); KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { @@ -1240,7 +1251,7 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) item=conflictItems.next() ) { if ( placeItem != item ) { KOAgendaItem *item2; - QPtrList conflictItems2 = item->conflictItems(); + Q3PtrList conflictItems2 = item->conflictItems(); for ( item2=conflictItems2.first(); item2 != 0; item2=conflictItems2.next() ) { if ( item2->subCells() != maxSubCells) { @@ -1325,9 +1336,9 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) if ( vySel < 0 ) off += vySel; //qDebug("OFF %d %d %d", off,vySel, vy ); - bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); + bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,QPainter::CompositionMode_Source); } else { - bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); + bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,QPainter::CompositionMode_Source); } } if ( mSelectionHeight > 0 ) { @@ -1342,7 +1353,7 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) int p_hei = 5; if ( hei < 5 ) p_hei = hei; hei -= 5; - bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); + bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,QPainter::CompositionMode_Source); offset += 5; } } @@ -1365,7 +1376,7 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) contentsToViewport ( cx, cy, vx,vy); // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) - bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); + bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,QPainter::CompositionMode_Source); if ( mSelectionHeight > 0 ) { //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); @@ -1379,7 +1390,7 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) int p_hei = 5; if ( hei < 5 ) p_hei = hei; hei -= 5; - bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); + bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,QPainter::CompositionMode_Source); offset += 5; } } @@ -1576,14 +1587,14 @@ void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// i int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; if ( lGridSpacingY > 0 ) { while (y < cy + ch) { - p->setPen( SolidLine ); + p->setPen( Qt::SolidLine ); p->drawLine(cx,y,cx+cw,y); y+=lGridSpacingY; - p->setPen( DotLine ); + p->setPen( Qt::DotLine ); p->drawLine(cx,y,cx+cw,y); y+=lGridSpacingY; } - p->setPen( SolidLine ); + p->setPen( Qt::SolidLine ); } mPixPainter.end() ; } @@ -1717,7 +1728,7 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) item->select(false); mUnusedItems.append( item ); mItems.remove( item ); - QPtrList oldconflictItems = item->conflictItems(); + Q3PtrList oldconflictItems = item->conflictItems(); KOAgendaItem *itemit; //globalFlagBlockAgendaItemPaint = 1; for ( itemit=oldconflictItems.first(); itemit != 0; @@ -1747,7 +1758,7 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) return; //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); QDate currentDate = QDate::currentDate(); - bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); + bool overdue = (!todo->isCompleted()) && (todo->dtDue() < (QDateTime)currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); QDateTime dt; if ( todo->hasCompletedDate() ) dt = todo->completed(); @@ -1779,7 +1790,7 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) } qApp->processEvents(); globalFlagBlockAgendaItemPaint = 0; - QPtrList oldconflictItems = item->conflictItems(); + Q3PtrList oldconflictItems = item->conflictItems(); KOAgendaItem *itemit; for ( itemit=oldconflictItems.first(); itemit != 0; itemit=oldconflictItems.next() ) { @@ -1867,7 +1878,7 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, int width = XEnd - XBegin + 1; int count = 0; KOAgendaItem *current = 0; - QPtrList multiItems; + Q3PtrList multiItems; for (cellX = XBegin;cellX <= XEnd;++cellX) { if (cellX == XBegin) cellYTop = YTop; else cellYTop = 0; @@ -1927,7 +1938,7 @@ void KOAgenda::resizeEvent ( QResizeEvent *ev ) mSelectionHeight = 0; mResizeTimer.start( 150 , true ); computeSizes(); - QScrollView::resizeEvent( ev ); + Q3ScrollView::resizeEvent( ev ); return; } @@ -2016,7 +2027,7 @@ void KOAgenda::popupAlarm() } // TODO: deal correctly with multiple alarms Alarm* alarm; - QPtrList list(mClickedItem->incidence()->alarms()); + Q3PtrList list(mClickedItem->incidence()->alarms()); for(alarm=list.first();alarm;alarm=list.next()) { alarm->toggleAlarm(); } @@ -2107,16 +2118,16 @@ void KOAgenda::selectItem(KOAgendaItem *item) void KOAgenda::keyPressEvent( QKeyEvent *kev ) { switch(kev->key()) { - case Key_PageDown: + case Qt::Key_PageDown: verticalScrollBar()->addPage(); break; - case Key_PageUp: + case Qt::Key_PageUp: verticalScrollBar()->subtractPage(); break; - case Key_Down: + case Qt::Key_Down: verticalScrollBar()->addLine(); break; - case Key_Up: + case Qt::Key_Up: verticalScrollBar()->subtractLine(); break; default: @@ -2146,7 +2157,7 @@ void KOAgenda::setDateList(const DateList &selectedDates) mSelectedDates = selectedDates; } -void KOAgenda::setHolidayMask(QMemArray *mask) +void KOAgenda::setHolidayMask(Q3MemArray *mask) { mHolidayMask = mask; @@ -2162,7 +2173,7 @@ void KOAgenda::setHolidayMask(QMemArray *mask) void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) { - QScrollView::contentsMousePressEvent(event); + Q3ScrollView::contentsMousePressEvent(event); } void KOAgenda::storePosition() @@ -2196,13 +2207,13 @@ void KOAgenda::restorePosition() void KOAgenda::moveChild( QWidget *w, int x , int y ) { ++x; - QScrollView::moveChild( w, x , y ); + Q3ScrollView::moveChild( w, x , y ); } #include #ifdef DESKTOP_VERSION #include #include -#include +#include #endif void KOAgenda::printSelection() @@ -2231,7 +2242,7 @@ void KOAgenda::printSelection() return; } QPainter p( printer ); - QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); + Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( printer ); QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); -- cgit v0.9.0.2