]> cloud.milkyroute.net Git - dolphin.git/commitdiff
As the Qt-issue 160611 is solved in Qt4.4 and Fredrik has improved KFileItemDelegate...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 12 Mar 2008 16:49:55 +0000 (16:49 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 12 Mar 2008 16:49:55 +0000 (16:49 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=784851

src/dolphincolumnwidget.cpp
src/dolphincolumnwidget.h
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/draganddrophelper.cpp
src/draganddrophelper.h
src/sidebartreeview.cpp
src/sidebartreeview.h

index f0656808dc97ec548083b22b79393bc8237aa968..bbaa5f7933bb36223ff562e5ecc282ec7c2b716f 100644 (file)
@@ -60,7 +60,6 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
     m_dolphinModel(0),
     m_proxyModel(0),
     m_iconManager(0),
     m_dolphinModel(0),
     m_proxyModel(0),
     m_iconManager(0),
-    m_dragging(false),
     m_dropRect()
 {
     setMouseTracking(true);
     m_dropRect()
 {
     setMouseTracking(true);
@@ -251,16 +250,11 @@ void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
-
-    m_dragging = true;
 }
 
 void DolphinColumnWidget::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QListView::dragLeaveEvent(event);
 }
 
 void DolphinColumnWidget::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QListView::dragLeaveEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    m_dragging = false;
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -301,7 +295,6 @@ void DolphinColumnWidget::dropEvent(QDropEvent* event)
         event->acceptProposedAction();
     }
     QListView::dropEvent(event);
         event->acceptProposedAction();
     }
     QListView::dropEvent(event);
-    m_dragging = false;
 }
 
 void DolphinColumnWidget::paintEvent(QPaintEvent* event)
 }
 
 void DolphinColumnWidget::paintEvent(QPaintEvent* event)
@@ -326,12 +319,6 @@ void DolphinColumnWidget::paintEvent(QPaintEvent* event)
     }
 
     QListView::paintEvent(event);
     }
 
     QListView::paintEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    if (m_dragging) {
-        const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
-        DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
-    }
 }
 
 void DolphinColumnWidget::mousePressEvent(QMouseEvent* event)
 }
 
 void DolphinColumnWidget::mousePressEvent(QMouseEvent* event)
index b8113cd6f373481218903e5c710bd1ff6f228336..3472f95d8be614d80516eeac0076802be541445f 100644 (file)
@@ -139,8 +139,7 @@ private:
 
     IconManager* m_iconManager;
 
 
     IconManager* m_iconManager;
 
-    bool m_dragging;   // TODO: remove this property when the issue #160611 is solved in Qt 4.4
-    QRect m_dropRect;  // TODO: remove this property when the issue #160611 is solved in Qt 4.4
+    QRect m_dropRect;
 };
 
 inline bool DolphinColumnWidget::isActive() const
 };
 
 inline bool DolphinColumnWidget::isActive() const
index 11b9938499683105044cc000ae1b060174ddf715..2eb631a649bb87ca8aba7d895db156ac54b5fab3 100644 (file)
@@ -49,7 +49,6 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     m_controller(controller),
     m_font(),
     m_decorationSize(),
     m_controller(controller),
     m_font(),
     m_decorationSize(),
-    m_dragging(false),
     m_showElasticBand(false),
     m_elasticBandOrigin(),
     m_elasticBandDestination()
     m_showElasticBand(false),
     m_elasticBandOrigin(),
     m_elasticBandDestination()
@@ -261,15 +260,11 @@ void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
         updateElasticBand();
         m_showElasticBand = false;
     }
         updateElasticBand();
         m_showElasticBand = false;
     }
-    m_dragging = true;
 }
 
 void DolphinDetailsView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QTreeView::dragLeaveEvent(event);
 }
 
 void DolphinDetailsView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QTreeView::dragLeaveEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    m_dragging = false;
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -280,10 +275,7 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     setDirtyRegion(m_dropRect);
     const QModelIndex index = indexAt(event->pos());
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     setDirtyRegion(m_dropRect);
     const QModelIndex index = indexAt(event->pos());
