]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'release/20.04'
authorNate Graham <nate@kde.org>
Wed, 3 Jun 2020 17:51:01 +0000 (11:51 -0600)
committerNate Graham <nate@kde.org>
Wed, 3 Jun 2020 17:51:01 +0000 (11:51 -0600)
1  2 
src/views/dolphinview.cpp

index c827f5768ed1a11699cc05f9964324f15e83a0e1,2caa8ec68185ec0a465cacd3f673c4cf6e8e02fe..9af6919277911779b9bbc74220bf5ad464a9f33f
@@@ -364,7 -364,7 +364,7 @@@ void DolphinView::markUrlAsCurrent(cons
      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
  
      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,40 -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());
@@@ -761,7 -740,7 +761,7 @@@ void DolphinView::duplicateSelectedItem
              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) {
@@@ -1153,7 -1132,7 +1153,7 @@@ void DolphinView::dropUrls(const QUrl &
      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.
@@@ -1206,11 -1185,6 +1206,11 @@@ void DolphinView::slotSelectedItemTextP
      }
  }
  
 +void DolphinView::slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to)
 +{
 +    slotItemCreated(to);
 +}
 +
  void DolphinView::slotItemCreated(const QUrl& url)
  {
      if (m_markFirstNewlySelectedItemAsCurrent) {
      m_selectedUrls << url;
  }
  
 -void DolphinView::slotPasteJobResult(KJob *job)
 +void DolphinView::slotJobResult(KJob *job)
  {
      if (job->error()) {
          emit errorMessage(job->errorString());
      }
      if (!m_selectedUrls.isEmpty()) {
 -        m_selectedUrls << KDirModel::simplifiedUrlList(m_selectedUrls);
 +        m_selectedUrls = KDirModel::simplifiedUrlList(m_selectedUrls);
      }
  }
  
@@@ -1519,31 -1493,13 +1519,31 @@@ void DolphinView::calculateItemCount(in
                                       KIO::filesize_t& totalFileSize) const
  {
      const int itemCount = m_model->count();
 +
 +    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, KIO::HideProgressInfo);
 +    job->exec();
 +    const auto entry =  job->statResult();
 +    if (entry.contains(KIO::UDSEntry::UDS_RECURSIVE_SIZE)) {
 +        totalFileSize = static_cast<KIO::filesize_t>(entry.numberValue(KIO::UDSEntry::UDS_RECURSIVE_SIZE));
 +        countFileSize = false;
 +    }
 +
      for (int i = 0; i < itemCount; ++i) {
          const KFileItem item = m_model->fileItem(i);
          if (item.isDir()) {
              ++folderCount;
          } else {
              ++fileCount;
 -            totalFileSize += item.size();
 +            if (countFileSize) {
 +                totalFileSize += item.size();
 +            }
          }
      }
  }
@@@ -1875,7 -1831,7 +1875,7 @@@ void DolphinView::pasteToUrl(const QUrl
      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