]>
cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/spaceinfoobserver.cpp
1 /***************************************************************************
2 * Copyright (C) 2014 by Frank Reininghaus <frank78ac@googlemail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "spaceinfoobserver.h"
22 #include "mountpointobserver.h"
26 SpaceInfoObserver::SpaceInfoObserver(const KUrl
& url
, QObject
* parent
) :
28 m_mountPointObserver(0)
30 if (url
.isLocalFile()) {
31 m_mountPointObserver
= MountPointObserver::observerForPath(url
.toLocalFile());
32 m_mountPointObserver
->ref();
33 connect(m_mountPointObserver
, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
37 SpaceInfoObserver::~SpaceInfoObserver()
39 if (m_mountPointObserver
) {
40 m_mountPointObserver
->deref();
41 m_mountPointObserver
= 0;
45 quint64
SpaceInfoObserver::size() const
47 if (m_mountPointObserver
&& m_mountPointObserver
->spaceInfo().isValid()) {
48 return m_mountPointObserver
->spaceInfo().size();
54 quint64
SpaceInfoObserver::available() const
56 if (m_mountPointObserver
&& m_mountPointObserver
->spaceInfo().isValid()) {
57 return m_mountPointObserver
->spaceInfo().available();
63 void SpaceInfoObserver::setUrl(const KUrl
& url
)
65 if (url
.isLocalFile()) {
66 MountPointObserver
* newObserver
= MountPointObserver::observerForPath(url
.toLocalFile());
67 if (newObserver
!= m_mountPointObserver
) {
68 if (m_mountPointObserver
) {
69 disconnect(m_mountPointObserver
, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
70 m_mountPointObserver
->deref();
71 m_mountPointObserver
= 0;
74 m_mountPointObserver
= newObserver
;
75 m_mountPointObserver
->ref();
76 connect(m_mountPointObserver
, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
81 if (m_mountPointObserver
) {
82 disconnect(m_mountPointObserver
, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
83 m_mountPointObserver
->deref();
84 m_mountPointObserver
= 0;