• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

kdiskfreespace.cpp

Go to the documentation of this file.
00001 /*
00002  * kdiskfreespace.cpp
00003  *
00004  * Copyright 2007 David Faure <faure@kde.org>
00005  * Copyright 2008 Dirk Mueller <mueller@kde.org>
00006  * Copyright 2008 Sebastian Trug <trueg@kde.org>
00007  *
00008  *  This library is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU Library General Public
00010  *  License version 2 as published by the Free Software Foundation.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Library General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Library General Public License
00018  *  along with this library; see the file COPYING.LIB.  If not, write to
00019  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  *  Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #include "kdiskfreespace.h"
00024 #include "kdiskfreespaceinfo.h"
00025 #include <QtCore/QTimer>
00026 
00027 #include <kdebug.h>
00028 
00029 
00030 class KDiskFreeSpace::Private
00031 {
00032 public:
00033     Private(KDiskFreeSpace *parent)
00034         : m_parent(parent)
00035     {}
00036 
00037     bool _k_calculateFreeSpace();
00038 
00039     KDiskFreeSpace   *m_parent;
00040     QString           m_path;
00041 };
00042 
00043 
00044 KDiskFreeSpace::KDiskFreeSpace(QObject *parent)
00045     : QObject(parent), d(new Private(this))
00046 {
00047 }
00048 
00049 
00050 KDiskFreeSpace::~KDiskFreeSpace()
00051 {
00052     delete d;
00053 }
00054 
00055 
00056 bool KDiskFreeSpace::readDF( const QString & mountPoint )
00057 {
00058     d->m_path = mountPoint;
00059     return d->_k_calculateFreeSpace();
00060 }
00061 
00062 
00063 bool KDiskFreeSpace::Private::_k_calculateFreeSpace()
00064 {
00065     KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( m_path );
00066     if ( info.isValid() ) {
00067         quint64 sizeKiB = info.size() / 1024;
00068         quint64 availKiB = info.available() / 1024;
00069         emit m_parent->foundMountPoint( info.mountPoint(), sizeKiB, sizeKiB-availKiB, availKiB );
00070     }
00071 
00072     emit m_parent->done();
00073 
00074     m_parent->deleteLater();
00075 
00076     return info.isValid();
00077 }
00078 
00079 KDiskFreeSpace * KDiskFreeSpace::findUsageInfo( const QString & path )
00080 {
00081     KDiskFreeSpace * job = new KDiskFreeSpace;
00082     job->d->m_path = path;
00083     QTimer::singleShot(0, job, SLOT(_k_calculateFreeSpace()));
00084     return job;
00085 }
00086 
00087 #include "kdiskfreespace.moc"
00088 

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal