diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2022-01-31 15:52:30 +0100 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2022-02-02 10:28:13 +0100 |
commit | 63937ffe6e2c0d62c419c981b210e38892bb566d (patch) | |
tree | 0caedeeb8fd91e205e0003038cbe37e3d4d6e7a6 /src/gui/itemmodels/qfilesystemmodel.cpp | |
parent | e2b98627a82e4cc9e8e47dd8bc71ef850becae7f (diff) |
Fix flags in QFileSystemModel
In 63eea5e5c69434871eaef9d9dc7184d7e54d7276, the
Qt::ItemNeverHasChildren flag was introduced. QFileSystemModel
was modified to use this flag for items which are not directories,
but only if the QFileSystemModel is not read-only and
the directory is writable.
This patch modifies QFileSystemModel to use the ItemNeverHasChildren
flags also if the model is read-only and if the item
is read-only.
Amends 63eea5e5c69434871eaef9d9dc7184d7e54d7276
Change-Id: Ie7f7d58ecf7baade93f9f03d120da84d3c005d42
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'src/gui/itemmodels/qfilesystemmodel.cpp')
-rw-r--r-- | src/gui/itemmodels/qfilesystemmodel.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/itemmodels/qfilesystemmodel.cpp b/src/gui/itemmodels/qfilesystemmodel.cpp index 0ee97d06be..d29a1c0114 100644 --- a/src/gui/itemmodels/qfilesystemmodel.cpp +++ b/src/gui/itemmodels/qfilesystemmodel.cpp @@ -987,14 +987,15 @@ Qt::ItemFlags QFileSystemModel::flags(const QModelIndex &index) const } flags |= Qt::ItemIsDragEnabled; + + if (!indexNode->isDir()) + flags |= Qt::ItemNeverHasChildren; if (d->readOnly) return flags; if ((index.column() == 0) && indexNode->permissions() & QFile::WriteUser) { flags |= Qt::ItemIsEditable; if (indexNode->isDir()) flags |= Qt::ItemIsDropEnabled; - else - flags |= Qt::ItemNeverHasChildren; } return flags; } |