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/calprintbase.cpp') diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index 7b7d54c..ecb9e03 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp @@ -25,11 +25,13 @@ #include #include -#include +#include #include -#include -#include +#include +#include #include +//Added by qt3to4: +#include #include #include @@ -145,8 +147,8 @@ CalPrintBase::~CalPrintBase() QWidget *CalPrintBase::configWidget( QWidget *w ) { - QFrame *wdg = new QFrame( w ); - QVBoxLayout *layout = new QVBoxLayout( wdg ); + Q3Frame *wdg = new Q3Frame( w ); + Q3VBoxLayout *layout = new Q3VBoxLayout( wdg ); QLabel *title = new QLabel( description(), wdg ); QFont titleFont( title->font() ); @@ -285,7 +287,7 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, p.setFont(QFont("helvetica", 7, QFont::Bold)); // int lineSpacing = p.fontMetrics().lineSpacing(); const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); - p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) ); + p.drawText(x, y, width, height/4, Qt::AlignCenter, calSys->monthName( qd ) ); int cellWidth = width/7; int cellHeight = height/8; @@ -301,7 +303,7 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek())); tmpStr=calSys->weekDayName( monthDate2 )[0].upper(); p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight, - AlignCenter, tmpStr); + Qt::AlignCenter, tmpStr); monthDate2 = monthDate2.addDays(1); } @@ -318,7 +320,7 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, } p.drawText( x+col*cellWidth, y+height/4+cellHeight+(row*cellHeight), - cellWidth, cellHeight, AlignCenter, + cellWidth, cellHeight, Qt::AlignCenter, tmpStr.setNum(monthDate.day()) ); monthDate = monthDate.addDays(1); } @@ -358,7 +360,7 @@ void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd, // p.fillRect( x+1, y+1, // width-2, height-2, // QBrush( Dense7Pattern ) ); - p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter, + p.drawText( x+5, y, width-10, height, Qt::AlignCenter | Qt::AlignVCenter, calSys->weekDayName( qd ) ); } @@ -401,16 +403,16 @@ void CalPrintBase::drawTimeLine(QPainter &p, p.setFont(QFont("helvetica", 12, QFont::Bold)); } p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight, - AlignTop|AlignRight, numStr); + Qt::AlignTop|Qt::AlignRight, numStr); p.setFont(QFont("helvetica", 10, QFont::Normal)); p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3, - AlignTop | AlignLeft, "00"); + Qt::AlignTop | Qt::AlignLeft, "00"); } else { QTime time( curTime.hour(), 0 ); numStr = KGlobal::locale()->formatTime( time ); p.setFont(QFont("helvetica", 14, QFont::Bold)); p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3, - AlignTop|AlignLeft, numStr); + Qt::AlignTop|Qt::AlignLeft, numStr); } currY+=cellHeight; } // enough space for half-hour line and time @@ -472,7 +474,7 @@ void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, p.drawRect( x, offset, width, height ); p.drawText( x+5, offset+5, width-10, height-10, - AlignCenter | AlignVCenter | AlignJustify | WordBreak, + Qt::AlignCenter | Qt::AlignVCenter | Qt::AlignJustify | Qt::WordBreak, text ); // reset the colors p.setBrush( oldBrush ); @@ -493,7 +495,7 @@ void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, if (!multiDayStr.isEmpty()) { // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) ); p.drawText( x+5, offset+5, width-10, height-10, - AlignLeft | AlignTop | AlignJustify , + Qt::AlignLeft | Qt::AlignTop | Qt::AlignJustify , multiDayStr); } } else { @@ -560,7 +562,7 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, // Calculate horizontal positions and widths of events taking into account // overlapping events - QPtrList cells; + Q3PtrList cells; cells.setAutoDelete( true ); Event::List::ConstIterator itEvents; @@ -568,7 +570,7 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, cells.append( new PrintCellItem( *itEvents, qd ) ); } - QPtrListIterator it1( cells ); + Q3PtrListIterator it1( cells ); for( it1.toFirst(); it1.current(); ++it1 ) { KOrg::CellItem *placeItem = it1.current(); @@ -593,7 +595,7 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, p.setBackgroundColor( oldBgColor ); } - p.setBrush( QBrush( NoBrush ) ); + p.setBrush( QBrush( Qt::NoBrush ) ); } @@ -635,7 +637,7 @@ void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, p.setPen( pe ); p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, - AlignLeft | AlignTop | AlignJustify | WordBreak, + Qt::AlignLeft | Qt::AlignTop | Qt::AlignJustify | Qt::TextWordWrap, text); // p.restore(); } @@ -670,7 +672,7 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, if (!hstring.isEmpty()) { p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); - p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, + p.drawText( x+5, y, width-25, mSubHeaderHeight, Qt::AlignLeft | Qt::AlignVCenter, hstring ); } p.setFont(QFont("helvetica", 10, QFont::Bold)); @@ -680,7 +682,7 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, if ( fm.width( dayNumStr ) > width -10 ) dayNumStr = local->formatDate(qd, true); } - p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, + p.drawText(x+5, y, width-10, mSubHeaderHeight, Qt::AlignRight | Qt::AlignVCenter, dayNumStr); Event::List eventList; eventList.fill( mCalendar->events( qd, true )); @@ -724,7 +726,7 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, } // doesFloat p.drawText(x+5, y+textY, width-10, lineSpacing, - AlignLeft|AlignBottom, outStr); + Qt::AlignLeft|Qt::AlignBottom, outStr); textY+=lineSpacing; } @@ -743,7 +745,7 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, text += i18n("To-Do: %1").arg(todo->summary()); p.drawText(x+5, y+textY, width-10, lineSpacing, - AlignLeft|AlignBottom, text); + Qt::AlignLeft|Qt::AlignBottom, text); textY+=lineSpacing; } } @@ -849,7 +851,7 @@ void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, for (int row = 0; row startPoints; + static Q3PtrList startPoints; if (level<1) { startPoints.clear(); } @@ -910,12 +912,12 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; } int left = possummary+(level*10); - rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); + rect = p.boundingRect(left, y, (posdue-left-5),-1, Qt::WordBreak, outStr); //qDebug("bottom1 %d ", rect.bottom() ); if ( !item->description().isEmpty() && desc ) { outStr = item->description(); rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, - WordBreak, outStr ); + Qt::WordBreak, outStr ); } //qDebug("bottom2 %d y+h %d y %d ph %d", rect.bottom(), y+height, y , pageHeight ); // if too big make new page @@ -933,8 +935,7 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & start = rct->mRect.bottom() + 1; else start = p.viewport().top(); - p.moveTo( center, start ); - p.lineTo( center, to ); + p.drawLine( center, start, center, to ); rct->mSamePage=false; } } @@ -951,12 +952,12 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & // Priority outStr.setNum(priority); - rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr); + rect = p.boundingRect(pospriority, y + 10, 5, -1, Qt::AlignCenter, outStr); // Make it a more reasonable size rect.setWidth(19); rect.setHeight(19); if ( priority > 0 && pospriority>=0 ) { - p.drawText(rect, AlignCenter, outStr); + p.drawText(rect, Qt::AlignCenter, outStr); p.drawRect(rect); // cross out the rectangle for completed items if ( item->isCompleted() ) { @@ -964,7 +965,7 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & p.drawLine( rect.topRight(), rect.bottomLeft() ); } else if (item->cancelled() ) { QPen pen = p.pen(); - p.setPen ( QPen ( black, 2) ); + p.setPen ( QPen ( Qt::black, 2) ); p.drawLine( rect.left()+2,rect.top()+rect.height()/2, rect.right()-2, +rect.top()+rect.height()/2 ); p.setPen( pen ); } @@ -981,9 +982,8 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & bottom = 0; int to( rect.top() + (rect.height()/2)+1 ); int endx( rect.left() ); - p.moveTo(center, bottom); - p.lineTo(center, to); - p.lineTo(endx, to); + p.drawLine(center,bottom, center,to); + p.drawLine(center,to, endx,to); } // if completed, use strike out font @@ -999,9 +999,9 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & outStr += " [" +item->dtDueStr(true)+"]"; } rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), - -1, WordBreak, outStr); + -1, Qt::WordBreak, outStr); QRect newrect; - p.drawText( rect, WordBreak, outStr, -1, &newrect ); + p.drawText( rect, Qt::WordBreak, outStr, -1, &newrect ); //ft.setStrikeOut(false); // p.setFont(ft); @@ -1016,8 +1016,8 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & y=newrect.bottom() + 5; outStr = item->description(); rect = p.boundingRect( left+20, y, x+width-(left+10), -1, - WordBreak, outStr ); - p.drawText( rect, WordBreak, outStr, -1, &newrect ); + Qt::WordBreak, outStr ); + p.drawText( rect, Qt::WordBreak, outStr, -1, &newrect ); } // Set the new line position @@ -1138,8 +1138,8 @@ void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, mSubHeaderHeight+= mSubHeaderHeight; KLocale *local = KGlobal::locale(); QFont font("helvetica", 18, QFont::Bold); - QPen penA( black,0); - QPen penB( black,3); + QPen penA( Qt::black,0); + QPen penB( Qt::black,3); p.setFont(font); int lineSpacing = p.fontMetrics().lineSpacing(); QString title; @@ -1161,7 +1161,7 @@ void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, QFontInfo info(p.font()); lineSpacing = p.fontMetrics().lineSpacing(); - p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title ); + p.drawText(0, lineSpacing * 0, width, lineSpacing, Qt::AlignRight |Qt::AlignTop, title ); title.truncate(0); @@ -1171,7 +1171,7 @@ void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE)); title += QString::number(fd.year()); - p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title ); + p.drawText(0, lineSpacing * 1, width, lineSpacing, Qt::AlignRight |Qt::AlignTop, title ); mSubHeaderHeight = tempStore ; } @@ -1197,7 +1197,7 @@ void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, p.setPen( Qt::black); p.setFont(QFont("helvetica", 12, QFont::Bold, true)); p.drawText(offsetLeft, mHeaderHeight + 5, - width, mSubHeaderHeight, AlignHCenter | AlignVCenter, + width, mSubHeaderHeight, Qt::AlignHCenter | Qt::AlignVCenter, dayName); p.setPen( QPen(Qt::black,2)); @@ -1254,10 +1254,10 @@ void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight, width-4, cheight); p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24, - cheight-10, AlignHCenter | AlignTop, text); + cheight-10, Qt::AlignHCenter | Qt::AlignTop, text); } } - p.setBrush(QBrush(NoBrush)); + p.setBrush(QBrush(Qt::NoBrush)); mSubHeaderHeight = tempStore ; } @@ -1274,12 +1274,12 @@ void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, QString numStr; for (int i = 0; i < hours; i++) { - p.setPen(QPen(black,1)); + p.setPen(QPen(Qt::black,1)); p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight); - p.setPen(QPen(gray,0)); + p.setPen(QPen(Qt::gray,0)); p.drawLine(37, offset+i*cellHeight+(cellHeight/2), width, offset+i*cellHeight+(cellHeight/2)); - p.setPen(QPen(black,0)); + p.setPen(QPen(Qt::black,0)); if ( !KGlobal::locale()->use12Clock() ) { numStr.setNum(i+startHour); @@ -1289,16 +1289,16 @@ void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, p.setFont(QFont("helvetica", 14, QFont::Bold)); } p.drawText(0, offset+i*cellHeight, 33, cellHeight/2, - AlignTop|AlignRight, numStr); + Qt::AlignTop|Qt::AlignRight, numStr); p.setFont(QFont("helvetica", 12, QFont::Bold)); p.drawText(37, offset+i*cellHeight, 45, cellHeight/2, - AlignTop | AlignLeft, "00"); + Qt::AlignTop | Qt::AlignLeft, "00"); } else { QTime time( i + startHour, 0 ); numStr = KGlobal::locale()->formatTime( time ); p.setFont(QFont("helvetica", 12, QFont::Bold)); p.drawText(4, offset+i*cellHeight, 70, cellHeight/2, - AlignTop|AlignLeft, numStr); + Qt::AlignTop|Qt::AlignLeft, numStr); } } mSubHeaderHeight = tempStore ; } -- cgit v0.9.0.2