[PC-BSD Commits] r5166 - pcbsd/trunk/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Mon Nov 30 16:18:14 PST 2009


Author: kris
Date: 2009-11-30 16:18:14 -0800 (Mon, 30 Nov 2009)
New Revision: 5166

Modified:
   pcbsd/trunk/SysInstaller/backend.cpp
   pcbsd/trunk/SysInstaller/sys-componentwidget.cpp
   pcbsd/trunk/SysInstaller/sysinstaller.h
Log:

Finished up component selection backend / gui logic for SysInstaller



Modified: pcbsd/trunk/SysInstaller/backend.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/backend.cpp	2009-11-30 18:21:06 UTC (rev 5165)
+++ pcbsd/trunk/SysInstaller/backend.cpp	2009-12-01 00:18:14 UTC (rev 5166)
@@ -194,6 +194,7 @@
    QStringList singleComponent;
 
    QString tmp, name, desc, icon, line;
+   QString selected = "off";
 
    Process p(QStringList() << "list-components");
 
@@ -209,7 +210,7 @@
           }
           if ( line.indexOf("icon:") != -1 ) {
             icon = line.remove(0, line.indexOf(": ") + 2); 
-            singleComponent << name << desc << icon;
+            singleComponent << name << desc << icon << selected;
             components << singleComponent;
             qDebug() << "Found Component:" << singleComponent;
             singleComponent.clear();

Modified: pcbsd/trunk/SysInstaller/sys-componentwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-componentwidget.cpp	2009-11-30 18:21:06 UTC (rev 5165)
+++ pcbsd/trunk/SysInstaller/sys-componentwidget.cpp	2009-12-01 00:18:14 UTC (rev 5166)
@@ -3,15 +3,61 @@
 
 void SysInstaller::connectComponentSlots()
 {
+  connect(pushComAdd,SIGNAL(clicked()), this, SLOT(slotAddComponent()));
+  connect(pushComDel,SIGNAL(clicked()), this, SLOT(slotRemoveComponent()));
+  
+  listComponents = Scripts::Backend::availComponents();
+  refreshComponents();
+}
+
+void SysInstaller::refreshComponents()
+{
   QString name;
   QIcon cIcon;
 
   listAvailComponents->clear();
-  listComponents = Scripts::Backend::availComponents();
+  listSelComponents->clear();
+
   for ( int i=0; i<listComponents.count(); ++i) {
      cIcon.addFile(listComponents.at(i).at(2));
      name = listComponents.at(i).at(1) + " - (" + listComponents.at(i).at(0) + ")";
-     new QListWidgetItem(cIcon, name, listAvailComponents);
+     if ( listComponents.at(i).at(3) == "off" )
+       new QListWidgetItem(cIcon, name, listAvailComponents);
+     else 
+       new QListWidgetItem(cIcon, name, listSelComponents);
   }
 
 }
+
+void SysInstaller::slotAddComponent()
+{
+  if ( ! listAvailComponents->currentItem() )
+    return;
+
+  QString name = listAvailComponents->currentItem()->text();
+  name.truncate(name.indexOf(")"));
+  name = name.remove(0, name.indexOf(" (") + 2 );
+  for ( int i=0; i<listComponents.count(); ++i) {
+     if ( listComponents.at(i).at(0) == name )
+       listComponents[i][3] = "on";
+  }
+
+  refreshComponents();
+
+}
+
+void SysInstaller::slotRemoveComponent()
+{
+  if ( ! listSelComponents->currentItem() )
+    return;
+
+  QString name = listSelComponents->currentItem()->text();
+  name.truncate(name.indexOf(")"));
+  name = name.remove(0, name.indexOf(" (") + 2 );
+  for ( int i=0; i<listComponents.count(); ++i) {
+     if ( listComponents.at(i).at(0) == name )
+       listComponents[i][3] = "off";
+  }
+
+  refreshComponents();
+}

Modified: pcbsd/trunk/SysInstaller/sysinstaller.h
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.h	2009-11-30 18:21:06 UTC (rev 5165)
+++ pcbsd/trunk/SysInstaller/sysinstaller.h	2009-12-01 00:18:14 UTC (rev 5166)
@@ -76,6 +76,8 @@
     void slotGotNetworkUrl(QString url);
 
     // Component slots
+    void slotAddComponent();
+    void slotRemoveComponent();
 
     // Source slots
     void slotChangedInstallType();
@@ -126,6 +128,8 @@
     void connectKeyboardSlots();
     void connectComponentSlots();
 
+    void refreshComponents(); // Function which re-draws components list widgets
+
     void proceed(bool);
     bool isInstalled();
     bool checkDiskRequirements();



More information about the Commits mailing list