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

svn at pcbsd.org svn at pcbsd.org
Thu Feb 21 05:15:34 PST 2008


Author: tim
Date: 2008-02-21 05:15:33 -0800 (Thu, 21 Feb 2008)
New Revision: 1406

Modified:
   pcbsd/trunk/kcmPBSystem/cvsupprogress.ui
   pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h
   pcbsd/trunk/kcmPBSystem/kcm.cpp
   pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
Log:
Multiple fixes to PBSystem. Also added a feature to allow the user to choose which parts of the sourcecode they download, for example just src-bin and src-etc.

Modified: pcbsd/trunk/kcmPBSystem/cvsupprogress.ui
===================================================================
--- pcbsd/trunk/kcmPBSystem/cvsupprogress.ui	2008-02-20 15:53:41 UTC (rev 1405)
+++ pcbsd/trunk/kcmPBSystem/cvsupprogress.ui	2008-02-21 13:15:33 UTC (rev 1406)
@@ -8,12 +8,12 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>610</width>
-            <height>396</height>
+            <width>361</width>
+            <height>328</height>
         </rect>
     </property>
     <property name="caption">
-        <string>CVSup Progress</string>
+        <string>CSup Progress</string>
     </property>
     <property name="modal">
         <bool>true</bool>
@@ -22,24 +22,8 @@
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
-        <widget class="QProgressBar" row="1" column="0" rowspan="1" colspan="3">
+        <widget class="QPushButton" row="5" column="2">
             <property name="name">
-                <cstring>progress</cstring>
-            </property>
-            <property name="frameShape">
-                <enum>NoFrame</enum>
-            </property>
-            <property name="frameShadow">
-            </property>
-            <property name="totalSteps">
-                <number>0</number>
-            </property>
-            <property name="progress">
-                <number>0</number>
-            </property>
-        </widget>
-        <widget class="QPushButton" row="3" column="2">
-            <property name="name">
                 <cstring>cancelBut</cstring>
             </property>
             <property name="text">
@@ -52,7 +36,7 @@
                 <bool>true</bool>
             </property>
         </widget>
-        <spacer row="3" column="0" rowspan="1" colspan="2">
+        <spacer row="5" column="0" rowspan="1" colspan="2">
             <property name="name">
                 <cstring>spacer19</cstring>
             </property>
@@ -69,24 +53,6 @@
                 </size>
             </property>
         </spacer>
-        <widget class="QTextEdit" row="2" column="0" rowspan="1" colspan="3">
-            <property name="name">
-                <cstring>outputBox</cstring>
-            </property>
-            <property name="enabled">
-                <bool>true</bool>
-            </property>
-            <property name="paletteBackgroundColor">
-                <color>
-                    <red>199</red>
-                    <green>199</green>
-                    <blue>199</blue>
-                </color>
-            </property>
-            <property name="readOnly">
-                <bool>true</bool>
-            </property>
-        </widget>
         <widget class="QLabel" row="0" column="0">
             <property name="name">
                 <cstring>progressLabel</cstring>
@@ -120,6 +86,54 @@
                 <string>Alt+F</string>
             </property>
         </widget>
+        <widget class="QTextEdit" row="4" column="0" rowspan="1" colspan="3">
+            <property name="name">
+                <cstring>outputBox</cstring>
+            </property>
+            <property name="enabled">
+                <bool>true</bool>
+            </property>
+            <property name="paletteBackgroundColor">
+                <color>
+                    <red>199</red>
+                    <green>199</green>
+                    <blue>199</blue>
+                </color>
+            </property>
+            <property name="readOnly">
+                <bool>true</bool>
+            </property>
+        </widget>
+        <widget class="QButtonGroup" row="3" column="0" rowspan="1" colspan="3">
+            <property name="name">
+                <cstring>srcSelectionGrp</cstring>
+            </property>
+            <property name="title">
+                <string></string>
+            </property>
+        </widget>
+        <widget class="QLabel" row="2" column="0">
+            <property name="name">
+                <cstring>textLabel1</cstring>
+            </property>
+            <property name="text">
+                <string>Parts of sourcecode to download:</string>
+            </property>
+        </widget>
+        <widget class="Line" row="1" column="0" rowspan="1" colspan="3">
+            <property name="name">
+                <cstring>line4</cstring>
+            </property>
+            <property name="frameShape">
+                <enum>HLine</enum>
+            </property>
+            <property name="frameShadow">
+                <enum>Sunken</enum>
+            </property>
+            <property name="orientation">
+                <enum>Horizontal</enum>
+            </property>
+        </widget>
     </grid>
 </widget>
 <connections>
