-rw-r--r-- | korganizer/calprintbase.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index 7b7d54c..ecb9e03 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp @@ -22,17 +22,19 @@ with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qpainter.h> #include <qlayout.h> -#include <qframe.h> +#include <q3frame.h> #include <qlabel.h> -#include <qptrlist.h> -#include <qintdict.h> +#include <q3ptrlist.h> +#include <q3intdict.h> #include <qfontmetrics.h> +//Added by qt3to4: +#include <Q3VBoxLayout> #include <kglobal.h> #include <klocale.h> #include <kdebug.h> #include <kconfig.h> #include <kcalendarsystem.h> @@ -142,14 +144,14 @@ 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() ); titleFont.setPointSize( 20 ); titleFont.setBold( true ); title->setFont( titleFont ); @@ -282,13 +284,13 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, int month = monthDate.month(); // draw the title 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; QString tmpStr; // correct begin of week @@ -298,13 +300,13 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, // draw days of week p.setFont(QFont("helvetica", 7, QFont::Bold)); for (int col = 0; col < 7; col++) { // 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); } // draw separator line p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight); @@ -315,13 +317,13 @@ void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, if (firstCol) { firstCol = true; col = weekdayColumn( monthDate.dayOfWeek() ); } 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); } } } @@ -355,13 +357,13 @@ void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd, p.setFont( QFont( "helvetica", 10, QFont::Bold ) ); p.drawRect( x, y, width, height ); // 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 ) ); } void CalPrintBase::drawTimeLine(QPainter &p, const QTime &fromTime, const QTime &toTime, @@ -398,22 +400,22 @@ void CalPrintBase::drawTimeLine(QPainter &p, if (cellHeight > 30) { p.setFont(QFont("helvetica", 16, QFont::Bold)); } else { 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 if (curTime.secsTo(endTime)>3600) curTime=curTime.addSecs(3600); else curTime=endTime; @@ -469,13 +471,13 @@ void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, if (mUseColors) setCategoryColors(p, currEvent); 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 ); p.setPen( oldPen ); p.setBackgroundColor(oldBgColor); @@ -490,13 +492,13 @@ void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, if (!expandable) { p.drawRect(x, offset, width, height); 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 { height=offset-y; } } @@ -557,21 +559,21 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, QDateTime startPrintDate = QDateTime( qd, fromTime ); QDateTime endPrintDate = QDateTime( qd, toTime ); // Calculate horizontal positions and widths of events taking into account // overlapping events - QPtrList<KOrg::CellItem> cells; + Q3PtrList<KOrg::CellItem> cells; cells.setAutoDelete( true ); Event::List::ConstIterator itEvents; for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { cells.append( new PrintCellItem( *itEvents, qd ) ); } - QPtrListIterator<KOrg::CellItem> it1( cells ); + Q3PtrListIterator<KOrg::CellItem> it1( cells ); for( it1.toFirst(); it1.current(); ++it1 ) { KOrg::CellItem *placeItem = it1.current(); KOrg::CellItem::placeItem( cells, placeItem ); } @@ -590,13 +592,13 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, p.setBrush( oldBrush ); p.setPen( oldPen ); p.setBackgroundColor( oldBgColor ); } - p.setBrush( QBrush( NoBrush ) ); + p.setBrush( QBrush( Qt::NoBrush ) ); } void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, const QDate &qd, const QDateTime &startPrintDate, @@ -632,13 +634,13 @@ void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, // p.save(); QPen pe = p.pen(); pe.setWidth( 2 ); 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(); } } void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, @@ -667,23 +669,23 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, hstring=KOCore::self()->holiday(qd); #endif 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)); if ( fullDate) { // use short date format, if long date is too long QFontMetrics fm ( p.font() ); 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 )); Todo::List todos; todos.fill( mCalendar->todos( qd )); QString outStr; @@ -721,13 +723,13 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, outStr += " " + currEvent->summary(); } } // doesFloat p.drawText(x+5, y+textY, width-10, lineSpacing, - AlignLeft|AlignBottom, outStr); + Qt::AlignLeft|Qt::AlignBottom, outStr); textY+=lineSpacing; } if ( textY<height ) { Todo::List::ConstIterator it2; @@ -740,13 +742,13 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, text += " "; } } 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; } } } @@ -846,13 +848,13 @@ void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, p.setFont(newFont); xoffset += 18; QDate weekDate(monthDate); for (int row = 0; row<rows; row++) { int calWeek = weekDate.weekNumber(); QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); - p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); + p.drawText( rc, Qt::AlignRight|Qt::AlignVCenter, QString::number(calWeek) ); weekDate = weekDate.addDays(7); } p.setFont(oldFont); } drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); @@ -894,31 +896,31 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & int posdue=posDueDt; if (posdue<0) posdue=x+width; QRect rect; TodoParentStart startpt; // This list keeps all starting points of the parent todos so the connection // lines of the tree can easily be drawn (needed if a new page is started) - static QPtrList<TodoParentStart> startPoints; + static Q3PtrList<TodoParentStart> startPoints; if (level<1) { startPoints.clear(); } // size of item outStr=item->summary(); if ( ! item->location().isEmpty() ) outStr += " ("+item->location()+")"; if ( item->hasDueDate() && posDueDt>=0 ) { 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 if ( rect.bottom() > y+height) { // first draw the connection lines from parent todos: if (level > 0 && connectSubTodos) { @@ -930,14 +932,13 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & // draw either from start point of parent or from top of the page if (rct->mSamePage) 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; } } y=0; height=pageHeight-y; mPrinter->newPage(); @@ -948,26 +949,26 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & if (r && pospriority >= 0 ) { pospriority = r->mRect.right() + 1; } // 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() ) { p.drawLine( rect.topLeft(), rect.bottomRight() ); 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 ); } } startpt.mRect = rect; //save for later @@ -978,15 +979,14 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & if (r->mSamePage ) bottom = r->mRect.bottom();//lutz + 1; else 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 // LR does not work - font is underlined, not striked out //QFont ft=p.font(); //ft.setStrikeOut( item->isCompleted() ); @@ -996,15 +996,15 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & if ( ! item->location().isEmpty() ) outStr += " ("+item->location()+")"; if ( item->hasDueDate() && posDueDt>=0 ) { 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); // due // if ( item->hasDueDate() && posDueDt>=0 ) { // outStr = local->formatDate(item->dtDue().date(),true); @@ -1013,14 +1013,14 @@ void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter & // } if ( !item->description().isEmpty() && desc ) { 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 y=newrect.bottom() + 10; //set the line position // If the item has subitems, we need to call ourselves recursively @@ -1135,14 +1135,14 @@ void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, int width, int ) { int tempStore = mSubHeaderHeight; 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; QString myOwner(mCalendar->getOwner()); if ( fd.month() == td.month() ) { title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' @@ -1158,23 +1158,23 @@ void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, // serifFont.setWeight(87); // serifFont.setItalic(true); p.setFont(serifFont); 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); p.setPen(penB ); p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1); p.setPen(penA ); 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 ; } void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, int height, int offsetLeft ) { @@ -1194,13 +1194,13 @@ void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, // width+1 to make sure there's a continuous, black bar across the top. p.setPen( QPen(Qt::black,2)); p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight); 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)); p.setFont(QFont("helvetica", 12)); p.setBrush(Qt::white); it = eventList.begin(); @@ -1251,16 +1251,16 @@ void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute()); int cheight = (int) (minuteInc * currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 ); 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 ; } void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, int height ) { @@ -1271,36 +1271,36 @@ void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, int offset = mHeaderHeight + mSubHeaderHeight + 10; int hours = endHour - startHour; int cellHeight = (height-offset) / hours; // hour increments. 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); if (cellHeight > 40) { p.setFont(QFont("helvetica", 16, QFont::Bold)); } else { 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 ; } #endif |