[PC-BSD Commits] r2055 - pcbsd/trunk/kcmPBSystem

svn at pcbsd.org svn at pcbsd.org
Sun Jun 8 14:16:19 PDT 2008


Author: tim
Date: 2008-06-08 14:16:18 -0700 (Sun, 08 Jun 2008)
New Revision: 2055

Modified:
   pcbsd/trunk/kcmPBSystem/PBSystem.pro
   pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
   pcbsd/trunk/kcmPBSystem/pbsystemtab.ui.h
Log:
Refactored PBSystem to make use of Utils library

Modified: pcbsd/trunk/kcmPBSystem/PBSystem.pro
===================================================================
--- pcbsd/trunk/kcmPBSystem/PBSystem.pro	2008-06-08 21:15:57 UTC (rev 2054)
+++ pcbsd/trunk/kcmPBSystem/PBSystem.pro	2008-06-08 21:16:18 UTC (rev 2055)
@@ -3,6 +3,10 @@
 
 CONFIG	+= qt warn_on release
 
+LIBS	+= -lpcbsd
+
+INCLUDEPATH	+= /PCBSD/includes
+
 HEADERS	+= kcm.h
 
 SOURCES	+= kcm.cpp

Modified: pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
===================================================================
--- pcbsd/trunk/kcmPBSystem/pbsystemtab.ui	2008-06-08 21:15:57 UTC (rev 2054)
+++ pcbsd/trunk/kcmPBSystem/pbsystemtab.ui	2008-06-08 21:16:18 UTC (rev 2055)
@@ -202,6 +202,12 @@
                                                 <verstretch>0</verstretch>
                                             </sizepolicy>
                                         </property>
+                                        <property name="frameShape">
+                                            <enum>NoFrame</enum>
+                                        </property>
+                                        <property name="frameShadow">
+                                            <enum>Plain</enum>
+                                        </property>
                                         <property name="text">
                                             <string>Base Version:</string>
                                         </property>
@@ -870,7 +876,7 @@
     <include location="global" impldecl="in declaration">kio/job.h</include>
     <include location="global" impldecl="in declaration">kfiledialog.h</include>
     <include location="global" impldecl="in declaration">kimageio.h</include>
-    <include location="global" impldecl="in declaration">sys/sysctl.h</include>
+    <include location="global" impldecl="in declaration">utils.h</include>
     <include location="local" impldecl="in implementation">pbsystemtab.ui.h</include>
 </includes>
 <variables>
@@ -919,7 +925,6 @@
     <function returnType="bool">checkValue( QString File, QString Key, QString Value )</function>
     <function>saveValue( QString File, QString oldKey, QString newKey )</function>
     <function access="private" returnType="QString">getValue( QString File, QString Key )</function>
-    <function returnType="QString">bytesToHumanReadable( float bytes )</function>
 </functions>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>

Modified: pcbsd/trunk/kcmPBSystem/pbsystemtab.ui.h
===================================================================
--- pcbsd/trunk/kcmPBSystem/pbsystemtab.ui.h	2008-06-08 21:15:57 UTC (rev 2054)
+++ pcbsd/trunk/kcmPBSystem/pbsystemtab.ui.h	2008-06-08 21:16:18 UTC (rev 2055)
@@ -27,17 +27,10 @@
     CheckPBVer();
     
     //Get & Set CPU Type
-    char cpuName[50];
-    size_t len = sizeof(cpuName);           
-    sysctlbyname("hw.model", cpuName, &len, NULL, 0);
-    cpuName[len] = '\0';
-    labelCPU->setText(QString(cpuName).stripWhiteSpace());
+    labelCPU->setText(Utils::sysctl("hw.model").stripWhiteSpace());
     
     //Get & Set RAM
-    int ram = 0;
-    len = sizeof(ram);
-    sysctlbyname("hw.realmem", &ram, &len, NULL, 0);
-    labelMemory->setText(bytesToHumanReadable(ram));
+    labelMemory->setText(Utils::bytesToHumanReadable(Utils::sysctlAsInt("hw.realmem")));
     
     // Load the available kernels into the list
     CheckKernels();
@@ -548,16 +541,3 @@
 }
 
 
-QString PBSystemTab::bytesToHumanReadable( float bytes )
-{
-    QStringList suffix = QStringList::split(" ", "B KB MB GB TB");
-    int i = 0;
-    while((bytes >= 1000) && (i < 5))
-    {
-	bytes = bytes / 1024;
-	i++;
-    }
-    QString result = QString::number(bytes, 'f', 0);
-    result += suffix[i];
-    return result;
-}



More information about the Commits mailing list