diff options
| author | Méven Car <[email protected]> | 2023-02-23 11:06:12 +0100 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2023-03-16 14:27:52 +0000 |
| commit | 9967a5cdee3ca7027871a6b2b640e94435d6b7af (patch) | |
| tree | bad3b840bb60a934f618625a14bddf800a635fc6 /src/kitemviews/kfileitemmodel.cpp | |
| parent | 43c2963b52c7b1aabcb57421e7d371a9463bf553 (diff) | |
Prevent dragging on non-writable directories
KFileItemModel::supportsDroppin now returns the rootItem when -1 is passed and checks for write access.
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index c7b3af76b..ebcd4b912 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -324,8 +324,13 @@ int KFileItemModel::indexForKeyboardSearch(const QString &text, int startFromInd bool KFileItemModel::supportsDropping(int index) const { - const KFileItem item = fileItem(index); - return !item.isNull() && (item.isDir() || item.isDesktopFile()); + KFileItem item; + if (index == -1) { + item = rootItem(); + } else { + item = fileItem(index); + } + return !item.isNull() && ((item.isDir() && item.isWritable()) || item.isDesktopFile()); } QString KFileItemModel::roleDescription(const QByteArray &role) const |
