Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/dropjob.cpp
Show First 20 Lines • Show All 261 Lines • ▼ Show 20 Line(s) | 257 | { | |||
---|---|---|---|---|---|
262 | } | 262 | } | ||
263 | 263 | | |||
264 | if (!m_destItem.isNull() && !m_destItem.isWritable() && (m_flags & KIO::NoPrivilegeExecution)) { | 264 | if (!m_destItem.isNull() && !m_destItem.isWritable() && (m_flags & KIO::NoPrivilegeExecution)) { | ||
265 | return KIO::ERR_WRITE_ACCESS_DENIED; | 265 | return KIO::ERR_WRITE_ACCESS_DENIED; | ||
266 | } | 266 | } | ||
267 | 267 | | |||
268 | bool allItemsAreFromTrash = true; | 268 | bool allItemsAreFromTrash = true; | ||
269 | bool containsTrashRoot = false; | 269 | bool containsTrashRoot = false; | ||
270 | foreach (const QUrl &url, m_urls) { | 270 | for (const QUrl &url : m_urls) { | ||
dfaure: qAsConst | |||||
m_urls is declared const in DropJobPrivate: https://cgit.kde.org/kio.git/tree/src/widgets/dropjob.cpp#n142 ahmadsamir: m_urls is declared const in DropJobPrivate: https://cgit.kde.org/kio. | |||||
dfaure: Oh, interesting :-) | |||||
271 | const bool local = url.isLocalFile(); | 271 | const bool local = url.isLocalFile(); | ||
272 | if (!local /*optimization*/ && url.scheme() == QLatin1String("trash")) { | 272 | if (!local /*optimization*/ && url.scheme() == QLatin1String("trash")) { | ||
273 | if (url.path().isEmpty() || url.path() == QLatin1String("/")) { | 273 | if (url.path().isEmpty() || url.path() == QLatin1String("/")) { | ||
274 | containsTrashRoot = true; | 274 | containsTrashRoot = true; | ||
275 | } | 275 | } | ||
276 | } else { | 276 | } else { | ||
277 | allItemsAreFromTrash = false; | 277 | allItemsAreFromTrash = false; | ||
278 | } | 278 | } | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
321 | { | 321 | { | ||
322 | Q_Q(DropJob); | 322 | Q_Q(DropJob); | ||
323 | 323 | | |||
324 | // Check what the source can do | 324 | // Check what the source can do | ||
325 | // TODO: Determining the mimetype of the source URLs is difficult for remote URLs, | 325 | // TODO: Determining the mimetype of the source URLs is difficult for remote URLs, | ||
326 | // we would need to KIO::stat each URL in turn, asynchronously.... | 326 | // we would need to KIO::stat each URL in turn, asynchronously.... | ||
327 | KFileItemList fileItems; | 327 | KFileItemList fileItems; | ||
328 | fileItems.reserve(m_urls.size()); | 328 | fileItems.reserve(m_urls.size()); | ||
329 | foreach (const QUrl &url, m_urls) { | 329 | for (const QUrl &url : m_urls) { | ||
dfaure: qAsConst | |||||
330 | fileItems.append(KFileItem(url)); | 330 | fileItems.append(KFileItem(url)); | ||
331 | } | 331 | } | ||
332 | const KFileItemListProperties itemProps(fileItems); | 332 | const KFileItemListProperties itemProps(fileItems); | ||
333 | 333 | | |||
334 | emit q->popupMenuAboutToShow(itemProps); | 334 | emit q->popupMenuAboutToShow(itemProps); | ||
335 | 335 | | |||
336 | const bool sReading = itemProps.supportsReading(); | 336 | const bool sReading = itemProps.supportsReading(); | ||
337 | const bool sDeleting = itemProps.supportsDeleting(); | 337 | const bool sDeleting = itemProps.supportsDeleting(); | ||
Show All 15 Lines | |||||
353 | Q_ASSERT(seq.endsWith(QLatin1Char('+'))); | 353 | Q_ASSERT(seq.endsWith(QLatin1Char('+'))); | ||
354 | seq.chop(1); | 354 | seq.chop(1); | ||
355 | QAction* popupLinkAction = new QAction(i18n("&Link Here") + QLatin1Char('\t') + seq, popup); | 355 | QAction* popupLinkAction = new QAction(i18n("&Link Here") + QLatin1Char('\t') + seq, popup); | ||
356 | popupLinkAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-link"))); | 356 | popupLinkAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-link"))); | ||
357 | popupLinkAction->setData(QVariant::fromValue(Qt::LinkAction)); | 357 | popupLinkAction->setData(QVariant::fromValue(Qt::LinkAction)); | ||
358 | 358 | | |||
359 | if (sMoving || (sReading && sDeleting)) { | 359 | if (sMoving || (sReading && sDeleting)) { | ||
360 | bool equalDestination = true; | 360 | bool equalDestination = true; | ||
361 | foreach (const QUrl &src, m_urls) { | 361 | for (const QUrl &src : m_urls) { | ||
dfaure: qAsConst | |||||
362 | if (!m_destUrl.matches(src.adjusted(QUrl::RemoveFilename), QUrl::StripTrailingSlash)) { | 362 | if (!m_destUrl.matches(src.adjusted(QUrl::RemoveFilename), QUrl::StripTrailingSlash)) { | ||
363 | equalDestination = false; | 363 | equalDestination = false; | ||
364 | break; | 364 | break; | ||
365 | } | 365 | } | ||
366 | } | 366 | } | ||
367 | 367 | | |||
368 | if (!equalDestination) { | 368 | if (!equalDestination) { | ||
369 | popup->addAction(popupMoveAction); | 369 | popup->addAction(popupMoveAction); | ||
Show All 9 Lines | |||||
379 | addPluginActions(popup, itemProps); | 379 | addPluginActions(popup, itemProps); | ||
380 | 380 | | |||
381 | popup->addSeparator(); | 381 | popup->addSeparator(); | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | void DropJobPrivate::addPluginActions(KIO::DropMenu *popup, const KFileItemListProperties &itemProps) | 384 | void DropJobPrivate::addPluginActions(KIO::DropMenu *popup, const KFileItemListProperties &itemProps) | ||
385 | { | 385 | { | ||
386 | const QVector<KPluginMetaData> plugin_offers = KPluginLoader::findPlugins(QStringLiteral("kf5/kio_dnd")); | 386 | const QVector<KPluginMetaData> plugin_offers = KPluginLoader::findPlugins(QStringLiteral("kf5/kio_dnd")); | ||
387 | foreach (const KPluginMetaData &service, plugin_offers) { | 387 | for (const KPluginMetaData &service : plugin_offers) { | ||
388 | KPluginFactory *factory = KPluginLoader(service.fileName()).factory(); | 388 | KPluginFactory *factory = KPluginLoader(service.fileName()).factory(); | ||
389 | if (factory) { | 389 | if (factory) { | ||
390 | KIO::DndPopupMenuPlugin *plugin = factory->create<KIO::DndPopupMenuPlugin>(); | 390 | KIO::DndPopupMenuPlugin *plugin = factory->create<KIO::DndPopupMenuPlugin>(); | ||
391 | if (plugin) { | 391 | if (plugin) { | ||
392 | const auto actions = plugin->setup(itemProps, m_destUrl); | 392 | const auto actions = plugin->setup(itemProps, m_destUrl); | ||
393 | for (auto action : actions) { | 393 | for (auto action : actions) { | ||
394 | action->setParent(popup); | 394 | action->setParent(popup); | ||
395 | } | 395 | } | ||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |
qAsConst