• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kfile
kdiskfreespace.cpp
Go to the documentation of this file.
1/*
2 * kdiskfreespace.cpp
3 *
4 * Copyright 2007 David Faure <faure@kde.org>
5 * Copyright 2008 Dirk Mueller <mueller@kde.org>
6 * Copyright 2008 Sebastian Trug <trueg@kde.org>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License version 2 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#include "kdiskfreespace.h"
24#include "kdiskfreespaceinfo.h"
25#include <QtCore/QTimer>
26
27#include <kdebug.h>
28
29
30class KDiskFreeSpace::Private
31{
32public:
33 Private(KDiskFreeSpace *parent)
34 : m_parent(parent)
35 {}
36
37 bool _k_calculateFreeSpace();
38
39 KDiskFreeSpace *m_parent;
40 QString m_path;
41};
42
43
44KDiskFreeSpace::KDiskFreeSpace(QObject *parent)
45 : QObject(parent), d(new Private(this))
46{
47}
48
49
50KDiskFreeSpace::~KDiskFreeSpace()
51{
52 delete d;
53}
54
55
56bool KDiskFreeSpace::readDF( const QString & mountPoint )
57{
58 d->m_path = mountPoint;
59 return d->_k_calculateFreeSpace();
60}
61
62
63bool KDiskFreeSpace::Private::_k_calculateFreeSpace()
64{
65 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( m_path );
66 if ( info.isValid() ) {
67 quint64 sizeKiB = info.size() / 1024;
68 quint64 availKiB = info.available() / 1024;
69 emit m_parent->foundMountPoint( info.mountPoint(), sizeKiB, sizeKiB-availKiB, availKiB );
70 }
71
72 emit m_parent->done();
73
74 m_parent->deleteLater();
75
76 return info.isValid();
77}
78
79KDiskFreeSpace * KDiskFreeSpace::findUsageInfo( const QString & path )
80{
81 KDiskFreeSpace * job = new KDiskFreeSpace;
82 job->d->m_path = path;
83 QTimer::singleShot(0, job, SLOT(_k_calculateFreeSpace()));
84 return job;
85}
86
87#include "kdiskfreespace.moc"
88
KDiskFreeSpace
Definition: kdiskfreespace.h:35
KDiskFreeSpace::readDF
bool readDF(const QString &mountPoint)
Call this to fire a search on the disk usage information for mountPoint.
Definition: kdiskfreespace.cpp:56
KDiskFreeSpace::findUsageInfo
static KDiskFreeSpace * findUsageInfo(const QString &path)
Call this to fire a search on the disk usage information for the mount point containing path.
Definition: kdiskfreespace.cpp:79
KDiskFreeSpace::~KDiskFreeSpace
~KDiskFreeSpace()
Destructor - this object autodeletes itself when it's done.
Definition: kdiskfreespace.cpp:50
KDiskFreeSpace::KDiskFreeSpace
KDiskFreeSpace(QObject *parent=0)
Constructor.
Definition: kdiskfreespace.cpp:44
QObject
kdebug.h
kdiskfreespace.h
kdiskfreespaceinfo.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal