[PC-BSD Commits] r19863 - users/ken/EasyPBI2

svn at pcbsd.org svn at pcbsd.org
Tue Oct 23 14:28:59 PDT 2012


Author: kenmoore
Date: 2012-10-23 21:28:58 +0000 (Tue, 23 Oct 2012)
New Revision: 19863

Modified:
   users/ken/EasyPBI2/mainGUI.cpp
Log:
FInish the pbi.conf editor for EasyPBI2, it now recognizes and supports both options frameworks



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-23 15:23:54 UTC (rev 19862)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-23 21:28:58 UTC (rev 19863)
@@ -356,12 +356,19 @@
     }
   }
 }
-
+/*----------------------------------
+   MENU OPTIONS
+  -----------------------------------
+*/
 void MainGUI::on_actionExit_triggered(){
   qDebug() << "Close EasyPBI requested";
   this->close();
 }
 
+/*----------------------------------
+   TOOLBAR OPTIONS
+  -----------------------------------
+*/
 void MainGUI::on_actionNew_Module_triggered(){
   qDebug() << "New Module triggered";
 }
@@ -384,6 +391,10 @@
   }
 }
 
+/*----------------------------------
+   MODULE EDITOR OPTIONS
+  -----------------------------------
+*/
 void MainGUI::slotModTabChanged(int newtab){
   switch(newtab){
     case 0:
@@ -403,6 +414,10 @@
   }	  
 }
 
+/*----------------------------------
+   PBI.CONF OPTIONS
+  -----------------------------------
+*/
 void MainGUI::on_push_change_makeport_clicked(){
   if( !CheckForPorts() ){
     //No ports tree available
@@ -423,7 +438,52 @@
 
 void MainGUI::slotAddMakeOption(QAction* act){
   qDebug() << "Trying to add build option:" << act->text();
-  
+  QString opt = act->text();
+  if(opt.isEmpty() ){ return; } //Do nothing if nothing selected
+  //Check whther the option is set or unset
+  QString typ = opt.section("_",0,0,QString::SectionSkipEmpty).toLower(); //get the type
+  opt = opt.section("_",1,50,QString::SectionSkipEmpty); //trim off the type of setting
+  QString chk = currentModule->readValue("makeport").section("/",-1);
+  bool isSet;
+  if(typ == "with"){chk.append("_SET"); isSet=TRUE;}
+  else if(typ=="without"){chk.append("_UNSET"); isSet=FALSE;}
+  else{ qDebug() << "Error: Unknown option type:"<<typ<<"option:"<<opt; return; }
+  //Now read the current option settings
+  QStringList curr = ui->edit_makeopts->toPlainText().split("\n"); //split according to lines
+  bool found = FALSE;
+  for(int i=0; i<curr.length(); i++){
+    if(curr[i].contains(chk) ){ //look for optionsNG framework
+      found = TRUE;	    
+      QStringList cOpts = curr[i].split(" ",QString::SkipEmptyParts);
+      if( !cOpts.contains(opt) ){
+	//Not found, add it to the end of the list
+	cOpts << opt;
+	curr[i] = cOpts.join(" ");
+      }
+    }else if(curr[i].contains(opt)){ //look for legacy options framework
+      QStringList cOpts = curr[i].split(" ",QString::SkipEmptyParts);
+      int index = cOpts.indexOf(opt);
+      if(index != -1){ //option currently set somehow
+	found = TRUE; 
+        if(isSet){ //option should be set
+          if( cOpts[index].contains("WITH_"+opt) ){} //Already set
+	  else if( cOpts[index].contains("WITHOUT_"+opt) ){ cOpts[index] = "WITH_"+opt+"=true"; }
+	  else if( curr[i].contains(chk.replace("_SET","_UNSET")) ){ cOpts.removeAt(index); found=FALSE;} //Remove the inverse option if it is set
+        }else{ //options should be unset
+          if( cOpts[index].contains("WITHOUT_"+opt) ){} //Already set
+	  else if( cOpts[index].contains("WITH_"+opt) ){ cOpts[index] = "WITHOUT_"+opt+"=true"; }
+	  else if( curr[i].contains(chk.replace("_UNSET","_SET")) ){ cOpts.removeAt(index); found=FALSE;} //Remove the inverse option if it is set
+	}
+        curr[i] = cOpts.join(" "); //put the line back together
+      }
+    } //end checking different options frameworks
+  } // end loop over lines
+  if(!found){
+    //Append the option to the end on a new line
+    curr << chk+"= "+opt;
+  }
+  //Now put the new options list back onto the GUI
+  ui->edit_makeopts->setPlainText(curr.join("\n"));
 }
 
 void MainGUI::on_push_addportbefore_clicked(){
@@ -512,7 +572,10 @@
     QMessageBox::warning(this,tr("EasyPBI Error"), tr("The PBI configuration file could not be saved. Please check your file permissions before trying again."));
   }
 }
-
+/*------------------------------------------------
+   RESOURCE EDITOR OPTIONS
+  -------------------------------------------------
+*/
 void MainGUI::slotResourceChanged(){
   //Get the current file selected
   QString cfile;



More information about the Commits mailing list