Got OK from the translator team to add this new string.
void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
if (index >= 0) {
- const KFileItem destItem = fileItemModel()->fileItem(index);
+ KFileItemModel* model = fileItemModel();
+ KFileItem destItem = model->fileItem(index);
+ if (destItem.isNull()) {
+ destItem = model->rootItem();
+ if (destItem.isNull()) {
+ kWarning() << "No destination item available for drop operation.";
+ return;
+ }
+ }
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
event->buttons(),
event->modifiers());
- DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+ DragAndDropHelper::dropUrls(destItem, &dropEvent);
}
}
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
Q_UNUSED(parent);
- DragAndDropHelper::dropUrls(KFileItem(), dest, event);
+ const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, dest);
+ DragAndDropHelper::dropUrls(destItem, event);
}
void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
- const KFileItem destItem = fileItemModel()->fileItem(index);
+ KFileItem destItem = fileItemModel()->fileItem(index);
+ if (destItem.isNull()) {
+ destItem = fileItemModel()->rootItem();
+ if (destItem.isNull()) {
+ kWarning() << "No destination item available for drop operation.";
+ return;
+ }
+ }
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+ const QString error = DragAndDropHelper::dropUrls(destItem, &dropEvent);
if (!error.isEmpty()) {
emit errorMessage(error);
}
#include <QtDBus>
#include <QDropEvent>
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event)
+QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event)
{
- const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
- const KUrl destination = dropToItem ? destItem.url() : destPath;
+ Q_ASSERT(!destItem.isNull());
+
+ const KUrl destination = destItem.url();
+ if (!destItem.isWritable()) {
+ return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destination.pathOrUrl());
+ }
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-dndextract")) {
}
}
- if (dropToItem) {
- KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
- } else {
- KonqOperations::doDrop(KFileItem(), destination, event, QApplication::activeWindow());
- }
+ KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
}
return QString();
* destination. A context menu with the options
* 'Move Here', 'Copy Here', 'Link Here' and
* 'Cancel' is offered to the user.
- * @param destItem Item of the destination (can be null, see KFileItem::isNull()).
- * @param destPath Path of the destination.
+ * @param destItem Item of the destination.
* @param event Drop event.
* @return Error message if dropping is not possible. If an empty string
* is returned, the dropping has been successful.
*/
- static QString dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event);
+ static QString dropUrls(const KFileItem& destItem, QDropEvent* event);
};
#endif