]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbar/mountpointobserver.h
SVN_SILENT made messages (.desktop file) - always resolve ours
[dolphin.git] / src / statusbar / mountpointobserver.h
index ac5f8ecc37391ff589d2f26e459e8ab625084b6a..4d1362cdb8bc0a9bcffa444fe5fccf6a5859e839 100644 (file)
@@ -1,28 +1,16 @@
-/***************************************************************************
- *   Copyright (C) 2014 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: 2014 Frank Reininghaus <frank78ac@googlemail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef MOUNTPOINTOBSERVER_H
 #define MOUNTPOINTOBSERVER_H
 
-#include <KDiskFreeSpaceInfo>
+#include <KIO/Job>
 
 #include <QObject>
+#include <QUrl>
 
 /**
  * A MountPointObserver can be used to determine the free space on a mount
@@ -52,21 +40,21 @@ class MountPointObserver : public QObject
 {
     Q_OBJECT
 
-    explicit MountPointObserver(const QString& mountPoint, QObject* parent = 0);
-    virtual ~MountPointObserver() {}
+    explicit MountPointObserver(const QUrl &url, QObject *parent = nullptr);
+    ~MountPointObserver() override
+    {
+    }
 
 public:
-    /**
-     * Obtains information about the available space on the observed mount point.
-     */
-    KDiskFreeSpaceInfo spaceInfo() const { return m_spaceInfo; }
-
     /**
      * Call this function to indicate that the caller intends to continue using this object. An
      * internal reference count is increased then. When the observer is not needed any more,
      * deref() should be called, which decreases the reference count again.
      */
-    void ref() { ++m_referenceCount; }
+    void ref()
+    {
+        ++m_referenceCount;
+    }
 
     /**
      * This function can be used to indicate that the caller does not need this MountPointObserver
@@ -80,28 +68,30 @@ public:
     }
 
     /**
-     * Returns a MountPointObserver for the given \a path. If the caller intends to continue using
+     * Returns a MountPointObserver for the given \a url. If the caller intends to continue using
      * the returned object, it must call its ref() method.
      */
-    static MountPointObserver* observerForPath(const QString& path);
+    static MountPointObserver *observerForUrl(const QUrl &url);
 
-signals:
+Q_SIGNALS:
     /**
-     * This signal is emitted if the information that spaceInfo() will return has changed.
+     * This signal is emitted when the size has been retrieved.
      */
-    void spaceInfoChanged();
+    void spaceInfoChanged(quint64 size, quint64 available);
 
-public slots:
+public Q_SLOTS:
     /**
-     * If this slot is invoked, MountPointObserver checks if the available space on the observed
-     * mount point has changed, and emits spaceInfoChanged() if that is the case.
+     * If this slot is invoked, MountPointObserver starts a new driveSize job
+     * to get the drive's size.
      */
     void update();
 
+private Q_SLOTS:
+    void freeSpaceResult(KJob *job);
+
 private:
-    const QString m_mountPoint;
+    const QUrl m_url;
     int m_referenceCount;
-    KDiskFreeSpaceInfo m_spaceInfo;
 
     friend class MountPointObserverCache;
 };