sysinfo.h

Go to the documentation of this file.
00001 
00023 #ifndef SYSINFO_H
00024 #define SYSINFO_H
00025 
00026 #include "graphic_items.h"
00027 
00028 class AbstractSysInfo : public GraphicText
00029 {
00030         Q_OBJECT
00031         Q_PROPERTY(SysUnit unit READ unit WRITE setUnit)
00032         Q_PROPERTY(QString postfix READ postfix WRITE setPostfix)
00033         Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
00034         Q_PROPERTY(int precision READ precision WRITE setPrecision)
00035         Q_ENUMS(SysUnit)
00036 
00037         public:
00038                 enum SysUnit { Bit, Byte, Kilobyte, Megabyte, Gigabyte, Terrabyte };
00039 
00040                 AbstractSysInfo() : m_precision(2), m_unit(Kilobyte) {};
00041                 bool init();
00042                 inline QGraphicsItem* graphicsItem() { return this; };
00043                 inline bool hasTimer() { return true; }
00044                 inline void setUnit(SysUnit unit) { m_unit = unit; }
00045                 inline void setPostfix(const QString& postfix) { m_postfix = postfix; }
00046                 inline void setPrefix(const QString& prefix) { m_prefix = prefix; }
00047                 inline void setPrecision(int precision) { m_precision = precision; }
00048                 inline SysUnit unit() { return m_unit; }
00049                 inline QString postfix() const { return m_postfix; }
00050                 inline QString prefix() const { return m_prefix; }
00051                 inline int precision() { return m_precision; }
00052 
00053         protected:
00054                 QString doubleToString(double);
00055                 void openProcDevice(const QString&, int skipLines = 0);
00056                 void closeProcDevice();
00057                 QString line() const;
00058                 bool nextLine();
00059 
00060         private:
00061                 QFile m_device;
00062                 QString m_line;
00063                 QTextStream m_allLines;
00064                 QString m_postfix;
00065                 QString m_prefix;
00066                 int m_precision;
00067                 SysUnit m_unit;
00068 };
00069 
00070 class MemoryInfo : public AbstractSysInfo
00071 {
00072         Q_OBJECT
00073         Q_PROPERTY(MemoryType type READ type WRITE setType)
00074         Q_ENUMS(MemoryType)
00075 
00076         public:
00077                 enum MemoryType { TotalMemory, FreeMemory, UsedMemory, TotalSwap, FreeSwap, UsedSwap };
00078 
00079                 MemoryInfo(): m_type(UsedMemory) {};
00080                 bool init();
00081                 void timer();
00082                 inline void setType(MemoryType type) { m_type = type; }
00083                 inline MemoryType type() { return m_type; }
00084         
00085         private:
00086                 QMap<QString, double> m_memInfo;
00087                 MemoryType m_type;
00088 };
00089 
00090 class CPUInfo : public AbstractSysInfo
00091 {
00092         Q_OBJECT
00093         Q_PROPERTY(CPUType type READ type WRITE setType)
00094         Q_ENUMS(CPUType)
00095 
00096         public:
00097                 enum CPUType { CPUMhz, Modelname, VendorID, Bogomips, CacheSize };
00098 
00099                 CPUInfo() : m_type(CPUMhz) {};
00100                 bool init();
00101                 void timer();
00102                 inline void setType(CPUType type) { m_type = type; }
00103                 inline CPUType type() { return m_type; }
00104 
00105         private:
00106                 QMap<QString, QString> m_cpuInfo;
00107                 CPUType m_type;
00108 };
00109 
00110 class HDDInfo : public AbstractSysInfo
00111 {
00112         Q_OBJECT
00113         Q_PROPERTY(QStringList partition READ partitions WRITE setPartition)
00114 
00115         public:
00116                 bool init();
00117                 void timer();
00118                 inline void setPartition(const QStringList& partNames) { m_devName = partNames.at(0); }
00119                 inline QStringList partitions() { return m_partNames; }
00120 
00121         private:
00122                 QString m_devName;
00123                 QStringList m_partNames;
00124 };
00125 
00126 class TimeInfo : public GraphicText
00127 {
00128         Q_OBJECT
00129         Q_PROPERTY(QString format READ format WRITE setFormat)
00130         Q_PROPERTY(bool analog READ analog WRITE setAnalog)
00131 
00132         public:
00133                 TimeInfo();
00134                 bool init();
00135                 void timer();
00136                 void paint(QPainter*, const QStyleOptionGraphicsItem* , QWidget* widget = 0);
00137                 QRectF boundingRect() const;
00138                 inline bool hasTimer() { return true; }
00139                 inline void setFormat(const QString& format) { m_format = format; }
00140                 inline void setAnalog(bool analog) { prepareGeometryChange(); m_analog = analog; }
00141                 inline QString format() const { return m_format; }
00142                 inline bool analog() { return m_analog; }
00143         
00144         private:
00145                 QString m_format;
00146                 QTime m_time;
00147                 bool m_analog;
00148 };
00149 
00150 class DateInfo : public GraphicText
00151 {
00152         Q_OBJECT
00153         Q_PROPERTY(QString format READ format WRITE setFormat)
00154 
00155         public:
00156                 DateInfo();
00157                 bool init();
00158                 void timer();
00159                 inline bool hasTimer() { return true; }
00160                 inline void setFormat(const QString& format) { m_format = format; }
00161                 inline QString format() const { return m_format; }
00162         
00163         private:
00164                 QString m_format;
00165 };
00166 
00167 class NetworkInfo : public AbstractSysInfo
00168 {
00169         Q_OBJECT
00170         Q_PROPERTY(QStringList device READ device WRITE setDevice)
00171         Q_PROPERTY(NetworkType type READ type WRITE setType)
00172         Q_ENUMS(NetworkType)
00173 
00174         public:
00175                 enum NetworkType { RXBytes, RXPackets, TXBytes, TXPackets };
00176 
00177                 NetworkInfo() : m_type(RXBytes) {};
00178                 bool init();
00179                 void timer();
00180                 inline void setDevice(const QStringList& device) {  m_devName = device.at(0); }
00181                 inline void setType(NetworkType type) { m_type = type; }
00182                 inline QStringList device() { return m_deviceNames; }
00183                 inline NetworkType type() { return m_type; }
00184 
00185         private:
00186                 QStringList m_deviceNames;
00187                 QString m_devName;
00188                 NetworkType m_type;
00189 };
00190 
00191 #endif

Generated on Thu Apr 5 13:06:31 2007 for LCDBuilder by  doxygen 1.4.7