[PC-BSD Commits] r7780 - pcbsd/current/src-qt4/pc-sysmanager

svn at pcbsd.org svn at pcbsd.org
Tue Oct 12 11:22:18 PDT 2010


Author: kris
Date: 2010-10-12 11:22:17 -0700 (Tue, 12 Oct 2010)
New Revision: 7780

Modified:
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
   pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
Log:

Update to system manager, now allow installing / deleleting system meta-pkgs



Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-12 18:03:42 UTC (rev 7779)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-12 18:22:17 UTC (rev 7780)
@@ -16,6 +16,7 @@
 #include <QTextStream>
 #include <QNetworkAccessManager>
 #include <QNetworkReply>
+#include <QProgressDialog>
 #include <QDebug>
 
 #include "pbsystemtab.h"
@@ -129,29 +130,19 @@
 
 void PBSystemTab::CheckPBVer()
 {
-    
  QSettings settings("PCBSD");
- QString value;
- bool check = TRUE;
+ Version = settings.value("/PC-BSD/Version", Version).toString();
+ labelPCBSD->setText(Version);
 
- value = settings.value("/PC-BSD/Version", value).toString();
+ Arch = getLineFromCommandOutput("uname -m");
  
- if ( check )
- {
-       labelPCBSD->setText(value);
- }
- 
 }
 
 
 void PBSystemTab::ReadUname()
 {
-
     if (GetUname->canReadLine() )
-    {	
 	labelBASEVer->setText( GetUname->readLine().simplified() );
-    }
-    
 }
 
 
@@ -692,6 +683,8 @@
 {
   metaPkgList = getPackageData();
 
+  treeMetaPkgs->clear();
+
   // First look for "parent" apps
   for (int z=0; z < metaPkgList.count(); ++z)
     if ( metaPkgList.at(z).at(3).isEmpty() ) {
@@ -760,6 +753,9 @@
   QString tmp, mName, mDesc, mIcon, mParent, mDesktop, mInstalled;
   QStringList package;
 
+  if ( ! metaPkgList.isEmpty() )
+  	disconnect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 0, 0);
+
   QProcess pcmp;
   qDebug() << "Searching for meta-pkgs...";
   pcmp.start(QString("pc-metapkgmanager"), QStringList() << "list");
@@ -808,14 +804,12 @@
 
 void PBSystemTab::saveMetaPkgs()
 {
-	QString pkgSource, rDir, addPkgs, delPkgs;
+	if ( ! haveMetaPkgChanges() )
+		return;
 
 	if ( ! haveAMetaDesktop() )
 		return;
 
-	if ( ! haveMetaPkgChanges() )
-		return;
-
 	addPkgs = getAddPkgs();
 	delPkgs = getDelPkgs();
 
@@ -826,12 +820,133 @@
 	} else 
 		rDir="NONE";
 
+	startMetaChanges();
+
+}
+
+void PBSystemTab::startMetaChanges()
+{
+
 	// We've gotten this far, now time to do the actual meta pkg changes
+	if ( ! delPkgs.isEmpty() ) {
 
+		delprogress = new QProgressDialog(tr("Removing Meta Packages. This may take a while..."), "&Cancel", 0, 0, this);
+ 	       	delprogress->setWindowModality(Qt::WindowModal);
+ 	       	delprogress->setAutoReset(false);
+ 	       	delprogress->setMinimumDuration(0);
+		delprogress->setValue(0);
+		delprogress->show();
+
+		delMetaProc = new QProcess();
+		delMetaProc->setProcessChannelMode(QProcess::MergedChannels);
+		connect( delMetaProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotMetaDelRead()) );
+		connect( delMetaProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotMetaDelDone()) );
+     		delMetaProc->start("pc-metapkgmanager", QStringList() << "del" << delPkgs);
+	} else
+		slotMetaDelDone();
+
+
 }
 
