+void DolphinView::trashSelectedItems()
+{
+ emit doingOperation(KonqFileUndoManager::TRASH);
+ KonqOperations::del(this, KonqOperations::TRASH, selectedUrls());
+}
+
+void DolphinView::deleteSelectedItems()
+{
+ const KUrl::List list = selectedUrls();
+ const bool del = KonqOperations::askDeleteConfirmation(list,
+ KonqOperations::DEL,
+ KonqOperations::DEFAULT_CONFIRMATION,
+ this);
+
+ if (del) {
+ KIO::Job* job = KIO::del(list);
+ connect(job, SIGNAL(result(KJob*)),
+ this, SLOT(slotDeleteFileFinished(KJob*)));
+ }
+}
+
+void DolphinView::slotDeleteFileFinished(KJob* job)
+{
+ if (job->error() == 0) {
+ emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
+ } else {
+ emit errorMessage(job->errorString());
+ }
+}
+
+void DolphinView::slotPreviewJobFinished(KJob* job)
+{
+ Q_ASSERT(job == m_previewJob);
+ m_previewJob = 0;
+}
+
+void DolphinView::cutSelectedItems()
+{
+ QMimeData* mimeData = new QMimeData();
+ const KUrl::List kdeUrls = selectedUrls();
+ const KUrl::List mostLocalUrls;
+ KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
+ QApplication::clipboard()->setMimeData(mimeData);
+}
+
+void DolphinView::copySelectedItems()
+{
+ QMimeData* mimeData = new QMimeData();
+ const KUrl::List kdeUrls = selectedUrls();
+ const KUrl::List mostLocalUrls;
+ KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
+ QApplication::clipboard()->setMimeData(mimeData);
+}
+
+void DolphinView::paste()
+{
+ QClipboard* clipboard = QApplication::clipboard();
+ const QMimeData* mimeData = clipboard->mimeData();
+
+ const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
+
+ // per default the pasting is done into the current Url of the view
+ KUrl destUrl(url());
+
+ // check whether the pasting should be done into a selected directory
+ const KUrl::List selectedUrls = this->selectedUrls();
+ if (selectedUrls.count() == 1) {
+ const KFileItem fileItem(S_IFDIR,
+ KFileItem::Unknown,
+ selectedUrls.first(),
+ true);
+ if (fileItem.isDir()) {
+ // only one item is selected which is a directory, hence paste
+ // into this directory
+ destUrl = selectedUrls.first();
+ }
+ }
+
+ if (KonqMimeData::decodeIsCutSelection(mimeData)) {
+ KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, destUrl);
+ emit doingOperation(KonqFileUndoManager::MOVE);
+ clipboard->clear();
+ } else {
+ KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, destUrl);
+ emit doingOperation(KonqFileUndoManager::COPY);
+ }
+}
+
+QPair<bool, QString> DolphinView::pasteInfo() const
+{
+ QPair<bool, QString> ret;
+ QClipboard* clipboard = QApplication::clipboard();
+ const QMimeData* mimeData = clipboard->mimeData();
+
+ KUrl::List urls = KUrl::List::fromMimeData(mimeData);
+ if (!urls.isEmpty()) {
+ ret.first = true;
+ ret.second = i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count());
+ } else {
+ ret.first = false;
+ ret.second = i18nc("@action:inmenu", "Paste");
+ }
+
+ if (ret.first) {
+ const KFileItemList items = selectedItems();
+ const uint count = items.count();
+ if (count > 1) {
+ // pasting should not be allowed when more than one file
+ // is selected
+ ret.first = false;
+ } else if (count == 1) {
+ // Only one file is selected. Pasting is only allowed if this
+ // file is a directory.
+ ret.first = items.first().isDir();
+ }
+ }
+ return ret;