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

svn at pcbsd.org svn at pcbsd.org
Fri Aug 26 09:29:59 PDT 2011


Author: kris
Date: 2011-08-26 09:29:59 -0700 (Fri, 26 Aug 2011)
New Revision: 12334

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

Improve and greatly simply the intial adding of meta-pkgs to treeWidget



Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2011-08-26 16:04:07 UTC (rev 12333)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2011-08-26 16:29:59 UTC (rev 12334)
@@ -609,72 +609,52 @@
 
   treeMetaPkgs->clear();
 
-  // First look for top-level stuff
-  for (int z=0; z < metaPkgList.count(); ++z)
-    if ( metaPkgList.at(z).at(3).isEmpty() ) {
+  addTreeItems(QString()); 
 
-	// Skip the "base-system" package, since we are installing it anyway
-	if (metaPkgList.at(z).at(0) == "base-system" )
-		continue;
+  connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
+}
 
-	QTreeWidgetItem *deskItem = new QTreeWidgetItem(treeMetaPkgs, \
-							 QStringList() << metaPkgList.at(z).at(0) );
-	deskItem->setIcon(0, QIcon(metaPkgList.at(z).at(2)));
-	deskItem->setToolTip(0, metaPkgList.at(z).at(1));
-	deskItem->setCheckState(0, Qt::Unchecked);
+void PBSystemTab::addTreeItems(QString parent)
+{
+  for (int z=0; z < metaPkgList.count(); ++z) {
+    if ( metaPkgList.at(z).at(3) != parent )
+      continue;
 
-	if ( metaPkgList.at(z).at(5) == "YES" )
-		deskItem->setCheckState(0, Qt::Checked);
-    }
+    // Hide the "base-system" package, since we are installing it anyway
+    if (metaPkgList.at(z).at(0) == "base-system" )
+      return;
 
-  // Now cycle through all the children
-  bool foundChild = true;
-  QStringList cAdded;
-  do
-  {
-    foundChild=false;
+    QTreeWidgetItem *deskItem = new QTreeWidgetItem(QStringList() << metaPkgList.at(z).at(0) );
+    deskItem->setIcon(0, QIcon(metaPkgList.at(z).at(2)));
+    deskItem->setToolTip(0, metaPkgList.at(z).at(1));
+    deskItem->setCheckState(0, Qt::Unchecked);
 
-    for (int z=0; z < metaPkgList.count(); ++z) {
-      if ( metaPkgList.at(z).at(3).isEmpty() || cAdded.contains(metaPkgList.at(z).at(0)) )
-        continue;
+    if ( metaPkgList.at(z).at(5) == "YES" )
+      deskItem->setCheckState(0, Qt::Checked);
 
-      QTreeWidgetItem *deskItem = new QTreeWidgetItem(QStringList() << metaPkgList.at(z).at(0) );
-      deskItem->setIcon(0, QIcon(metaPkgList.at(z).at(2)));
-      deskItem->setToolTip(0, metaPkgList.at(z).at(1));
-      deskItem->setCheckState(0, Qt::Unchecked);
-
-      if ( metaPkgList.at(z).at(5) == "YES" )
-        deskItem->setCheckState(0, Qt::Checked);
-
-      // Now locate the parent app
+    if ( parent.isEmpty() ) {
+      treeMetaPkgs->addTopLevelItem(deskItem);
+    } else {
+      // Locate the parent to attach to
       QTreeWidgetItemIterator it(treeMetaPkgs);
       while (*it) {
-        if ((*it)->text(0) != metaPkgList.at(z).at(3)) {
-          ++it;
-	  continue;
-        }
-
-         // If the child is installed, then check the parent as well
-	if ( metaPkgList.at(z).at(5) == "YES" )
-	  (*it)->setCheckState(0, Qt::Checked);
-
-	// Add child to parent
-        (*it)->addChild(deskItem);
-               
-        // Save to the list of added
-	cAdded << metaPkgList.at(z).at(0); 
-        foundChild=true;
-        break;
+        if ((*it)->text(0) == parent ) {
+	  (*it)->addChild(deskItem);
+          if ( metaPkgList.at(z).at(5) == "YES" && (*it)->checkState(0) == Qt::Unchecked)
+	    (*it)->setCheckState(0, Qt::PartiallyChecked);
+          if ( metaPkgList.at(z).at(5) == "NO" && (*it)->checkState(0) == Qt::Checked)
+	    (*it)->setCheckState(0, Qt::PartiallyChecked);
+	  break;
+	}
+        it++;
       }
+    }
 
-    } // End of for loop
-
-  } while (foundChild);
-
-    connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
+    // Now look for any possible children
+    addTreeItems(metaPkgList.at(z).at(0));    
+  }
 }
 
-
 // Check if a meta-pkg is installed
 bool PBSystemTab::isMetaPkgInstalled(QString mPkg)
 {

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2011-08-26 16:04:07 UTC (rev 12333)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2011-08-26 16:29:59 UTC (rev 12334)
@@ -148,6 +148,7 @@
     void saveMetaPkgs();
     void startMetaChanges();
     void uncheckAllChildrenPkgs(QString parent);
+    void addTreeItems(QString);
 
     updaterStatus *UpdaterStatusDialog;
     dialogMetaProgress *metaProgressDel;



More information about the Commits mailing list