Windows QPA: Port from QList to QVector
Use a QVector where possible. Otherwise, try to introduce auto to make migration easier. Change-Id: I9deadb363fabd1755deca180ed5cb771390fcb30 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
1315133233
commit
c355602595
@ -466,14 +466,14 @@ inline void QWindowsFileDialogSharedData::setSelectedNameFilter(const QString &f
|
|||||||
inline QList<QUrl> QWindowsFileDialogSharedData::selectedFiles() const
|
inline QList<QUrl> QWindowsFileDialogSharedData::selectedFiles() const
|
||||||
{
|
{
|
||||||
m_data->mutex.lock();
|
m_data->mutex.lock();
|
||||||
const QList<QUrl> result = m_data->selectedFiles;
|
const auto result = m_data->selectedFiles;
|
||||||
m_data->mutex.unlock();
|
m_data->mutex.unlock();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString QWindowsFileDialogSharedData::selectedFile() const
|
inline QString QWindowsFileDialogSharedData::selectedFile() const
|
||||||
{
|
{
|
||||||
const QList<QUrl> files = selectedFiles();
|
const auto files = selectedFiles();
|
||||||
return files.isEmpty() ? QString() : files.front().toLocalFile();
|
return files.isEmpty() ? QString() : files.front().toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const
|
|||||||
|| pformatetc->cfFormat == CF_TEXT
|
|| pformatetc->cfFormat == CF_TEXT
|
||||||
|| formatName == QStringLiteral("UniformResourceLocator")
|
|| formatName == QStringLiteral("UniformResourceLocator")
|
||||||
|| formatName == QStringLiteral("UniformResourceLocatorW")) {
|
|| formatName == QStringLiteral("UniformResourceLocatorW")) {
|
||||||
QList<QUrl> urls = dropData->urls();
|
const auto urls = dropData->urls();
|
||||||
return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); });
|
return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1388,7 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const
|
|||||||
if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
|
if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
|
||||||
const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods;
|
const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods;
|
||||||
const int matchedKey = int(key) + missingMods;
|
const int matchedKey = int(key) + missingMods;
|
||||||
const QList<int>::iterator it =
|
const auto it =
|
||||||
std::find_if(result.begin(), result.end(),
|
std::find_if(result.begin(), result.end(),
|
||||||
[key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });
|
[key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });
|
||||||
// QTBUG-67200: Use the match with the least modifiers (prefer
|
// QTBUG-67200: Use the match with the least modifiers (prefer
|
||||||
|
@ -107,7 +107,7 @@ static inline QByteArray msgConversionError(const char *func, const char *format
|
|||||||
msg += ": Unable to convert DIB image. The image converter plugin for '";
|
msg += ": Unable to convert DIB image. The image converter plugin for '";
|
||||||
msg += format;
|
msg += format;
|
||||||
msg += "' is not available. Available formats: ";
|
msg += "' is not available. Available formats: ";
|
||||||
const QList<QByteArray> &formats = QImageReader::supportedImageFormats();
|
const auto &formats = QImageReader::supportedImageFormats();
|
||||||
for (const QByteArray &af : formats) {
|
for (const QByteArray &af : formats) {
|
||||||
msg += af;
|
msg += af;
|
||||||
msg += ' ';
|
msg += ' ';
|
||||||
@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI()
|
|||||||
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||||
{
|
{
|
||||||
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
|
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
|
||||||
const QList<QUrl> urls = mimeData->urls();
|
const auto urls = mimeData->urls();
|
||||||
for (const QUrl &url : urls) {
|
for (const QUrl &url : urls) {
|
||||||
if (url.isLocalFile())
|
if (url.isLocalFile())
|
||||||
return true;
|
return true;
|
||||||
@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
{
|
{
|
||||||
if (canConvertFromMime(formatetc, mimeData)) {
|
if (canConvertFromMime(formatetc, mimeData)) {
|
||||||
if (getCf(formatetc) == CF_HDROP) {
|
if (getCf(formatetc) == CF_HDROP) {
|
||||||
const QList<QUrl> &urls = mimeData->urls();
|
const auto &urls = mimeData->urls();
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
int size = sizeof(DROPFILES)+2;
|
int size = sizeof(DROPFILES)+2;
|
||||||
for (const QUrl &url : urls) {
|
for (const QUrl &url : urls) {
|
||||||
@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
return setData(result, pmedium);
|
return setData(result, pmedium);
|
||||||
}
|
}
|
||||||
if (getCf(formatetc) == CF_INETURL_W) {
|
if (getCf(formatetc) == CF_INETURL_W) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
const auto urls = mimeData->urls();
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
if (!urls.isEmpty()) {
|
if (!urls.isEmpty()) {
|
||||||
QString url = urls.at(0).toString();
|
QString url = urls.at(0).toString();
|
||||||
@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
|||||||
return setData(result, pmedium);
|
return setData(result, pmedium);
|
||||||
}
|
}
|
||||||
if (getCf(formatetc) == CF_INETURL) {
|
if (getCf(formatetc) == CF_INETURL) {
|
||||||
QList<QUrl> urls = mimeData->urls();
|
const auto urls = mimeData->urls();
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
if (!urls.isEmpty())
|
if (!urls.isEmpty())
|
||||||
result = urls.at(0).toString().toLocal8Bit();
|
result = urls.at(0).toString().toLocal8Bit();
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include <QtCore/qt_windows.h>
|
#include <QtCore/qt_windows.h>
|
||||||
|
|
||||||
#include <QtCore/qvector.h>
|
#include <QtCore/qvector.h>
|
||||||
#include <QtCore/qlist.h>
|
|
||||||
#include <QtCore/qvariant.h>
|
#include <QtCore/qvariant.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -95,7 +94,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void ensureInitialized() const;
|
void ensureInitialized() const;
|
||||||
|
|
||||||
mutable QList<QWindowsMime *> m_mimes;
|
mutable QVector<QWindowsMime *> m_mimes;
|
||||||
mutable int m_internalMimeCount = 0;
|
mutable int m_internalMimeCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
|
|||||||
return {0, 0};
|
return {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
using WindowsScreenDataList = QList<QWindowsScreenData>;
|
using WindowsScreenDataList = QVector<QWindowsScreenData>;
|
||||||
|
|
||||||
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
|
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
|
||||||
{
|
{
|
||||||
@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
|
static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens,
|
||||||
const QString &monitorName)
|
const QString &monitorName)
|
||||||
{
|
{
|
||||||
for (int i= 0; i < screens.size(); ++i)
|
for (int i= 0; i < screens.size(); ++i)
|
||||||
@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData,
|
static inline int indexOfMonitor(const WindowsScreenDataList &screenData,
|
||||||
const QString &monitorName)
|
const QString &monitorName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < screenData.size(); ++i)
|
for (int i = 0; i < screenData.size(); ++i)
|
||||||
|
@ -127,7 +127,7 @@ private:
|
|||||||
class QWindowsScreenManager
|
class QWindowsScreenManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using WindowsScreenList = QList<QWindowsScreen *>;
|
using WindowsScreenList = QVector<QWindowsScreen *>;
|
||||||
|
|
||||||
QWindowsScreenManager();
|
QWindowsScreenManager();
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co
|
|||||||
return posFrame;
|
return posFrame;
|
||||||
|
|
||||||
// Find the original screen containing the coordinates.
|
// Find the original screen containing the coordinates.
|
||||||
const QList<QScreen *> screens = screenForGL->virtualSiblings();
|
const auto screens = screenForGL->virtualSiblings();
|
||||||
const QScreen *orgScreen = nullptr;
|
const QScreen *orgScreen = nullptr;
|
||||||
for (QScreen *screen : screens) {
|
for (QScreen *screen : screens) {
|
||||||
if (screen->handle()->availableGeometry().contains(posFrame)) {
|
if (screen->handle()->availableGeometry().contains(posFrame)) {
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
|
#include <QtCore/qvector.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY *
|
|||||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||||
|
|
||||||
// First put selected items in a list, then build a safe array with the right size.
|
// First put selected items in a list, then build a safe array with the right size.
|
||||||
QList<QAccessibleInterface *> selectedList;
|
QVector<QAccessibleInterface *> selectedList;
|
||||||
for (int i = 0; i < accessible->childCount(); ++i) {
|
for (int i = 0; i < accessible->childCount(); ++i) {
|
||||||
if (QAccessibleInterface *child = accessible->child(i)) {
|
if (QAccessibleInterface *child = accessible->child(i)) {
|
||||||
if (child->state().selected) {
|
if (child->state().selected) {
|
||||||
|
@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR
|
|||||||
if (!tableCellInterface)
|
if (!tableCellInterface)
|
||||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||||
|
|
||||||
QList<QAccessibleInterface *> headers = tableCellInterface->rowHeaderCells();
|
const auto headers = tableCellInterface->rowHeaderCells();
|
||||||
|
|
||||||
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
||||||
for (LONG i = 0; i < headers.size(); ++i) {
|
for (LONG i = 0; i < headers.size(); ++i) {
|
||||||
@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF
|
|||||||
if (!tableCellInterface)
|
if (!tableCellInterface)
|
||||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||||
|
|
||||||
QList<QAccessibleInterface *> headers = tableCellInterface->columnHeaderCells();
|
const auto headers = tableCellInterface->columnHeaderCells();
|
||||||
|
|
||||||
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
||||||
for (LONG i = 0; i < headers.size(); ++i) {
|
for (LONG i = 0; i < headers.size(); ++i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user