summaryrefslogtreecommitdiffstats
path: root/src/printsupport
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-04-11 14:36:55 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-04-11 14:36:55 +0200
commit98d3e40fb7c88b670a93e73dace2d0f05a5f903c (patch)
treeb1292124a86c219fb434db4ec28e8f805ff52287 /src/printsupport
parenta74e4b85be83e2da47f4a1d8fcf0e78079335b80 (diff)
parentbab494e4d046f5617d19f5fec35eeff94377c51f (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: mkspecs/qnx-armv7le-qcc/qplatformdefs.h src/printsupport/kernel/qcups.cpp src/widgets/styles/qstyle.h tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp Change-Id: Ia41e13051169a6d4a8a1267548e7d47b859bb267
Diffstat (limited to 'src/printsupport')
-rw-r--r--src/printsupport/kernel/qcups.cpp2
-rw-r--r--src/printsupport/kernel/qprinter.cpp160
-rw-r--r--src/printsupport/kernel/qprinter.h6
-rw-r--r--src/printsupport/printsupport.pro3
4 files changed, 105 insertions, 66 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 288ad16da0..3a92f9b6db 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -88,7 +88,7 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
QDateTime localDateTime = QDateTime::currentDateTime();
// Check if time is for tomorrow in case of DST change overnight
if (holdUntilTime < localDateTime.time())
- localDateTime.addDays(1);
+ localDateTime = localDateTime.addDays(1);
localDateTime.setTime(holdUntilTime);
return localDateTime.toUTC().time().toString(QStringLiteral("HH:mm"));
}
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 153fb23d36..bdc9a98f2e 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -220,6 +220,87 @@ void QPrinterPrivate::setProperty(QPrintEngine::PrintEnginePropertyKey key, cons
}
+class QPrinterPagedPaintDevicePrivate : public QPagedPaintDevicePrivate
+{
+public:
+ QPrinterPagedPaintDevicePrivate(QPrinterPrivate *d)
+ : QPagedPaintDevicePrivate(), pd(d)
+ {}
+
+ virtual ~QPrinterPagedPaintDevicePrivate()
+ {}
+
+ bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE
+ {
+ if (pd->paintEngine->type() != QPaintEngine::Pdf
+ && pd->printEngine->printerState() == QPrinter::Active) {
+ qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
+ return false;
+ }
+
+ // Try to set the print engine page layout
+ pd->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newPageLayout));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().isEquivalentTo(newPageLayout);
+ }
+
+ bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE
+ {
+ if (pd->paintEngine->type() != QPaintEngine::Pdf
+ && pd->printEngine->printerState() == QPrinter::Active) {
+ qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
+ return false;
+ }
+
+
+ // Try to set the print engine page size
+ pd->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().pageSize().isEquivalentTo(pageSize);
+ }
+
+ bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE
+ {
+ // Set the print engine value
+ pd->setProperty(QPrintEngine::PPK_Orientation, orientation);
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().orientation() == orientation;
+ }
+
+ bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE
+ {
+ return setPageMargins(margins, pageLayout().units());
+ }
+
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE
+ {
+ // Try to set print engine margins
+ QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);
+ pd->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().margins() == margins && pageLayout().units() == units;
+ }
+
+ QPageLayout pageLayout() const Q_DECL_OVERRIDE
+ {
+ return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
+ }
+
+ QPrinterPrivate *pd;
+};
+
/*!
\class QPrinter
@@ -601,6 +682,8 @@ QPrinter::QPrinter(PrinterMode mode)
: QPagedPaintDevice(),
d_ptr(new QPrinterPrivate(this))
{
+ delete d;
+ d = new QPrinterPagedPaintDevicePrivate(d_func());
d_ptr->init(QPrinterInfo(), mode);
}
@@ -613,6 +696,8 @@ QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)
: QPagedPaintDevice(),
d_ptr(new QPrinterPrivate(this))
{
+ delete d;
+ d = new QPrinterPagedPaintDevicePrivate(d_func());
d_ptr->init(printer, mode);
}
@@ -947,7 +1032,10 @@ void QPrinter::setCreator(const QString &creator)
d->setProperty(QPrintEngine::PPK_Creator, creator);
}
+// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here
+#ifdef Q_QDOC
/*!
+ \fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)
\since 5.3
Sets the page layout to \a newLayout.
@@ -961,23 +1049,8 @@ void QPrinter::setCreator(const QString &creator)
\sa pageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-bool QPrinter::setPageLayout(const QPageLayout &newLayout)
-{
- Q_D(QPrinter);
-
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE_RETURN("QPrinter::setPageLayout", false);
-
- // Try to set the print engine page layout
- d->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newLayout));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().isEquivalentTo(newLayout);
-}
-
/*!
+ \fn bool QPrinter::setPageSize(const QPageSize &pageSize)
\since 5.3
Sets the page size to \a pageSize.
@@ -995,23 +1068,8 @@ bool QPrinter::setPageLayout(const QPageLayout &newLayout)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageSize(const QPageSize &pageSize)
-{
- Q_D(QPrinter);
-
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE_RETURN("QPrinter::setPageSize", false);
-
- // Try to set the print engine page size
- d->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().pageSize().isEquivalentTo(pageSize);
-}
-
/*!
+ \fn bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
\since 5.3
Sets the page \a orientation to QPageLayout::Portrait or QPageLayout::Landscape.
@@ -1029,20 +1087,8 @@ bool QPrinter::setPageSize(const QPageSize &pageSize)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
-{
- Q_D(QPrinter);
-
- // Set the print engine value
- d->setProperty(QPrintEngine::PPK_Orientation, orientation);
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().orientation() == orientation;
-}
-
/*!
+ \fn bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\since 5.3
Set the page margins to \a margins in the given \a units. If \a units are
@@ -1059,21 +1105,10 @@ bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
-{
- Q_D(QPrinter);
-
- // Try to set print engine margins
- QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);
- d->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().margins() == margins && pageLayout().units() == units;
-}
-
/*!
+ \fn QPageLayout QPrinter::pageLayout() const
+ \since 5.3
+
Returns the current page layout. Use this method to access the current
QPageSize, QPageLayout::Orientation, QMarginsF, fullPageRect() and paintRect().
@@ -1082,12 +1117,7 @@ bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-
-QPageLayout QPrinter::pageLayout() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
-}
+#endif
/*!
\obsolete Use pageLayout().pageOrientation() instead.
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index 1f0639d81f..fa102d0fe3 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -307,11 +307,17 @@ public:
void setCreator(const QString &);
QString creator() const;
+#ifdef Q_QDOC
bool setPageLayout(const QPageLayout &pageLayout);
bool setPageSize(const QPageSize &pageSize);
bool setPageOrientation(QPageLayout::Orientation orientation);
+ bool setPageMargins(const QMarginsF &margins);
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
QPageLayout pageLayout() const;
+#else
+ using QPagedPaintDevice::setPageSize;
+ using QPagedPaintDevice::setPageMargins;
+#endif
void setOrientation(Orientation);
Orientation orientation() const;
diff --git a/src/printsupport/printsupport.pro b/src/printsupport/printsupport.pro
index a92d36f7bc..b32ba91c07 100644
--- a/src/printsupport/printsupport.pro
+++ b/src/printsupport/printsupport.pro
@@ -4,6 +4,9 @@ QT = core-private gui-private widgets-private
MODULE_CONFIG = needs_printsupport_plugin
DEFINES += QT_NO_USING_NAMESPACE
+MODULE_PLUGIN_TYPES = \
+ printsupport
+
QMAKE_DOCS = $$PWD/doc/qtprintsupport.qdocconf
load(qt_module)