void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
{
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- event->acceptProposedAction();
- requestActivation();
- }
+ event->acceptProposedAction();
+ requestActivation();
DolphinTreeView::dragEnterEvent(event);
}
void DolphinColumnView::dragMoveEvent(QDragMoveEvent* event)
{
DolphinTreeView::dragMoveEvent(event);
-
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- // accept url drops, independently from the destination item
- event->acceptProposedAction();
- }
+ event->acceptProposedAction();
}
void DolphinColumnView::dropEvent(QDropEvent* event)
void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
{
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- event->acceptProposedAction();
- }
+ event->acceptProposedAction();
DolphinTreeView::dragEnterEvent(event);
}
void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
{
DolphinTreeView::dragMoveEvent(event);
-
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- // Accept URL drops, independently from the destination item
- event->acceptProposedAction();
- }
+ event->acceptProposedAction();
}
void DolphinDetailsView::dropEvent(QDropEvent* event)
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
{
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- event->acceptProposedAction();
- }
+ event->acceptProposedAction();
}
void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
m_dropRect.setSize(QSize()); // set as invalid
}
}
- if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
- // accept url drops, independently from the destination item
- event->acceptProposedAction();
- }
+ event->acceptProposedAction();
setDirtyRegion(m_dropRect);
}
return s_dragAndDropHelper->instance;
}
-bool DragAndDropHelper::isMimeDataSupported(const QMimeData* mimeData) const
-{
- // We support everything, cf KonqOperations::doDrop which can save any data.
- //return mimeData->hasUrls() || mimeData->hasFormat("application/x-kde-dndextract");
- Q_UNUSED(mimeData);
- return true;
-}
-
void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
DolphinViewController* dolphinViewController)
QPixmap DragAndDropHelper::createDragPixmap(QAbstractItemView* itemView) const
{
- const QModelIndexList selectedIndexes = itemView->selectionModel()->selectedIndexes();
+ const QModelIndexList selectedIndexes = itemView->selectionModel()->selectedIndexes();
Q_ASSERT(!selectedIndexes.isEmpty());
-
+
QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(itemView->model());
KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
-
+
const int itemCount = selectedIndexes.count();
-
+
// If more than one item is dragged, align the items inside a
// rectangular grid. The maximum grid size is limited to 5 x 5 items.
int xCount = 3;
xCount = 4;
size = KIconLoader::SizeSmallMedium;
}
-
+
if (itemCount < xCount) {
xCount = itemCount;
}
-
+
int yCount = itemCount / xCount;
if (itemCount % xCount != 0) {
++yCount;
yCount = xCount;
}
- // Draw the selected items into the grid cells
+ // Draw the selected items into the grid cells
QPixmap dragPixmap(xCount * size + xCount - 1, yCount * size + yCount - 1);
dragPixmap.fill(Qt::transparent);
-
+
QPainter painter(&dragPixmap);
int x = 0;
int y = 0;
const KFileItem item = dirModel->itemForIndex(index);
const QPixmap pixmap = item.pixmap(size, size);
painter.drawPixmap(x, y, pixmap);
-
+
x += size + 1;
if (x >= dragPixmap.width()) {
x = 0;
break;
}
}
-
+
return dragPixmap;
}
public:
static DragAndDropHelper& instance();
- /**
- * Returns true, if Dolphin supports the dragging of
- * the given mime data.
- */
- bool isMimeDataSupported(const QMimeData* mimeData) const;
-
/**
* Creates a drag object for the view \a itemView for all selected items.
*/
DolphinViewController* dolphinViewController = 0);
/**
- * Returns true if and only if the view \a itemView was the last view to
+ * Returns true if and only if the view \a itemView was the last view to
* be passed to startDrag(...), and that drag is still in progress.
*/
bool isDragSource(QAbstractItemView* itemView) const;
private:
DragAndDropHelper();
-
+
/**
* Creates a pixmap the contains the all icons of the items
* that are dragged.
*/
QPixmap createDragPixmap(QAbstractItemView* itemView) const;
-
+
// The last view passed in startDrag(...), or 0 if
// no startDrag(...) initiated drag is in progress.
QAbstractItemView *m_dragSource;