-bool PBSystemTab::getMediaLocation(QString &pkgSource, QString &rDir)
+void PBSystemTab::slotMetaDelRead()
 {
+	bool ok;
+
+	if ( delMetaProc->canReadLine() ) {
+		QString line = delMetaProc->readLine();
+		if ( line.indexOf("Pending package changes: ") != -1 ) {
+			line = line.replace("Pending package changes: ", "");
+			line.toInt(&ok);
+			if ( ok ) {
+				delprogress->setMaximum(line.toInt(&ok));
+				delprogress->setValue(0);
+			}
+			
+		} else {
+			delprogress->setValue(delprogress->value() + 1);
+			delprogress->setLabelText(line);
+		}
+	}
+
+        if (delprogress->wasCanceled()) {
+		delMetaProc->kill();
+              	return;
+	}
+}
+
+void PBSystemTab::slotMetaDelDone()
+{
+	if ( delprogress )
+		delprogress->close();
+
+	// We've gotten this far, now time to do the actual meta pkg changes
+	if ( ! addPkgs.isEmpty() ) {
+
+		addprogress = new QProgressDialog(tr("Adding Meta Packages. This may take a while..."), "&Cancel", 0, 0, this);
+ 	       	addprogress->setWindowModality(Qt::WindowModal);
+ 	       	addprogress->setAutoReset(false);
+ 	       	addprogress->setMinimumDuration(0);
+		addprogress->setValue(0);
+		addprogress->show();
+
+		addMetaProc = new QProcess();
+		addMetaProc->setProcessChannelMode(QProcess::MergedChannels);
+		connect( addMetaProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotMetaAddRead()) );
+		connect( addMetaProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotMetaAddDone()) );
+     		addMetaProc->start("pc-metapkgmanager", QStringList() << "add" << addPkgs << rDir);
+	} else
+		slotMetaAddDone();
+}
+
+void PBSystemTab::slotMetaAddRead()
+{
+	bool ok;
+
+	// This functionality needs to be re-written to not loop, uses to much CPU
+	if ( addMetaProc->canReadLine() ) {
+		QString line = addMetaProc->readLine();
+		if ( line.indexOf("Pending package changes: ") != -1 ) {
+			line = line.replace("Pending package changes: ", "");
+			line.toInt(&ok);
+			if ( ok ) {
+				addprogress->setMaximum(line.toInt(&ok));
+				addprogress->setValue(0);
+			}
+			
+		} else {
+			addprogress->setValue(addprogress->value() + 1);
+			addprogress->setLabelText(line);
+		}
+	}
+
+        if (addprogress->wasCanceled()) {
+		addMetaProc->kill();
+        	return;
+	}
+}
+
+void PBSystemTab::slotMetaAddDone()
+{
+	if ( addprogress )
+		addprogress->close();
+ 
+	// Need to unmount media / cleanup mount point
+	if ( pkgSource == "LOCAL" ) {
+		rDir = rDir.replace("/packages", "");
+		getLineFromCommandOutput("umount " + rDir); 
+		getLineFromCommandOutput("rmdir " + rDir); 
+	}
+
+	populateMetaPkgs();
+
+        QMessageBox::information(this, tr("System Packages"),
+        tr("System packages updated successfully."),
+        QMessageBox::Ok,
+        QMessageBox::Ok);
+}
+
+bool PBSystemTab::getMediaLocation(QString &source, QString &dir)
+{
 	QMessageBox promptSource;
 	promptSource.setIcon(QMessageBox::Question);
 
@@ -847,16 +962,16 @@
 		return false;
 
 	if ( promptSource.clickedButton() == localB )
-		pkgSource="LOCAL";
+		source="LOCAL";
 	if ( promptSource.clickedButton() == mirrorB )
-		pkgSource="MIRROR";
+		source="MIRROR";
 
-	if ( pkgSource == "LOCAL" )
-		rDir = findLocalInstallMedia();
+	if ( source == "LOCAL" )
+		dir = findLocalInstallMedia() + "/packages";
 	else
-		rDir = Utils::getMasterMirror();
+		dir = Utils::getMasterMirror() + "/" + Version + "/" + Arch + "/netinstall/";
 
-	if ( rDir == "NOT FOUND" || rDir.isEmpty() ) {
+	if ( dir == "NOT FOUND" || dir.isEmpty() ) {
         	QMessageBox::warning(this, tr("No media detected."),
           	tr("Could not locate installation media on this system!"),
           	QMessageBox::Ok,
@@ -871,7 +986,7 @@
 // Function which starts script to locate installation media
 QString PBSystemTab::findLocalInstallMedia()
 {
-	return getLineFromCommandOutput("/usr/local/share/pcbsd/scripts/find-install-media.sh");
+	return getLineFromCommandOutput("/usr/local/share/pcbsd/scripts/find-install-media.sh").simplified();
 }
 
 bool PBSystemTab::haveAMetaDesktop()
@@ -969,9 +1084,7 @@
 			else
 				aItem->parent()->setCheckState(0, Qt::PartiallyChecked);	
 		if (aItem->checkState(0) == Qt::Unchecked && aItem->parent() )
-			if ( allChildrenPkgsUnchecked(aItem->parent()->text(0)))
-				aItem->parent()->setCheckState(0, Qt::Unchecked);	
-			else
+			if ( ! allChildrenPkgsUnchecked(aItem->parent()->text(0)))
 				aItem->parent()->setCheckState(0, Qt::PartiallyChecked);	
 
 

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-12 18:03:42 UTC (rev 7779)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-12 18:22:17 UTC (rev 7780)
@@ -1,15 +1,16 @@
 #ifndef PBSYSTEMTAB_H
 #define PBSYSTEMTAB_H
 
-#include <qfile.h>
-#include <qmessagebox.h>
-#include <qdialog.h>
-#include <QProcess>
+#include <QDialog>
+#include <QFile>
+#include <QMenu>
+#include <QMessageBox>
 #include <QNetworkAccessManager>
 #include <QNetworkReply>
+#include <QProcess>
+#include <QProgressDialog>
+#include <QTextStream>
 #include <QTimer>
-#include <QMenu>
-#include <QTextStream>
 
 #include <pcbsd-utils.h>
 #include "updaterDialog.h"
@@ -102,6 +103,10 @@
     // Meta Package Slots
     void slotApplyMetaChanges();
     void slotDeskPkgsChanged(QTreeWidgetItem *aItem, int aCol);
+    void slotMetaAddDone();
+    void slotMetaAddRead();
+    void slotMetaDelDone();
+    void slotMetaDelRead();
 
 private:
     CVSUpProgress *cvsUpUi;
@@ -143,18 +148,27 @@
     // Meta pkg stuff
     bool allChildrenPkgsChecked(QString parent);
     bool allChildrenPkgsUnchecked(QString parent);
-    void checkAllChildrenPkgs(QString parent);
+    bool isMetaPkgInstalled(QString mPkg);
+    bool haveAMetaDesktop();
+    bool haveMetaPkgChanges();
+    bool getMediaLocation(QString &pkgsource, QString &rDir);
+    QList<QStringList> getPackageData();
+    QList<QStringList> metaPkgList;
+    QProcess *addMetaProc;
+    QProcess *delMetaProc;
+    QProgressDialog *delprogress;
+    QProgressDialog *addprogress;
+    QString addPkgs;
+    QString delPkgs;
     QString findLocalInstallMedia();
     QString getAddPkgs();
     QString getDelPkgs();
-    bool getMediaLocation(QString &pkgsource, QString &rDir);
+    QString pkgSource;
+    QString rDir;
+    void checkAllChildrenPkgs(QString parent);
     void populateMetaPkgs();
-    QList<QStringList> getPackageData();
-    QList<QStringList> metaPkgList;
-    bool isMetaPkgInstalled(QString mPkg);
-    bool haveAMetaDesktop();
-    bool haveMetaPkgChanges();
     void saveMetaPkgs();
+    void startMetaChanges();
     void uncheckAllChildrenPkgs(QString parent);
 
     updaterStatus *UpdaterStatusDialog;



More information about the Commits mailing list