superkaramba
Go to the documentation of this file.
14 #include <QTextStream>
16 #if defined __FreeBSD__
18 #include <sys/sysctl.h>
21 #if defined(Q_OS_NETBSD)
22 #include <sys/param.h>
24 #include <sys/sysctl.h>
34 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
35 struct timeval boottime;
40 int days, hours, i, mins, secs;
55 mib[1] = KERN_BOOTTIME;
56 size =
sizeof(boottime);
57 if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
58 boottime.tv_sec != 0) {
59 uptime = now - boottime.tv_sec;
62 days = uptime / 86400;
64 hours = uptime / 3600;
70 QFile file(
"/proc/uptime");
72 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
80 int uptime = rx.cap(0).toInt();
81 int days = uptime / 86400;
82 uptime -= days * 86400;
83 int hours = uptime / 3600;
84 uptime -= hours * 3600;
85 int mins = uptime / 60;
100 if (format.length() == 0) {
101 format =
"%dd %h:%M";
103 format.replace(QRegExp(
"%d"), QString::number(days));
104 format.replace(QRegExp(
"%H"), QString::number(hours).rightJustified(2,
'0'));
105 format.replace(QRegExp(
"%M"), QString::number(mins).rightJustified(2,
'0'));
106 format.replace(QRegExp(
"%S"), QString::number(secs).rightJustified(2,
'0'));
107 format.replace(QRegExp(
"%h"), QString::number(hours));
108 format.replace(QRegExp(
"%m"), QString::number(mins));
109 format.replace(QRegExp(
"%s"), QString::number(secs));
114 #if !defined __FreeBSD__ && !defined(Q_OS_NETBSD)
UptimeSensor(int interval)
QString getParam(const QString &) const
virtual void setValue(int)
QList< QObject * > * objList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by
doxygen 1.8.7 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.