- QString text(i18nc("@action:inmenu", "Paste"));
- QClipboard* clipboard = QApplication::clipboard();
- const QMimeData* mimeData = clipboard->mimeData();
-
- KUrl::List urls = KUrl::List::fromMimeData(mimeData);
- if (!urls.isEmpty()) {
- pasteAction->setEnabled(true);
-
- pasteAction->setText(i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count()));
- } else {
- pasteAction->setEnabled(false);
- pasteAction->setText(i18nc("@action:inmenu", "Paste"));
- }
-
- if (pasteAction->isEnabled()) {
- KUrl::List urls = m_activeViewContainer->view()->selectedUrls();
- const uint count = urls.count();
- if (count > 1) {
- // pasting should not be allowed when more than one file
- // is selected
- pasteAction->setEnabled(false);
- } else if (count == 1) {
- // Only one file is selected. Pasting is only allowed if this
- // file is a directory.
- // TODO: this doesn't work with remote protocols; instead we need a
- // m_activeViewContainer->selectedFileItems() to get the real KFileItems
- const KFileItem fileItem(S_IFDIR,
- KFileItem::Unknown,
- urls.first(),
- true);
- pasteAction->setEnabled(fileItem.isDir());
- }
- }
+ QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
+ pasteAction->setEnabled(pasteInfo.first);
+ pasteAction->setText(pasteInfo.second);