Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/dropjob.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 96 | { | |||
---|---|---|---|---|---|
97 | // Check for the drop of a bookmark -> we want a Link action | 97 | // Check for the drop of a bookmark -> we want a Link action | ||
98 | if (m_mimeData->hasFormat(QStringLiteral("application/x-xbel"))) { | 98 | if (m_mimeData->hasFormat(QStringLiteral("application/x-xbel"))) { | ||
99 | m_keyboardModifiers |= Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier); | 99 | m_keyboardModifiers |= Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier); | ||
100 | m_dropAction = Qt::LinkAction; | 100 | m_dropAction = Qt::LinkAction; | ||
101 | } | 101 | } | ||
102 | if (m_destItem.isNull() && m_destUrl.isLocalFile()) { | 102 | if (m_destItem.isNull() && m_destUrl.isLocalFile()) { | ||
103 | m_destItem = KFileItem(m_destUrl); | 103 | m_destItem = KFileItem(m_destUrl); | ||
104 | } | 104 | } | ||
105 | | ||||
106 | if (!(m_flags & KIO::NoPrivilegeExecution)) { | ||||
107 | m_privilegeExecutionEnabled = true; | ||||
dfaure: that line is clearly useless, given the line just before. | |||||
108 | switch (m_dropAction) { | ||||
109 | case Qt::CopyAction: | ||||
110 | m_operationType = Copy; | ||||
111 | break; | ||||
112 | case Qt::MoveAction: | ||||
113 | m_operationType = Move; | ||||
114 | break; | ||||
115 | case Qt::LinkAction: | ||||
116 | m_operationType = Symlink; | ||||
117 | break; | ||||
118 | default: | ||||
119 | m_operationType = Other; | ||||
120 | break; | ||||
121 | } | ||||
122 | } | ||||
105 | } | 123 | } | ||
106 | 124 | | |||
107 | bool destIsDirectory() const | 125 | bool destIsDirectory() const | ||
108 | { | 126 | { | ||
109 | if (!m_destItem.isNull()) { | 127 | if (!m_destItem.isNull()) { | ||
110 | return m_destItem.isDir(); | 128 | return m_destItem.isDir(); | ||
111 | } | 129 | } | ||
112 | // We support local dir, remote dir, local desktop file, local executable. | 130 | // We support local dir, remote dir, local desktop file, local executable. | ||
Show All 11 Lines | |||||
124 | const QMimeData *m_mimeData; | 142 | const QMimeData *m_mimeData; | ||
125 | const QList<QUrl> m_urls; | 143 | const QList<QUrl> m_urls; | ||
126 | QMap<QString, QString> m_metaData; | 144 | QMap<QString, QString> m_metaData; | ||
127 | Qt::DropAction m_dropAction; | 145 | Qt::DropAction m_dropAction; | ||
128 | QPoint m_relativePos; | 146 | QPoint m_relativePos; | ||
129 | Qt::KeyboardModifiers m_keyboardModifiers; | 147 | Qt::KeyboardModifiers m_keyboardModifiers; | ||
130 | QUrl m_destUrl; | 148 | QUrl m_destUrl; | ||
131 | KFileItem m_destItem; // null for remote URLs not found in the dirlister cache | 149 | KFileItem m_destItem; // null for remote URLs not found in the dirlister cache | ||
132 | const JobFlags m_flags; | 150 | const JobFlags m_flags; | ||
dfaure: can be const again, given the above comment | |||||
133 | QList<QAction *> m_appActions; | 151 | QList<QAction *> m_appActions; | ||
134 | QList<QAction *> m_pluginActions; | 152 | QList<QAction *> m_pluginActions; | ||
135 | bool m_triggered; // Tracks whether an action has been triggered in the popup menu. | 153 | bool m_triggered; // Tracks whether an action has been triggered in the popup menu. | ||
136 | QSet<KIO::DropMenu *> m_menus; | 154 | QSet<KIO::DropMenu *> m_menus; | ||
137 | 155 | | |||
138 | Q_DECLARE_PUBLIC(DropJob) | 156 | Q_DECLARE_PUBLIC(DropJob) | ||
139 | 157 | | |||
140 | void slotStart(); | 158 | void slotStart(); | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
238 | // Returns a KIO error code, in case of error. | 256 | // Returns a KIO error code, in case of error. | ||
239 | int DropJobPrivate::determineDropAction() | 257 | int DropJobPrivate::determineDropAction() | ||
240 | { | 258 | { | ||
241 | Q_Q(DropJob); | 259 | Q_Q(DropJob); | ||
242 | 260 | | |||
243 | if (!KProtocolManager::supportsWriting(m_destUrl)) { | 261 | if (!KProtocolManager::supportsWriting(m_destUrl)) { | ||
244 | return KIO::ERR_CANNOT_WRITE; | 262 | return KIO::ERR_CANNOT_WRITE; | ||
245 | } | 263 | } | ||
246 | if (!m_destItem.isNull() && !m_destItem.isWritable()) { | 264 | | ||
265 | if (!m_destItem.isNull() && !m_destItem.isWritable() && (m_flags & KIO::NoPrivilegeExecution)) { | ||||
247 | return KIO::ERR_WRITE_ACCESS_DENIED; | 266 | return KIO::ERR_WRITE_ACCESS_DENIED; | ||
248 | } | 267 | } | ||
249 | 268 | | |||
250 | bool allItemsAreFromTrash = true; | 269 | bool allItemsAreFromTrash = true; | ||
251 | bool containsTrashRoot = false; | 270 | bool containsTrashRoot = false; | ||
252 | foreach (const QUrl &url, m_urls) { | 271 | foreach (const QUrl &url, m_urls) { | ||
253 | const bool local = url.isLocalFile(); | 272 | const bool local = url.isLocalFile(); | ||
254 | if (!local /*optimization*/ && url.scheme() == QLatin1String("trash")) { | 273 | if (!local /*optimization*/ && url.scheme() == QLatin1String("trash")) { | ||
▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | 489 | case Qt::LinkAction: | |||
473 | break; | 492 | break; | ||
474 | default: | 493 | default: | ||
475 | qCWarning(KIO_WIDGETS) << "Unknown drop action" << int(m_dropAction); | 494 | qCWarning(KIO_WIDGETS) << "Unknown drop action" << int(m_dropAction); | ||
476 | q->setError(KIO::ERR_UNSUPPORTED_ACTION); | 495 | q->setError(KIO::ERR_UNSUPPORTED_ACTION); | ||
477 | q->emitResult(); | 496 | q->emitResult(); | ||
478 | return; | 497 | return; | ||
479 | } | 498 | } | ||
480 | Q_ASSERT(job); | 499 | Q_ASSERT(job); | ||
500 | job->setParentJob(q); | ||||
481 | job->setMetaData(m_metaData); | 501 | job->setMetaData(m_metaData); | ||
482 | QObject::connect(job, &KIO::CopyJob::copyingDone, q, [q](KIO::Job*, const QUrl &, const QUrl &to) { | 502 | QObject::connect(job, &KIO::CopyJob::copyingDone, q, [q](KIO::Job*, const QUrl &, const QUrl &to) { | ||
483 | emit q->itemCreated(to); | 503 | emit q->itemCreated(to); | ||
484 | }); | 504 | }); | ||
485 | QObject::connect(job, &KIO::CopyJob::copyingLinkDone, q, [q](KIO::Job*, const QUrl&, const QString&, const QUrl &to) { | 505 | QObject::connect(job, &KIO::CopyJob::copyingLinkDone, q, [q](KIO::Job*, const QUrl&, const QString&, const QUrl &to) { | ||
486 | emit q->itemCreated(to); | 506 | emit q->itemCreated(to); | ||
487 | }); | 507 | }); | ||
488 | q->addSubjob(job); | 508 | q->addSubjob(job); | ||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
that line is clearly useless, given the line just before.