-    if (!index.isValid() || (index.column() != DolphinModel::Name)) {
-        m_dragging = false;
-    } else {
-        m_dragging = true;
+    if (index.isValid() && (index.column() == DolphinModel::Name)) {
         const KFileItem item = m_controller->itemForIndex(index);
         if (!item.isNull() && item.isDir()) {
             m_dropRect = visualRect(index);
         const KFileItem item = m_controller->itemForIndex(index);
         if (!item.isNull() && item.isDir()) {
             m_dropRect = visualRect(index);
@@ -314,7 +306,6 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
                                           item);
     }
     QTreeView::dropEvent(event);
                                           item);
     }
     QTreeView::dropEvent(event);
-    m_dragging = false;
 }
 
 void DolphinDetailsView::paintEvent(QPaintEvent* event)
 }
 
 void DolphinDetailsView::paintEvent(QPaintEvent* event)
@@ -335,12 +326,6 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event)
         style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
         painter.restore();
     }
         style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
         painter.restore();
     }
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    if (m_dragging) {
-        const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
-        DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
-    }
 }
 
 void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
 }
 
 void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
index 295936258a79365f55226c45c2a341bfca1c9bb1..88471746d0435b98007ee0c15bed18b4036b9fd6 100644 (file)
@@ -161,8 +161,7 @@ private:
     QFont m_font;
     QSize m_decorationSize;
 
     QFont m_font;
     QSize m_decorationSize;
 
-    bool m_dragging;   // TODO: remove this property when the issue #160611 is solved in Qt 4.4
-    QRect m_dropRect;  // TODO: remove this property when the issue #160611 is solved in Qt 4.4
+    QRect m_dropRect;
 
     bool m_showElasticBand;
     QPoint m_elasticBandOrigin;
 
     bool m_showElasticBand;
     QPoint m_elasticBandOrigin;
index e92d8ba3b95a8d8773aead89cca923ac4a156428..dda538e16ddb4b341d05793264f398d79e4bc1d6 100644 (file)
@@ -46,7 +46,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     m_decorationPosition(QStyleOptionViewItem::Top),
     m_displayAlignment(Qt::AlignHCenter),
     m_itemSize(),
     m_decorationPosition(QStyleOptionViewItem::Top),
     m_displayAlignment(Qt::AlignHCenter),
     m_itemSize(),
-    m_dragging(false),
     m_dropRect()
 {
     Q_ASSERT(controller != 0);
     m_dropRect()
 {
     Q_ASSERT(controller != 0);
@@ -57,9 +56,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     setDragEnabled(true);
     viewport()->setAcceptDrops(true);
 
     setDragEnabled(true);
     viewport()->setAcceptDrops(true);
 
-    setMouseTracking(true);
-    viewport()->setAttribute(Qt::WA_Hover);
-
     // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
     // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
     // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
     // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
     // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
     // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
@@ -221,15 +217,11 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
-    m_dragging = true;
 }
 
 void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     KCategorizedView::dragLeaveEvent(event);
 }
 
 void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     KCategorizedView::dragLeaveEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    m_dragging = false;
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -273,19 +265,6 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
     }
 
     KCategorizedView::dropEvent(event);
     }
 
     KCategorizedView::dropEvent(event);
-
-    m_dragging = false;
-}
-
-void DolphinIconsView::paintEvent(QPaintEvent* event)
-{
-    KCategorizedView::paintEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    if (m_dragging) {
-        const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
-        DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
-    }
 }
 
 void DolphinIconsView::keyPressEvent(QKeyEvent* event)
 }
 
 void DolphinIconsView::keyPressEvent(QKeyEvent* event)
