From e81ece3f8f4f930182f2b415e387691b7fa8c985 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 9 Jul 2019 10:01:01 +0200 Subject: QFileSystemModel: Improve class structure Use member initialization in private classes and repack members to minimize padding. Use delegating constructors and default constructors/destructors. Task-number: QTBUG-76493 Change-Id: Iaea8880811782ee5846c128590b83c23e6fae445 Reviewed-by: Volker Hilsheimer --- src/widgets/dialogs/qfilesystemmodel_p.h | 55 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 35 deletions(-) (limited to 'src/widgets/dialogs/qfilesystemmodel_p.h') diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index d8f9f2b076..844e417e2d 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -99,13 +99,13 @@ public: class QFileSystemNode { public: + Q_DISABLE_COPY_MOVE(QFileSystemNode) + explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = nullptr) - : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(nullptr) {} + : fileName(filename), parent(p) {} ~QFileSystemNode() { qDeleteAll(children); delete info; - info = nullptr; - parent = nullptr; } QString fileName; @@ -204,31 +204,16 @@ public: } } - bool populatedChildren; - bool isVisible; QHash children; QList visibleChildren; - int dirtyChildrenIndex; + QExtendedInformation *info = nullptr; QFileSystemNode *parent; - - - QExtendedInformation *info; - + int dirtyChildrenIndex = -1; + bool populatedChildren = false; + bool isVisible = false; }; - QFileSystemModelPrivate() : - forceSort(true), - sortColumn(0), - sortOrder(Qt::AscendingOrder), - readOnly(true), - setRootPath(false), - filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs), - nameFilterDisables(true), // false on windows, true on mac and unix - disableRecursiveSort(false) - { - delayedSortTimer.setSingleShot(true); - } - + QFileSystemModelPrivate() = default; void init(); /* \internal @@ -303,18 +288,7 @@ public: QFileInfoGatherer fileInfoGatherer; #endif // filesystemwatcher QTimer delayedSortTimer; - bool forceSort; - int sortColumn; - Qt::SortOrder sortOrder; - bool readOnly; - bool setRootPath; - QDir::Filters filters; QHash bypassFilters; - bool nameFilterDisables; - //This flag is an optimization for the QFileDialog - //It enable a sort which is not recursive, it means - //we sort only what we see. - bool disableRecursiveSort; #if QT_CONFIG(regularexpression) QStringList nameFilters; #endif @@ -322,7 +296,6 @@ public: QFileSystemNode root; - QBasicTimer fetchingTimer; struct Fetching { QString dir; QString file; @@ -330,6 +303,18 @@ public: }; QVector toFetch; + QBasicTimer fetchingTimer; + + QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs; + int sortColumn = 0; + Qt::SortOrder sortOrder = Qt::AscendingOrder; + bool forceSort = true; + bool readOnly = true; + bool setRootPath = false; + bool nameFilterDisables = true; // false on windows, true on mac and unix + // This flag is an optimization for QFileDialog. It enables a sort which is + // not recursive, meaning we sort only what we see. + bool disableRecursiveSort = false; }; Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE); -- cgit v1.2.3