┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2013-01-09 15:16:30 +0100
committerEmmanuel Pescosta <[email protected]>2013-01-09 15:16:30 +0100
commit804d8119b3e9afeb900d54814d665f820cb79adb (patch)
tree44881bd18152cd93cd528aabf22449fdacb9f67b
parent9f9cd60d1ca0c3a41a0d7ebaeb453917cddcf13e (diff)
Fix Bug 233335 - Wrong icons selected after pasting files and renaming them (because there exists items with it's names
Fixed the "same" buggy behavior when dropping files/folders Select also putted files (PUT operation - SimpleJob) - e.g. Paste content from clipboard BUG: 233335 REVIEW: 107351
-rw-r--r--src/dolphinmainwindow.cpp3
-rw-r--r--src/dolphinviewcontainer.cpp3
-rw-r--r--src/panels/folders/folderspanel.cpp3
-rw-r--r--src/panels/places/placespanel.cpp15
-rw-r--r--src/views/dolphinview.cpp32
-rw-r--r--src/views/dolphinview.h13
-rw-r--r--src/views/draganddrophelper.cpp16
-rw-r--r--src/views/draganddrophelper.h11
8 files changed, 55 insertions, 41 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 11e03d0f1..d72fb2305 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1276,7 +1276,8 @@ void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
const ViewTab& viewTab = m_viewTab[tab];
const DolphinView* view = viewTab.isPrimaryViewActive ? viewTab.primaryView->view()
: viewTab.secondaryView->view();
- const QString error = DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event);
+ QString error;
+ DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
if (!error.isEmpty()) {
activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
}
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 26a6803ae..b2c8605d8 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -620,7 +620,8 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
- const QString error = DragAndDropHelper::dropUrls(KFileItem(), destination, event);
+ QString error;
+ DragAndDropHelper::dropUrls(KFileItem(), destination, event, error);
if (!error.isEmpty()) {
showMessage(error, Error);
}
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp
index 6e3a7678f..8ce853a2a 100644
--- a/src/panels/folders/folderspanel.cpp
+++ b/src/panels/folders/folderspanel.cpp
@@ -236,7 +236,8 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
+ QString error;
+ DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent, error);
if (!error.isEmpty()) {
emit errorMessage(error);
}
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 61c15a7a1..9f9306946 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -352,7 +352,11 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->buttons(),
event->modifiers());
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent);
+ QString error;
+ DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent, error);
+ if (!error.isEmpty()) {
+ emit errorMessage(error);
+ }
}
void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
@@ -364,7 +368,11 @@ void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
if (success) {
KUrl destUrl = m_model->placesItem(index)->url();
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent);
+ QString error;
+ DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent, error);
+ if (!error.isEmpty()) {
+ emit errorMessage(error);
+ }
}
delete m_itemDropEventMimeData;
@@ -384,7 +392,8 @@ void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent*
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
Q_UNUSED(parent);
- const QString error = DragAndDropHelper::dropUrls(KFileItem(), dest, event);
+ QString error;
+ DragAndDropHelper::dropUrls(KFileItem(), dest, event, error);
if (!error.isEmpty()) {
emit errorMessage(error);
}
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index f0fad1976..9575ffba7 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1023,14 +1023,16 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent);
+ QString error;
+ KonqOperations* op = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
if (!error.isEmpty()) {
emit errorMessage(error);
}
- if (destUrl == url()) {
+ if (op && destUrl == url()) {
// Mark the dropped urls as selected.
- markPastedUrlsAsSelected(event->mimeData());
+ m_clearSelectionBeforeSelectingNewItems = true;
+ connect(op, SIGNAL(urlPasted(KUrl)), this, SLOT(slotUrlPasted(KUrl)));
}
}
@@ -1066,6 +1068,11 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons
}
}
+void DolphinView::slotAboutToCreate(const KUrl::List& urls)
+{
+ m_selectedUrls << urls;
+}
+
void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
{
const int currentCount = current.count();
@@ -1523,8 +1530,11 @@ void DolphinView::applyModeToView()
void DolphinView::pasteToUrl(const KUrl& url)
{
- markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
- KonqOperations::doPaste(this, url);
+ KonqOperations* op = KonqOperations::doPasteV2(this, url);
+ if (op) {
+ m_clearSelectionBeforeSelectingNewItems = true;
+ connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
+ }
}
KUrl::List DolphinView::simplifiedSelectedUrls() const
@@ -1552,18 +1562,6 @@ QMimeData* DolphinView::selectionMimeData() const
return m_model->createMimeData(selectedIndexes);
}
-void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
-{
- const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
- KUrl::List destUrls;
- foreach (const KUrl& source, sourceUrls) {
- KUrl destination(url().url() + '/' + source.fileName());
- destUrls << destination;
- }
- markUrlsAsSelected(destUrls);
- m_clearSelectionBeforeSelectingNewItems = true;
-}
-
void DolphinView::updateWritableState()
{
const bool wasFolderWritable = m_isFolderWritable;
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index a2fe9f62a..13cc66545 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -566,6 +566,11 @@ private slots:
void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
+ /*
+ * Is called when new items get pasted or dropped.
+ */
+ void slotAboutToCreate(const KUrl::List& urls);
+
/**
* Emits the signal \a selectionChanged() with a small delay. This is
* because getting all file items for the selection can be an expensive
@@ -722,14 +727,6 @@ private:
QMimeData* selectionMimeData() const;
/**
- * Is invoked after a paste operation or a drag & drop
- * operation and URLs from \a mimeData as selected.
- * This allows to select all newly pasted
- * items in restoreViewState().
- */
- void markPastedUrlsAsSelected(const QMimeData* mimeData);
-
- /**
* Updates m_isFolderWritable dependent on whether the folder represented by
* the current URL is writable. If the state has changed, the signal
* writeableStateChanged() will be emitted.
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index f81d4d0bf..f8ae0ad03 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -28,10 +28,13 @@
#include <QtDBus>
#include <QDropEvent>
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event)
+KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event, QString& error)
{
+ error.clear();
+
if (!destItem.isNull() && !destItem.isWritable()) {
- return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
+ error = i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
+ return 0;
}
const QMimeData* mimeData = event->mimeData();
@@ -49,15 +52,16 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destU
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
foreach (const KUrl& url, urls) {
if (url == destUrl) {
- return i18nc("@info:status", "A folder cannot be dropped into itself");
+ error = i18nc("@info:status", "A folder cannot be dropped into itself");
+ return 0;
}
}
- KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow());
+ return KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow(), QList<QAction*>());
} else {
- KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow());
+ return KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow(), QList<QAction*>());
}
- return QString();
+ return 0;
}
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index ac16f7cf2..eda5fc5c2 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -29,6 +29,7 @@ class KFileItem;
class KUrl;
class QDropEvent;
class QWidget;
+class KonqOperations;
class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper
{
@@ -46,13 +47,15 @@ public:
* @param destUrl URL of the item destination. Is used only if destItem::isNull()
* is true.
* @param event Drop event.
- * @return Error message intended to be shown for users if dropping is not
+ * @param error Error message intended to be shown for users if dropping is not
* possible. If an empty string is returned, the dropping has been
* successful.
+ * @return KonqOperations pointer
*/
- static QString dropUrls(const KFileItem& destItem,
- const KUrl& destUrl,
- QDropEvent* event);
+ static KonqOperations* dropUrls(const KFileItem& destItem,
+ const KUrl& destUrl,
+ QDropEvent* event,
+ QString& error);
};
#endif