[PC-BSD Commits] r12330 - pcbsd/current/src-qt4/pc-sysmanager
svn at pcbsd.org
svn at pcbsd.org
Fri Aug 26 08:56:14 PDT 2011
Author: kris
Date: 2011-08-26 08:56:14 -0700 (Fri, 26 Aug 2011)
New Revision: 12330
Modified:
pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
Log:
Enhance system manager, now meta-pkgs can have unlimited nested categories
Modified: pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp 2011-08-26 15:49:07 UTC (rev 12329)
+++ pcbsd/current/src-qt4/pc-sysmanager/pbsystemtab.cpp 2011-08-26 15:56:14 UTC (rev 12330)
@@ -609,7 +609,7 @@
treeMetaPkgs->clear();
- // First look for "parent" apps
+ // First look for top-level stuff
for (int z=0; z < metaPkgList.count(); ++z)
if ( metaPkgList.at(z).at(3).isEmpty() ) {
@@ -627,34 +627,50 @@
deskItem->setCheckState(0, Qt::Checked);
}
- // First look for "parent" apps
- for (int z=0; z < metaPkgList.count(); ++z)
- if ( ! metaPkgList.at(z).at(3).isEmpty() ) {
- 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);
+ // Now cycle through all the children
+ bool foundChild = true;
+ QStringList cAdded;
+ do
+ {
+ foundChild=false;
- if ( metaPkgList.at(z).at(5) == "YES" )
- deskItem->setCheckState(0, Qt::Checked);
+ for (int z=0; z < metaPkgList.count(); ++z) {
+ if ( metaPkgList.at(z).at(3).isEmpty() || cAdded.contains(metaPkgList.at(z).at(0)) )
+ continue;
- // Now locate the parent app
- QTreeWidgetItemIterator it(treeMetaPkgs);
- while (*it) {
- if ((*it)->text(0) == metaPkgList.at(z).at(3)) {
+ 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 the child is installed, then check the parent as well
- if ( metaPkgList.at(z).at(5) == "YES" )
- (*it)->setCheckState(0, Qt::Checked);
+ if ( metaPkgList.at(z).at(5) == "YES" )
+ deskItem->setCheckState(0, Qt::Checked);
- // Add child to parent
- (*it)->addChild(deskItem);
- break;
- }
- ++it;
+ // Now locate the parent app
+ 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;
+ }
+
+ } // End of for loop
+
+ } while (foundChild);
+
connect(treeMetaPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDeskPkgsChanged(QTreeWidgetItem *, int)));
}
@@ -1054,52 +1070,101 @@
{
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;
+ 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 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;
+ 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 PBSystemTab::checkAllChildrenPkgs(QString parent)
{
QTreeWidgetItemIterator it(treeMetaPkgs);
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 PBSystemTab::uncheckAllChildrenPkgs(QString parent)
{
QTreeWidgetItemIterator it(treeMetaPkgs);
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;
- }
+ }
}
void PBSystemTab::slotMetaRightClick()
More information about the Commits
mailing list