summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r--src/printsupport/kernel/qcups.cpp16
-rw-r--r--src/printsupport/kernel/qcups_p.h6
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha.cpp13
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha_p.h6
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.cpp4
-rw-r--r--src/printsupport/kernel/qprint_p.h4
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp20
-rw-r--r--src/printsupport/kernel/qprinter.cpp6
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp16
9 files changed, 67 insertions, 24 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 8c67b416a9..2f0f1205ca 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -59,6 +59,16 @@ void QCUPSSupport::setCupsOption(QStringList &cupsOptions, const QString &option
}
}
+void QCUPSSupport::clearCupsOption(QStringList &cupsOptions, const QString &option)
+{
+ // ### use const_iterator once QList::erase takes them
+ const QStringList::iterator it = std::find(cupsOptions.begin(), cupsOptions.end(), option);
+ if (it != cupsOptions.end()) {
+ Q_ASSERT(it + 1 < cupsOptions.end());
+ cupsOptions.erase(it, it+1);
+ }
+}
+
static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, const QTime holdUntilTime)
{
switch (jobHold) {
@@ -94,14 +104,16 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
{
+ QStringList cupsOptions = cupsOptionsList(printer);
const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime);
if (!jobHoldUntilArgument.isEmpty()) {
- QStringList cupsOptions = cupsOptionsList(printer);
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
jobHoldUntilArgument);
- setCupsOptions(printer, cupsOptions);
+ } else {
+ clearCupsOption(cupsOptions, QStringLiteral("job-hold-until"));
}
+ setCupsOptions(printer, cupsOptions);
}
void QCUPSSupport::setJobBilling(QPrinter *printer, const QString &jobBilling)
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index afcb2c6f3b..f6ba983e9f 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -117,6 +117,7 @@ public:
static QStringList cupsOptionsList(QPrinter *printer);
static void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions);
static void setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value);
+ static void clearCupsOption(QStringList &cupsOptions, const QString &option);
static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
@@ -127,6 +128,11 @@ public:
const PagesPerSheetLayout pagesPerSheetLayout);
static void setPageRange(QPrinter *printer, int pageFrom, int pageTo);
};
+Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QCUPSSupport::PageSet, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheetLayout, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp
index a81f3eae43..79026e5762 100644
--- a/src/printsupport/kernel/qpaintengine_alpha.cpp
+++ b/src/printsupport/kernel/qpaintengine_alpha.cpp
@@ -186,7 +186,8 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg
Q_D(QAlphaPaintEngine);
QPolygonF poly;
- for (int i=0; i<pointCount; ++i)
+ poly.reserve(pointCount);
+ for (int i = 0; i < pointCount; ++i)
poly.append(points[i]);
QPainterPath path;
@@ -383,6 +384,7 @@ QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate()
m_pic(0),
m_picengine(0),
m_picpainter(0),
+ m_numberOfCachedRects(0),
m_hasalpha(false),
m_alphaPen(false),
m_alphaBrush(false),
@@ -433,7 +435,14 @@ void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect)
bool QAlphaPaintEnginePrivate::canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const
{
- return somethingInRectHasAlpha && m_dirtyrgn.intersects(rect.toAlignedRect());
+ if (somethingInRectHasAlpha) {
+ if (m_dirtyRects.count() != m_numberOfCachedRects) {
+ m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.count());
+ m_numberOfCachedRects = m_dirtyRects.count();
+ }
+ return m_cachedDirtyRgn.intersects(rect.toAlignedRect());
+ }
+ return false;
}
void QAlphaPaintEnginePrivate::drawAlphaImage(const QRectF &rect)
diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h
index 2becad7379..49a9938e56 100644
--- a/src/printsupport/kernel/qpaintengine_alpha_p.h
+++ b/src/printsupport/kernel/qpaintengine_alpha_p.h
@@ -99,7 +99,9 @@ public:
QRegion m_alphargn;
QRegion m_cliprgn;
- QRegion m_dirtyrgn;
+ mutable QRegion m_cachedDirtyRgn;
+ mutable int m_numberOfCachedRects;
+ QVector<QRect> m_dirtyRects;
bool m_hasalpha;
bool m_alphaPen;
@@ -115,7 +117,7 @@ public:
QPen m_pen;
void addAlphaRect(const QRectF &rect);
- void addDirtyRect(const QRectF &rect) { m_dirtyrgn |= rect.toAlignedRect(); }
+ void addDirtyRect(const QRectF &rect) { m_dirtyRects.append(rect.toAlignedRect()); }
bool canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const;
QRectF addPenWidth(const QPainterPath &path);
diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp
index 091cc6f008..9adf39ffcd 100644
--- a/src/printsupport/kernel/qplatformprintplugin.cpp
+++ b/src/printsupport/kernel/qplatformprintplugin.cpp
@@ -55,6 +55,7 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
static QPlatformPrinterSupport *printerSupport = 0;
+#ifndef QT_NO_LIBRARY
static void cleanupPrinterSupport()
{
#ifndef QT_NO_PRINTER
@@ -62,6 +63,7 @@ static void cleanupPrinterSupport()
#endif
printerSupport = 0;
}
+#endif // !QT_NO_LIBRARY
/*!
\internal
@@ -73,6 +75,7 @@ static void cleanupPrinterSupport()
*/
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
{
+#ifndef QT_NO_LIBRARY
if (!printerSupport) {
const QMultiMap<int, QString> keyMap = loader()->keyMap();
if (!keyMap.isEmpty())
@@ -80,6 +83,7 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
if (printerSupport)
qAddPostRoutine(cleanupPrinterSupport);
}
+#endif // !QT_NO_LIBRARY
return printerSupport;
}
diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h
index a097d26a9e..6a05cc1589 100644
--- a/src/printsupport/kernel/qprint_p.h
+++ b/src/printsupport/kernel/qprint_p.h
@@ -245,7 +245,7 @@ public:
// but where would it live? Not in base module as don't want to link to CUPS.
// May have to have two copies in plugins to keep in sync.
- static QPrint::InputSlot ppdChoiceToInputSlot(ppd_choice_t choice)
+ static QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice)
{
QPrint::InputSlot input;
input.key = choice.choice;
@@ -255,7 +255,7 @@ public:
return input;
}
- static QPrint::OutputBin ppdChoiceToOutputBin(ppd_choice_t choice)
+ static QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice)
{
QPrint::OutputBin output;
output.key = choice.choice;
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 707847ba3f..00a8ca7c98 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1150,7 +1150,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->updateMetrics();
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_Orientation," << orientation << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_Orientation," << orientation << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
break;
@@ -1173,7 +1173,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->setPageSize(pageSize);
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PageSize," << value.toInt() << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_PageSize," << value.toInt() << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
}
@@ -1189,7 +1189,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->setPageSize(pageSize);
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PaperName," << value.toString() << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_PaperName," << value.toString() << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
}
@@ -1228,7 +1228,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->stretch_y = d->dpi_y / double(d->resolution);
d->updateMetrics();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_Resolution," << value.toInt() << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_Resolution," << value.toInt() << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
break;
@@ -1242,7 +1242,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->setPageSize(pageSize);
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_WindowsPageSize," << value.toInt() << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_WindowsPageSize," << value.toInt() << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
break;
@@ -1258,7 +1258,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->setPageSize(pageSize);
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_CustomPaperSize," << value.toSizeF() << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_CustomPaperSize," << value.toSizeF() << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
}
@@ -1273,7 +1273,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
margins.at(2).toReal(), margins.at(3).toReal()));
d->updateMetrics();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PageMargins," << margins << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_PageMargins," << margins << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
break;
@@ -1288,7 +1288,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->setPageSize(pageSize);
d->doReinit();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageSize," << pageSize << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageSize," << pageSize << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
}
@@ -1301,7 +1301,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->m_pageLayout.setMargins(pair.first);
d->updateMetrics();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageMargins," << pair.first << pair.second << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageMargins," << pair.first << pair.second << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
break;
@@ -1317,7 +1317,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->m_pageLayout.setMargins(pageLayout.margins());
d->updateMetrics();
#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageLayout," << pageLayout << ")";
+ qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageLayout," << pageLayout << ')';
d->debugMetrics();
#endif // QT_DEBUG_METRICS
}
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index e9009aa2f7..2cecf61573 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -160,7 +160,7 @@ void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinte
initEngines(format, printer);
if (oldPrintEngine) {
- foreach (QPrintEngine::PrintEnginePropertyKey key, m_properties.values()) {
+ foreach (QPrintEngine::PrintEnginePropertyKey key, m_properties) {
QVariant prop;
// PPK_NumberOfCopies need special treatmeant since it in most cases
// will return 1, disregarding the actual value that was set
@@ -1942,7 +1942,9 @@ QList<int> QPrinter::supportedResolutions() const
QList<QVariant> varlist
= d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
QList<int> intlist;
- for (int i=0; i<varlist.size(); ++i)
+ const int numSupportedResolutions = varlist.size();
+ intlist.reserve(numSupportedResolutions);
+ for (int i = 0; i < numSupportedResolutions; ++i)
intlist << varlist.at(i).toInt();
return intlist;
}
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index ad488a10ed..1be574891b 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -316,7 +316,9 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::PaperSize> list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(QPrinter::PaperSize(pageSize.id()));
return list;
}
@@ -336,7 +338,9 @@ QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const
{
Q_D(const QPrinterInfo);
QList<QPair<QString, QSizeF> > list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
return list;
}
@@ -376,7 +380,9 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::DuplexMode> list;
- foreach (QPrint::DuplexMode mode, d->m_printDevice.supportedDuplexModes())
+ const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
+ list.reserve(supportedDuplexModes.size());
+ foreach (QPrint::DuplexMode mode, supportedDuplexModes)
list << QPrinter::DuplexMode(mode);
return list;
}
@@ -416,7 +422,9 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
QList<QPrinterInfo> list;
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
- foreach (const QString &id, ps->availablePrintDeviceIds())
+ const QStringList availablePrintDeviceIds = ps->availablePrintDeviceIds();
+ list.reserve(availablePrintDeviceIds.size());
+ foreach (const QString &id, availablePrintDeviceIds)
list.append(QPrinterInfo(id));
}
return list;