- Reactivate dropping of URLs
- Remove unused/obsolete code
- Simplify DragAndDropHelper interface
#include <QApplication>
#include <QBoxLayout>
#include <QApplication>
#include <QBoxLayout>
+#include <QDropEvent>
+#include <QGraphicsSceneDragDropEvent>
#include <QGraphicsView>
#include <QPropertyAnimation>
#include <QTimer>
#include <QGraphicsView>
#include <QPropertyAnimation>
#include <QTimer>
+#include <views/draganddrophelper.h>
#include <views/renamedialog.h>
#include <KDebug>
#include <views/renamedialog.h>
#include <KDebug>
void FoldersPanel::setAutoScrolling(bool enable)
{
void FoldersPanel::setAutoScrolling(bool enable)
{
- //m_treeView->setAutoHorizontalScroll(enable);
+ // TODO: Not supported yet in Dolphin 2.0
FoldersPanelSettings::setAutoScrolling(enable);
}
FoldersPanelSettings::setAutoScrolling(enable);
}
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
+ connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
// TODO: Check whether it makes sense to make an explicit API for KItemListContainer
// to make the background transparent.
// TODO: Check whether it makes sense to make an explicit API for KItemListContainer
// to make the background transparent.
const int key = event->key();
if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) {
event->accept();
const int key = event->key();
if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) {
event->accept();
- //updateActiveView(m_treeView->currentIndex());
} else {
Panel::keyPressEvent(event);
}
} else {
Panel::keyPressEvent(event);
}
+void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
+{
+ if (index >= 0) {
+ const KFileItem destItem = fileItemModel()->fileItem(index);
+
+ QDropEvent dropEvent(event->pos().toPoint(),
+ event->possibleActions(),
+ event->mimeData(),
+ event->buttons(),
+ event->modifiers());
+
+ DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+ }
+}
+
void FoldersPanel::slotLoadingCompleted()
{
if (m_controller->view()->opacity() == 0) {
void FoldersPanel::slotLoadingCompleted()
{
if (m_controller->view()->opacity() == 0) {
m_updateCurrentItem = false;
}
m_updateCurrentItem = false;
}
-void FoldersPanel::slotHorizontalScrollBarMoved(int value)
-{
- Q_UNUSED(value);
- // Disable the auto-scrolling until the vertical scrollbar has
- // been moved by the user.
- //m_treeView->setAutoHorizontalScroll(false);
-}
-
-void FoldersPanel::slotVerticalScrollBarMoved(int value)
-{
- Q_UNUSED(value);
- // Enable the auto-scrolling again (it might have been disabled by
- // moving the horizontal scrollbar).
- //m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling());
-}
-
void FoldersPanel::startFadeInAnimation()
{
QPropertyAnimation* anim = new QPropertyAnimation(m_controller->view(), "opacity", this);
void FoldersPanel::startFadeInAnimation()
{
QPropertyAnimation* anim = new QPropertyAnimation(m_controller->view(), "opacity", this);
class KDirLister;
class KFileItemModel;
class KItemListController;
class KDirLister;
class KFileItemModel;
class KItemListController;
+class QGraphicsSceneDragDropEvent;
/**
* @brief Shows a tree view of the directories starting from
/**
* @brief Shows a tree view of the directories starting from
void slotItemMiddleClicked(int index);
void slotItemContextMenuRequested(int index, const QPointF& pos);
void slotViewContextMenuRequested(const QPointF& pos);
void slotItemMiddleClicked(int index);
void slotItemContextMenuRequested(int index, const QPointF& pos);
void slotViewContextMenuRequested(const QPointF& pos);
+ void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotLoadingCompleted();
void slotLoadingCompleted();
- void slotHorizontalScrollBarMoved(int value);
-
- void slotVerticalScrollBarMoved(int value);
-
/**
* Increases the opacity of the view step by step until it is fully
* opaque.
/**
* Increases the opacity of the view step by step until it is fully
* opaque.
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
- DragAndDropHelper::dropUrls(KFileItem(), dest, event, parent);
+ Q_UNUSED(parent);
+ DragAndDropHelper::dropUrls(KFileItem(), dest, event);
}
void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
}
void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
event->buttons(),
event->modifiers());
event->buttons(),
event->modifiers());
- DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this);
+ DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
#include <KLocale>
#include <konq_operations.h>
#include <KUrl>
#include <KLocale>
#include <konq_operations.h>
#include <KUrl>
#include <QtDBus>
#include <QDropEvent>
#include <QtDBus>
#include <QDropEvent>
QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
const KUrl& destPath,
QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
const KUrl& destPath,
- QDropEvent* event,
- QWidget* widget)
{
const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
const KUrl destination = dropToItem ? destItem.url() : destPath;
{
const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
const KUrl destination = dropToItem ? destItem.url() : destPath;
if (urlsCount == 1 && urls.first() == destination) {
return i18nc("@info:status", "A folder cannot be dropped into itself");
} else if (dropToItem) {
if (urlsCount == 1 && urls.first() == destination) {
return i18nc("@info:status", "A folder cannot be dropped into itself");
} else if (dropToItem) {
- KonqOperations::doDrop(destItem, destination, event, widget);
+ KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
- KonqOperations::doDrop(KFileItem(), destination, event, widget);
+ KonqOperations::doDrop(KFileItem(), destination, event, QApplication::activeWindow());
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
* @param destPath Path of the destination.
* @param event Drop event.
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
* @param destPath Path of the destination.
* @param event Drop event.
- * @param widget Source widget where the dragging has been started.
* @return Error message if dropping is not possible. If an empty string
* is returned, the dropping has been successful.
*/
static QString dropUrls(const KFileItem& destItem,
const KUrl& destPath,
* @return Error message if dropping is not possible. If an empty string
* is returned, the dropping has been successful.
*/
static QString dropUrls(const KFileItem& destItem,
const KUrl& destPath,
- QDropEvent* event,
- QWidget* widget);