Changeset 85e9308


Ignore:
Timestamp:
12/13/13 11:13:28 (12 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
2e12b91
Parents:
75b7abf
Message:

Get all the EasyPBI simplifications and recommendations working again (except available binaries - those can't be read from the package system at the moment). All the module editing is now done, I jut need to finish reading/using info from the pkg system, and overhaul the build process.

Location:
src-qt4/EasyPBI-devel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/EasyPBI-devel/ModuleUtils.cpp

    rcbead0d1 r85e9308  
    11#include "ModuleUtils.h" 
    22 
     3// ===================== 
     4//    VALID/RECOMMENDATIONS 
     5// ===================== 
    36QStringList ModuleUtils::validXdgCategories(){ 
    47  QStringList out; 
     
    3841} 
    3942 
     43QStringList ModuleUtils::validExternalLinkTypes(){ 
     44  QStringList out; 
     45  out << "binary" << "linux" << "keep" << "replace" << "nocrash"; 
     46  return out; 
     47} 
     48 
     49QString ModuleUtils::addExternalLinkType(QString current, QString newtype){ 
     50  QStringList types = current.remove(" ").split(","); 
     51  bool ok = false; 
     52  for(int i=0; i<types.length(); i++){ 
     53    //Check for special cases 
     54    if( (types[i] == "keep") && (newtype=="replace") ){ 
     55      types[i] = newtype; 
     56      ok = true; 
     57      break; 
     58    }else if( (types[i] == "replace") && (newtype=="keep") ){ 
     59      types[i] = newtype; 
     60      ok = true; 
     61      break; 
     62    }else if( (types[i]=="binary") && (newtype=="linux") ){ 
     63      types[i] = newtype; 
     64      ok = true; 
     65      break; 
     66    }else if( (types[i]=="linux") && (newtype=="binary") ){ 
     67      types[i] = newtype; 
     68      ok = true; 
     69      break; 
     70    }else if( types[i] == newtype ){ 
     71      ok=true; 
     72      break; 
     73    } 
     74  } 
     75  if(!ok){ types << newtype; } //append the type to the list 
     76  return types.join(","); 
     77} 
     78 
     79QStringList ModuleUtils::validRepoCategories(){ 
     80  QStringList out; 
     81  out << "Accessibility" << "Archivers" << "Astronomy" << "Audio" << "Benchmarks" << "Biology" \ 
     82        << "CAD" << "Communications" << "Converters" << "Databases" << "Desktop Utilities" \ 
     83        << "Development" << "Editors" << "Emulators" << "File Transfer" << "Finance" \ 
     84        << "Games" << "Graphics" << "IRC" << "Japanese" << "Java" << "Languages" \ 
     85        << "Mail" << "Math" << "Miscellaneous" << "Multimedia" << "Network" << "Network - IM"  \ 
     86        << "Network - Management" << "Network - P2P" << "News" << "Non-Port" << "Polish"  \ 
     87        << "Print" << "Science" << "Security" << "Shells" << "System Utilities" << "Text Processing" \ 
     88        << "Ports - Management" << "Web" << "X11" << "X11 - Clocks" << "X11 - File Managers"  \ 
     89        << "X11 - Fonts" << "X11 - Toolkits" << "X11 - Window Managers"; 
     90  return out; 
     91} 
     92 
     93QString ModuleUtils::recommendedRepoCategory(QString portCategory){ 
     94  QStringList cat = ModuleUtils::validRepoCategories(); 
     95  QStringList pcat;  //WARNING: Make sure these correspond exactly to the "valid" categories above 
     96  pcat << "accessibility" << "archivers" << "astro" << "audio" << "benchmarks" << "biology" \ 
     97        << "cad" << "comms" << "converters" << "databases" << "deskutils" \ 
     98        << "devel" << "editors" << "emulators" << "ftp" << "finance" \ 
     99        << "games" << "graphics" << "irc" << "japanese" << "java" << "lang" \ 
     100        << "mail" << "math" << "misc" << "multimedia" << "net" << "net-im" \ 
     101        << "net-mgmt" << "net-p2p" << "news" << "nonport" << "polish" \ 
     102        << "print" << "science" << "security" << "shells" << "sysutils" << "textproc" \ 
     103        << "ports-mgmt" << "www" << "x11" << "x11-clocks" << "x11-fm" \ 
     104        << "x11-fonts" << "x11-toolkits" << "x11-wm"; 
     105  int index = pcat.indexOf(portCategory.toLower()); 
     106  if( index < 0 || index >= cat.length() ) { index = pcat.indexOf("nonport"); }  
     107  return cat[index]; 
     108} 
     109 
     110QStringList ModuleUtils::validRepoTypes(){ 
     111  QStringList out; 
     112  out << "Graphical" << "Text" << "Server"; 
     113  return out; 
     114} 
     115 
     116 
     117// ======================= 
     118//     XDG SIMPLIFICATIONS 
     119// ======================= 
    40120bool ModuleUtils::xdgExecUsesRoot(QString exec){ 
    41121  QString first = exec.section(" ",0,0,QString::SectionSkipEmpty); 
  • src-qt4/EasyPBI-devel/ModuleUtils.h

    r0d8df9e r85e9308  
    1212 
    1313public: 
     14        //Valid/Recommended values 
    1415        static QStringList validXdgCategories(); 
    1516        static QString recommendedXdgCategory(QString portCategory); 
     17        static QStringList validExternalLinkTypes(); 
     18        static QString addExternalLinkType(QString current, QString newtype); 
     19        static QStringList validRepoCategories(); 
     20        static QString recommendedRepoCategory(QString portCategory); 
     21        static QStringList validRepoTypes(); 
     22         
     23        //XDG Simplifications 
    1624        static bool xdgExecUsesRoot(QString exec); 
    1725        static QString pruneXdgLine(QString exec); 
    1826        static QString generateXdgExec(QString shortExec, bool useRoot); 
    1927        static QString generateXdgPath(QString shortline); 
     28 
     29        //General Module Utilities 
    2030        static void compressModule(QString modulePath); 
    2131        static PBIModule newModule(QString moduleDir, QString port, QString iconFile); 
  • src-qt4/EasyPBI-devel/backend.cpp

    r3038c71 r85e9308  
    6060QStringList Backend::getPkgInfo(QString pkgname){ 
    6161  //Function to query the package repository and pull down information about a particular package 
    62   //Output: <name>, <port>, <maintainer>, <website> 
    63   QString cmd = "pkg rquery \"%n\\n%o\\n%m\\n%w\" "+pkgname; 
     62  //Output: <name>, <version>, <website>, <license> 
     63  QString cmd = "pkg rquery \"%n\\n%v\\n%w\\n%L\" "+pkgname; 
    6464  QStringList out = Backend::getCmdOutput(cmd); 
    6565  return out; 
     
    6868QStringList Backend::getPkgOpts(QString pkgname){ 
    6969  //Function to query the package repository and pull down information about a particular package 
    70   //Output: <name>, <port>, <maintainer>, <website> 
     70  //Output: <option>=<on/off> 
    7171  QString cmd = "pkg rquery \"%Ok=%Ov\" "+pkgname; 
    7272  QStringList out = Backend::getCmdOutput(cmd); 
  • src-qt4/EasyPBI-devel/mainGUI.cpp

    rcbead0d1 r85e9308  
    1616       //Setup Initial state of GUI objects and connect signal/slots 
    1717       ui->setupUi(this);  //load the mainGUI.ui file 
     18        XDGUPDATING=false; 
    1819        // Create the config class 
    1920        settings = new Config(); 
     
    2223        ui->actionRefresh_Module->setIcon(Backend::icon("refresh")); 
    2324        //Setup the pushbutton menu lists 
    24         menu_elOpts.addAction("binary"); 
    25         menu_elOpts.addAction("linux"); 
    26         menu_elOpts.addAction("keep"); 
    27         menu_elOpts.addAction("replace"); 
    28         menu_elOpts.addAction("nocrash"); 
     25        QStringList tmp = ModuleUtils::validExternalLinkTypes(); 
     26        for(int i=0; i<tmp.length(); i++){ menu_elOpts.addAction(tmp[i]); } 
     27        tmp = ModuleUtils::validRepoTypes(); 
     28        for(int i=0; i<tmp.length(); i++){ menu_validRepoTypes.addAction(tmp[i]); } 
    2929        //Setup Toolbar 
    3030        ui->actionNew_Module->setIcon(Backend::icon("new")); 
     
    4141        ui->push_change_makeport->setIcon(Backend::icon("file")); 
    4242        ui->push_config_save->setIcon(Backend::icon("save")); 
     43        ui->tool_repoType->setIcon(Backend::icon("left")); 
     44          ui->tool_repoType->setMenu(&menu_validRepoTypes); 
     45          connect(&menu_validRepoTypes, SIGNAL(triggered(QAction*)), this, SLOT(slotSetRepoType(QAction*)) ); 
     46        ui->tool_repoCat->setIcon(Backend::icon("left")); 
     47          ui->tool_repoCat->setMenu(&menu_validRepoCats); 
     48          connect(&menu_validRepoCats, SIGNAL(triggered(QAction*)), this, SLOT(slotSetRepoCat(QAction*)) ); 
    4349        // -- resources tab -- 
    4450        ui->push_resources_savewrapper->setIcon(Backend::icon("save")); 
     
    5258        connect(ui->push_xdg_refresh, SIGNAL(clicked()), this, SLOT(slotXdgTypeChanged()) ); 
    5359        ui->push_xdg_exec->setIcon(Backend::icon("left")); 
    54         ui->push_xdg_exec->setMenu(&menu_bins); 
    55         connect(&menu_bins, SIGNAL(triggered(QAction*)), this, SLOT(slotAddBin(QAction*)) ); 
     60        //ui->push_xdg_exec->setMenu(&menu_bins); 
     61        //connect(&menu_bins, SIGNAL(triggered(QAction*)), this, SLOT(slotAddBin(QAction*)) ); 
    5662        ui->push_xdg_savechanges->setIcon(Backend::icon("save")); 
    5763        ui->push_xdg_menu->setIcon(Backend::icon("left")); 
     
    6773        // -- External links tab -- 
    6874        ui->push_el_file->setIcon(Backend::icon("left")); 
    69         ui->push_el_file->setMenu(&menu_el_bins); 
    70         connect(&menu_el_bins,SIGNAL(triggered(QAction*)),this,SLOT(slotELSetFile(QAction*)) ); 
     75        //ui->push_el_file->setMenu(&menu_el_bins); 
     76        //connect(&menu_el_bins,SIGNAL(triggered(QAction*)),this,SLOT(slotELSetFile(QAction*)) ); 
    7177        ui->push_el_filetype->setIcon(Backend::icon("left")); 
    7278        ui->push_el_filetype->setMenu(&menu_elOpts); 
     
    163169    updateConfigVisibility(); //on first run, always need to do this manually 
    164170} 
    165  
    166 /*bool MainGUI::isValidPort(QString pPath, bool allowOverride){ 
    167   bool ok = FALSE; 
    168   if( QFile::exists(pPath) && QFile::exists(pPath+"/Makefile") && QFile::exists(pPath+"/distinfo") ){ 
    169     ok = TRUE; 
    170   } 
    171   //Display a warning message 
    172   if(allowOverride){ 
    173     ok = (QMessageBox::Apply == QMessageBox::warning(this,tr("EasyPBI: Invalid Port"), tr("The directory selected does not appear to be a valid FreeBSD port.")+"\n\n"+tr("Do you wish to continue using it anyway?"), QMessageBox::Apply | QMessageBox::Cancel, QMessageBox::Cancel) );  
    174   }else{ 
    175     QMessageBox::warning(this,tr("EasyPBI: Invalid Port"), tr("The directory selected is not a valid FreeBSD port. Please select a port directory which contains the appropriate Makefile and distinfo.")); 
    176   } 
    177   return ok; 
    178 }*/ 
    179171 
    180172void MainGUI::updateConfigVisibility(){ 
     
    247239      ui->list_progicon->addItem( MODULE.text("PBI_PROGICON") ); 
    248240    } 
     241    //Update the available/recommended repo categories 
     242    menu_validRepoCats.clear(); 
     243    QStringList tmp = ModuleUtils::validRepoCategories(); 
     244    QString recCat = ModuleUtils::recommendedRepoCategory(MODULE.text("PBI_MAKEPORT").section("/",0,0,QString::SectionSkipEmpty) ); 
     245    for(int i=0; i<tmp.length(); i++){ 
     246      if(recCat == tmp[i]){ menu_validRepoCats.addAction(QIcon(Backend::icon("start")), tmp[i]); } 
     247      else{ menu_validRepoCats.addAction(tmp[i]); } 
     248    } 
    249249    //Now disable the save button 
    250250    ui->push_config_save->setEnabled(FALSE);  //disable the save button until something changes 
     
    269269  } 
    270270  //------SCRIPTS----- 
    271   if( doall || doeditor || (item == "scripts")){ 
    272     //Update the list of available scripts and determine if one needs to be read 
    273     bool loadScript = FALSE; 
    274     QStringList good = MODULE.existingScripts(); 
    275     int currentIndex = ui->list_scripts_file->currentIndex(); 
    276     for(int i=1; i< ui->list_scripts_file->count(); i++){ //Skip the first item (is nothing) 
    277       if( good.contains(ui->list_scripts_file->itemText(i) ) ){ 
    278         if(i == currentIndex){ loadScript = TRUE; } 
    279         ui->list_scripts_file->setItemIcon(i,Backend::icon("file")); 
    280       }else{ 
    281         ui->list_scripts_file->setItemIcon(i,Backend::icon("close")); 
    282       } 
    283     } 
    284     //Update the GUI appropriately 
    285     if(loadScript){ 
    286       //Read and display the script 
    287       QStringList contents = MODULE.readScript(ui->list_scripts_file->currentText()); 
    288       ui->text_scripts_edit->setPlainText(contents.join("\n")); 
    289       //Setup display items 
    290       ui->push_scripts_create->setVisible(FALSE); 
    291       ui->push_scripts_remove->setVisible(TRUE); 
    292       ui->push_scripts_save->setVisible(TRUE); 
    293       ui->text_scripts_edit->setVisible(TRUE); 
    294     }else{ 
    295       //Setup display items 
    296       ui->push_scripts_create->setVisible(TRUE); 
    297       ui->push_scripts_remove->setVisible(FALSE); 
    298       ui->push_scripts_save->setVisible(FALSE); 
    299       ui->text_scripts_edit->setVisible(FALSE); 
    300     } 
    301     if(currentIndex == 0){ ui->push_scripts_create->setVisible(FALSE); } 
    302     ui->push_scripts_save->setEnabled(FALSE); //disable the save button until something changes 
    303      
     271  if( doall || doeditor || (item == "scripts")  ){ 
     272    //Update the list of available scripts 
     273    QStringList exist = MODULE.existingScripts(); 
     274    QStringList valid = MODULE.validScripts(); 
     275    QString current="junk"; 
     276    if(ui->list_scripts_file->count() > 0){ 
     277        current = ui->list_scripts_file->currentText(); //get the current item before clearing it 
     278    } 
     279    ui->list_scripts_file->clear(); 
     280    ui->list_scripts_file->addItem("-- Installation Scripts --"); 
     281    int index = 0; 
     282    for(int i=0; i<valid.length(); i++){ 
     283      if(exist.contains(valid[i])){  
     284         exist.removeAll(valid[i]);  
     285         ui->list_scripts_file->addItem(Backend::icon("file"), valid[i]); 
     286      }else{ ui->list_scripts_file->addItem(Backend::icon("close"), valid[i]); } 
     287      if(valid[i] == current){ index = i+1; } 
     288    } 
     289    //Now add the rest of the existing scripts (that are no longer valid) 
     290    for(int i=0; i<exist.length(); i++){ 
     291      ui->list_scripts_file->addItem(Backend::icon("delete"), exist[i]); 
     292      if(exist[i] == current){ index = valid.length()+i+1; } 
     293    } 
     294    //Now reset to the appropriate item (will automatically load appropriately) 
     295    ui->list_scripts_file->setCurrentIndex(index); 
    304296  } 
    305297  //------EXTERNAL-LINKS------ 
     
    321313    ui->line_el_filetype->clear(); 
    322314    //update the available binaries 
    323     menu_el_bins.clear(); 
     315    /*menu_el_bins.clear(); 
    324316    QStringList cBins; //Not setup yet in the package framework 
    325317    if(!cBins.isEmpty()){ 
     
    327319        menu_el_bins.addAction(cBins[i]); 
    328320      }  
    329     } 
     321    }*/ 
    330322  } 
    331323  //------FREENAS PLUGINS------- 
     
    511503  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), settings->value("portsdir")); 
    512504  if(portSel.isEmpty()){return;} //action cancelled or closed    
    513   //Check if the port is valid 
    514   /*if( !isValidPort(portSel) ){ 
    515     return; 
    516   }*/ 
     505 
    517506  //Save the port info to the GUI 
    518507  ui->line_makeport->setText(portSel.remove(settings->value("portsdir")+"/")); 
     
    528517  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), settings->value("portsdir")); 
    529518  if(portSel.isEmpty()){return;} //action cancelled or closed    
    530   //Check if the port is valid 
    531   /*if( !isValidPort(portSel,TRUE) ){ 
    532     return; 
    533   }*/ 
    534519  //Save the port info to the GUI 
    535520  if(ui->list_portafter->count() == 1 && ui->list_portafter->currentText().isEmpty() ){ ui->list_portafter->clear(); } 
     
    587572  tmp.clear(); //just to remove compiler warning about unused variable 
    588573  ui->push_config_save->setEnabled(TRUE);        
     574} 
     575 
     576void MainGUI::slotSetRepoType(QAction* act){ 
     577  ui->line_repoType->setText(act->text()); 
     578} 
     579 
     580void MainGUI::slotSetRepoCat(QAction* act){ 
     581  ui->line_repoCat->setText(act->text()); 
    589582} 
    590583 
     
    737730  //Update the buttons that only need a refresh when the type changes (such as menu's) 
    738731  //Available binaries pushbuttons 
    739   menu_bins.clear(); 
     732  /*menu_bins.clear(); 
    740733  QStringList cBins; //not re-implemented yet 
    741734  if(!cBins.isEmpty()){ 
     
    743736      menu_bins.addAction(cBins[i]); 
    744737    }  
    745   } 
     738  }*/ 
    746739  //Menu categories 
    747740  QString recMenu = ModuleUtils::recommendedXdgCategory(MODULE.text("PBI_MAKEPORT").section("/",0,0) ); 
     
    10601053*/ 
    10611054void MainGUI::slotScriptChanged(int index){ 
    1062   index=0; //just to remove the warning about unused variables 
    1063   refreshGUI("scripts"); 
     1055  //Update the GUI appropriately 
     1056    QStringList exist = MODULE.existingScripts(); 
     1057    if( exist.contains(ui->list_scripts_file->currentText()) ){ 
     1058      //Read and display the script 
     1059      QStringList contents = MODULE.readScript(ui->list_scripts_file->currentText()); 
     1060      ui->text_scripts_edit->setPlainText(contents.join("\n")); 
     1061      //Setup display items 
     1062      ui->push_scripts_create->setVisible(FALSE); 
     1063      ui->push_scripts_remove->setVisible(TRUE); 
     1064      ui->push_scripts_save->setVisible(TRUE); 
     1065      ui->text_scripts_edit->setVisible(TRUE); 
     1066    }else{ 
     1067      //Setup display items 
     1068      ui->push_scripts_create->setVisible(TRUE); 
     1069      ui->push_scripts_remove->setVisible(FALSE); 
     1070      ui->push_scripts_save->setVisible(FALSE); 
     1071      ui->text_scripts_edit->setVisible(FALSE); 
     1072    } 
     1073    if(index == 0){ ui->push_scripts_create->setVisible(FALSE); } 
     1074    ui->push_scripts_save->setEnabled(FALSE); //disable the save button until something changes 
    10641075} 
    10651076 
     
    12141225  QString cmd; 
    12151226  // -- PBI from ports 
    1216   //if(radio_module_port->isChecked()){ 
    12171227    //Check that the ports tree is available 
    12181228    if( !settings->check("isportsavailable") ){  
     
    12391249    } 
    12401250    if( settings->check("usesignature") && QFile::exists(settings->value("sigfile")) ){ cmd += " --sign " + settings->value("sigfile"); } 
    1241      
    1242   // -- PBI from local directory 
    1243   /*}else if(radio_module_local->isChecked() ){ 
    1244         //get the base command 
    1245         cmd = settings->value("pbi_create"); 
    1246         //Setup the ports options if non-standard port location 
    1247         if(settings->value("portsdir") != "/usr/ports"){ cmd += " -d " + settings->value("portsdir"); } 
    1248         //Setup the output directory 
    1249         cmd += " -o "+outdir; 
    1250         //Load the module 
    1251         cmd += " -c "+modDir; 
    1252         //Sign the PBI  
    1253         if( settings->check("usesignature") && QFile::exists(settings->value("sigfile")) ){ cmd += " --sign " + settings->value("sigfile"); } 
    1254         //Now setup the directory to package 
    1255         cmd += " "+ currentModule->readValue("packagedir"); 
    1256   }*/ 
     1251 
    12571252  //Display the command created in hte terminal 
    12581253  qDebug() << "Build PBI command created:"<<cmd; 
  • src-qt4/EasyPBI-devel/mainGUI.h

    rcbead0d1 r85e9308  
    5555    //pbi.conf functions 
    5656    void on_push_change_makeport_clicked(); 
    57     //void on_push_change_progdir_clicked(); 
    58     //void slotAddMakeOption(QAction*); 
    59     //void on_push_addportbefore_clicked(); 
    60     //void on_push_rmportbefore_clicked(); 
    6157    void on_push_addportafter_clicked(); 
    6258    void on_push_rmportafter_clicked(); 
    6359    void on_push_config_save_clicked(); 
    6460    void slotOptionChanged(QString tmp=""); 
     61    void slotSetRepoType(QAction* act); 
     62    void slotSetRepoCat(QAction* act); 
    6563    //resources functions 
    6664    void slotResourceChanged(); 
     
    108106    QLineEdit *line_module; 
    109107    //QRadioButton *radio_module_port, *radio_module_local; 
    110     QMenu menu_elOpts, menu_validMenuCats, menu_bins, menu_el_bins; 
     108    QMenu menu_elOpts, menu_validMenuCats, menu_validRepoCats, menu_validRepoTypes; 
    111109    bool XDGUPDATING; 
    112110 
  • src-qt4/EasyPBI-devel/mainGUI.ui

    rcbead0d1 r85e9308  
    591591                       <string>...</string> 
    592592                      </property> 
     593                      <property name="popupMode"> 
     594                       <enum>QToolButton::InstantPopup</enum> 
     595                      </property> 
    593596                     </widget> 
    594597                    </item> 
     
    614617                      <property name="text"> 
    615618                       <string>...</string> 
     619                      </property> 
     620                      <property name="popupMode"> 
     621                       <enum>QToolButton::InstantPopup</enum> 
    616622                      </property> 
    617623                     </widget> 
Note: See TracChangeset for help on using the changeset viewer.