]> cloud.milkyroute.net Git - dolphin.git/commitdiff
drag and drop fixes for the column view (implied a signal changed which affected...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 17 Sep 2007 14:36:41 +0000 (14:36 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 17 Sep 2007 14:36:41 +0000 (14:36 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=713430

src/dolphincolumnview.cpp
src/dolphincolumnview.h
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphinmainwindow.cpp
src/dolphinview.cpp
src/dolphinview.h

index 658bd858711add93d1170e4efc0b76e8bd5719be..32111253cbd614f5bc8526fcb76f6be6424c8eca 100644 (file)
@@ -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()
index eff09c08a6d39d7c3f9ff96c0f4e47224d6d833e..8c61aae6cf605cb5b3ea2a4acf1490f39834e59c 100644 (file)
@@ -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:
index 0f308481fba40691ef1a2de818c019fd7ed3e1ea..32560844254e34519cd9f9dc8fea819aef2f7783 100644 (file)
@@ -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);
 }
 
 
index d91e7f5c1c1f576c6418903836105a88881cc1e0..a7f227306d958ee1a7e0cca7abcb36fa21fdff88 100644 (file)
@@ -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. */
index defe93192fc6cc377405fd1253f3ea4368fcbb95..86a724da1e034dd69ef55f6e387fda9e25530000 100644 (file)
@@ -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());
     }
index 42a039c8c12f05cc127797efe353e9bef1d4120d..d9bfef8a476e2623b28163c376adee2d99cc094e 100644 (file)
@@ -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();
index 84f18332767f1b0354467c1018ec78fef1df6427..f3dbfcf6ed6d3301c91df6b6099895fa5726e1e8 100644 (file)
@@ -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();
index 31ee64fed30ace145f5218def93d855bfa30955b..aeb10dc9c144a97307032098ff03085f256a01d5 100644 (file)
@@ -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);
 }
 
index 159613cd9508842e5698a57cc2254b50102f37ec..6799215e0843fc058372abb0aa4701e489fd694e 100644 (file)
@@ -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);
 
     /**