]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kdirectorycontentscounter.h
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / kitemviews / private / kdirectorycontentscounter.h
index 425c3632aa39f4e447aed5aa64ccb7dbc7afc115..cc8616ff7915a6c7e441046c55dbc2497300bc37 100644 (file)
@@ -1,22 +1,9 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *   Copyright (C) 2013 by Frank Reininghaus <frank78ac@googlemail.com>    *
- *                                                                         *
- *   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 <peter.penz19@gmail.com>
+ *   SPDX-FileCopyrightText: 2013 Frank Reininghaus <frank78ac@googlemail.com>
+ *
+ *   SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef KDIRECTORYCONTENTSCOUNTER_H
 #define KDIRECTORYCONTENTSCOUNTER_H
@@ -24,7 +11,7 @@
 #include "kdirectorycontentscounterworker.h"
 
 #include <QSet>
-#include <QQueue>
+#include <QHash>
 
 class KDirWatch;
 class KFileItemModel;
@@ -35,8 +22,8 @@ class KDirectoryContentsCounter : public QObject
     Q_OBJECT
 
 public:
-    explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = 0);
-    ~KDirectoryContentsCounter();
+    explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = nullptr);
+    ~KDirectoryContentsCounter() override;
 
     /**
      * Requests the number of items inside the directory \a path. The actual
@@ -45,28 +32,23 @@ public:
      *
      * The directory \a path is watched for changes, and the signal is emitted
      * again if a change occurs.
-     */
-    void addDirectory(const QString& path);
-
-    /**
-     * In contrast to \a addDirectory, this function counts the items inside
-     * the directory \a path synchronously and returns the result.
      *
-     * The directory is watched for changes, and the signal \a result is
-     * emitted if a change occurs.
+     * Uses a cache internally to speed up first result,
+     * but emit again result when the cache was updated
      */
-    int countDirectoryContentsSynchronously(const QString& path);
+    void scanDirectory(const QString& path);
 
 signals:
     /**
-     * Signals that the directory \a path contains \a count items.
+     * Signals that the directory \a path contains \a count items of size \a
+     * Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit
      */
-    void result(const QString& path, int count);
+    void result(const QString& path, int count, long size);
 
     void requestDirectoryContentsCount(const QString& path, KDirectoryContentsCounterWorker::Options options);
 
 private slots:
-    void slotResult(const QString& path, int count);
+    void slotResult(const QString& path, int count, long size);
     void slotDirWatchDirty(const QString& path);
     void slotItemsRemoved();
 
@@ -76,9 +58,12 @@ private:
 private:
     KFileItemModel* m_model;
 
-    QQueue<QString> m_queue;
+    // Used as FIFO queues.
+    std::list<QString> m_priorityQueue;
+    std::list<QString> m_queue;
+
+    static QThread* m_workerThread;
 
-    QThread* m_workerThread;
     KDirectoryContentsCounterWorker* m_worker;
     bool m_workerIsBusy;
 
@@ -87,4 +72,4 @@ private:
                                     // to get all watched directories.
 };
 
-#endif
\ No newline at end of file
+#endif