X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1b5b731621ea79cff04f745890693ebe060515cc..f0d201dcf1fb46e172e950c6f1767c5e8e6b9495:/src/dolphinpart_ext.cpp diff --git a/src/dolphinpart_ext.cpp b/src/dolphinpart_ext.cpp index e98c0648e..a6d52e583 100644 --- a/src/dolphinpart_ext.cpp +++ b/src/dolphinpart_ext.cpp @@ -1,20 +1,7 @@ /* This file is part of the KDE project - * Copyright (c) 2012 Dawit Alemayehu + * SPDX-FileCopyrightText: 2012 Dawit Alemayehu * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. + * SPDX-License-Identifier: LGPL-2.0-or-later */ #include "dolphinpart_ext.h" @@ -22,9 +9,90 @@ #include "dolphinpart.h" #include "views/dolphinview.h" -#include +DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part) + :KParts::BrowserExtension( part ) + ,m_part(part) +{ + +} + +void DolphinPartBrowserExtension::restoreState(QDataStream &stream) +{ + KParts::BrowserExtension::restoreState(stream); + m_part->view()->restoreState(stream); +} + +void DolphinPartBrowserExtension::saveState(QDataStream &stream) +{ + KParts::BrowserExtension::saveState(stream); + m_part->view()->saveState(stream); +} + +void DolphinPartBrowserExtension::cut() +{ + m_part->view()->cutSelectedItemsToClipboard(); +} + +void DolphinPartBrowserExtension::copy() +{ + m_part->view()->copySelectedItemsToClipboard(); +} + +void DolphinPartBrowserExtension::paste() +{ + m_part->view()->paste(); +} + +void DolphinPartBrowserExtension::pasteTo(const QUrl&) +{ + m_part->view()->pasteIntoFolder(); +} + +void DolphinPartBrowserExtension::reparseConfiguration() +{ + m_part->view()->readSettings(); +} + + +DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart* part) + :KParts::FileInfoExtension(part) + ,m_part(part) +{ +} + +bool DolphinPartFileInfoExtension::hasSelection() const +{ + return m_part->view()->selectedItemsCount() > 0; +} + +KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const +{ + return (KParts::FileInfoExtension::AllItems | KParts::FileInfoExtension::SelectedItems); +} + +KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode) const +{ + KFileItemList list; + + if (mode == KParts::FileInfoExtension::None) + return list; -#include + if (!(supportedQueryModes() & mode)) + return list; + + switch (mode) { + case KParts::FileInfoExtension::SelectedItems: + if (hasSelection()) + return m_part->view()->selectedItems(); + break; + case KParts::FileInfoExtension::AllItems: + return m_part->view()->items(); + default: + break; + } + + return list; +} DolphinPartListingFilterExtension::DolphinPartListingFilterExtension(DolphinPart* part) : KParts::ListingFilterExtension(part) @@ -96,12 +164,11 @@ KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingN void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList& items) { - emit listingEvent(KParts::ListingNotificationExtension::ItemsAdded, items); + Q_EMIT listingEvent(KParts::ListingNotificationExtension::ItemsAdded, items); } void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemList& items) { - emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items); + Q_EMIT listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items); } -#include "dolphinpart_ext.moc"