Changeset View
Changeset View
Standalone View
Standalone View
src/core/kfileitemlistproperties.cpp
Show All 31 Lines | |||||
32 | public: | 32 | public: | ||
33 | KFileItemListPropertiesPrivate() | 33 | KFileItemListPropertiesPrivate() | ||
34 | : m_isDirectory(false), | 34 | : m_isDirectory(false), | ||
35 | m_isFile(false), | 35 | m_isFile(false), | ||
36 | m_supportsReading(false), | 36 | m_supportsReading(false), | ||
37 | m_supportsDeleting(false), | 37 | m_supportsDeleting(false), | ||
38 | m_supportsWriting(false), | 38 | m_supportsWriting(false), | ||
39 | m_supportsMoving(false), | 39 | m_supportsMoving(false), | ||
40 | m_supportsPrivilegeExecution(false), | ||||
40 | m_isLocal(true) | 41 | m_isLocal(true) | ||
41 | { } | 42 | { } | ||
42 | void setItems(const KFileItemList &items); | 43 | void setItems(const KFileItemList &items); | ||
43 | 44 | | |||
44 | void determineMimeTypeAndGroup() const; | 45 | void determineMimeTypeAndGroup() const; | ||
45 | 46 | | |||
46 | KFileItemList m_items; | 47 | KFileItemList m_items; | ||
47 | mutable QString m_mimeType; | 48 | mutable QString m_mimeType; | ||
48 | mutable QString m_mimeGroup; | 49 | mutable QString m_mimeGroup; | ||
49 | bool m_isDirectory : 1; | 50 | bool m_isDirectory : 1; | ||
50 | bool m_isFile : 1; | 51 | bool m_isFile : 1; | ||
51 | bool m_supportsReading : 1; | 52 | bool m_supportsReading : 1; | ||
52 | bool m_supportsDeleting : 1; | 53 | bool m_supportsDeleting : 1; | ||
53 | bool m_supportsWriting : 1; | 54 | bool m_supportsWriting : 1; | ||
54 | bool m_supportsMoving : 1; | 55 | bool m_supportsMoving : 1; | ||
56 | bool m_supportsPrivilegeExecution : 1; | ||||
55 | bool m_isLocal : 1; | 57 | bool m_isLocal : 1; | ||
56 | }; | 58 | }; | ||
57 | 59 | | |||
58 | KFileItemListProperties::KFileItemListProperties() | 60 | KFileItemListProperties::KFileItemListProperties() | ||
59 | : d(new KFileItemListPropertiesPrivate) | 61 | : d(new KFileItemListPropertiesPrivate) | ||
60 | { | 62 | { | ||
61 | } | 63 | } | ||
62 | 64 | | |||
Show All 22 Lines | 77 | { | |||
85 | m_mimeType.clear(); | 87 | m_mimeType.clear(); | ||
86 | m_mimeGroup.clear(); | 88 | m_mimeGroup.clear(); | ||
87 | 89 | | |||
88 | QFileInfo parentDirInfo; | 90 | QFileInfo parentDirInfo; | ||
89 | for (const KFileItem &item : items) { | 91 | for (const KFileItem &item : items) { | ||
90 | bool isLocal = false; | 92 | bool isLocal = false; | ||
91 | const QUrl url = item.mostLocalUrl(&isLocal); | 93 | const QUrl url = item.mostLocalUrl(&isLocal); | ||
92 | m_isLocal = m_isLocal && isLocal; | 94 | m_isLocal = m_isLocal && isLocal; | ||
95 | m_supportsPrivilegeExecution = KProtocolManager::supportsPrivilegeExecution(url); | ||||
93 | m_supportsReading = m_supportsReading && KProtocolManager::supportsReading(url); | 96 | m_supportsReading = m_supportsReading && KProtocolManager::supportsReading(url); | ||
94 | m_supportsDeleting = m_supportsDeleting && KProtocolManager::supportsDeleting(url); | 97 | m_supportsDeleting = m_supportsDeleting && KProtocolManager::supportsDeleting(url); | ||
95 | m_supportsWriting = m_supportsWriting && KProtocolManager::supportsWriting(url) && item.isWritable(); | 98 | m_supportsWriting = m_supportsWriting && KProtocolManager::supportsWriting(url) && (m_supportsPrivilegeExecution ||item.isWritable()); | ||
96 | m_supportsMoving = m_supportsMoving && KProtocolManager::supportsMoving(url); | 99 | m_supportsMoving = m_supportsMoving && KProtocolManager::supportsMoving(url); | ||
97 | 100 | | |||
98 | // For local files we can do better: check if we have write permission in parent directory | 101 | // For local files we can do better: check if we have write permission in parent directory | ||
99 | // TODO: if we knew about the parent KFileItem, we could even do that for remote protocols too | 102 | // TODO: if we knew about the parent KFileItem, we could even do that for remote protocols too | ||
100 | #ifndef Q_OS_WIN | 103 | #ifndef Q_OS_WIN | ||
101 | if (m_isLocal && (m_supportsDeleting || m_supportsMoving)) { | 104 | if (m_isLocal && (m_supportsDeleting || m_supportsMoving)) { | ||
102 | const QString directory = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile(); | 105 | const QString directory = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile(); | ||
103 | if (parentDirInfo.filePath() != directory) { | 106 | if (parentDirInfo.filePath() != directory) { | ||
104 | parentDirInfo.setFile(directory); | 107 | parentDirInfo.setFile(directory); | ||
105 | } | 108 | } | ||
106 | if (!parentDirInfo.isWritable()) { | 109 | if (!parentDirInfo.isWritable() && !m_supportsPrivilegeExecution) { | ||
107 | m_supportsDeleting = false; | 110 | m_supportsDeleting = false; | ||
108 | m_supportsMoving = false; | 111 | m_supportsMoving = false; | ||
109 | } | 112 | } | ||
110 | } | 113 | } | ||
111 | #else | 114 | #else | ||
112 | if (m_isLocal && m_supportsDeleting) { | 115 | if (m_isLocal && m_supportsDeleting) { | ||
113 | if (!QFileInfo(url.toLocalFile()).isWritable()) | 116 | if (!QFileInfo(url.toLocalFile()).isWritable()) | ||
114 | m_supportsDeleting = false; | 117 | m_supportsDeleting = false; | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |