25 #include <tqpainter.h>
31 #include <tdefileivi.h>
32 #include <tdefileitem.h>
33 #include <tdeapplication.h>
34 #include <kdirlister.h>
35 #include <kstandarddirs.h>
36 #include <kiconloader.h>
37 #include <konq_settings.h>
38 #include <tdelocale.h>
42 # include <sys/statvfs.h>
44 # include <sys/mount.h>
45 # define statvfs statfs
46 # define f_frsize f_bsize
49 #include "kivfreespaceoverlay.h"
51 KIVFreeSpaceOverlay::KIVFreeSpaceOverlay(
KFileIVI* freespace)
53 m_freespace = freespace;
56 KIVFreeSpaceOverlay::~KIVFreeSpaceOverlay()
61 void KIVFreeSpaceOverlay::start()
63 if ( !m_freespace->item()->isReadable() ) {
66 TQTimer::singleShot(0,
this, TQ_SLOT(slotDisplay()));
69 void KIVFreeSpaceOverlay::timerEvent(TQTimerEvent *)
74 void KIVFreeSpaceOverlay::slotDisplay()
76 KFileItem* item = m_freespace->item();
78 if (item->mimetype().contains(
"_mounted")) {
80 KURL localURL = item->mostLocalURL(isLocal);
82 m_freespace->setOverlayProgressBar(-1);
85 TQString localPath = localURL.path();
86 if (localPath !=
"") {
87 TDEIO::filesize_t m_total = 0;
88 TDEIO::filesize_t m_used = 0;
89 TDEIO::filesize_t m_free = 0;
92 memset(&vfs, 0,
sizeof(vfs));
94 if ( ::statvfs(TQFile::encodeName(localPath), &vfs) != -1 )
96 m_total =
static_cast<TDEIO::filesize_t
>(vfs.f_blocks) *
static_cast<TDEIO::filesize_t
>(vfs.f_frsize);
97 m_free =
static_cast<TDEIO::filesize_t
>(vfs.f_bavail) *
static_cast<TDEIO::filesize_t
>(vfs.f_frsize);
98 m_used = m_total - m_free;
99 m_freespace->setOverlayProgressBar((m_used/(m_total*1.0))*100.0);
102 m_freespace->setOverlayProgressBar(-1);
106 m_freespace->setOverlayProgressBar(-1);
112 m_freespace->setOverlayProgressBar(-1);
118 #include "kivfreespaceoverlay.moc"
KFileIVI (short form of "Konq - File - IconViewItem") is, as expected, an improved TDEIconViewItem,...