]>
cloud.milkyroute.net Git - dolphin.git/blob - src/statusbarspaceinfo.cpp
9bc091b7a03ba80cf33028ed8a8e821634c76e36
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and *
3 * and Patrice Tremblay *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "statusbarspaceinfo.h"
23 #include <kdiskfreespace.h>
24 #include <kmountpoint.h>
31 StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget
* parent
) :
37 // Update the space information each 10 seconds. Polling is useful
38 // here, as files can be deleted/added outside the scope of Dolphin.
39 QTimer
* timer
= new QTimer(this);
40 connect(timer
, SIGNAL(timeout()), this, SLOT(refresh()));
44 StatusBarSpaceInfo::~StatusBarSpaceInfo()
48 void StatusBarSpaceInfo::setUrl(const KUrl
& url
)
52 QTimer::singleShot(300, this, SLOT(update()));
55 QString
StatusBarSpaceInfo::text() const
60 void StatusBarSpaceInfo::slotFoundMountPoint(const QString
& mountPoint
,
68 m_text
= i18nc("@info:status", "%1 free", KIO::convertSizeFromKiB(kBAvailable
));
71 setMaximum(kBAvailable
);
75 void StatusBarSpaceInfo::refresh()
77 // KDiskFreeSpace is for local paths only
78 if (!m_url
.isLocalFile()) {
82 m_text
= i18nc("@info:status", "Getting size...");
86 KMountPoint::Ptr mp
= KMountPoint::currentMountPoints().findByPath(m_url
.path());
91 KDiskFreeSpace
* job
= new KDiskFreeSpace(this);
92 connect(job
, SIGNAL(foundMountPoint(const QString
&,
96 this, SLOT(slotFoundMountPoint(const QString
&,
101 job
->readDF(mp
->mountPoint());
104 #include "statusbarspaceinfo.moc"