index 20d41051abddb738533ac60980022f541dff3fee..d96d7c7e904e2883f124edc93750b8a9c32a6420 100644 (file)
@@ -60,7 +60,6 @@ protected:
     virtual void dragLeaveEvent(QDragLeaveEvent* event);
     virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
     virtual void dragLeaveEvent(QDragLeaveEvent* event);
     virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
-    virtual void paintEvent(QPaintEvent* event);
     virtual void keyPressEvent(QKeyEvent* event);
     virtual void wheelEvent(QWheelEvent* event);
 
     virtual void keyPressEvent(QKeyEvent* event);
     virtual void wheelEvent(QWheelEvent* event);
 
@@ -104,9 +103,7 @@ private:
     Qt::Alignment m_displayAlignment;
 
     QSize m_itemSize;
     Qt::Alignment m_displayAlignment;
 
     QSize m_itemSize;
-
-    bool m_dragging;   // TODO: remove this property when the issue #160611 is solved in Qt 4.4
-    QRect m_dropRect;  // TODO: remove this property when the issue #160611 is solved in Qt 4.4
+    QRect m_dropRect;
 };
 
 #endif
 };
 
 #endif
index 7095346bce2f7b3afee060ebefe5e4109012f94e..ab674cd5cdb79551cd10de44a521fbd57c4b75e8 100644 (file)
 
 #include <QAbstractItemView>
 #include <QAbstractProxyModel>
 
 #include <QAbstractItemView>
 #include <QAbstractProxyModel>
-#include <QBrush>
 #include <QDrag>
 #include <QDrag>
-#include <QPainter>
-#include <QRect>
-#include <QWidget>
 
 void DragAndDropHelper::startDrag(QAbstractItemView* itemView, Qt::DropActions supportedActions)
 {
 
 void DragAndDropHelper::startDrag(QAbstractItemView* itemView, Qt::DropActions supportedActions)
 {
@@ -57,40 +53,3 @@ void DragAndDropHelper::startDrag(QAbstractItemView* itemView, Qt::DropActions s
         drag->exec(supportedActions, Qt::IgnoreAction);
     }
 }
         drag->exec(supportedActions, Qt::IgnoreAction);
     }
 }
-
-void DragAndDropHelper::drawHoverIndication(QAbstractItemView* itemView,
-                                            const QRect& bounds,
-                                            const QBrush& brush)
-{
-    if (bounds.isEmpty()) {
-        return;
-    }
-
-    QWidget* widget = itemView->viewport();
-
-    QPainter painter(widget);
-    painter.save();
-    QBrush blendedBrush(brush);
-    QColor color = blendedBrush.color();
-    color.setAlpha(64);
-    blendedBrush.setColor(color);
-
-    if (dynamic_cast<DolphinIconsView*>(itemView)) {
-        const int radius = 10;
-        QPainterPath path(QPointF(bounds.left(), bounds.top() + radius));
-        path.quadTo(bounds.left(), bounds.top(), bounds.left() + radius, bounds.top());
-        path.lineTo(bounds.right() - radius, bounds.top());
-        path.quadTo(bounds.right(), bounds.top(), bounds.right(), bounds.top() + radius);
-        path.lineTo(bounds.right(), bounds.bottom() - radius);
-        path.quadTo(bounds.right(), bounds.bottom(), bounds.right() - radius, bounds.bottom());
-        path.lineTo(bounds.left() + radius, bounds.bottom());
-        path.quadTo(bounds.left(), bounds.bottom(), bounds.left(), bounds.bottom() - radius);
-        path.closeSubpath();
-
-        painter.setRenderHint(QPainter::Antialiasing);
-        painter.fillPath(path, blendedBrush);
-    } else {
-        painter.fillRect(bounds, blendedBrush);
-    }
-    painter.restore();
-}
index 8e1e4531f467870d159f09c721f16e51e4f74d77..93f9ddd127065904030da1e4128cbd8502f808ab 100644 (file)
@@ -28,7 +28,7 @@ class QRect;
 class QWidget;
 
 /**
 class QWidget;
 
 /**
- * @brief Helper class to bypass some drag & drop limitations in Qt.
+ * @brief Helper class for having a common drag and drop behavior.
  *
  * The class is used by DolphinIconsView, DolphinDetailsView,
  * DolphinColumnView and SidebarTreeView to have a consistent
  *
  * The class is used by DolphinIconsView, DolphinDetailsView,
  * DolphinColumnView and SidebarTreeView to have a consistent
@@ -42,11 +42,6 @@ public:
      * Creates a drag object for the view \a itemView for all selected items.
      */
     static void startDrag(QAbstractItemView* itemView, Qt::DropActions supportedActions);
      * Creates a drag object for the view \a itemView for all selected items.
      */
     static void startDrag(QAbstractItemView* itemView, Qt::DropActions supportedActions);