@@ -137,10 +151,11 @@
     </connection>
 </connections>
 <includes>
-    <include location="local" impldecl="in declaration">qprocess.h</include>
+    <include location="global" impldecl="in declaration">qprocess.h</include>
     <include location="local" impldecl="in declaration">fastestcvsup.h</include>
     <include location="global" impldecl="in declaration">kmessagebox.h</include>
     <include location="global" impldecl="in declaration">kio/job.h</include>
+    <include location="global" impldecl="in declaration">qcheckbox.h</include>
     <include location="local" impldecl="in implementation">cvsupprogress.ui.h</include>
 </includes>
 <variables>
@@ -148,6 +163,7 @@
     <variable access="private">QProcess *cvsup;</variable>
     <variable access="private">int step;</variable>
     <variable access="private">FastestCvsup *changeUi;</variable>
+    <variable access="private">QStringList srcNames;</variable>
 </variables>
 <slots>
     <slot access="private">displayOutput()</slot>
@@ -156,11 +172,11 @@
     <slot access="private">changeServers()</slot>
     <slot>setCvsupServer( QString * server )</slot>
     <slot>writeServer( QString server )</slot>
+    <slot access="private">boxTicked()</slot>
 </slots>
 <functions>
     <function>setup( QString task, QString supfile )</function>
     <function access="private">start()</function>
-    <function access="private">init()</function>
     <function access="private" returnType="QString">getServer()</function>
 </functions>
 <pixmapinproject/>

Modified: pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h
===================================================================
--- pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h	2008-02-20 15:53:41 UTC (rev 1405)
+++ pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h	2008-02-21 13:15:33 UTC (rev 1406)
@@ -21,55 +21,120 @@
     this->supfile = supfile;
     if (! QFile::exists(this->supfile)) {  KIO::file_copy("/usr/share/examples/cvsup/standard-supfile", this->supfile, -1, false); }
     progressLabel->setText(tr("Selected CVSup server: ") + getServer());
