author | zautrix <zautrix> | 2005-03-08 09:24:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-08 09:24:53 (UTC) |
commit | 91e7aeec0b15d28eb263c0699fdce4a00a3669c6 (patch) (side-by-side diff) | |
tree | 10bf2d72c94ab030c7a08b22d0880997c99dcfff /korganizer | |
parent | a50b432c475d2a0b97b3f8707666f7d2990cd8db (diff) | |
download | kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.zip kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.gz kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.bz2 |
todo printing fixes
-rw-r--r-- | korganizer/calprintbase.cpp | 26 | ||||
-rw-r--r-- | korganizer/calprinter.cpp | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index 6bb407d..f66fddc 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp @@ -728,469 +728,477 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, } } // doesFloat p.drawText(x+5, y+textY, width-10, lineSpacing, AlignLeft|AlignBottom, outStr); textY+=lineSpacing; } if ( textY<height ) { Todo::List::ConstIterator it2; for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { Todo *todo = *it2; QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { text += KGlobal::locale()->formatTime(todo->dtDue().time()); text += " "; } } text += i18n("To-Do: %1").arg(todo->summary()); p.drawText(x+5, y+textY, width-10, lineSpacing, AlignLeft|AlignBottom, text); textY+=lineSpacing; } } } /////////////////////////////////////////////////////////////////////////////// void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, int x, int y, int width, int height) { QDate weekDate = qd; bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); int cellWidth, cellHeight; int vcells; if (portrait) { cellWidth = width/2; vcells=3; } else { cellWidth = width/6; vcells=1; } cellHeight = height/vcells; // correct begin of week int weekdayCol = weekdayColumn( qd.dayOfWeek() ); weekDate = qd.addDays( -weekdayCol ); for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { if (i<5) { drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), cellWidth, cellHeight, true); } else if (i==5) { drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), cellWidth, cellHeight/2, true); } else if (i==6) { drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); } } // for i through all weekdays } void CalPrintBase::drawTimeTable(QPainter &p, const QDate &fromDate, const QDate &toDate, QTime &fromTime, QTime &toTime, int x, int y, int width, int height) { // timeline is 1.5 hours: int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); int timelineWidth = 60; int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); int currY=y; int currX=x; drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); currY+=mSubHeaderHeight; drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, timelineWidth, height-mSubHeaderHeight-alldayHeight ); currX=x+timelineWidth; // draw each day QDate curDate(fromDate); while (curDate<=toDate) {Event::List eventList; eventList.fill( mCalendar->events(curDate, true)); drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); currX+=cellWidth; curDate=curDate.addDays(1); } } /////////////////////////////////////////////////////////////////////////////// void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, int x, int y, int width, int height) { int yoffset = mSubHeaderHeight; int xoffset = 0; QDate monthDate(QDate(qd.year(), qd.month(), 1)); QDate monthFirst(monthDate); QDate monthLast(monthDate.addMonths(1).addDays(-1)); int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); monthDate = monthDate.addDays(-weekdayCol); int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; int cellHeight = (height-yoffset) / rows; if (weeknumbers) { QFont oldFont(p.font()); QFont newFont(p.font()); newFont.setPointSize(7); 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) ); weekDate = weekDate.addDays(7); } p.setFont(oldFont); } drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); int cellWidth = (width-xoffset) / 7; QColor back = p.backgroundColor(); bool darkbg = false; for (int row = 0; row < rows; row++) { for (int col = 0; col < 7; col++) { // show days from previous/next month with a grayed background if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { p.setBackgroundColor( QColor( 240, 240, 240) ); darkbg = true; } drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); if ( darkbg ) { p.setBackgroundColor( back ); darkbg = false; } monthDate = monthDate.addDays(1); } } } /////////////////////////////////////////////////////////////////////////////// void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, bool desc, int pospriority, int possummary, int posDueDt, int level, int x, int &y, int width, int &height, int pageHeight, TodoParentStart *r ) { if ( !completed && item->isCompleted() ) return; QString outStr; // int fontHeight = 10; const KLocale *local = KGlobal::locale(); int priority=item->priority(); 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; 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); + //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 ); } + //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) { TodoParentStart *rct; for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { int start; int center = rct->mRect.left() + (rct->mRect.width()/2); int to = p.viewport().bottom(); // 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 ); rct->mSamePage=false; } } y=0; height=pageHeight-y; mPrinter->newPage(); } // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up //to the RH side of the parent item's priority if (r && pospriority >= 0 ) { pospriority = r->mRect.right() + 1; } // Priority outStr.setNum(priority); rect = p.boundingRect(pospriority, y + 10, 5, -1, 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.drawRect(rect); // cross out the rectangle for completed items if ( item->isCompleted() ) { - p.drawLine( rect.topLeft(), rect.bottomRight() ); - p.drawLine( rect.topRight(), rect.bottomLeft() ); + 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.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 // Connect the dots if (level > 0 && connectSubTodos) { int bottom; int center( r->mRect.left() + (r->mRect.width()/2)+1 ); 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); } // if completed, use strike out font - QFont ft=p.font(); - ft.setStrikeOut( item->isCompleted() ); - p.setFont( ft ); + // LR does not work - font is underlined, not striked out + //QFont ft=p.font(); + //ft.setStrikeOut( item->isCompleted() ); + //p.setFont( ft ); // summary outStr=item->summary(); if ( ! item->location().isEmpty() ) outStr += " ("+item->location()+")"; if ( item->hasDueDate() && posDueDt>=0 ) { - outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; + outStr += " [" +item->dtDueStr(true)+"]"; } rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), -1, WordBreak, outStr); QRect newrect; p.drawText( rect, WordBreak, outStr, -1, &newrect ); - ft.setStrikeOut(false); - p.setFont(ft); + //ft.setStrikeOut(false); + // p.setFont(ft); // due // if ( item->hasDueDate() && posDueDt>=0 ) { // outStr = local->formatDate(item->dtDue().date(),true); // rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr); // p.drawText(rect, AlignTop|AlignLeft, outStr); // } 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 ); } // Set the new line position y=newrect.bottom() + 10; //set the line position // If the item has subitems, we need to call ourselves recursively Incidence::List l;l.fill( item->relations()); Incidence::List::ConstIterator it; startPoints.append( &startpt ); for( it = l.begin(); it != l.end(); ++it ) { count++; drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos, desc, pospriority, possummary, posDueDt, level+1, x, y, width, height, pageHeight, &startpt); } startPoints.remove(&startpt); } int CalPrintBase::weekdayColumn( int weekday ) { return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7; } void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, const QDate &td ) { QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek; mPrinter->setOrientation(KPrinter::Portrait); int minus = 0; if (KGlobal::locale()->weekStartsMonday()) { // correct to monday fromWeek = fd.addDays(-(fd.dayOfWeek()-1)); // correct to sunday toWeek = td.addDays(7-fd.dayOfWeek()); minus = 1; } else { // correct to sunday fromWeek = fd.addDays(-(fd.dayOfWeek()%7)); // correct to saturday toWeek = td.addDays(6-td.dayOfWeek()); } fromDay = fd; curDay = fd; toDay = td; p.setFont( QFont("Helvetica") ); // the painter initially begins at 72 dpi per the Qt docs. int pageWidth = p.viewport().width(); int pageHeight = p.viewport().height(); int margin=0; mHeaderHeight = 110; mSubHeaderHeight = 20; p.setViewport(margin, margin, p.viewport().width()-margin, p.viewport().height()-margin); curWeek = fromWeek.addDays(6); int columnWidth = int( pageWidth / 4.5 ); do { // if ( (curDay.dayOfWeek()-1)%7 < 3 ) switch((curDay.dayOfWeek()-minus)%7){ case 0: drawSplitTimes( p, pageWidth, columnWidth, pageHeight ); drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 0.5 ) ); break; case 1: drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 1.5 ) ); break; case 2: drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 2.5 ) ); break; case 3: drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 3.5 ) ); mPrinter->newPage(); break; case 4: drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth, pageHeight ); drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 0.5 ) ); drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek, curWeek, pageWidth, mHeaderHeight ); break; case 5: drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 1.5 ) ); break; case 6: drawSplitDay( p, curDay, columnWidth, pageHeight, int( columnWidth * 2.5 ) ); if ( curDay < toDay ) mPrinter->newPage(); curWeek = curWeek.addDays( 7 ); break; } curDay = curDay.addDays(1); } while (curDay <= toDay); } void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td, const QDate &, 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); 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()) + ' ' + '-' + ' ' + QString::number(td.day()); } else { title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day()); } // Grrrrrrr! why can't I set the font to a serif font?!?!? QFont serifFont("Helvetica", 30); // serifFont.setFamily("Serif"); // 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 ); 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 ); mSubHeaderHeight = tempStore ; } void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, int height, int offsetLeft ) { int tempStore = mSubHeaderHeight; mSubHeaderHeight+= mSubHeaderHeight; int startHour = KOPrefs::instance()->mDayBegins; int endHour = 20; int offset = mHeaderHeight + mSubHeaderHeight + 10; Event::List eventList; eventList.fill( mCalendar->events( qd, true )); Event::List::Iterator it; Event *currEvent; KLocale *local = KGlobal::locale(); QString dayName; dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day()); //p.setBrush(QBrush(black)); // 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)); diff --git a/korganizer/calprinter.cpp b/korganizer/calprinter.cpp index 6b5b0fe..0cdf28e 100644 --- a/korganizer/calprinter.cpp +++ b/korganizer/calprinter.cpp @@ -1,299 +1,299 @@ /* This file is part of KOrganizer. Copyright (c) 1998 Preston Brown This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qvbuttongroup.h> #include <qwidgetstack.h> #include <qradiobutton.h> #include <qlayout.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qlabel.h> #include <qvbox.h> #include <qsplitter.h> #include <kprinter.h> #include <kglobal.h> #include <ksimpleconfig.h> #include <kmessagebox.h> #include <kdebug.h> //#include <kdeversion.h> #include "koprefsdialog.h" #include "calprinter.h" #ifndef KORG_NOPRINTER //#include "calprinter.moc" #include "calprintplugins.h" CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar ) : QObject( parent, "CalPrinter" ) { mCalendar = calendar; mParent = parent; mPrinter = new KPrinter; mPrinter->setOrientation( KPrinter::Portrait ); mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" )); //KSimpleConfig( "korganizer_printing.rc" ); init( mPrinter, calendar ); } CalPrinter::~CalPrinter() { kdDebug() << "~CalPrinter()" << endl; CalPrintBase *plug = mPrintPlugins.first(); while ( plug ) { plug->doSaveConfig(); plug = mPrintPlugins.next(); } mConfig->sync(); delete mConfig; delete mPrintDialog; delete mPrinter; } void CalPrinter::init( KPrinter *printer, Calendar *calendar ) { mPrintPlugins.setAutoDelete( true ); mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) ); mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) ); mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) ); mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) ); // TODO_RK: Add a plugin interface here mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent ); CalPrintBase *plug = mPrintPlugins.first(); while ( plug ) { connect( mPrintDialog, SIGNAL( okClicked() ), plug, SLOT( readSettingsWidget() ) ); plug->doLoadConfig(); plug = mPrintPlugins.next(); } } void CalPrinter::setupPrinter() { KMessageBox::sorry( mParent, i18n("Not implemented.") ); #if 0 KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent); optionsDlg->readConfig(); optionsDlg->showPrinterTab(); connect(optionsDlg, SIGNAL(configChanged()), mParent, SLOT(updateConfig())); optionsDlg->show(); #endif } void CalPrinter::setDateRange( const QDate &fd, const QDate &td ) { CalPrintBase *plug = mPrintPlugins.first(); while ( plug ) { plug->setDateRange( fd, td ); plug = mPrintPlugins.next(); } } void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td ) { mPrintDialog->setPreview( true ); mPrintDialog->setPrintType( int( type ) ); setDateRange( fd, td ); if ( mPrintDialog->exec() == QDialog::Accepted ) { doPrint( mPrintDialog->selectedPlugin(), true ); } } void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td ) { - mPrintDialog->resize( 640, 380 ); + mPrintDialog->resize( 640, 440 ); mPrintDialog->setPreview( false ); mPrintDialog->setPrintType( int( type ) ); setDateRange( fd, td ); if ( mPrintDialog->exec() == QDialog::Accepted ) { doPrint( mPrintDialog->selectedPlugin(), false ); } } void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview ) { // FIXME: add a better caption to the Printingdialog //mPrinter->setPreviewOnly( preview ); if ( preview || mPrinter->setup( mParent ) ) { switch ( mPrintDialog->orientation() ) { case eOrientPlugin: mPrinter->setOrientation( selectedStyle->orientation()); break; case eOrientPortrait: mPrinter->setOrientation( KPrinter::Portrait ); break; case eOrientLandscape: mPrinter->setOrientation( KPrinter::Landscape ); break; case eOrientPrinter: default: break; } selectedStyle->doPrint(); } //mPrinter->setPreviewOnly( false ); } /////////////////////////////////////////////////////////////////////////////// void CalPrinter::updateConfig() { } /****************************************************************************/ CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p, QWidget *parent, const char *name ) : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ), mPrinter( p ), mPrintPlugins( plugins ) { QVBox *page = new QVBox(this);//makeVBoxMainWidget(); setMainWidget( page ); QHBox *printerLayout = new QHBox( page ); mPrinterLabel = new QLabel( printerLayout ); QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."), printerLayout ); setupButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0, 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) ); QSplitter *splitter = new QSplitter( page ); splitter->setOrientation( QSplitter::Horizontal ); mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" ); // use the minimal width possible = max width of the radio buttons, not extensible /* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)5, 0, 0, mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/ QWidget *splitterRight = new QWidget( splitter, "splitterRight" ); QGridLayout *splitterRightLayout = new QGridLayout( splitterRight ); splitterRightLayout->setMargin( marginHint() ); splitterRightLayout->setSpacing( spacingHint() ); mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" ); splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 ); QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"), splitterRight, "orientationLabel" ); splitterRightLayout->addWidget( orientationLabel, 1, 0 ); mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" ); mOrientationSelection->insertItem( i18n("Use Default of Selected Style") ); mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") ); mOrientationSelection->insertItem( i18n("Portrait") ); mOrientationSelection->insertItem( i18n("Landscape") ); splitterRightLayout->addWidget( mOrientationSelection, 1, 1 ); // signals and slots connections connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) ); connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) ); // buddies orientationLabel->setBuddy( mOrientationSelection ); CalPrintBase *plug = mPrintPlugins.first(); QRadioButton *radioButton; int id = 0; while ( plug ) { radioButton = new QRadioButton( plug->description(), mTypeGroup ); mTypeGroup->insert( radioButton, id ); //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 ); mConfigArea->addWidget( plug->configWidget( mConfigArea ), id ); plug = mPrintPlugins.next(); id++; } // setMinimumSize( minimumSizeHint() ); //resize( minimumSizeHint() ); } CalPrintDialog::~CalPrintDialog() { } void CalPrintDialog::setupPrinter() { if ( mPrinter->setup( this ) ) { setPrinterLabel(); } } void CalPrintDialog::setPreview(bool preview) { setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") ); mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>") : i18n( "<qt>Printing on printer <b>%1</b></qt>"); setPrinterLabel(); } void CalPrintDialog::setPrinterLabel() { QString printerName( mPrinter->printerName() ); if ( printerName.isEmpty() ) mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) ); else mPrinterLabel->setText( mPreviewText.arg( printerName ) ); } void CalPrintDialog::setPrintType( int i ) { // TODO: Make a safe correlation between type and the radio button mTypeGroup->setButton( i ); mConfigArea->raiseWidget( i ); } CalPrintBase *CalPrintDialog::selectedPlugin() { int pos = mTypeGroup->id( mTypeGroup->selected() ); if ( pos < 0 ) return 0; CalPrintBase *retval = mPrintPlugins.at( pos ); return retval; } void CalPrintDialog::slotOk() { mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem(); KDialogBase::slotOk(); emit okClicked(); } #endif |