]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Merge branch 'release/20.08' into master
[dolphin.git] / src / views / dolphinview.cpp
index aef0e85d603149198720e584543b11ec5068e671..f102e9acb1a6a9905643a85379715b10415d660e 100644 (file)
@@ -1,22 +1,9 @@
-/***************************************************************************
- *   Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com>        *
- *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Gregor Kališnik <gregor@podnapisi.net>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphinview.h"
 
@@ -692,7 +679,7 @@ void DolphinView::copySelectedItemsToClipboard()
     QApplication::clipboard()->setMimeData(mimeData);
 }
 
-void DolphinView::copySelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl)
+void DolphinView::copySelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
 {
     KIO::CopyJob* job = KIO::copy(selection.urlList(), destinationUrl, KIO::DefaultFlags);
     KJobWidgets::setWindow(job, this);
@@ -702,7 +689,7 @@ void DolphinView::copySelectedItemsToInactiveSplitView(const KFileItemList &sele
     KIO::FileUndoManager::self()->recordCopyJob(job);
 }
 
-void DolphinView::moveSelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl)
+void DolphinView::moveSelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
 {
     KIO::CopyJob* job = KIO::move(selection.urlList(), destinationUrl, KIO::DefaultFlags);
     KJobWidgets::setWindow(job, this);
@@ -761,7 +748,7 @@ void DolphinView::duplicateSelectedItems()
             duplicateURL.setPath(originalDirectoryPath + i18nc("<filename> copy", "%1 copy", originalFilenameWithoutExtension) + originalExtension);
         }
 
-        KIO::CopyJob* job = KIO::copyAs(originalURL, duplicateURL, KIO::HideProgressInfo);
+        KIO::CopyJob* job = KIO::copyAs(originalURL, duplicateURL);
         KJobWidgets::setWindow(job, this);
 
         if (job) {
@@ -1522,8 +1509,12 @@ void DolphinView::calculateItemCount(int& fileCount,
 
     bool countFileSize = true;
 
+    if (!m_model->rootItem().url().isValid()) {
+        return;
+    }
+
     // In case we have a precomputed value
-    const auto job = KIO::statDetails(m_model->rootItem().url(), KIO::StatJob::SourceSide, KIO::StatRecursiveSize);
+    const auto job = KIO::statDetails(m_model->rootItem().url(), KIO::StatJob::SourceSide, KIO::StatRecursiveSize, KIO::HideProgressInfo);
     job->exec();
     const auto entry =  job->statResult();
     if (entry.contains(KIO::UDSEntry::UDS_RECURSIVE_SIZE)) {
@@ -1945,3 +1936,21 @@ void DolphinView::forceUrlsSelection(const QUrl& current, const QList<QUrl>& sel
     markUrlAsCurrent(current);
     markUrlsAsSelected(selected);
 }
+
+void DolphinView::copyPathToClipboard()
+{
+    const KFileItemList list = selectedItems();
+    if (list.isEmpty()) {
+        return;
+    }
+    const KFileItem& item = list.at(0);
+    QString path = item.localPath();
+    if (path.isEmpty()) {
+        path = item.url().toDisplayString();
+    }
+    QClipboard* clipboard = QApplication::clipboard();
+    if (clipboard == nullptr) {
+        return;
+    }
+    clipboard->setText(path);
+}