+
+    //Populate source selection box
+    QFile srcFile(this->supfile);
+    new QGridLayout(srcSelectionGrp, 5, 5);
+    QStringList checkedItems;
+    if (srcFile.open(IO_ReadOnly))
+    {
+       QTextStream stream(&srcFile);
+       QString line;
+       while (!stream.atEnd())
+       {
+          line = stream.readLine();
+          int findResult = line.find("src-");
+          if (findResult < 2 && findResult > -1)
+          {
+             QString srcName = line.section("-", 1);
+             srcNames += srcName;
+             if (line.at(0) != '#') checkedItems += srcName;
+          }
+       }
+       srcFile.close();
+       srcNames.sort();
+       for (QStringList::Iterator it = srcNames.begin(); it != srcNames.end(); ++it)
+       {
+         QCheckBox *srcBox = new QCheckBox(*it, srcSelectionGrp, *it + "Chk");
+         if (checkedItems.contains(*it) > 0) srcBox->setChecked(true);
+         srcSelectionGrp->layout()->add(srcBox);
+       }
+       QCheckBox *allChk = (QCheckBox*) srcSelectionGrp->child("allChk", "QCheckBox", false);
+       if (allChk != NULL) connect(allChk, SIGNAL(clicked()), this, SLOT(boxTicked()));
+       boxTicked();
+    }
+    else
+    {
+       KMessageBox::error(this, tr("Unable to open file") + ": " + supfile, tr("Error"));
+    }
 }
 
 
 void CVSUpProgress::start()
 {
-    outputBox->clear();
-    cancelBut->setText(tr("&Cancel"));
-    cvsup = new QProcess(this);
-    cvsup->addArgument("/usr/bin/csup");
-    cvsup->addArgument(supfile);
-    connect(cvsup, SIGNAL(readyReadStdout()), this, SLOT(displayOutput()));
-    connect(cvsup, SIGNAL(processExited()), this, SLOT(cvsupFinished()));
-    if (!cvsup->start()) { KMessageBox::error(this, tr("Unable to execute command") + ": /usr/bin/csup " + supfile, tr("Error")); }
+   //Save src settings
+   QFile supRead(supfile);
+   QStringList lines;
+   bool allChecked = false;
+   QCheckBox *allChk = (QCheckBox*) srcSelectionGrp->child("allChk", "QCheckBox", false);
+   if (allChk != NULL) allChecked = allChk->isChecked();
+   if (supRead.open(IO_ReadOnly))
+   {
+      QTextStream stream(&supRead);
+      QString line;
+      while (! stream.atEnd())
+      {
+         line = stream.readLine();
+         int findResult = line.find("src-");
+         if (findResult < 2 && findResult > -1)
+         {
+            QString writeLine = "";
+            QString srcName = line.section("-", 1);
+            QCheckBox *srcChk = (QCheckBox*) srcSelectionGrp->child(srcName + "Chk", "QCheckBox", false);
+            if (srcChk != NULL)
+            {
+               if (!srcChk->isChecked() || (allChecked && (srcName != "all"))) writeLine += "#";
+               writeLine += "src-" + srcName;
+               lines += writeLine;
+            }
+         }
+         else lines += line;
+      }
+      supRead.close();
+   }
+   QFile supWrite(supfile);
+   if (supWrite.open(IO_WriteOnly))
+   {
+      QTextStream stream(&supWrite);
+      for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { stream << *it << "\n"; }
+      supWrite.close();
+   }
+
+   //Fetch Source
+   outputBox->clear();
+   cancelBut->setText(tr("&Cancel"));
+   cvsup = new QProcess(this);
+   cvsup->addArgument("/usr/bin/csup");
+   cvsup->addArgument(supfile);
+   connect(cvsup, SIGNAL(processExited()), this, SLOT(cvsupFinished()));
+   connect(cvsup, SIGNAL(readyReadStdout()), this, SLOT(displayOutput()));
+   if (!cvsup->start()) { KMessageBox::error(this, tr("Unable to execute command") + ": /usr/bin/csup " + supfile, tr("Error")); }
 }
 
 
 void CVSUpProgress::displayOutput()
 {
-    step++;
     outputBox->append(cvsup->readLineStdout());
-    progress->setProgress(step);
 }
 
 
-void CVSUpProgress::init()
-{
-    step = 0;
-}
-
-
 void CVSUpProgress::cvsupFinished()
 {
     progressLabel->setText("Finished!");
     cancelBut->setText(tr("&Close"));
-    progress->setTotalSteps(1);
-    progress->setProgress(1);
 }
 
 
 void CVSUpProgress::quitSlot()
 {
     if (cancelBut->text() == tr("&Cancel")) {
-	cvsup->kill();	
+   cvsup->kill(); 
     }
     else if (cancelBut->text() == tr("&Start"))
     {
-	if (getServer() == "UNSET") { KMessageBox::information(this, tr("CVSup server not set. To set your CVSup server, please click the 'Find Fastest...' button and follow the instructions.\n\nAlternatively, the CVSup server for this operation may be set manually from the following file") + ":\n" + supfile, tr("Please set CVSup server before proceeding")); }
-	else { start(); }
-	return;
+   if (getServer() == "UNSET") { KMessageBox::information(this, tr("CVSup server not set. To set your CVSup server, please click the 'Find Fastest...' button and follow the instructions.\n\nAlternatively, the CVSup server for this operation may be set manually from the following file") + ":\n" + supfile, tr("Please set CVSup server before proceeding")); }
+   else { start(); }
+   return;
     }
     this->close();
 }
