┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-09-17 14:36:41 +0000
committerPeter Penz <[email protected]>2007-09-17 14:36:41 +0000
commitd78fe954abb9ea0ed05f8c22d6842a457c0a209e (patch)
tree6529cc7867105862a8a564bb74a8042091695983 /src
parentb3db0a708a630d9f59857ab7dcbfe8f29e3e8eb9 (diff)
drag and drop fixes for the column view (implied a signal changed which affected other views too)
svn path=/trunk/KDE/kdebase/apps/; revision=713430
Diffstat (limited to 'src')
-rw-r--r--src/dolphincolumnview.cpp31
-rw-r--r--src/dolphincolumnview.h2
-rw-r--r--src/dolphincontroller.cpp7
-rw-r--r--src/dolphincontroller.h13
-rw-r--r--src/dolphindetailsview.cpp1
-rw-r--r--src/dolphiniconsview.cpp1
-rw-r--r--src/dolphinmainwindow.cpp3
-rw-r--r--src/dolphinview.cpp13
-rw-r--r--src/dolphinview.h7
9 files changed, 38 insertions, 40 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index 658bd8587..32111253c 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -115,7 +115,11 @@ ColumnWidget::ColumnWidget(QWidget* parent,
viewport()->setAttribute(Qt::WA_Hover);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ setSelectionBehavior(SelectItems);
setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setDragDropMode(QAbstractItemView::DragDrop);
+ setDropIndicatorShown(false);
+ setFocusPolicy(Qt::NoFocus);
// apply the column mode settings to the widget
const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
@@ -227,6 +231,7 @@ void ColumnWidget::dropEvent(QDropEvent* event)
if (!urls.isEmpty()) {
event->acceptProposedAction();
m_view->m_controller->indicateDroppedUrls(urls,
+ url(),
indexAt(event->pos()),
event->source());
}
@@ -398,12 +403,11 @@ QModelIndex DolphinColumnView::indexAt(const QPoint& point) const
foreach (ColumnWidget* column, m_columns) {
const QPoint topLeft = column->frameGeometry().topLeft();
const QPoint adjustedPoint(point.x() - topLeft.x(), point.y() - topLeft.y());
- QModelIndex index = column->indexAt(adjustedPoint);
+ const QModelIndex index = column->indexAt(adjustedPoint);
if (index.isValid()) {
return index;
}
}
- return activeColumn()->indexAt(point);
return QModelIndex();
}
@@ -451,7 +455,7 @@ int DolphinColumnView::horizontalOffset() const
int DolphinColumnView::verticalOffset() const
{
- return 0; // activeColumn()->verticalOffset();
+ return 0;
}
void DolphinColumnView::mousePressEvent(QMouseEvent* event)
@@ -460,25 +464,6 @@ void DolphinColumnView::mousePressEvent(QMouseEvent* event)
QAbstractItemView::mousePressEvent(event);
}
-void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
-{
- if (event->mimeData()->hasUrls()) {
- event->acceptProposedAction();
- }
-}
-
-void DolphinColumnView::dropEvent(QDropEvent* event)
-{
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- if (!urls.isEmpty()) {
- m_controller->indicateDroppedUrls(urls,
- indexAt(event->pos()),
- event->source());
- event->acceptProposedAction();
- }
- QAbstractItemView::dropEvent(event);
-}
-
void DolphinColumnView::resizeEvent(QResizeEvent* event)
{
QAbstractItemView::resizeEvent(event);
@@ -633,6 +618,8 @@ void DolphinColumnView::setActiveColumnIndex(int index)
m_index = index;
m_columns[m_index]->setActive(true);
+
+ m_controller->setUrl(m_columns[m_index]->url());
}
void DolphinColumnView::layoutColumns()
diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h
index eff09c08a..8c61aae6c 100644
--- a/src/dolphincolumnview.h
+++ b/src/dolphincolumnview.h
@@ -58,8 +58,6 @@ protected:
virtual int verticalOffset() const;
virtual void mousePressEvent(QMouseEvent* event);
- virtual void dragEnterEvent(QDragEnterEvent* event);
- virtual void dropEvent(QDropEvent* event);
virtual void resizeEvent(QResizeEvent* event);
private slots:
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index 0f308481f..325608442 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -54,10 +54,11 @@ void DolphinController::triggerActivation()
}
void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
- const QModelIndex& index,
- QWidget* source)
+ const KUrl& destPath,
+ const QModelIndex& destIndex,
+ QWidget* source)
{
- emit urlsDropped(urls, index, source);
+ emit urlsDropped(urls, destPath, destIndex, source);
}
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
index d91e7f5c1..a7f227306 100644
--- a/src/dolphincontroller.h
+++ b/src/dolphincontroller.h
@@ -66,7 +66,8 @@ public:
void triggerActivation();
void indicateDroppedUrls(const KUrl::List& urls,
- const QModelIndex& index,
+ const KUrl& destPath,
+ const QModelIndex& destIndex,
QWidget* source);
void indicateSortingChange(DolphinView::Sorting sorting);
@@ -132,12 +133,14 @@ signals:
void activated();
/**
- * Is emitted if the URLs \a urls have been dropped to the index
- * \a index. \a source indicates the widget where the dragging has
- * been started from.
+ * 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 destIndex.
+ * \a source indicates the widget where the dragging has been started from.
*/
void urlsDropped(const KUrl::List& urls,
- const QModelIndex& index,
+ const KUrl& destPath,
+ const QModelIndex& destIndex,
QWidget* source);
/** Is emitted if the sorting has been changed to \a sorting. */
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index defe93192..86a724da1 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -241,6 +241,7 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
if (!urls.isEmpty()) {
event->acceptProposedAction();
m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
indexAt(event->pos()),
event->source());
}
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 42a039c8c..d9bfef8a4 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -185,6 +185,7 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
indexAt(event->pos()),
event->source());
event->acceptProposedAction();
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 84f183327..f3dbfcf6e 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -150,6 +150,9 @@ void DolphinMainWindow::refreshViews()
void DolphinMainWindow::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
+ kDebug() << "Source" << urls;
+ kDebug() << "Destination:" << destination;
+
Qt::DropAction action = Qt::CopyAction;
Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 31ee64fed..aeb10dc9c 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -93,8 +93,8 @@ DolphinView::DolphinView(QWidget* parent,
this, SIGNAL(urlChanged(const KUrl&)));
connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
this, SLOT(openContextMenu(const QPoint&)));
- connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&, QWidget*)),
- this, SLOT(dropUrls(const KUrl::List&, const QModelIndex&, QWidget*)));
+ connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const QModelIndex&, QWidget*)),
+ this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const QModelIndex&, QWidget*)));
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
@@ -655,12 +655,13 @@ void DolphinView::openContextMenu(const QPoint& pos)
}
void DolphinView::dropUrls(const KUrl::List& urls,
- const QModelIndex& index,
+ const KUrl& destPath,
+ const QModelIndex& destIndex,
QWidget* source)
{
KFileItem directory;
- if (isValidNameIndex(index)) {
- KFileItem item = fileItem(index);
+ if (isValidNameIndex(destIndex)) {
+ KFileItem item = fileItem(destIndex);
Q_ASSERT(!item.isNull());
if (item.isDir()) {
// the URLs are dropped above a directory
@@ -675,7 +676,7 @@ void DolphinView::dropUrls(const KUrl::List& urls,
}
const KUrl& destination = (directory.isNull()) ?
- url() : directory.url();
+ destPath : directory.url();
dropUrls(urls, destination);
}
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 159613cd9..6799215e0 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -429,11 +429,14 @@ private slots:
void openContextMenu(const QPoint& pos);
/**
- * Drops the URLs \a urls to the index \a index. \a source
+ * 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 destIndex. \a source
* indicates the widget where the dragging has been started from.
*/
void dropUrls(const KUrl::List& urls,
- const QModelIndex& index,
+ const KUrl& destPath,
+ const QModelIndex& destIndex,
QWidget* source);
/**