X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b6700f77dd8e07fdab0d40ea4bc91f8d0c03ae70..a24327cd50ef17b953ecb908d260b73460158107:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 02210baf4..e69f18d7e 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1,22 +1,9 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 by Peter Penz * - * Copyright (C) 2006 by Gregor Kališnik * - * * - * 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 + * SPDX-FileCopyrightText: 2006 Gregor Kališnik + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "dolphinview.h" @@ -147,6 +134,9 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading); connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged); connect(controller, &KItemListController::selectedItemTextPressed, this, &DolphinView::slotSelectedItemTextPressed); + connect(controller, &KItemListController::increaseZoom, this, &DolphinView::slotIncreaseZoom); + connect(controller, &KItemListController::decreaseZoom, this, &DolphinView::slotDecreaseZoom); + connect(controller, &KItemListController::swipeUp, this, &DolphinView::slotSwipeUp); connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted); connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted); @@ -522,7 +512,7 @@ QString DolphinView::statusBarText() const if (m_container->controller()->selectionManager()->hasSelection()) { // Give a summary of the status of the selected files const KFileItemList list = selectedItems(); - foreach (const KFileItem& item, list) { + for (const KFileItem& item : list) { if (item.isDir()) { ++folderCount; } else { @@ -761,7 +751,7 @@ void DolphinView::duplicateSelectedItems() duplicateURL.setPath(originalDirectoryPath + i18nc(" 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) { @@ -973,7 +963,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) QPointer menu = new QMenu(QApplication::activeWindow()); KItemListView* view = m_container->controller()->view(); - const QSet visibleRolesSet = view->visibleRoles().toSet(); + const QList visibleRolesSet = view->visibleRoles(); bool indexingEnabled = false; #ifdef HAVE_BALOO @@ -986,7 +976,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) // Add all roles to the menu that can be shown or hidden by the user const QList rolesInfo = KFileItemModel::rolesInformation(); - foreach (const KFileItemModel::RoleInfo& info, rolesInfo) { + for (const KFileItemModel::RoleInfo& info : rolesInfo) { if (info.role == "text") { // It should not be possible to hide the "text" role continue; @@ -1043,8 +1033,9 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) // Apply the current column-widths as custom column-widths and turn // off the automatic resizing of the columns QList columnWidths; - columnWidths.reserve(view->visibleRoles().count()); - foreach (const QByteArray& role, view->visibleRoles()) { + const auto visibleRoles = view->visibleRoles(); + columnWidths.reserve(visibleRoles.count()); + for (const QByteArray& role : visibleRoles) { columnWidths.append(header->columnWidth(role)); } props.setHeaderColumnWidths(columnWidths); @@ -1065,8 +1056,9 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) QList columnWidths; if (!header->automaticColumnResizing()) { - columnWidths.reserve(view->visibleRoles().count()); - foreach (const QByteArray& role, view->visibleRoles()) { + const auto visibleRoles = view->visibleRoles(); + columnWidths.reserve(visibleRoles.count()); + for (const QByteArray& role : visibleRoles) { columnWidths.append(header->columnWidth(role)); } } @@ -1087,7 +1079,7 @@ void DolphinView::slotHeaderColumnWidthChangeFinished(const QByteArray& role, qr columnWidths.clear(); columnWidths.reserve(visibleRoles.count()); const KItemListHeader* header = m_view->header(); - foreach (const QByteArray& role, visibleRoles) { + for (const QByteArray& role : visibleRoles) { const int width = header->columnWidth(role); columnWidths.append(width); } @@ -1511,6 +1503,8 @@ void DolphinView::hideToolTip(const ToolTipManager::HideBehavior behavior) if (GeneralSettings::showToolTips()) { m_toolTipManager->hideToolTip(behavior); } +#else + Q_UNUSED(behavior) #endif } @@ -1522,8 +1516,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)) { @@ -1880,7 +1878,7 @@ QList DolphinView::simplifiedSelectedUrls() const const KFileItemList items = selectedItems(); urls.reserve(items.count()); - foreach (const KFileItem& item, items) { + for (const KFileItem& item : items) { urls.append(item.url()); } @@ -1945,3 +1943,36 @@ void DolphinView::forceUrlsSelection(const QUrl& current, const QList& 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); +} + +void DolphinView::slotIncreaseZoom() +{ + setZoomLevel(zoomLevel() + 1); +} + +void DolphinView::slotDecreaseZoom() +{ + setZoomLevel(zoomLevel() - 1); +} + +void DolphinView::slotSwipeUp() +{ + emit goUpRequested(); +}