[PC-BSD Commits] r7775 - in pcbsd/current/src-qt4/pc-sysmanager: . scripts

svn at pcbsd.org svn at pcbsd.org
Sun Oct 10 11:02:23 PDT 2010


Author: kris
Date: 2010-10-10 11:02:22 -0700 (Sun, 10 Oct 2010)
New Revision: 7775

Added:
   pcbsd/current/src-qt4/pc-sysmanager/scripts/find-install-media.sh
Modified:
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
Log:

Added support for prompting user which install media they want to use, validate this choice, and mount the disk/usb if necessary.



Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-10 16:31:24 UTC (rev 7774)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-10 18:02:22 UTC (rev 7775)
@@ -808,14 +808,72 @@
 
 void PBSystemTab::saveMetaPkgs()
 {
+	QString pkgSource, rDir, addPkgs, delPkgs;
+
 	if ( ! haveAMetaDesktop() )
 		return;
 
 	if ( ! haveMetaPkgChanges() )
 		return;
-	
+
+	addPkgs = getAddPkgs();
+	delPkgs = getDelPkgs();
+
+	// If adding pkgs, then we need an installation source
+	if ( ! addPkgs.isEmpty() ) {
+		if ( ! getMediaLocation(pkgSource, rDir) )
+			return;
+	} else 
+		rDir="NONE";
+
+	// We've gotten this far, now time to do the actual meta pkg changes
+
 }
 
+bool PBSystemTab::getMediaLocation(QString &pkgSource, QString &rDir)
+{
+	QMessageBox promptSource;
+	promptSource.setIcon(QMessageBox::Question);
+
+	promptSource.setWindowTitle(tr("Select installation source."));
+	promptSource.setText(tr("Do you want to install from a local DVD/USB or Mirror server?"));
+
+	QPushButton *localB = promptSource.addButton(tr("DVD/USB"), QMessageBox::ActionRole);
+	QPushButton *mirrorB = promptSource.addButton(tr("Mirror"), QMessageBox::AcceptRole);
+	QPushButton *cancelB = promptSource.addButton(tr("&Cancel"), QMessageBox::RejectRole);
+
+	promptSource.exec();
+	if ( promptSource.clickedButton() == cancelB )
+		return false;
+
+	if ( promptSource.clickedButton() == localB )
+		pkgSource="LOCAL";
+	if ( promptSource.clickedButton() == mirrorB )
+		pkgSource="MIRROR";
+
+	if ( pkgSource == "LOCAL" )
+		rDir = findLocalInstallMedia();
+	else
+		rDir = Utils::getMasterMirror();
+
+	if ( rDir == "NOT FOUND" || rDir.isEmpty() ) {
+        	QMessageBox::warning(this, tr("No media detected."),
+          	tr("Could not locate installation media on this system!"),
+          	QMessageBox::Ok,
+          	QMessageBox::Ok);
+		return false;
+	}
+
+	// If we get here, hurray! We have a valid installation media, ready to make changes
+	return true;	
+}
+
+// Function which starts script to locate installation media
+QString PBSystemTab::findLocalInstallMedia()
+{
+	return getLineFromCommandOutput("/usr/local/share/pcbsd/scripts/find-install-media.sh");
+}
+
 bool PBSystemTab::haveAMetaDesktop()
 {
         QTreeWidgetItemIterator it(treeMetaPkgs);
@@ -841,9 +899,9 @@
         while (*it) {
 	  for (int z=0; z < metaPkgList.count(); ++z)
 	    // See if any packages status have changed
-	    if ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::Unchecked \
-	      || (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::PartiallyChecked \
-	      || (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "NO" && (*it)->checkState(0) == Qt::Checked )
+	    if ( ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::Unchecked ) \
+	      || ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::PartiallyChecked ) \
+	      || ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "NO" && (*it)->checkState(0) == Qt::Checked ) )
 		return true;
          ++it;
         }
@@ -851,6 +909,44 @@
 	return false;
 }
 
+QString PBSystemTab::getAddPkgs()
+{
+	QString tmp;
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        while (*it) {
+	  for (int z=0; z < metaPkgList.count(); ++z)
+	    // See if any packages status have changed
+	    if ( ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "NO" && (*it)->checkState(0) == Qt::Checked ) || \
+	         ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "NO" && (*it)->checkState(0) == Qt::PartiallyChecked ) )
+		if ( tmp.isEmpty() )
+			tmp = (*it)->text(0);
+		else
+			tmp = tmp + "," + (*it)->text(0);
+         ++it;
+        }
+
+	return tmp;
+}
+
+QString PBSystemTab::getDelPkgs()
+{
+	QString tmp;
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        while (*it) {
+	  for (int z=0; z < metaPkgList.count(); ++z)
+	    // See if any packages status have changed
+	    if ( (*it)->text(0) == metaPkgList.at(z).at(0) && metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::Unchecked )
+		if ( tmp.isEmpty() )
+			tmp = (*it)->text(0);
+		else
+			tmp = tmp + "," + (*it)->text(0);
+         ++it;
+        }
+
+	return tmp;
+}
+
+
 // Time to save meta-pkgs
 void PBSystemTab::slotApplyMetaChanges() {
     saveMetaPkgs();

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-10 16:31:24 UTC (rev 7774)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-10 18:02:22 UTC (rev 7775)
@@ -144,6 +144,10 @@
     bool allChildrenPkgsChecked(QString parent);
     bool allChildrenPkgsUnchecked(QString parent);
     void checkAllChildrenPkgs(QString parent);
+    QString findLocalInstallMedia();
+    QString getAddPkgs();
+    QString getDelPkgs();
+    bool getMediaLocation(QString &pkgsource, QString &rDir);
     void populateMetaPkgs();
     QList<QStringList> getPackageData();
     QList<QStringList> metaPkgList;


Property changes on: pcbsd/current/src-qt4/pc-sysmanager/scripts/find-install-media.sh
___________________________________________________________________
Added: svn:executable
   + *



More information about the Commits mailing list