-
-    // TODO: remove this method when the issue #160611 is solved in Qt 4.4
-    static void drawHoverIndication(QAbstractItemView* itemView,
-                                    const QRect& bounds,
-                                    const QBrush& brush);
 };
 
 #endif
 };
 
 #endif
index 5ac3b0cbf166645b0f4be5df76b1842688c2768a..f14ddbacb399653f9dc76fec99b4c8b85e28aad0 100644 (file)
@@ -30,8 +30,7 @@
 #include <QScrollBar>
 
 SidebarTreeView::SidebarTreeView(QWidget* parent) :
 #include <QScrollBar>
 
 SidebarTreeView::SidebarTreeView(QWidget* parent) :
-    QTreeView(parent),
-    m_dragging(false)
+    QTreeView(parent)
 {
     setAcceptDrops(true);
     setUniformRowHeights(true);
 {
     setAcceptDrops(true);
     setUniformRowHeights(true);
@@ -95,20 +94,14 @@ void SidebarTreeView::startDrag(Qt::DropActions supportedActions)
 void SidebarTreeView::dragEnterEvent(QDragEnterEvent* event)
 {
     QTreeView::dragEnterEvent(event);
 void SidebarTreeView::dragEnterEvent(QDragEnterEvent* event)
 {
     QTreeView::dragEnterEvent(event);
-
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
     if (event->mimeData()->hasUrls()) {
         event->acceptProposedAction();
     }
-
-    m_dragging = true;
 }
 
 void SidebarTreeView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QTreeView::dragLeaveEvent(event);
 }
 
 void SidebarTreeView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     QTreeView::dragLeaveEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    m_dragging = false;
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -140,18 +133,6 @@ void SidebarTreeView::dropEvent(QDropEvent* event)
             emit urlsDropped(urls, index);
         }
     }
             emit urlsDropped(urls, index);
         }
     }
-    m_dragging = false;
-}
-
-void SidebarTreeView::paintEvent(QPaintEvent* event)
-{
-    QTreeView::paintEvent(event);
-
-    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-    if (m_dragging) {
-        const QBrush& brush = palette().brush(QPalette::Normal, QPalette::Highlight);
-        DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
-    }
 }
 
 #include "sidebartreeview.moc"
 }
 
 #include "sidebartreeview.moc"
index b2e42e24fbb80c058de8303301397c84e7258a54..a181290f228e660cfdf6b5b72bb4f07cb7f4cc39 100644 (file)
@@ -51,11 +51,9 @@ protected:
     virtual void dragLeaveEvent(QDragLeaveEvent* event);
     virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
     virtual void dragLeaveEvent(QDragLeaveEvent* event);
     virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
-    virtual void paintEvent(QPaintEvent* event);
 
 private:
 
 private:
-    bool m_dragging;   // TODO: remove this property when the issue #160611 is solved in Qt 4.4
-    QRect m_dropRect;  // TODO: remove this property when the issue #160611 is solved in Qt 4.4
+    QRect m_dropRect;
 };
 
 #endif
 };
 
 #endif