[PC-BSD Commits] r120 - pcbsd/trunk/kcmPBSystem
svn at pcbsd.org
svn at pcbsd.org
Wed Mar 7 14:59:50 PST 2007
Author: tim
Date: 2007-03-07 23:59:49 +0100 (Wed, 07 Mar 2007)
New Revision: 120
Added:
pcbsd/trunk/kcmPBSystem/fastestcvsup.ui
pcbsd/trunk/kcmPBSystem/fastestcvsup.ui.h
Modified:
pcbsd/trunk/kcmPBSystem/PBSystem.pro
pcbsd/trunk/kcmPBSystem/cvsupprogress.ui
pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h
pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
Log:
Added fastest_cvsup functionality. Fully functional, only scans UK servers at the moment however.
Support for scanning desired servers only on the way...
Modified: pcbsd/trunk/kcmPBSystem/PBSystem.pro
===================================================================
--- pcbsd/trunk/kcmPBSystem/PBSystem.pro 2007-03-07 22:55:23 UTC (rev 119)
+++ pcbsd/trunk/kcmPBSystem/PBSystem.pro 2007-03-07 22:59:49 UTC (rev 120)
@@ -10,7 +10,8 @@
FORMS = pbsystemtab.ui \
cvsupprogress.ui \
portsnapprogress.ui \
- notroot.ui
+ notroot.ui \
+ fastestcvsup.ui
IMAGES = NewLogoSmall.png \
system.png
Modified: pcbsd/trunk/kcmPBSystem/cvsupprogress.ui
===================================================================
--- pcbsd/trunk/kcmPBSystem/cvsupprogress.ui 2007-03-07 22:55:23 UTC (rev 119)
+++ pcbsd/trunk/kcmPBSystem/cvsupprogress.ui 2007-03-07 22:59:49 UTC (rev 120)
@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>610</width>
- <height>369</height>
+ <height>396</height>
</rect>
</property>
<property name="caption">
@@ -22,24 +22,15 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
- <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <widget class="QProgressBar" row="1" column="0" rowspan="1" colspan="3">
<property name="name">
- <cstring>progressLabel</cstring>
+ <cstring>progress</cstring>
</property>
<property name="frameShape">
<enum>NoFrame</enum>
</property>
<property name="frameShadow">
- <enum>Plain</enum>
</property>
- <property name="text">
- <string>Please wait...</string>
- </property>
- </widget>
- <widget class="QProgressBar" row="1" column="0" rowspan="1" colspan="2">
- <property name="name">
- <cstring>progress</cstring>
- </property>
<property name="totalSteps">
<number>0</number>
</property>
@@ -47,8 +38,39 @@
<number>0</number>
</property>
</widget>
- <widget class="QTextEdit" row="2" column="0" rowspan="1" colspan="2">
+ <widget class="QPushButton" row="3" column="2">
<property name="name">
+ <cstring>cancelBut</cstring>
+ </property>
+ <property name="text">
+ <string>&Start</string>
+ </property>
+ <property name="accel">
+ <string>Alt+S</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer19</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>481</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QTextEdit" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
<cstring>outputBox</cstring>
</property>
<property name="enabled">
@@ -65,37 +87,39 @@
<bool>true</bool>
</property>
</widget>
- <widget class="QPushButton" row="3" column="1">
+ <widget class="QLabel" row="0" column="0">
<property name="name">
- <cstring>cancelBut</cstring>
+ <cstring>progressLabel</cstring>
</property>
- <property name="text">
- <string>&Cancel</string>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="accel">
- <string>Alt+C</string>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
</property>
- <property name="default">
- <bool>true</bool>
+ <property name="frameShadow">
+ <enum>Plain</enum>
</property>
+ <property name="text">
+ <string>Please wait...</string>
+ </property>
</widget>
- <spacer row="3" column="0">
+ <widget class="QPushButton" row="0" column="1" rowspan="1" colspan="2">
<property name="name">
- <cstring>spacer19</cstring>
+ <cstring>changeServerBut</cstring>
</property>
- <property name="orientation">
- <enum>Horizontal</enum>
+ <property name="text">
+ <string>&Find Fastest...</string>
</property>
- <property name="sizeType">
- <enum>Expanding</enum>
+ <property name="accel">
+ <string>Alt+F</string>
</property>
- <property name="sizeHint">
- <size>
- <width>481</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
+ </widget>
</grid>
</widget>
<connections>
@@ -105,25 +129,38 @@
<receiver>CVSUpProgress</receiver>
<slot>quitSlot()</slot>
</connection>
+ <connection>
+ <sender>changeServerBut</sender>
+ <signal>clicked()</signal>
+ <receiver>CVSUpProgress</receiver>
+ <slot>changeServers()</slot>
+ </connection>
</connections>
<includes>
<include location="local" 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="local" impldecl="in implementation">cvsupprogress.ui.h</include>
</includes>
<variables>
<variable access="private">QString supfile;</variable>
<variable access="private">QProcess *cvsup;</variable>
<variable access="private">int step;</variable>
+ <variable access="private">FastestCvsup *changeUi;</variable>
</variables>
<slots>
<slot access="private">displayOutput()</slot>
<slot access="private">cvsupFinished()</slot>
<slot access="private">quitSlot()</slot>
+ <slot access="private">changeServers()</slot>
+ <slot>setCvsupServer( QString * server )</slot>
+ <slot>writeServer( QString server )</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/>
<layoutdefaults spacing="6" margin="11"/>
Modified: pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h
===================================================================
--- pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h 2007-03-07 22:55:23 UTC (rev 119)
+++ pcbsd/trunk/kcmPBSystem/cvsupprogress.ui.h 2007-03-07 22:59:49 UTC (rev 120)
@@ -18,18 +18,16 @@
captionText += task;
this->setCaption(captionText);
- QString labelText = tr("Please wait, updating ");
- labelText += task;
- labelText += "...";
- progressLabel->setText(labelText);
+ progressLabel->setText(tr("Selected CVSup server: ") + getServer());
this->supfile = supfile;
- start();
}
void CVSUpProgress::start()
{
+ outputBox->clear();
+ cancelBut->setText(tr("&Cancel"));
cvsup = new QProcess(this);
cvsup->addArgument("cvsup");
cvsup->addArgument(supfile);
@@ -64,8 +62,78 @@
void CVSUpProgress::quitSlot()
{
- if (cancelBut->text() == "&Cancel") {
- cvsup->kill();
+ if (cancelBut->text() == tr("&Cancel")) {
+ cvsup->kill();
}
+ else if (cancelBut->text() == tr("&Start"))
+ {
+ start();
+ return;
+ }
this->close();
}
+
+
+void CVSUpProgress::changeServers()
+{
+ changeUi = new FastestCvsup();
+ connect(changeUi, SIGNAL(found(QString*)), this, SLOT(setCvsupServer(QString*)));
+ changeUi->show();
+}
+
+
+void CVSUpProgress::setCvsupServer( QString *server )
+{
+ int question = KMessageBox::questionYesNo(this, tr("PC-BSD has your fastest server to be:\n") + *server + tr("\n\nWould you like to use this server in future?"), tr("Confirm server selection"));
+ if (question)
+ {
+ writeServer(*server);
+ progressLabel->setText(tr("Selected CVSup server: ") + getServer());
+ }
+}
+
+void CVSUpProgress::writeServer(QString server)
+{
+ QFile supfile("/root/standard-supfile");
+ QStringList lines;
+ if (supfile.open(IO_ReadOnly))
+ {
+ QTextStream stream(&supfile);
+ QString line;
+ while (! stream.atEnd())
+ {
+ line = stream.readLine();
+ if (line.contains("*default host=")) { lines += "*default host=" + server; }
+ else { lines += line; }
+ }
+ }
+ supfile.close();
+
+ if (supfile.open(IO_ReadWrite))
+ {
+ QTextStream stream(&supfile);
+ for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { stream << *it << "\n"; }
+ }
+ supfile.close();
+}
+
+
+QString CVSUpProgress::getServer()
+{
+ QString result = "UNSET";
+
+ QFile supfile("/root/standard-supfile");
+ if (supfile.open(IO_ReadOnly))
+ {
+ QTextStream stream(&supfile);
+ QString line;
+ while (! stream.atEnd())
+ {
+ line = stream.readLine();
+ if (line.contains("*default host=")) { result = QStringList::split("=", line)[1]; }
+ }
+ }
+ supfile.close();
+
+ return result;
+}
Added: pcbsd/trunk/kcmPBSystem/fastestcvsup.ui
Added: pcbsd/trunk/kcmPBSystem/fastestcvsup.ui.h
Modified: pcbsd/trunk/kcmPBSystem/pbsystemtab.ui
===================================================================
--- pcbsd/trunk/kcmPBSystem/pbsystemtab.ui 2007-03-07 22:55:23 UTC (rev 119)
+++ pcbsd/trunk/kcmPBSystem/pbsystemtab.ui 2007-03-07 22:59:49 UTC (rev 120)
@@ -811,8 +811,8 @@
<function access="private">showRebootRequired()</function>
<function access="private">InstallNewKernel()</function>
<function access="private">LoadKernSettings()</function>
- <function access="private" returnType="bool">checkValue( QString File, QString Key, QString Value )</function>
- <function access="private">saveValue( QString File, QString oldKey, QString newKey )</function>
+ <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>
</functions>
<pixmapinproject/>
More information about the Commits
mailing list