From 1d0ee8954825a38b789351558a04cbde04fa0490 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2017 11:24:15 +0100 Subject: QSideBar: replace a QPair with a struct Instead of the incomprehensible "names" .first and .second, the code can now use .index and .path. Change-Id: I1449ba668f703b9a8b9391b0a0774072c8c6e8aa Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qsidebar.cpp | 10 +++++----- src/widgets/dialogs/qsidebar_p.h | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index 713ccb6556..9bb046db61 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -274,7 +274,7 @@ void QUrlModel::addUrls(const QList &list, int row, bool move) continue; insertRows(row, 1); setUrl(index(row, 0), url, idx); - watching.append(qMakePair(idx, cleanUrl)); + watching.append({idx, cleanUrl}); } } @@ -326,7 +326,7 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto { QModelIndex parent = topLeft.parent(); for (int i = 0; i < watching.count(); ++i) { - QModelIndex index = watching.at(i).first; + QModelIndex index = watching.at(i).index; if (index.model() && topLeft.model()) { Q_ASSERT(index.model() == topLeft.model()); } @@ -335,7 +335,7 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto && index.column() >= topLeft.column() && index.column() <= bottomRight.column() && index.parent() == parent) { - changed(watching.at(i).second); + changed(watching.at(i).path); } } } @@ -349,12 +349,12 @@ void QUrlModel::layoutChanged() const int numPaths = watching.count(); paths.reserve(numPaths); for (int i = 0; i < numPaths; ++i) - paths.append(watching.at(i).second); + paths.append(watching.at(i).path); watching.clear(); for (int i = 0; i < numPaths; ++i) { QString path = paths.at(i); QModelIndex newIndex = fileSystemModel->index(path); - watching.append(QPair(newIndex, path)); + watching.append({newIndex, path}); if (newIndex.isValid()) changed(path); } diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 3e177e7e68..0685e81b2b 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -108,9 +108,16 @@ private: void changed(const QString &path); void addIndexToWatch(const QString &path, const QModelIndex &index); QFileSystemModel *fileSystemModel; - QVector > watching; + struct WatchItem { + QModelIndex index; + QString path; + }; + friend class QTypeInfo; + + QVector watching; QList invalidUrls; }; +Q_DECLARE_TYPEINFO(QUrlModel::WatchItem, Q_MOVABLE_TYPE); class Q_AUTOTEST_EXPORT QSidebar : public QListView { -- cgit v1.2.3