itemRect.setHeight(maxHeight);
}
- if (leftToRightFlow && bypassVisualRectIssue()) {
- // TODO: check inline comment inside bypassVisualRectIssue() for details
+ KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model());
+ if (leftToRightFlow && !proxyModel->isCategorizedModel()) {
+ // TODO: QListView::visualRect() calculates a wrong position of the items under
+ // certain circumstances (e. g. if the text is too long). This issue is bypassed
+ // by the following code (I'll try create a patch for Qt but as Dolphin must also work with
+ // Qt 4.3.0 this workaround must get applied at least for KDE 4.0).
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
const int margin = settings->gridSpacing();
const int gridWidth = gridSize().width();
void DolphinIconsView::startDrag(Qt::DropActions supportedActions)
{
- if (bypassVisualRectIssue()) {
- // TODO: check inline comment inside bypassVisualRectIssue() for details
- DragAndDropHelper::startDrag(this, supportedActions);
- } else {
- KCategorizedView::startDrag(supportedActions);
- }
+ // TODO: invoking KCategorizedView::startDrag() should not be necessary, we'll
+ // fix this in KDE 4.1
+ KCategorizedView::startDrag(supportedActions);
+ DragAndDropHelper::startDrag(this, supportedActions);
}
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
{
- if (bypassVisualRectIssue()) {
- // TODO: check inline comment inside bypassVisualRectIssue() for details
- QAbstractItemView::dragLeaveEvent(event);
- } else {
- KCategorizedView::dragLeaveEvent(event);
- }
+ KCategorizedView::dragLeaveEvent(event);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
m_dragging = false;
void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
{
- if (bypassVisualRectIssue()) {
- // TODO: check inline comment inside bypassVisualRectIssue() for details
- QAbstractItemView::dragMoveEvent(event);
- } else {
- KCategorizedView::dragMoveEvent(event);
- }
+ KCategorizedView::dragMoveEvent(event);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
}
}
- if (bypassVisualRectIssue()) {
- // TODO: check inline comment inside bypassVisualRectIssue() for details
- QAbstractItemView::dropEvent(event);
- } else {
- KCategorizedView::dropEvent(event);
- }
+ KCategorizedView::dropEvent(event);
m_dragging = false;
}
return dirModel->itemForIndex(dirIndex);
}
-bool DolphinIconsView::bypassVisualRectIssue() const
-{
- // TODO: QListView::visualRect() calculates a wrong position of the items under
- // certain circumstances (e. g. if the text is too long). This issue is bypassed
- // inside DolphinIconsView::visualRect(), but internally QListView does not use
- // visualRect() but the (non-virtual) QListView::rectForIndex(). This leads
- // to problems in combination with drag & drop operations: visual fragments get
- // created. To bypass the drag & drop issue the calls for QListView::dragMoveEvent(),
- // QListView::dropEvent() are replaced by the QAbstractItemView counterparts and
- // QAbstractItemView::startDrag() has been reimplemented.
- //
- // I'll try create a patch for Qt but as Dolphin must also work with
- // Qt 4.3.0 this workaround must get applied at least for KDE 4.0.
- KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model());
- return !proxyModel->isCategorizedModel();
-}
-
#include "dolphiniconsview.moc"
#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)
// 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;
if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->categoryDrawer || !d->proxyModel->isCategorizedModel())
{
+#if defined(DOLPHIN_DRAGANDDROP)
+ QAbstractItemView::dragMoveEvent(event);
+#else
QListView::dragMoveEvent(event);
+#endif
return;
}
{
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,