use KDirModel::mimeData() for cut/copy operations as suggested by David Faure

CCMAIL: faure@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=891865
This commit is contained in:
Peter Penz 2008-12-03 07:14:37 +00:00
parent fe06efe734
commit add0f6db79
6 changed files with 41 additions and 2 deletions

View file

@ -269,6 +269,11 @@ KFileItemList DolphinColumnView::selectedItems() const
return activeColumn()->selectedItems();
}
QMimeData* DolphinColumnView::selectionMimeData() const
{
return activeColumn()->selectionMimeData();
}
void DolphinColumnView::selectAll()
{
activeColumn()->selectAll();

View file

@ -112,6 +112,12 @@ public:
* Returns the selected items of the active column.
*/
KFileItemList selectedItems() const;
/**
* Returns the MIME data for the selected items
* of the active column.
*/
QMimeData* selectionMimeData() const;
public slots:
/** @see QAbstractItemView::selectAll() */

View file

@ -277,6 +277,12 @@ KFileItemList DolphinColumnWidget::selectedItems() const
return itemList;
}
QMimeData* DolphinColumnWidget::selectionMimeData() const
{
const QItemSelection selection = m_proxyModel->mapSelectionToSource(selectionModel()->selection());
return m_dolphinModel->mimeData(selection.indexes());
}
QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
{
QStyleOptionViewItem viewOptions = QListView::viewOptions();

View file

@ -111,6 +111,11 @@ public:
KFileItem itemAt(const QPoint& pos) const;
KFileItemList selectedItems() const;
/**
* Returns the MIME data for the selected items.
*/
QMimeData* selectionMimeData() const;
protected:
virtual QStyleOptionViewItem viewOptions() const;

View file

@ -701,7 +701,7 @@ void DolphinView::deleteSelectedItems()
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = new QMimeData();
QMimeData* mimeData = selectionMimeData();
const KUrl::List kdeUrls = simplifiedSelectedUrls();
const KUrl::List mostLocalUrls;
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
@ -710,7 +710,7 @@ void DolphinView::cutSelectedItems()
void DolphinView::copySelectedItems()
{
QMimeData* mimeData = new QMimeData();
QMimeData* mimeData = selectionMimeData();
const KUrl::List kdeUrls = selectedUrls();
const KUrl::List mostLocalUrls;
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
@ -1424,4 +1424,16 @@ bool DolphinView::itemsExpandable() const
return (m_detailsView != 0) && m_detailsView->itemsExpandable();
}
QMimeData* DolphinView::selectionMimeData() const
{
if (isColumnViewActive()) {
return m_columnView->selectionMimeData();
}
const QAbstractItemView* view = itemView();
Q_ASSERT((view != 0) && (view->selectionModel() != 0));
const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
return m_dolphinModel->mimeData(selection.indexes());
}
#include "dolphinview.moc"

View file

@ -704,6 +704,11 @@ private:
* is currently shown.
*/
void deleteExpandedViews();
/**
* Returns the MIME data for all selected items.
*/
QMimeData* selectionMimeData() const;
private:
bool m_active : 1;