]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
DolphinView: rename new methods to copy/move urls
[dolphin.git] / src / views / dolphinview.cpp
index f0dc17837a5ddcad2bb3a18a50aa5bb19382fb1e..02210baf4714f0490719ac17bb7d2a41bca828e3 100644 (file)
@@ -364,7 +364,7 @@ void DolphinView::markUrlAsCurrent(const QUrl &url)
     m_scrollToCurrentItem = true;
 }
 
-void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
+void DolphinView::selectItems(const QRegularExpression &regexp, bool enabled)
 {
     const KItemListSelectionManager::SelectionMode mode = enabled
                                                         ? KItemListSelectionManager::Select
@@ -373,7 +373,7 @@ void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
 
     for (int index = 0; index < m_model->count(); index++) {
         const KFileItem item = m_model->fileItem(index);
-        if (pattern.exactMatch(item.text())) {
+        if (regexp.match(item.text()).hasMatch()) {
             // An alternative approach would be to store the matching items in a KItemSet and
             // select them in one go after the loop, but we'd need a new function
             // KItemListSelectionManager::setSelected(KItemSet, SelectionMode mode)
@@ -679,19 +679,40 @@ void DolphinView::deleteSelectedItems()
     }
 }
 
-void DolphinView::cutSelectedItems()
+void DolphinView::cutSelectedItemsToClipboard()
 {
     QMimeData* mimeData = selectionMimeData();
     KIO::setClipboardDataCut(mimeData, true);
     QApplication::clipboard()->setMimeData(mimeData);
 }
 
-void DolphinView::copySelectedItems()
+void DolphinView::copySelectedItemsToClipboard()
 {
     QMimeData* mimeData = selectionMimeData();
     QApplication::clipboard()->setMimeData(mimeData);
 }
 
+void DolphinView::copySelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
+{
+    KIO::CopyJob* job = KIO::copy(selection.urlList(), destinationUrl, KIO::DefaultFlags);
+    KJobWidgets::setWindow(job, this);
+
+    connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+    connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotCopyingDone);
+    KIO::FileUndoManager::self()->recordCopyJob(job);
+}
+
+void DolphinView::moveSelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
+{
+    KIO::CopyJob* job = KIO::move(selection.urlList(), destinationUrl, KIO::DefaultFlags);
+    KJobWidgets::setWindow(job, this);
+
+    connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+    connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotCopyingDone);
+    KIO::FileUndoManager::self()->recordCopyJob(job);
+
+}
+
 void DolphinView::paste()
 {
     pasteToUrl(url());
@@ -1132,7 +1153,7 @@ void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *
     KIO::DropJob* job = DragAndDropHelper::dropUrls(destUrl, dropEvent, dropWidget);
 
     if (job) {
-        connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult);
+        connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
 
         if (destUrl == url()) {
             // Mark the dropped urls as selected.
@@ -1185,6 +1206,11 @@ void DolphinView::slotSelectedItemTextPressed(int index)
     }
 }
 
+void DolphinView::slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to)
+{
+    slotItemCreated(to);
+}
+
 void DolphinView::slotItemCreated(const QUrl& url)
 {
     if (m_markFirstNewlySelectedItemAsCurrent) {
@@ -1194,7 +1220,7 @@ void DolphinView::slotItemCreated(const QUrl& url)
     m_selectedUrls << url;
 }
 
-void DolphinView::slotPasteJobResult(KJob *job)
+void DolphinView::slotJobResult(KJob *job)
 {
     if (job->error()) {
         emit errorMessage(job->errorString());
@@ -1845,7 +1871,7 @@ void DolphinView::pasteToUrl(const QUrl& url)
     m_clearSelectionBeforeSelectingNewItems = true;
     m_markFirstNewlySelectedItemAsCurrent = true;
     connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
-    connect(job, &KIO::PasteJob::result, this, &DolphinView::slotPasteJobResult);
+    connect(job, &KIO::PasteJob::result, this, &DolphinView::slotJobResult);
 }
 
 QList<QUrl> DolphinView::simplifiedSelectedUrls() const