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>bb10
parent
2356c173b2
commit
5cb54cb5eb
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue