From 1618cbf79921cbeffd99cf5667aa9e3e19d81212 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 4 Sep 2009 12:13:12 +0200 Subject: Added support for quering a printer for the actual number of copies. The logic of numCopies() returning 1 to indicate how many times you have to run your printing code is not ideal and prevents the "property" to be used as a placeholder for the value, which was required by KDE. Added QPrinter::actualNumCopies() to ask for the value set through setNumCopies() or through the print dialog. Reviewed-by: Trond --- src/gui/painting/qprinter.cpp | 17 +++++++++++++++++ src/gui/painting/qprinter.h | 2 ++ tests/auto/qprinter/tst_qprinter.cpp | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp index 882e6bc..882f994 100644 --- a/src/gui/painting/qprinter.cpp +++ b/src/gui/painting/qprinter.cpp @@ -1286,6 +1286,23 @@ int QPrinter::numCopies() const /*! + Returns the number of copies that will be printed. The default + value is 1. + + This function always returns the actual value specified in the print + dialog or using setNumCopies(). + + \sa setNumCopies(), numCopies(); +*/ +int QPrinter::actualNumCopies() const +{ + Q_D(const QPrinter); + return qt_printerRealNumCopies(d->paintEngine); +} + + + +/*! Sets the number of copies to be printed to \a numCopies. The printer driver reads this setting and prints the specified diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h index 46419f4..16f2182 100644 --- a/src/gui/painting/qprinter.h +++ b/src/gui/painting/qprinter.h @@ -197,6 +197,8 @@ public: void setNumCopies(int); int numCopies() const; + int actualNumCopies() const; + void setPaperSource(PaperSource); PaperSource paperSource() const; diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index 89be43f..aa64f13 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -105,6 +105,8 @@ private slots: void testCustomPageSizes(); void printDialogCompleter(); + void testActualNumCopies(); + private: }; @@ -959,5 +961,12 @@ void tst_QPrinter::printDialogCompleter() #endif } +void tst_QPrinter::testActualNumCopies() +{ + QPrinter p; + p.setNumCopies(15); + QCOMPARE(p.actualNumCopies(), 15); +} + QTEST_MAIN(tst_QPrinter) #include "tst_qprinter.moc" -- cgit v0.12