@@ -88,8 +153,8 @@
     int question = KMessageBox::questionYesNo(this, tr("PC-BSD has detected the fastest server to be:\n") + *server + tr("\n\nWould you like to use this server in future?"), tr("Confirm server selection"));
     if (question == KMessageBox::Yes)
     {
-	writeServer(*server);
-	progressLabel->setText(tr("Selected CVSup server: ") + getServer());
+   writeServer(*server);
+   progressLabel->setText(tr("Selected CVSup server: ") + getServer());
     }
 }
 
@@ -99,23 +164,23 @@
     QStringList lines;
     if (supRead.open(IO_ReadOnly))
     {
-	QTextStream stream(&supRead);
-	QString line;
-	while (! stream.atEnd())
-	{
-	    line = stream.readLine();
-	    if (line.contains("*default host=")) { lines += "*default host=" + server; }
-	    else { lines += line; }
-	}
-	supRead.close();
+   QTextStream stream(&supRead);
+   QString line;
+   while (! stream.atEnd())
+   {
+       line = stream.readLine();
+       if (line.contains("*default host=")) { lines += "*default host=" + server; }
+       else { lines += line; }
+   }
+   supRead.close();
     }
     
     QFile supWrite(supfile);
     if (supWrite.open(IO_WriteOnly))
     {
-	QTextStream stream(&supWrite);
-	for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { stream << *it << "\n"; }
-	supWrite.close();
+   QTextStream stream(&supWrite);
+   for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { stream << *it << "\n"; }
+   supWrite.close();
     }
 }
 
@@ -127,15 +192,33 @@
     QFile supfile(this->supfile);
     if (supfile.open(IO_ReadOnly))
     {
-	QTextStream stream(&supfile);
-	QString line;
-	while (! stream.atEnd())
-	{
-	    line = stream.readLine();
-	    if (line.contains("*default host=")  && !(line.contains("CHANGE_THIS"))) { result = QStringList::split("=", line)[1]; }
-	}
+      QTextStream stream(&supfile);
+      QString line;
+      while (! stream.atEnd())
+      {
+         line = stream.readLine();
+         if (line.contains("*default host=")  && !(line.contains("CHANGE_THIS")))
+         {
+            supfile.close();
+            return QStringList::split("=", line)[1];
+         }
+      }
     }
     supfile.close();
     
     return result;
 }
+
+
+void CVSUpProgress::boxTicked()
+{
+   QCheckBox *allChk = (QCheckBox*) srcSelectionGrp->child("allChk", "QCheckBox", false);
+   if (allChk != NULL)
+   {
+      for (QStringList::Iterator it = srcNames.begin(); it != srcNames.end(); ++it)
+      {
+         QCheckBox *chkBox = (QCheckBox*) srcSelectionGrp->child(*it + "Chk", "QCheckBox", false);
+         if ((chkBox != NULL) && (chkBox != allChk)) chkBox->setEnabled(!allChk->isChecked());
+      }
+   }
+}

Modified: pcbsd/trunk/kcmPBSystem/kcm.cpp
===================================================================
--- pcbsd/trunk/kcmPBSystem/kcm.cpp	2008-02-20 15:53:41 UTC (rev 1405)
+++ pcbsd/trunk/kcmPBSystem/kcm.cpp	2008-02-21 13:15:33 UTC (rev 1406)
@@ -79,7 +79,7 @@
    }
 }
 
-PCBSDSysTool::PCBSDSysTool( QWidget  *parent,  const char *name,  const QStringList &  list ) : PCBSDKCModule( parent, name) 
+PCBSDSysTool::PCBSDSysTool( QWidget  *parent,  const char *name,  const QStringList&) : PCBSDKCModule( parent, name)
 {
 }
 

Modified: pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
===================================================================
--- pcbsd/trunk/kcmPBSystem/pbsystemtab.ui	2008-02-20 15:53:41 UTC (rev 1405)
+++ pcbsd/trunk/kcmPBSystem/pbsystemtab.ui	2008-02-21 13:15:33 UTC (rev 1406)
@@ -638,7 +638,7 @@
                             <cstring>cvsupBGrp</cstring>
                         </property>
                         <property name="title">
-                            <string>CVSup</string>
+                            <string>CSup</string>
                         </property>
                         <grid>
                             <property name="name">



More information about the Commits mailing list