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

svn at pcbsd.org svn at pcbsd.org
Sun Oct 10 09:31:24 PDT 2010


Author: kris
Date: 2010-10-10 09:31:24 -0700 (Sun, 10 Oct 2010)
New Revision: 7774

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

Updated system manager, now we do logic checking on installing system packages, make sure
we update parent / child status 



Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-10 11:46:08 UTC (rev 7773)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp	2010-10-10 16:31:24 UTC (rev 7774)
@@ -55,6 +55,7 @@
     connect(splashSelect, SIGNAL(activated(int)), this, SIGNAL(changed()));
     connect(pushRefreshList, SIGNAL( clicked() ), this, SLOT( slotUpdateMirrorList() ) );
     connect(pushSave, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+    connect(pushApplyMeta, SIGNAL( clicked() ), this, SLOT( slotApplyMetaChanges() ) );
     connect(pushClose, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
 
     // Connect the mirror radio buttons, so we can enable disable objects based on status
@@ -618,7 +619,6 @@
     miscSavePressed();
     saveKernScreen();
     saveMirrorConfig();
-    saveMetaPkgs();
 }
 
 void PBSystemTab::saveMirrorConfig() {
@@ -732,8 +732,7 @@
         }
     }
 
-    //connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
-
+    connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
 }
 
 
@@ -811,6 +810,10 @@
 {
 	if ( ! haveAMetaDesktop() )
 		return;
+
+	if ( ! haveMetaPkgChanges() )
+		return;
+	
 }
 
 bool PBSystemTab::haveAMetaDesktop()
@@ -830,5 +833,117 @@
           QMessageBox::Ok);
 
 	return false;
+}
 
+bool PBSystemTab::haveMetaPkgChanges()
+{
+        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 \
+	      || (*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;
+        }
+
+	return false;
 }
+
+// Time to save meta-pkgs
+void PBSystemTab::slotApplyMetaChanges() {
+    saveMetaPkgs();
+}
+
+
+
+// The User changed the tree widget checked / unchecked stuff sanity check
+void PBSystemTab::slotDeskPkgsChanged(QTreeWidgetItem *aItem, int aCol)
+{
+	if (!aItem)
+  	  return;
+
+        disconnect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 0, 0);
+
+	if (aItem->childCount() == 0) {
+		if (aItem->checkState(0) == Qt::Checked && aItem->parent() )
+			if ( allChildrenPkgsChecked(aItem->parent()->text(0)))
+				aItem->parent()->setCheckState(0, Qt::Checked);	
+			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
+				aItem->parent()->setCheckState(0, Qt::PartiallyChecked);	
+
+
+	} else {
+		if (aItem->checkState(0) == Qt::Checked )
+			checkAllChildrenPkgs(aItem->text(0));
+		else
+			uncheckAllChildrenPkgs(aItem->text(0));
+	}
+	
+
+    connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
+
+	if ( haveMetaPkgChanges() )
+		pushApplyMeta->setEnabled(true);
+	else
+		pushApplyMeta->setEnabled(false);
+}
+
+// Check the "parent" app to see if all its children are checked or not
+bool PBSystemTab::allChildrenPkgsChecked(QString parent)
+{
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        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;
+         ++it;
+        }
+	return true;
+}
+
+// Check the "parent" app to see if all its children are checked or not
+bool PBSystemTab::allChildrenPkgsUnchecked(QString parent)
+{
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        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;
+         ++it;
+        }
+	return true;
+}
+
+
+// Check all children of parent
+void PBSystemTab::checkAllChildrenPkgs(QString parent)
+{
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        while (*it) {
+         if ((*it)->parent())
+		if ((*it)->parent()->text(0) == parent) 
+			(*it)->setCheckState(0, Qt::Checked);
+         ++it;
+        }
+}
+
+// Check all children of parent
+void PBSystemTab::uncheckAllChildrenPkgs(QString parent)
+{
+        QTreeWidgetItemIterator it(treeMetaPkgs);
+        while (*it) {
+         if ((*it)->parent())
+		if ((*it)->parent()->text(0) == parent) 
+			(*it)->setCheckState(0, Qt::Unchecked);
+         ++it;
+        }
+}

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-10 11:46:08 UTC (rev 7773)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.h	2010-10-10 16:31:24 UTC (rev 7774)
@@ -99,6 +99,9 @@
     void slotPopulateSysUpdates();
     void slotUpdateSysTrayTrigger();
 
+    // Meta Package Slots
+    void slotApplyMetaChanges();
+    void slotDeskPkgsChanged(QTreeWidgetItem *aItem, int aCol);
 
 private:
     CVSUpProgress *cvsUpUi;
@@ -138,12 +141,17 @@
     void loadPatchData(QString patchFile, int patchNum);
 
     // Meta pkg stuff
+    bool allChildrenPkgsChecked(QString parent);
+    bool allChildrenPkgsUnchecked(QString parent);
+    void checkAllChildrenPkgs(QString parent);
     void populateMetaPkgs();
     QList<QStringList> getPackageData();
     QList<QStringList> metaPkgList;
     bool isMetaPkgInstalled(QString mPkg);
     bool haveAMetaDesktop();
+    bool haveMetaPkgChanges();
     void saveMetaPkgs();
+    void uncheckAllChildrenPkgs(QString parent);
 
     updaterStatus *UpdaterStatusDialog;
     

Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.ui
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.ui	2010-10-10 11:46:08 UTC (rev 7773)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.ui	2010-10-10 16:31:24 UTC (rev 7774)
@@ -718,7 +718,7 @@
        <string>System Packages</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_11">
-       <item row="0" column="0">
+       <item row="0" column="0" colspan="2">
         <widget class="QTreeWidget" name="treeMetaPkgs">
          <property name="iconSize">
           <size>
@@ -728,21 +728,44 @@
          </property>
          <column>
           <property name="text">
-           <string>Available Meta Packages</string>
+           <string>Available System Packages</string>
           </property>
          </column>
         </widget>
        </item>
-       <item row="1" column="0">
+       <item row="1" column="0" colspan="2">
         <widget class="QLabel" name="label_2">
          <property name="text">
-          <string>Above you may select the base meta packages you wish to have installed on this system. Adding new packages will require your original installation medium, or a properly configured mirror server.</string>
+          <string>Above you may select the base system packages you wish to have installed. Adding new packages will require your original installation medium, or a properly configured mirror server.</string>
          </property>
          <property name="wordWrap">
           <bool>true</bool>
          </property>
         </widget>
        </item>
+       <item row="3" column="0">
+        <widget class="QPushButton" name="pushApplyMeta">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="text">
+          <string>&amp;Apply Changes</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <spacer name="horizontalSpacer_6">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="TabPage">



More information about the Commits mailing list