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

svn at pcbsd.org svn at pcbsd.org
Thu Nov 1 07:00:52 PDT 2012


Author: kenmoore
Date: 2012-11-01 14:00:52 +0000 (Thu, 01 Nov 2012)
New Revision: 20101

Modified:
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/mainGUI.ui
   users/ken/EasyPBI2/modBuild.cpp
   users/ken/EasyPBI2/modBuild.h
Log:
Finish up the external-links tab, now it is working great.



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-11-01 01:06:31 UTC (rev 20100)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-11-01 14:00:52 UTC (rev 20101)
@@ -83,12 +83,12 @@
 	ui->list_scripts_file->addItems(QStringList() << " ---"+tr("Installation Scripts")+"---" << "pre-portmake.sh" << "post-portmake.sh" << "pre-install.sh" << "post-install.sh" << "pre-remove.sh" );
 	connect(ui->list_scripts_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotScriptChanged(int)) );
 	// -- External links tab --
-	ui->push_el_files->setIcon(Backend::icon("left"));
-	menu_binList.addAction("No Binaries Detected");
-	ui->push_el_files->setMenu(&menu_binList);
-	
+	ui->push_el_file->setIcon(Backend::icon("left"));
+	ui->push_el_file->setMenu(&menu_el_bins);
+	connect(&menu_el_bins,SIGNAL(triggered(QAction*)),this,SLOT(slotELSetFile(QAction*)) );
 	ui->push_el_filetype->setIcon(Backend::icon("left"));
 	ui->push_el_filetype->setMenu(&menu_elOpts);
+	connect(&menu_elOpts,SIGNAL(triggered(QAction*)),this,SLOT(slotELSetType(QAction*)) );
 	//Setup PBI Builder
 	ui->push_build_stop->setIcon(Backend::icon("close"));
 	ui->push_build_save->setIcon(Backend::icon("save"));
@@ -335,6 +335,21 @@
   //------EXTERNAL-LINKS------
   if( doall || doeditor || (item == "external-links")){
     //nothing to make visible/invisible here
+    //Load the external-links file
+    ui->list_el_view->clear();
+    ui->list_el_view->addItems( currentModule->externalLinks() );
+    //Clear the input boxes
+    ui->line_el_file->clear();
+    ui->line_el_linkto->clear();
+    ui->line_el_filetype->clear();
+    //update the available binaries
+    menu_el_bins.clear();
+    QStringList cBins = currentModule->currentBins;
+    if(!cBins.isEmpty()){
+      for(int i=0; i<cBins.length(); i++){
+        menu_el_bins.addAction(cBins[i]);
+      } 
+    }
   }
   //------FREENAS PLUGINS-------
   if( doall || doeditor || (item == "freenas")){
@@ -1087,6 +1102,7 @@
   -------------------------------------------------
 */
 void MainGUI::slotScriptChanged(int index){
+  index=0; //just to remove the warning about unused variables
   refreshGUI("scripts");
 }
 
@@ -1116,7 +1132,79 @@
   QString filename = currentModule->path() + "/scripts/"+ui->list_scripts_file->currentText();
   //Save the file
   bool ok = ModBuild::createFile(filename,contents);
+  //display a warning if error
+  //if(!ok){
+    //QMessageBox::warning(this,
+  //}
   //Now refresh the UI
   refreshGUI("scripts");
 }
+/*------------------------------------------------
+   EXTERNAL-LINKS EDITOR OPTIONS
+  -------------------------------------------------
+*/
+void MainGUI::on_push_el_add_clicked(){
+  //Read the user inputs
+  QString file = ui->line_el_file->text();
+  QString linkto = ui->line_el_linkto->text();
+  QString opts = ui->line_el_filetype->text();
+  //check for valid inputs
+  if( file.isEmpty() || linkto.isEmpty() || opts.isEmpty() ){ return; }
+  //Add the link
+  qDebug() << "Adding the link"<<file<<linkto<<opts.split(",");
+  currentModule->addExternalLink(file, linkto, opts.split(",") );
+  //Save the file
+  qDebug() << "Saving the file";
+  currentModule->writeExternalLinks();
+  //Refresh the UI
+  qDebug() << "Refresh the UI";
+  refreshGUI("external-links");
+}
 
