forked from pool/libqt5-qtbase
241 lines
10 KiB
Diff
241 lines
10 KiB
Diff
|
From 5cb54cb5ebae99fab121061e25e26eec3056203a Mon Sep 17 00:00:00 2001
|
||
|
From: Marc Mutz <marc.mutz@kdab.com>
|
||
|
Date: Tue, 12 Dec 2017 12:44:02 +0100
|
||
|
Subject: [PATCH 44/54] QPlatformPrintDevice: use QVector, not QList in the API
|
||
|
|
||
|
QPlaformPrintDevice uses QVector to store, but QList in the getters to
|
||
|
retrieve these data. Port API from QList to QVector to avoid
|
||
|
conversion between the two containers on every access.
|
||
|
|
||
|
Saves almost 4KiB in text size (another 0.9% of QtPrintSupport).
|
||
|
|
||
|
Change-Id: If33df141b87753803c45d9f4dae501a68abe49af
|
||
|
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
|
||
|
---
|
||
|
src/printsupport/kernel/qplatformprintdevice.cpp | 16 ++++++++--------
|
||
|
src/printsupport/kernel/qplatformprintdevice.h | 8 ++++----
|
||
|
src/printsupport/kernel/qprintdevice.cpp | 16 ++++++++--------
|
||
|
src/printsupport/kernel/qprintdevice_p.h | 8 ++++----
|
||
|
src/printsupport/kernel/qprintengine_win.cpp | 8 ++++----
|
||
|
src/printsupport/kernel/qprinterinfo.cpp | 2 +-
|
||
|
6 files changed, 29 insertions(+), 29 deletions(-)
|
||
|
|
||
|
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
|
||
|
index 82bddedb1b..2f76156a91 100644
|
||
|
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
|
||
|
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
|
||
|
@@ -313,11 +313,11 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const
|
||
|
return input;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
|
||
|
+QVector<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
|
||
|
{
|
||
|
if (!m_haveInputSlots)
|
||
|
loadInputSlots();
|
||
|
- return m_inputSlots.toList();
|
||
|
+ return m_inputSlots;
|
||
|
}
|
||
|
|
||
|
void QPlatformPrintDevice::loadOutputBins() const
|
||
|
@@ -337,11 +337,11 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
|
||
|
+QVector<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
|
||
|
{
|
||
|
if (!m_haveOutputBins)
|
||
|
loadOutputBins();
|
||
|
- return m_outputBins.toList();
|
||
|
+ return m_outputBins;
|
||
|
}
|
||
|
|
||
|
void QPlatformPrintDevice::loadDuplexModes() const
|
||
|
@@ -353,11 +353,11 @@ QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const
|
||
|
return QPrint::DuplexNone;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
|
||
|
+QVector<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
|
||
|
{
|
||
|
if (!m_haveDuplexModes)
|
||
|
loadDuplexModes();
|
||
|
- return m_duplexModes.toList();
|
||
|
+ return m_duplexModes;
|
||
|
}
|
||
|
|
||
|
void QPlatformPrintDevice::loadColorModes() const
|
||
|
@@ -369,11 +369,11 @@ QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const
|
||
|
return QPrint::GrayScale;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
|
||
|
+QVector<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
|
||
|
{
|
||
|
if (!m_haveColorModes)
|
||
|
loadColorModes();
|
||
|
- return m_colorModes.toList();
|
||
|
+ return m_colorModes;
|
||
|
}
|
||
|
|
||
|
#ifndef QT_NO_MIMETYPE
|
||
|
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
|
||
|
index 1cac009660..8af76464b5 100644
|
||
|
--- a/src/printsupport/kernel/qplatformprintdevice.h
|
||
|
+++ b/src/printsupport/kernel/qplatformprintdevice.h
|
||
|
@@ -110,16 +110,16 @@ public:
|
||
|
virtual QList<int> supportedResolutions() const;
|
||
|
|
||
|
virtual QPrint::InputSlot defaultInputSlot() const;
|
||
|
- virtual QList<QPrint::InputSlot> supportedInputSlots() const;
|
||
|
+ virtual QVector<QPrint::InputSlot> supportedInputSlots() const;
|
||
|
|
||
|
virtual QPrint::OutputBin defaultOutputBin() const;
|
||
|
- virtual QList<QPrint::OutputBin> supportedOutputBins() const;
|
||
|
+ virtual QVector<QPrint::OutputBin> supportedOutputBins() const;
|
||
|
|
||
|
virtual QPrint::DuplexMode defaultDuplexMode() const;
|
||
|
- virtual QList<QPrint::DuplexMode> supportedDuplexModes() const;
|
||
|
+ virtual QVector<QPrint::DuplexMode> supportedDuplexModes() const;
|
||
|
|
||
|
virtual QPrint::ColorMode defaultColorMode() const;
|
||
|
- virtual QList<QPrint::ColorMode> supportedColorModes() const;
|
||
|
+ virtual QVector<QPrint::ColorMode> supportedColorModes() const;
|
||
|
|
||
|
virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
|
||
|
virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
|
||
|
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
|
||
|
index 7096f5a2f6..2bc6906364 100644
|
||
|
--- a/src/printsupport/kernel/qprintdevice.cpp
|
||
|
+++ b/src/printsupport/kernel/qprintdevice.cpp
|
||
|
@@ -210,9 +210,9 @@ QPrint::InputSlot QPrintDevice::defaultInputSlot() const
|
||
|
return isValid() ? d->defaultInputSlot() : QPrint::InputSlot();
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
|
||
|
+QVector<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
|
||
|
{
|
||
|
- return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>();
|
||
|
+ return isValid() ? d->supportedInputSlots() : QVector<QPrint::InputSlot>{};
|
||
|
}
|
||
|
|
||
|
QPrint::OutputBin QPrintDevice::defaultOutputBin() const
|
||
|
@@ -220,9 +220,9 @@ QPrint::OutputBin QPrintDevice::defaultOutputBin() const
|
||
|
return isValid() ? d->defaultOutputBin() : QPrint::OutputBin();
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
|
||
|
+QVector<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
|
||
|
{
|
||
|
- return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>();
|
||
|
+ return isValid() ? d->supportedOutputBins() : QVector<QPrint::OutputBin>{};
|
||
|
}
|
||
|
|
||
|
QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
|
||
|
@@ -230,9 +230,9 @@ QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
|
||
|
return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
|
||
|
+QVector<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
|
||
|
{
|
||
|
- return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>();
|
||
|
+ return isValid() ? d->supportedDuplexModes() : QVector<QPrint::DuplexMode>{};
|
||
|
}
|
||
|
|
||
|
QPrint::ColorMode QPrintDevice::defaultColorMode() const
|
||
|
@@ -240,9 +240,9 @@ QPrint::ColorMode QPrintDevice::defaultColorMode() const
|
||
|
return isValid() ? d->defaultColorMode() : QPrint::GrayScale;
|
||
|
}
|
||
|
|
||
|
-QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
|
||
|
+QVector<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
|
||
|
{
|
||
|
- return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>();
|
||
|
+ return isValid() ? d->supportedColorModes() : QVector<QPrint::ColorMode>{};
|
||
|
}
|
||
|
|
||
|
QVariant QPrintDevice::property(PrintDevicePropertyKey key) const
|
||
|
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
|
||
|
index 1a26d3afcf..3dff2e54fe 100644
|
||
|
--- a/src/printsupport/kernel/qprintdevice_p.h
|
||
|
+++ b/src/printsupport/kernel/qprintdevice_p.h
|
||
|
@@ -120,16 +120,16 @@ public:
|
||
|
QList<int> supportedResolutions() const;
|
||
|
|
||
|
QPrint::InputSlot defaultInputSlot() const;
|
||
|
- QList<QPrint::InputSlot> supportedInputSlots() const;
|
||
|
+ QVector<QPrint::InputSlot> supportedInputSlots() const;
|
||
|
|
||
|
QPrint::OutputBin defaultOutputBin() const;
|
||
|
- QList<QPrint::OutputBin> supportedOutputBins() const;
|
||
|
+ QVector<QPrint::OutputBin> supportedOutputBins() const;
|
||
|
|
||
|
QPrint::DuplexMode defaultDuplexMode() const;
|
||
|
- QList<QPrint::DuplexMode> supportedDuplexModes() const;
|
||
|
+ QVector<QPrint::DuplexMode> supportedDuplexModes() const;
|
||
|
|
||
|
QPrint::ColorMode defaultColorMode() const;
|
||
|
- QList<QPrint::ColorMode> supportedColorModes() const;
|
||
|
+ QVector<QPrint::ColorMode> supportedColorModes() const;
|
||
|
|
||
|
enum PrintDevicePropertyKey {
|
||
|
PDPK_CustomBase = 0xff00
|
||
|
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
|
||
|
index e399118cc9..ba234b3aae 100644
|
||
|
--- a/src/printsupport/kernel/qprintengine_win.cpp
|
||
|
+++ b/src/printsupport/kernel/qprintengine_win.cpp
|
||
|
@@ -1024,7 +1024,7 @@ bool QWin32PrintEnginePrivate::resetDC()
|
||
|
return hdc != 0;
|
||
|
}
|
||
|
|
||
|
-static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
|
||
|
+static int indexOfId(const QVector<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
|
||
|
{
|
||
|
for (int i = 0; i < inputSlots.size(); ++i) {
|
||
|
if (inputSlots.at(i).id == id)
|
||
|
@@ -1033,7 +1033,7 @@ static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSl
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
-static int indexOfWindowsId(const QList<QPrint::InputSlot> &inputSlots, int windowsId)
|
||
|
+static int indexOfWindowsId(const QVector<QPrint::InputSlot> &inputSlots, int windowsId)
|
||
|
{
|
||
|
for (int i = 0; i < inputSlots.size(); ++i) {
|
||
|
if (inputSlots.at(i).windowsId == windowsId)
|
||
|
@@ -1210,7 +1210,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||
|
case PPK_PaperSource: {
|
||
|
if (!d->devMode)
|
||
|
break;
|
||
|
- const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
|
||
|
+ const auto inputSlots = d->m_printDevice.supportedInputSlots();
|
||
|
const int paperSource = value.toInt();
|
||
|
const int index = paperSource >= DMBIN_USER ?
|
||
|
indexOfWindowsId(inputSlots, paperSource) : indexOfId(inputSlots, QPrint::InputSlotId(paperSource));
|
||
|
@@ -1465,7 +1465,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||
|
if (d->devMode->dmDefaultSource >= DMBIN_USER) {
|
||
|
value = int(d->devMode->dmDefaultSource);
|
||
|
} else {
|
||
|
- const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
|
||
|
+ const auto inputSlots = d->m_printDevice.supportedInputSlots();
|
||
|
const int index = indexOfWindowsId(inputSlots, d->devMode->dmDefaultSource);
|
||
|
value = index >= 0 ? inputSlots.at(index).id : QPrint::Auto;
|
||
|
}
|
||
|
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
|
||
|
index d271e069ad..49a0c9ece4 100644
|
||
|
--- a/src/printsupport/kernel/qprinterinfo.cpp
|
||
|
+++ b/src/printsupport/kernel/qprinterinfo.cpp
|
||
|
@@ -380,7 +380,7 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
|
||
|
{
|
||
|
Q_D(const QPrinterInfo);
|
||
|
QList<QPrinter::DuplexMode> list;
|
||
|
- const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
|
||
|
+ const auto supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
|
||
|
list.reserve(supportedDuplexModes.size());
|
||
|
for (QPrint::DuplexMode mode : supportedDuplexModes)
|
||
|
list << QPrinter::DuplexMode(mode);
|
||
|
--
|
||
|
2.15.1
|
||
|
|