]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kcategorizedview.cpp
Fix i18n
[dolphin.git] / src / kcategorizedview.cpp
index 4f542f9c7fc0e12849f0633d1dbe0a27f316b4f1..7018b33bcf80d0002cbf9948ec02a4415824b3c1 100644 (file)
 #include "kcategorydrawer.h"
 #include "kcategorizedsortfilterproxymodel.h"
 
+// By defining DOLPHIN_DRAGANDDROP the custom drag and drop implementation of
+// KCategorizedView is bypassed to have a consistent drag and drop look for all
+// views. Hopefully transparent pixmaps for drag objects will be supported in
+// Qt 4.4, so that this workaround can be skipped.
+#define DOLPHIN_DRAGANDDROP
+
 KCategorizedView::Private::Private(KCategorizedView *listView)
     : listView(listView)
     , categoryDrawer(0)
@@ -355,7 +361,7 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
     }
 
     QStyleOption optionCopy = option;
-    const QString category = proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
+    const QString category = proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
 
     optionCopy.state &= ~QStyle::State_Selected;
 
@@ -1055,7 +1061,9 @@ void KCategorizedView::startDrag(Qt::DropActions supportedActions)
     //        ARGB window so it is no transparent. Use QAbstractItemView when
     //        this is fixed on Qt.
     // QAbstractItemView::startDrag(supportedActions);
+#if !defined(DOLPHIN_DRAGANDDROP)
     QListView::startDrag(supportedActions);
+#endif
 
     d->isDragging = false;
     d->mouseButtonPressed = false;
@@ -1081,7 +1089,11 @@ void KCategorizedView::dragMoveEvent(QDragMoveEvent *event)
     if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
         !d->categoryDrawer || !d->proxyModel->isCategorizedModel())
     {
+#if defined(DOLPHIN_DRAGANDDROP)
+        QAbstractItemView::dragMoveEvent(event);
+#else
         QListView::dragMoveEvent(event);
+#endif
         return;
     }
 
@@ -1092,7 +1104,20 @@ void KCategorizedView::dragLeaveEvent(QDragLeaveEvent *event)
 {
     d->dragLeftViewport = true;
 
+#if defined(DOLPHIN_DRAGANDDROP)
+    QAbstractItemView::dragLeaveEvent(event);
+#else
     QListView::dragLeaveEvent(event);
+#endif
+}
+
+void KCategorizedView::dropEvent(QDropEvent *event)
+{
+#if defined(DOLPHIN_DRAGANDDROP)
+    QAbstractItemView::dropEvent(event);
+#else
+    QListView::dropEvent(event);
+#endif
 }
 
 QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
@@ -1304,7 +1329,7 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
     }
 
     // Add all elements mapped to the source model and explore categories
-    QString prevCategory = d->proxyModel->data(d->proxyModel->index(0, d->proxyModel->sortColumn()), KCategorizedSortFilterProxyModel::CategoryRole).toString();
+    QString prevCategory = d->proxyModel->data(d->proxyModel->index(0, d->proxyModel->sortColumn()), KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
     QString lastCategory = prevCategory;
     QModelIndexList modelIndexList;
     struct Private::ElementInfo elementInfo;
@@ -1321,7 +1346,7 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
 
         d->modelIndexList << index;
 
-        lastCategory = d->proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
+        lastCategory = d->proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
 
         elementInfo.category = lastCategory;