+void MainGUI::on_push_el_remove_clicked(){
+  //Get the currently selected link
+  int row = ui->list_el_view->currentRow();
+  if(row == -1){ return; }
+  QString line = ui->list_el_view->currentItem()->text();
+  QString file = line.section("\t",0,0,QString::SectionSkipEmpty);
+  QString linkto = line.section("\t",1,1,QString::SectionSkipEmpty);
+  //Remove the link
+  currentModule->removeExternalLink(file,linkto);
+  //Save the file
+  currentModule->writeExternalLinks();
+  //Refresh the UI
+  refreshGUI("external-links");
+}
+
+void MainGUI::slotELSetFile(QAction* act){
+  //get the selected file and set it in the UI
+  ui->line_el_file->setText( act->text() );
+  ui->line_el_linkto->setText( act->text() );
+}
+
+void MainGUI::slotELSetType(QAction* act){
+  //Get the current types
+  QStringList types = ui->line_el_filetype->text().split(",", QString::SkipEmptyParts);
+  //get the new type
+  QString ntype  = act->text();
+  //Now properly add the type as appropriate
+  bool ok = FALSE;
+  for(int i=0; i<types.length(); i++){
+    //Check for special cases
+    if( (types[i] == "keep") && (ntype=="replace") ){
+      types[i] = ntype;
+      ok = TRUE;
+      break;
+    }else if( (types[i] == "replace") && (ntype=="keep") ){
+      types[i] = ntype;
+      ok = TRUE;
+      break;
+    }else if( types[i] == ntype ){
+      ok=TRUE;
+      break;
+    }
+  }
+  if(!ok){ types << ntype; } //append the type to the list
+  //Add the new types to the UI
+  ui->line_el_filetype->setText( types.join(",") );
+}

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-11-01 01:06:31 UTC (rev 20100)
+++ users/ken/EasyPBI2/mainGUI.h	2012-11-01 14:00:52 UTC (rev 20101)
@@ -71,6 +71,11 @@
     void on_push_scripts_create_clicked();
     void on_push_scripts_remove_clicked();
     void on_push_scripts_save_clicked();
+    //External-Links functions
+    void on_push_el_add_clicked();
+    void on_push_el_remove_clicked();
+    void slotELSetFile(QAction*);
+    void slotELSetType(QAction*);
 
 
 private:
@@ -78,7 +83,7 @@
     ModBuild *currentModule;
     QLineEdit *line_module;
     QRadioButton *radio_module_port, *radio_module_local;
-    QMenu menu_addOpt, menu_binList, menu_elOpts, menu_validMenuCats, menu_validMenuCatsNew, menu_mime, menu_mimenew, menu_bins, menu_binsnew;
+    QMenu menu_addOpt, menu_elOpts, menu_validMenuCats, menu_validMenuCatsNew, menu_mime, menu_mimenew, menu_bins, menu_binsnew, menu_el_bins;
 
     QString PROG_DIR, PORTS_DIR, PBIOUT_DIR, MODOUT_DIR, CACHE_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
     QString SU_CMD, PBIBUILD_CMD, PBICREATE_CMD, PBI_BUILDING_NOW;

Modified: users/ken/EasyPBI2/mainGUI.ui
===================================================================
(Binary files differ)

Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp	2012-11-01 01:06:31 UTC (rev 20100)
+++ users/ken/EasyPBI2/modBuild.cpp	2012-11-01 14:00:52 UTC (rev 20101)
@@ -640,7 +640,6 @@
 bool ModBuild::loadExternalLinks(){
     //reset the structure
     linksStruct.clear();
-    linksStruct << "" << "" << "";    
     //Read the new file
     QFile file(modulePath+"/external-links");
     if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
@@ -651,8 +650,8 @@
     QString original, linkto, types;
     while(!in.atEnd()){
       QString line = in.readLine();
-      line.replace("\t"," ");
-      if(!line.startsWith("#")){
+      line.replace("\t"," ").simplified();
+      if(!line.startsWith("#") && !line.isEmpty()){
         original = line.section(" ",0,0,QString::SectionSkipEmpty);
         linkto =  line.section(" ",1,1,QString::SectionSkipEmpty);
         types =  line.section(" ",2,2,QString::SectionSkipEmpty);
@@ -680,6 +679,7 @@
   //add the desired binaries
   for(int i=0; i<linksStruct.length(); i++){
     QStringList link = linksStruct[i].split("::");
+    qDebug() << "save link:" << link;
     contents << link[0] +"     "+link[1]+"     "+link[2];
   }
   //Create the external-links file
@@ -711,6 +711,13 @@
   }	
 }
 
+QStringList ModBuild::externalLinks(){
+  //Return the currently available links
+  QStringList output = linksStruct;
+  output.replaceInStrings("::","\t");
+  return output;
+}
+
 bool ModBuild::addResource(bool isNewWrapper, QString resourcePath){
   if(resourcePath.isEmpty()){
     qDebug() << "Warning: no resource selected";

Modified: users/ken/EasyPBI2/modBuild.h
===================================================================
--- users/ken/EasyPBI2/modBuild.h	2012-11-01 01:06:31 UTC (rev 20100)
+++ users/ken/EasyPBI2/modBuild.h	2012-11-01 14:00:52 UTC (rev 20101)
@@ -55,6 +55,7 @@
   bool writeExternalLinks();
   void addExternalLink(QString, QString, QStringList);
   void removeExternalLink(QString, QString);
+  QStringList externalLinks();
     //resources functions
   bool addResource(bool, QString);
   bool removeResource(QString);



More information about the Commits mailing list