X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7a2885853a424042cb631f83a1db278560679d9e..82b542cb2b9eb61b30e2a9a613081b7ab286e9ad:/src/kitemviews/kfileitemmodel.h diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 132a76e46..471cfc2d2 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -1,21 +1,8 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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: 2011 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #ifndef KFILEITEMMODEL_H #define KFILEITEMMODEL_H @@ -33,9 +20,14 @@ #include -class KFileItemModelDirLister; +class KDirLister; + class QTimer; +namespace KIO { + class Job; +} + /** * @brief KItemModelBase implementation for KFileItems. * @@ -93,6 +85,12 @@ public: void setSortDirectoriesFirst(bool dirsFirst); bool sortDirectoriesFirst() const; + /** + * Sets a separate sorting with hidden files and folders last (true) or not (false). + */ + void setSortHiddenLast(bool hiddenLast); + bool sortHiddenLast() const; + void setShowHiddenFiles(bool show); bool showHiddenFiles() const; @@ -198,7 +196,7 @@ public: */ static QList rolesInformation(); -signals: +Q_SIGNALS: /** * Is emitted if the loading of a directory has been started. It is * assured that a signal directoryLoadingCompleted() will be send after @@ -258,12 +256,18 @@ signals: */ void urlIsFileError(const QUrl& url); + /** + * It is emitted for files when they change and + * for dirs when files are added or removed. + */ + void fileItemsChanged(const KFileItemList &changedFileItems); + protected: void onGroupedSortingChanged(bool current) override; void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override; void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override; -private slots: +private Q_SLOTS: /** * Resorts all items dependent on the set sortRole(), sortOrder() * and foldersFirst() settings. @@ -277,6 +281,7 @@ private slots: void slotRefreshItems(const QList >& items); void slotClear(); void slotSortingChoiceChanged(); + void slotListerError(KIO::Job *job); void dispatchPendingItemsToInsert(); @@ -304,7 +309,8 @@ private: enum RemoveItemsBehavior { KeepItemData, - DeleteItemData + DeleteItemData, + DeleteItemDataIfUnfiltered }; void insertItems(QList& items); @@ -464,12 +470,22 @@ private: */ bool isConsistent() const; + /** + * Filters out the expanded folders that don't pass the filter themselves and don't have any filter-passing children. + * Will update the removedItemRanges arguments to include the parents that have been filtered. + * @returns the number of parents that have been filtered. + * @param removedItemRanges The ranges of items being deleted/filtered, will get updated + * @param parentsToEnsureVisible Parents that must be visible no matter what due to being ancestors of newly visible items + */ + int filterChildlessParents(KItemRangeList &removedItemRanges, const QSet &parentsToEnsureVisible = QSet()); + private: - KFileItemModelDirLister* m_dirLister; + KDirLister *m_dirLister = nullptr; QCollator m_collator; bool m_naturalSorting; bool m_sortDirsFirst; + bool m_sortHiddenLast; RoleType m_sortRole; int m_sortingProgressPercent; // Value of directorySortingProgress() signal