* only show the hover-drop-indicator on directories (dropping on file-items is handled like dropping on the viewport)
* simplified signature of drop signal (source widget not required anymore)
svn path=/trunk/KDE/kdebase/apps/; revision=731129
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
setDirtyRegion(m_dropRect);
}
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
- if (index.isValid()) {
- const KFileItem item = itemForIndex(index);
- m_view->m_controller->indicateDroppedUrls(urls,
- url(),
- item,
- event->source());
- event->acceptProposedAction();
- }
+ const KFileItem item = itemForIndex(index);
+ m_view->m_controller->indicateDroppedUrls(urls,
+ url(),
+ item);
+ event->acceptProposedAction();
}
QListView::dropEvent(event);
m_dragging = false;
}
QListView::dropEvent(event);
m_dragging = false;
void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source)
+ const KFileItem& destItem)
- emit urlsDropped(urls, destPath, destItem, source);
+ emit urlsDropped(urls, destPath, destItem);
* @param urls URLs that are dropped above a destination.
* @param destPath Path of the destination.
* @param destItem Destination item (can be null, see KFileItem::isNull()).
* @param urls URLs that are dropped above a destination.
* @param destPath Path of the destination.
* @param destItem Destination item (can be null, see KFileItem::isNull()).
- * @param source Pointer to the view implementation which invoked this method.
*/
void indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
*/
void indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Informs the abstract Dolphin view about a sorting change done inside
/**
* Informs the abstract Dolphin view about a sorting change done inside
* Is emitted if the URLs \a urls have been dropped to the destination
* path \a destPath. If the URLs have been dropped above an item of
* the destination path, the item is indicated by \a destItem
* Is emitted if the URLs \a urls have been dropped to the destination
* path \a destPath. If the URLs have been dropped above an item of
* the destination path, the item is indicated by \a destItem
- * (can be null, see KFileItem::isNull()). \a source indicates
- * the widget where the dragging has been started from.
+ * (can be null, see KFileItem::isNull()).
*/
void urlsDropped(const KUrl::List& urls,
const KUrl& destPath,
*/
void urlsDropped(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Is emitted if the sorting has been changed to \a sorting by
/**
* Is emitted if the sorting has been changed to \a sorting by
m_dragging = false;
} else {
m_dragging = true;
m_dragging = false;
} else {
m_dragging = true;
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
}
setDirtyRegion(m_dropRect);
}
}
if (!urls.isEmpty()) {
event->acceptProposedAction();
const QModelIndex index = indexAt(event->pos());
if (!urls.isEmpty()) {
event->acceptProposedAction();
const QModelIndex index = indexAt(event->pos());
if (index.isValid() && (index.column() == DolphinModel::Name)) {
if (index.isValid() && (index.column() == DolphinModel::Name)) {
- const KFileItem item = itemForIndex(index);
- m_controller->indicateDroppedUrls(urls,
- m_controller->url(),
- item,
- event->source());
+ item = itemForIndex(index);
+ m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
+ item);
}
QTreeView::dropEvent(event);
m_dragging = false;
}
QTreeView::dropEvent(event);
m_dragging = false;
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
- m_dropRect = visualRect(index);
+ if (itemForIndex(index).isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
setDirtyRegion(m_dropRect);
}
setDirtyRegion(m_dropRect);
}
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
- if (index.isValid()) {
- const KFileItem item = itemForIndex(index);
- m_controller->indicateDroppedUrls(urls,
- m_controller->url(),
- item,
- event->source());
- event->acceptProposedAction();
- }
+ const KFileItem item = itemForIndex(index);
+ m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
+ item);
+ event->acceptProposedAction();
connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
this, SLOT(openContextMenu(const QPoint&)));
connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
this, SLOT(openContextMenu(const QPoint&)));
- connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)),
- this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)));
+ connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&)),
+ this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&)));
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destPath,
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source)
-{
- bool dropAboveDir = false;
- if (!destItem.isNull()) {
- dropAboveDir = destItem.isDir();
- if (!dropAboveDir) {
- // the dropping is done above a file
- return;
- }
- } else if (source == itemView()) {
- // the dropping is done into the same viewport where the dragging
- // has been started
- return;
+ const KFileItem& destItem)
+{
+ const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
+ destItem.url() : destPath;
+ const KUrl sourceDir = KUrl(urls.first().directory());
+ if (sourceDir != destination) {
+ dropUrls(urls, destination);
-
- const KUrl& destination = dropAboveDir ? destItem.url() : destPath;
- dropUrls(urls, destination);
}
void DolphinView::dropUrls(const KUrl::List& urls,
}
void DolphinView::dropUrls(const KUrl::List& urls,
/**
* Drops the URLs \a urls to the destination path \a destPath. If
* the URLs are dropped above an item inside the destination path,
/**
* Drops the URLs \a urls to the destination path \a destPath. If
* the URLs are dropped above an item inside the destination path,
- * the item is indicated by \a destItem. \a source
- * indicates the widget where the dragging has been started from.
+ * the item is indicated by \a destItem.
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destPath,
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destPath,
- const KFileItem& destItem,
- QWidget* source);
+ const KFileItem& destItem);
/**
* Drops the URLs \a urls at the
/**
* Drops the URLs \a urls at the