[PC-BSD Commits] r12335 - pcbsd/current/src-qt4/pc-sysinstaller

svn at pcbsd.org svn at pcbsd.org
Fri Aug 26 09:57:24 PDT 2011


Author: kris
Date: 2011-08-26 09:57:24 -0700 (Fri, 26 Aug 2011)
New Revision: 12335

Modified:
   pcbsd/current/src-qt4/pc-sysinstaller/sys-pkgmgmt.cpp
   pcbsd/current/src-qt4/pc-sysinstaller/sysinstaller.h
Log:

Port over the changes to support multiple child layers of meta-pkgs in pc-sysinstaller



Modified: pcbsd/current/src-qt4/pc-sysinstaller/sys-pkgmgmt.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysinstaller/sys-pkgmgmt.cpp	2011-08-26 16:29:59 UTC (rev 12334)
+++ pcbsd/current/src-qt4/pc-sysinstaller/sys-pkgmgmt.cpp	2011-08-26 16:57:24 UTC (rev 12335)
@@ -22,71 +22,61 @@
   file.close();
   // Done with NVIDIA check
   
-
   // Start by reading our list of desktop pkgs, and populate the GUI
+  addTreeItems(QString(), usingNVIDIA);
 
-  // First look for "parent" apps
-  for (int z=0; z < listDeskPkgs.count(); ++z)
-    if ( listDeskPkgs.at(z).at(3).isEmpty() ) {
+  treeWidgetDesktopPackages->setMouseTracking(TRUE);
+  connect(treeWidgetDesktopPackages, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
+  connect(treeWidgetDesktopPackages, SIGNAL(itemEntered(QTreeWidgetItem *, int)), this, SLOT(slotShowLabelDesc(QTreeWidgetItem *, int)));
 
-	// Skip the "base-system" package, since we are installing it anyway
-	if (listDeskPkgs.at(z).at(0) == "base-system" )
-		continue;
+  treeWidgetDesktopPackages->setContextMenuPolicy(Qt::CustomContextMenu);
+  connect(treeWidgetDesktopPackages, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotMetaRightClick()) );
 
-	QTreeWidgetItem *deskItem = new QTreeWidgetItem(treeWidgetDesktopPackages, \
-							 QStringList() << listDeskPkgs.at(z).at(0) );
-	deskItem->setIcon(0, QIcon(listDeskPkgs.at(z).at(2)));
-	deskItem->setToolTip(0, listDeskPkgs.at(z).at(1));
-	deskItem->setCheckState(0, Qt::Unchecked);
+}
 
-	if ( listDeskPkgs.at(z).at(0) == "KDE" )
-		deskItem->setCheckState(0, Qt::Checked);
+void SysInstaller::addTreeItems(QString parent, bool usingNVIDIA)
+{
+  for (int z=0; z < listDeskPkgs.count(); ++z) {
+    if ( listDeskPkgs.at(z).at(3) != parent )
+      continue;
 
-	// Is this a desktop, if so bold it
-	if ( listDeskPkgs.at(z).at(4) == "YES" )
-		deskItem->setText(0, "<b>" + listDeskPkgs.at(z).at(0) + "</b>");
+    // Hide the "base-system" package, since we are installing it anyway
+    if (listDeskPkgs.at(z).at(0) == "base-system" )
+      return;
 
-	if ( listDeskPkgs.at(z).at(0) == "NVIDIA" && usingNVIDIA )
-		deskItem->setCheckState(0, Qt::Checked);
-    }
+    QTreeWidgetItem *deskItem = new QTreeWidgetItem(QStringList() << listDeskPkgs.at(z).at(0) );
+    deskItem->setIcon(0, QIcon(listDeskPkgs.at(z).at(2)));
+    deskItem->setToolTip(0, listDeskPkgs.at(z).at(1));
+    deskItem->setCheckState(0, Qt::Unchecked);
 
-  // Now look for child apps
-  for (int z=0; z < listDeskPkgs.count(); ++z)
-    if ( ! listDeskPkgs.at(z).at(3).isEmpty() ) {
-	QTreeWidgetItem *deskItem = new QTreeWidgetItem(QStringList() << listDeskPkgs.at(z).at(0) );
-	deskItem->setIcon(0, QIcon(listDeskPkgs.at(z).at(2)));
-	deskItem->setToolTip(0, listDeskPkgs.at(z).at(1));
+    if ( listDeskPkgs.at(z).at(0) == "KDE" )
+      deskItem->setCheckState(0, Qt::Checked);
 
-	if ( listDeskPkgs.at(z).at(3) == "KDE" )
-		deskItem->setCheckState(0, Qt::Checked);
-	else
-		deskItem->setCheckState(0, Qt::Unchecked);
+    if ( listDeskPkgs.at(z).at(3) == "KDE" )
+      deskItem->setCheckState(0, Qt::Checked);
 
-	// Is this a desktop, if so bold it
-	if ( listDeskPkgs.at(z).at(4) == "YES" )
-		deskItem->setText(0, "<b>" + listDeskPkgs.at(z).at(0) + "</b>");
+    if ( listDeskPkgs.at(z).at(0) == "NVIDIA" && usingNVIDIA )
+      deskItem->setCheckState(0, Qt::Checked);
 
-	if ( listDeskPkgs.at(z).at(0) == "NVIDIA" && usingNVIDIA )
-		deskItem->setCheckState(0, Qt::Checked);
-
-	// Now locate the parent app
-        QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
-        while (*it) {
-         if ((*it)->text(0) == listDeskPkgs.at(z).at(3)) {
-             (*it)->addChild(deskItem);
-	     break;
-	 }
-         ++it;
-        }
+    if ( parent.isEmpty() ) {
+      treeWidgetDesktopPackages->addTopLevelItem(deskItem);
+    } else {
+      // Locate the parent to attach to
+      QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
+      while (*it) {
+        if ((*it)->text(0) == parent ) {
+	  (*it)->addChild(deskItem);
+          if ( deskItem->checkState(0) == Qt::Checked && (*it)->checkState(0) == Qt::Unchecked)
+            (*it)->setCheckState(0, Qt::PartiallyChecked);
+	  break;
+	}
+        it++;
+      }
     }
 
-    treeWidgetDesktopPackages->setMouseTracking(TRUE);
-    connect(treeWidgetDesktopPackages, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
-    connect(treeWidgetDesktopPackages, SIGNAL(itemEntered(QTreeWidgetItem *, int)), this, SLOT(slotShowLabelDesc(QTreeWidgetItem *, int)));
-
-    treeWidgetDesktopPackages->setContextMenuPolicy(Qt::CustomContextMenu);
-    connect(treeWidgetDesktopPackages, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotMetaRightClick()) );
-
+    // Now look for any possible children
+    addTreeItems(listDeskPkgs.at(z).at(0), usingNVIDIA);    
+  }
 }
 
 // Slot to show meta-pkg description on mouseover
