┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-10-30 19:44:55 +0000
committerPeter Penz <[email protected]>2007-10-30 19:44:55 +0000
commitd9f5e191a6bd32a4dc15b3a3eb34795cda7697dd (patch)
tree0d03dac95431421dd5045a09f8c1e921098df3b6
parent65c11d72c949695143023641e59f2d1bb645d39d (diff)
* fixed drag & drop issue in column view (dropping on files was not possible -> handled as viewport now)
* only show the hover-drop-indicator on directories (dropping on file-items is handled like dropping on the viewport) * simplified signature of drop signal (source widget not required anymore) svn path=/trunk/KDE/kdebase/apps/; revision=731129
-rw-r--r--src/dolphincolumnwidget.cpp19
-rw-r--r--src/dolphincontroller.cpp5
-rw-r--r--src/dolphincontroller.h10
-rw-r--r--src/dolphindetailsview.cpp16
-rw-r--r--src/dolphiniconsview.cpp19
-rw-r--r--src/dolphinview.cpp26
-rw-r--r--src/dolphinview.h6
7 files changed, 45 insertions, 56 deletions
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp
index c212e6ad8..e2670f10d 100644
--- a/src/dolphincolumnwidget.cpp
+++ b/src/dolphincolumnwidget.cpp
@@ -222,7 +222,11 @@ void DolphinColumnWidget::dragMoveEvent(QDragMoveEvent* event)
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
@@ -231,14 +235,11 @@ void DolphinColumnWidget::dropEvent(QDropEvent* event)
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
- if (index.isValid()) {
- const KFileItem item = itemForIndex(index);
- m_view->m_controller->indicateDroppedUrls(urls,
- url(),
- item,
- event->source());
- event->acceptProposedAction();
- }
+ const KFileItem item = itemForIndex(index);
+ m_view->m_controller->indicateDroppedUrls(urls,
+ url(),
+ item);
+ event->acceptProposedAction();
}
QListView::dropEvent(event);
m_dragging = false;
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index 897d4266b..58f6f681f 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -62,10 +62,9 @@ void DolphinController::requestActivation()
void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source)
+ const KFileItem& destItem)
{
- emit urlsDropped(urls, destPath, destItem, source);
+ emit urlsDropped(urls, destPath, destItem);
}
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
index c5f0e1a2b..16b5f5587 100644
--- a/src/dolphincontroller.h
+++ b/src/dolphincontroller.h
@@ -128,12 +128,10 @@ public:
* @param urls URLs that are dropped above a destination.
* @param destPath Path of the destination.
* @param destItem Destination item (can be null, see KFileItem::isNull()).
- * @param source Pointer to the view implementation which invoked this method.
*/
void indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Informs the abstract Dolphin view about a sorting change done inside
@@ -251,13 +249,11 @@ signals:
* Is emitted if the URLs \a urls have been dropped to the destination
* path \a destPath. If the URLs have been dropped above an item of
* the destination path, the item is indicated by \a destItem
- * (can be null, see KFileItem::isNull()). \a source indicates
- * the widget where the dragging has been started from.
+ * (can be null, see KFileItem::isNull()).
*/
void urlsDropped(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Is emitted if the sorting has been changed to \a sorting by
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index ee123b65c..e55c2582d 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -249,7 +249,11 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
m_dragging = false;
} else {
m_dragging = true;
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
}
@@ -260,13 +264,13 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
if (!urls.isEmpty()) {
event->acceptProposedAction();
const QModelIndex index = indexAt(event->pos());
+ KFileItem item;
if (index.isValid() && (index.column() == DolphinModel::Name)) {
- const KFileItem item = itemForIndex(index);
- m_controller->indicateDroppedUrls(urls,
- m_controller->url(),
- item,
- event->source());
+ item = itemForIndex(index);
}
+ m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
+ item);
}
QTreeView::dropEvent(event);
m_dragging = false;
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 30e47da89..eb3aa13c6 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -188,7 +188,11 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
@@ -198,14 +202,11 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
- if (index.isValid()) {
- const KFileItem item = itemForIndex(index);
- m_controller->indicateDroppedUrls(urls,
- m_controller->url(),
- item,
- event->source());
- event->acceptProposedAction();
- }
+ const KFileItem item = itemForIndex(index);
+ m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
+ item);
+ event->acceptProposedAction();
}
}
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index c280b40d0..004b158ed 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -103,8 +103,8 @@ DolphinView::DolphinView(QWidget* parent,
connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
this, SLOT(openContextMenu(const QPoint&)));
- connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)),
- this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)));
+ connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&)),
+ this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&)));
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
@@ -730,24 +730,14 @@ void DolphinView::openContextMenu(const QPoint& pos)
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source)
+ const KFileItem& destItem)
{
- bool dropAboveDir = false;
- if (!destItem.isNull()) {
- dropAboveDir = destItem.isDir();
- if (!dropAboveDir) {
- // the dropping is done above a file
- return;
- }
- } else if (source == itemView()) {
- // the dropping is done into the same viewport where the dragging
- // has been started
- return;
+ const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
+ destItem.url() : destPath;
+ const KUrl sourceDir = KUrl(urls.first().directory());
+ if (sourceDir != destination) {
+ dropUrls(urls, destination);
}
-
- const KUrl& destination = dropAboveDir ? destItem.url() : destPath;
- dropUrls(urls, destination);
}
void DolphinView::dropUrls(const KUrl::List& urls,
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 442ff5a60..593209e06 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -489,13 +489,11 @@ private slots:
/**
* Drops the URLs \a urls to the destination path \a destPath. If
* the URLs are dropped above an item inside the destination path,
- * the item is indicated by \a destItem. \a source
- * indicates the widget where the dragging has been started from.
+ * the item is indicated by \a destItem.
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Drops the URLs \a urls at the