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
|
||||
{
|
||||
m_data->mutex.lock();
|
||||
const QList<QUrl> result = m_data->selectedFiles;
|
||||
const auto result = m_data->selectedFiles;
|
||||
m_data->mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
inline QString QWindowsFileDialogSharedData::selectedFile() const
|
||||
{
|
||||
const QList<QUrl> files = selectedFiles();
|
||||
const auto files = selectedFiles();
|
||||
return files.isEmpty() ? QString() : files.front().toLocalFile();
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const
|
||||
|| pformatetc->cfFormat == CF_TEXT
|
||||
|| formatName == QStringLiteral("UniformResourceLocator")
|
||||
|| 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(); });
|
||||
}
|
||||
}
|
||||
|
@ -1388,7 +1388,7 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const
|
||||
if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
|
||||
const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods;
|
||||
const int matchedKey = int(key) + missingMods;
|
||||
const QList<int>::iterator it =
|
||||
const auto it =
|
||||
std::find_if(result.begin(), result.end(),
|
||||
[key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });
|
||||
// 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 += format;
|
||||
msg += "' is not available. Available formats: ";
|
||||
const QList<QByteArray> &formats = QImageReader::supportedImageFormats();
|
||||
const auto &formats = QImageReader::supportedImageFormats();
|
||||
for (const QByteArray &af : formats) {
|
||||
msg += af;
|
||||
msg += ' ';
|
||||
@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI()
|
||||
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||
{
|
||||
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
|
||||
const QList<QUrl> urls = mimeData->urls();
|
||||
const auto urls = mimeData->urls();
|
||||
for (const QUrl &url : urls) {
|
||||
if (url.isLocalFile())
|
||||
return true;
|
||||
@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
||||
{
|
||||
if (canConvertFromMime(formatetc, mimeData)) {
|
||||
if (getCf(formatetc) == CF_HDROP) {
|
||||
const QList<QUrl> &urls = mimeData->urls();
|
||||
const auto &urls = mimeData->urls();
|
||||
QStringList fileNames;
|
||||
int size = sizeof(DROPFILES)+2;
|
||||
for (const QUrl &url : urls) {
|
||||
@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
||||
return setData(result, pmedium);
|
||||
}
|
||||
if (getCf(formatetc) == CF_INETURL_W) {
|
||||
QList<QUrl> urls = mimeData->urls();
|
||||
const auto urls = mimeData->urls();
|
||||
QByteArray result;
|
||||
if (!urls.isEmpty()) {
|
||||
QString url = urls.at(0).toString();
|
||||
@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
|
||||
return setData(result, pmedium);
|
||||
}
|
||||
if (getCf(formatetc) == CF_INETURL) {
|
||||
QList<QUrl> urls = mimeData->urls();
|
||||
const auto urls = mimeData->urls();
|
||||
QByteArray result;
|
||||
if (!urls.isEmpty())
|
||||
result = urls.at(0).toString().toLocal8Bit();
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -95,7 +94,7 @@ public:
|
||||
private:
|
||||
void ensureInitialized() const;
|
||||
|
||||
mutable QList<QWindowsMime *> m_mimes;
|
||||
mutable QVector<QWindowsMime *> m_mimes;
|
||||
mutable int m_internalMimeCount = 0;
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
using WindowsScreenDataList = QList<QWindowsScreenData>;
|
||||
using WindowsScreenDataList = QVector<QWindowsScreenData>;
|
||||
|
||||
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
|
||||
{
|
||||
@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
|
||||
static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens,
|
||||
const QString &monitorName)
|
||||
{
|
||||
for (int i= 0; i < screens.size(); ++i)
|
||||
@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData,
|
||||
static inline int indexOfMonitor(const WindowsScreenDataList &screenData,
|
||||
const QString &monitorName)
|
||||
{
|
||||
for (int i = 0; i < screenData.size(); ++i)
|
||||
|
@ -127,7 +127,7 @@ private:
|
||||
class QWindowsScreenManager
|
||||
{
|
||||
public:
|
||||
using WindowsScreenList = QList<QWindowsScreen *>;
|
||||
using WindowsScreenList = QVector<QWindowsScreen *>;
|
||||
|
||||
QWindowsScreenManager();
|
||||
|
||||
|
@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co
|
||||
return posFrame;
|
||||
|
||||
// Find the original screen containing the coordinates.
|
||||
const QList<QScreen *> screens = screenForGL->virtualSiblings();
|
||||
const auto screens = screenForGL->virtualSiblings();
|
||||
const QScreen *orgScreen = nullptr;
|
||||
for (QScreen *screen : screens) {
|
||||
if (screen->handle()->availableGeometry().contains(posFrame)) {
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qvector.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY *
|
||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||
|
||||
// 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) {
|
||||
if (QAccessibleInterface *child = accessible->child(i)) {
|
||||
if (child->state().selected) {
|
||||
|
@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR
|
||||
if (!tableCellInterface)
|
||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||
|
||||
QList<QAccessibleInterface *> headers = tableCellInterface->rowHeaderCells();
|
||||
const auto headers = tableCellInterface->rowHeaderCells();
|
||||
|
||||
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
||||
for (LONG i = 0; i < headers.size(); ++i) {
|
||||
@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF
|
||||
if (!tableCellInterface)
|
||||
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||
|
||||
QList<QAccessibleInterface *> headers = tableCellInterface->columnHeaderCells();
|
||||
const auto headers = tableCellInterface->columnHeaderCells();
|
||||
|
||||
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
|
||||
for (LONG i = 0; i < headers.size(); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user