src/gui/dialogs/qprintpreviewdialog.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   222     } else {
   222     } else {
   223         ownPrinter = true;
   223         ownPrinter = true;
   224         printer = new QPrinter;
   224         printer = new QPrinter;
   225         preview = new QPrintPreviewWidget(printer, q);
   225         preview = new QPrintPreviewWidget(printer, q);
   226     }
   226     }
   227     QObject::connect(preview, SIGNAL(paintRequested(QPrinter *)), q, SIGNAL(paintRequested(QPrinter *)));
   227     QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*)));
   228     QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
   228     QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
   229     setupActions();
   229     setupActions();
   230 
   230 
   231     pageNumEdit = new LineEdit;
   231     pageNumEdit = new LineEdit;
   232     pageNumEdit->setAlignment(Qt::AlignRight);
   232     pageNumEdit->setAlignment(Qt::AlignRight);
   444 }
   444 }
   445 
   445 
   446 void QPrintPreviewDialogPrivate::updateNavActions()
   446 void QPrintPreviewDialogPrivate::updateNavActions()
   447 {
   447 {
   448     int curPage = preview->currentPage();
   448     int curPage = preview->currentPage();
   449     int numPages = preview->numPages();
   449     int numPages = preview->pageCount();
   450     nextPageAction->setEnabled(curPage < numPages);
   450     nextPageAction->setEnabled(curPage < numPages);
   451     prevPageAction->setEnabled(curPage > 1);
   451     prevPageAction->setEnabled(curPage > 1);
   452     firstPageAction->setEnabled(curPage > 1);
   452     firstPageAction->setEnabled(curPage > 1);
   453     lastPageAction->setEnabled(curPage < numPages);
   453     lastPageAction->setEnabled(curPage < numPages);
   454     pageNumEdit->setText(QString::number(curPage));
   454     pageNumEdit->setText(QString::number(curPage));
   456 
   456 
   457 void QPrintPreviewDialogPrivate::updatePageNumLabel()
   457 void QPrintPreviewDialogPrivate::updatePageNumLabel()
   458 {
   458 {
   459     Q_Q(QPrintPreviewDialog);
   459     Q_Q(QPrintPreviewDialog);
   460 
   460 
   461     int numPages = preview->numPages();
   461     int numPages = preview->pageCount();
   462     int maxChars = QString::number(numPages).length();
   462     int maxChars = QString::number(numPages).length();
   463     pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
   463     pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
   464     int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
   464     int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
   465     int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
   465     int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
   466     pageNumEdit->setMinimumWidth(maxWidth);
   466     pageNumEdit->setMinimumWidth(maxWidth);
   513     else if (action == nextPageAction)
   513     else if (action == nextPageAction)
   514         preview->setCurrentPage(curPage + 1);
   514         preview->setCurrentPage(curPage + 1);
   515     else if (action == firstPageAction)
   515     else if (action == firstPageAction)
   516         preview->setCurrentPage(1);
   516         preview->setCurrentPage(1);
   517     else if (action == lastPageAction)
   517     else if (action == lastPageAction)
   518         preview->setCurrentPage(preview->numPages());
   518         preview->setCurrentPage(preview->pageCount());
   519     updateNavActions();
   519     updateNavActions();
   520 }
   520 }
   521 
   521 
   522 void QPrintPreviewDialogPrivate::_q_setMode(QAction* action)
   522 void QPrintPreviewDialogPrivate::_q_setMode(QAction* action)
   523 {
   523 {