@@ -155,58 +145,106 @@
 	return false;
 }
 
-
 // Check the "parent" app to see if all its children are checked or not
 bool SysInstaller::allChildrenPkgsChecked(QString parent)
 {
         QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
         while (*it) {
-         if ((*it)->text(0) == parent )
-		for ( int i = 0; i < (*it)->childCount() ; ++i)
-		   if ((*it)->child(i)->checkState(0) != Qt::Checked ) 
-	     		return false;
+         if ((*it)->text(0) == parent ) {
+	   if ( (*it)->childCount() <= 0)
+	     return true;
+
+	   for ( int i = 0; i < (*it)->childCount() ; ++i) {
+	     if ( ! allChildrenPkgsChecked((*it)->child(i)->text(0)))
+	       return false;
+
+             if ((*it)->child(i)->checkState(0) != Qt::Checked ) 
+	       return false;
+	   }
+         }
          ++it;
         }
 	return true;
 }
 
-// Check the "parent" app to see if all its children are checked or not
+// Check the "parent" app to see if all its children are unchecked or not
 bool SysInstaller::allChildrenPkgsUnchecked(QString parent)
 {
         QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
         while (*it) {
-         if ((*it)->text(0) == parent )
-		for ( int i = 0; i < (*it)->childCount() ; ++i)
-		   if ((*it)->child(i)->checkState(0) != Qt::Unchecked ) 
-	     		return false;
+         if ((*it)->text(0) == parent ) {
+	   if ( (*it)->childCount() <= 0)
+	     return true;
+
+	   for ( int i = 0; i < (*it)->childCount() ; ++i) {
+	     if ( ! allChildrenPkgsUnchecked((*it)->child(i)->text(0)))
+	       return false;
+
+             if ((*it)->child(i)->checkState(0) != Qt::Unchecked ) 
+	       return false;
+	   }
+         }
          ++it;
         }
 	return true;
 }
 
-
 // Check all children of parent
 void SysInstaller::checkAllChildrenPkgs(QString parent)
 {
         QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
         while (*it) {
-         if ((*it)->parent())
-		if ((*it)->parent()->text(0) == parent) 
-			(*it)->setCheckState(0, Qt::Checked);
+         if (! (*it)->parent()) {
+           ++it;
+	   continue;
+	 } 
+
+         // Lets walk the tree see what pops up
+	 bool pFound=false;
+         QTreeWidgetItem *itP = (*it)->parent();
+	 do {
+	   pFound=false;
+	   if (itP->text(0) == parent) {
+	     (*it)->setCheckState(0, Qt::Checked);
+	     break;
+	   }
+	   if ( itP->parent() ) {
+	     itP = itP->parent();
+             pFound=true;
+           }
+         } while (pFound);
+
          ++it;
-        }
+       }
 }
 
-// Check all children of parent
+// UnCheck all children of parent
 void SysInstaller::uncheckAllChildrenPkgs(QString parent)
 {
         QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
         while (*it) {
-         if ((*it)->parent())
-		if ((*it)->parent()->text(0) == parent) 
-			(*it)->setCheckState(0, Qt::Unchecked);
+         if (! (*it)->parent()) {
+           ++it;
+	   continue;
+	 } 
+
+         // Lets walk the tree see what pops up
+	 bool pFound=false;
+         QTreeWidgetItem *itP = (*it)->parent();
+	 do {
+	   pFound=false;
+	   if (itP->text(0) == parent) {
+	     (*it)->setCheckState(0, Qt::Unchecked);
+	     break;
+	   }
+	   if ( itP->parent() ) {
+	     itP = itP->parent();
+             pFound=true;
+           }
+         } while (pFound);
+
          ++it;
-        }
+       }
 }
 
 // Return the configuration for desktop packages

Modified: pcbsd/current/src-qt4/pc-sysinstaller/sysinstaller.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysinstaller/sysinstaller.h	2011-08-26 16:29:59 UTC (rev 12334)
+++ pcbsd/current/src-qt4/pc-sysinstaller/sysinstaller.h	2011-08-26 16:57:24 UTC (rev 12335)
@@ -173,6 +173,7 @@
     void checkAllChildrenPkgs(QString parent);
     void uncheckAllChildrenPkgs(QString parent);
     bool haveMetaDesktopChecked();
+    void addTreeItems(QString, bool);
 
     QStackedWidget *stackWidget;
     dialogFileSystem *dfs;



More information about the Commits mailing list