Changeset c8de217


Ignore:
Timestamp:
12/13/13 18:47:20 (14 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, releng/10.1.1
Children:
cea69ea
Parents:
d200413
Message:

Get the new package selection dialog working in EasyPBI. It still needs testing with a fully stocked pkg repo, since the 1.2.x pkgs are not available yet.

Location:
src-qt4/EasyPBI-devel
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/EasyPBI-devel/EasyPBI.pro

    r69ec30c rc8de217  
    2222        aboutDialog.cpp \ 
    2323        PBIModule.cpp \ 
    24         ModuleUtils.cpp 
     24        ModuleUtils.cpp \ 
     25        pkgSelect.cpp 
    2526 
    2627HEADERS  += mainGUI.h \ 
     
    3233            aboutDialog.h \ 
    3334            PBIModule.h \ 
    34             ModuleUtils.h 
     35            ModuleUtils.h \ 
     36            pkgSelect.h 
    3537 
    3638FORMS    += mainGUI.ui \ 
    3739            newModuleDialog.ui \ 
    3840            preferencesDialog.ui \ 
    39             aboutDialog.ui  
     41            aboutDialog.ui \ 
     42            pkgSelect.ui 
    4043 
    4144RESOURCES+= EasyPBI.qrc 
  • src-qt4/EasyPBI-devel/EasyPBI.qrc

    r3038c71 rc8de217  
    11<RCC> 
    22  <qresource prefix="png"> 
     3    <file>icons/search.png</file> 
     4    <file>icons/accept.png</file> 
     5    <file>icons/cancel.png</file> 
    36    <file>icons/config.png</file> 
    47    <file>icons/pcbsd.png</file> 
  • src-qt4/EasyPBI-devel/Makefile

    r0d8df9e rc8de217  
    11############################################################################# 
    22# Makefile for building: EasyPBI 
    3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Dec 10 17:24:04 2013 
     3# Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Dec 13 21:15:29 2013 
    44# Project:  EasyPBI.pro 
    55# Template: app 
     
    5353                aboutDialog.cpp \ 
    5454                PBIModule.cpp \ 
    55                 ModuleUtils.cpp moc_mainGUI.cpp \ 
     55                ModuleUtils.cpp \ 
     56                pkgSelect.cpp moc_mainGUI.cpp \ 
    5657                moc_newModuleDialog.cpp \ 
    5758                moc_preferencesDialog.cpp \ 
    5859                moc_aboutDialog.cpp \ 
     60                moc_pkgSelect.cpp \ 
    5961                qrc_EasyPBI.cpp 
    6062OBJECTS       = main.o \ 
     
    6870                PBIModule.o \ 
    6971                ModuleUtils.o \ 
     72                pkgSelect.o \ 
    7073                moc_mainGUI.o \ 
    7174                moc_newModuleDialog.o \ 
    7275                moc_preferencesDialog.o \ 
    7376                moc_aboutDialog.o \ 
     77                moc_pkgSelect.o \ 
    7478                qrc_EasyPBI.o 
    7579DIST          = /usr/local/share/qt4/mkspecs/common/unix.conf \ 
     
    127131all: Makefile $(TARGET) 
    128132 
    129 $(TARGET): ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h $(OBJECTS)   
     133$(TARGET): ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h ui_pkgSelect.h $(OBJECTS)   
    130134        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) 
    131135 
     
    192196dist:  
    193197        @$(CHK_DIR_EXISTS) .tmp/EasyPBI1.0.0 || $(MKDIR) .tmp/EasyPBI1.0.0  
    194         $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents mainGUI.h modBuild.h backend.h newModuleDialog.h config.h preferencesDialog.h aboutDialog.h PBIModule.h ModuleUtils.h .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents EasyPBI.qrc .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents main.cpp mainGUI.cpp modBuild.cpp backend.cpp newModuleDialog.cpp config.cpp preferencesDialog.cpp aboutDialog.cpp PBIModule.cpp ModuleUtils.cpp .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents mainGUI.ui newModuleDialog.ui preferencesDialog.ui aboutDialog.ui .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents i18n/EasyPBI_af.ts i18n/EasyPBI_ar.ts i18n/EasyPBI_az.ts i18n/EasyPBI_bg.ts i18n/EasyPBI_bn.ts i18n/EasyPBI_bs.ts i18n/EasyPBI_ca.ts i18n/EasyPBI_cs.ts i18n/EasyPBI_cy.ts i18n/EasyPBI_da.ts i18n/EasyPBI_de.ts i18n/EasyPBI_el.ts i18n/EasyPBI_en_GB.ts i18n/EasyPBI_en_ZA.ts i18n/EasyPBI_es.ts i18n/EasyPBI_et.ts i18n/EasyPBI_eu.ts i18n/EasyPBI_fa.ts i18n/EasyPBI_fi.ts i18n/EasyPBI_fr.ts i18n/EasyPBI_fr_CA.ts i18n/EasyPBI_gl.ts i18n/EasyPBI_he.ts i18n/EasyPBI_hi.ts i18n/EasyPBI_hr.ts i18n/EasyPBI_hu.ts i18n/EasyPBI_id.ts i18n/EasyPBI_is.ts i18n/EasyPBI_it.ts i18n/EasyPBI_ja.ts i18n/EasyPBI_ka.ts i18n/EasyPBI_ko.ts i18n/EasyPBI_lt.ts i18n/EasyPBI_lv.ts i18n/EasyPBI_mk.ts i18n/EasyPBI_mn.ts i18n/EasyPBI_ms.ts i18n/EasyPBI_mt.ts i18n/EasyPBI_nb.ts i18n/EasyPBI_nl.ts i18n/EasyPBI_pa.ts i18n/EasyPBI_pl.ts i18n/EasyPBI_pt.ts i18n/EasyPBI_pt_BR.ts i18n/EasyPBI_ro.ts i18n/EasyPBI_ru.ts i18n/EasyPBI_sa.ts i18n/EasyPBI_sk.ts i18n/EasyPBI_sl.ts i18n/EasyPBI_sr.ts i18n/EasyPBI_sv.ts i18n/EasyPBI_sw.ts i18n/EasyPBI_ta.ts i18n/EasyPBI_tg.ts i18n/EasyPBI_th.ts i18n/EasyPBI_tr.ts i18n/EasyPBI_uk.ts i18n/EasyPBI_uz.ts i18n/EasyPBI_vi.ts i18n/EasyPBI_zh_CN.ts i18n/EasyPBI_zh_HK.ts i18n/EasyPBI_zh_TW.ts i18n/EasyPBI_zu.ts .tmp/EasyPBI1.0.0/ && (cd `dirname .tmp/EasyPBI1.0.0` && $(TAR) EasyPBI1.0.0.tar EasyPBI1.0.0 && $(COMPRESS) EasyPBI1.0.0.tar) && $(MOVE) `dirname .tmp/EasyPBI1.0.0`/EasyPBI1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/EasyPBI1.0.0 
     198        $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents mainGUI.h modBuild.h backend.h newModuleDialog.h config.h preferencesDialog.h aboutDialog.h PBIModule.h ModuleUtils.h pkgSelect.h .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents EasyPBI.qrc .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents main.cpp mainGUI.cpp modBuild.cpp backend.cpp newModuleDialog.cpp config.cpp preferencesDialog.cpp aboutDialog.cpp PBIModule.cpp ModuleUtils.cpp pkgSelect.cpp .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents mainGUI.ui newModuleDialog.ui preferencesDialog.ui aboutDialog.ui pkgSelect.ui .tmp/EasyPBI1.0.0/ && $(COPY_FILE) --parents i18n/EasyPBI_af.ts i18n/EasyPBI_ar.ts i18n/EasyPBI_az.ts i18n/EasyPBI_bg.ts i18n/EasyPBI_bn.ts i18n/EasyPBI_bs.ts i18n/EasyPBI_ca.ts i18n/EasyPBI_cs.ts i18n/EasyPBI_cy.ts i18n/EasyPBI_da.ts i18n/EasyPBI_de.ts i18n/EasyPBI_el.ts i18n/EasyPBI_en_GB.ts i18n/EasyPBI_en_ZA.ts i18n/EasyPBI_es.ts i18n/EasyPBI_et.ts i18n/EasyPBI_eu.ts i18n/EasyPBI_fa.ts i18n/EasyPBI_fi.ts i18n/EasyPBI_fr.ts i18n/EasyPBI_fr_CA.ts i18n/EasyPBI_gl.ts i18n/EasyPBI_he.ts i18n/EasyPBI_hi.ts i18n/EasyPBI_hr.ts i18n/EasyPBI_hu.ts i18n/EasyPBI_id.ts i18n/EasyPBI_is.ts i18n/EasyPBI_it.ts i18n/EasyPBI_ja.ts i18n/EasyPBI_ka.ts i18n/EasyPBI_ko.ts i18n/EasyPBI_lt.ts i18n/EasyPBI_lv.ts i18n/EasyPBI_mk.ts i18n/EasyPBI_mn.ts i18n/EasyPBI_ms.ts i18n/EasyPBI_mt.ts i18n/EasyPBI_nb.ts i18n/EasyPBI_nl.ts i18n/EasyPBI_pa.ts i18n/EasyPBI_pl.ts i18n/EasyPBI_pt.ts i18n/EasyPBI_pt_BR.ts i18n/EasyPBI_ro.ts i18n/EasyPBI_ru.ts i18n/EasyPBI_sa.ts i18n/EasyPBI_sk.ts i18n/EasyPBI_sl.ts i18n/EasyPBI_sr.ts i18n/EasyPBI_sv.ts i18n/EasyPBI_sw.ts i18n/EasyPBI_ta.ts i18n/EasyPBI_tg.ts i18n/EasyPBI_th.ts i18n/EasyPBI_tr.ts i18n/EasyPBI_uk.ts i18n/EasyPBI_uz.ts i18n/EasyPBI_vi.ts i18n/EasyPBI_zh_CN.ts i18n/EasyPBI_zh_HK.ts i18n/EasyPBI_zh_TW.ts i18n/EasyPBI_zu.ts .tmp/EasyPBI1.0.0/ && (cd `dirname .tmp/EasyPBI1.0.0` && $(TAR) EasyPBI1.0.0.tar EasyPBI1.0.0 && $(COMPRESS) EasyPBI1.0.0.tar) && $(MOVE) `dirname .tmp/EasyPBI1.0.0`/EasyPBI1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/EasyPBI1.0.0 
    195199 
    196200 
     
    213217mocables: compiler_moc_header_make_all compiler_moc_source_make_all 
    214218 
    215 compiler_moc_header_make_all: moc_mainGUI.cpp moc_newModuleDialog.cpp moc_preferencesDialog.cpp moc_aboutDialog.cpp 
     219compiler_moc_header_make_all: moc_mainGUI.cpp moc_newModuleDialog.cpp moc_preferencesDialog.cpp moc_aboutDialog.cpp moc_pkgSelect.cpp 
    216220compiler_moc_header_clean: 
    217         -$(DEL_FILE) moc_mainGUI.cpp moc_newModuleDialog.cpp moc_preferencesDialog.cpp moc_aboutDialog.cpp 
     221        -$(DEL_FILE) moc_mainGUI.cpp moc_newModuleDialog.cpp moc_preferencesDialog.cpp moc_aboutDialog.cpp moc_pkgSelect.cpp 
    218222moc_mainGUI.cpp: modBuild.h \ 
    219223                backend.h \ 
     
    239243        /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) aboutDialog.h -o moc_aboutDialog.cpp 
    240244 
     245moc_pkgSelect.cpp: backend.h \ 
     246                pkgSelect.h 
     247        /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) pkgSelect.h -o moc_pkgSelect.cpp 
     248 
    241249compiler_rcc_make_all: qrc_EasyPBI.cpp 
    242250compiler_rcc_clean: 
    243251        -$(DEL_FILE) qrc_EasyPBI.cpp 
    244252qrc_EasyPBI.cpp: EasyPBI.qrc \ 
     253                icons/search.png \ 
    245254                icons/freebsd.png \ 
    246255                icons/EasyPBI_Logo.jpg \ 
     
    250259                icons/EasyPBIicon.png \ 
    251260                icons/config.png \ 
     261                icons/accept.png \ 
     262                icons/cancel.png \ 
    252263                icons/plus.png \ 
    253264                HISTORY.txt \ 
     
    260271compiler_moc_source_make_all: 
    261272compiler_moc_source_clean: 
    262 compiler_uic_make_all: ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h 
     273compiler_uic_make_all: ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h ui_pkgSelect.h 
    263274compiler_uic_clean: 
    264         -$(DEL_FILE) ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h 
     275        -$(DEL_FILE) ui_mainGUI.h ui_newModuleDialog.h ui_preferencesDialog.h ui_aboutDialog.h ui_pkgSelect.h 
    265276ui_mainGUI.h: mainGUI.ui 
    266277        /usr/local/bin/uic-qt4 mainGUI.ui -o ui_mainGUI.h 
     
    274285ui_aboutDialog.h: aboutDialog.ui 
    275286        /usr/local/bin/uic-qt4 aboutDialog.ui -o ui_aboutDialog.h 
     287 
     288ui_pkgSelect.h: pkgSelect.ui 
     289        /usr/local/bin/uic-qt4 pkgSelect.ui -o ui_pkgSelect.h 
    276290 
    277291compiler_yacc_decl_make_all: 
     
    339353        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ModuleUtils.o ModuleUtils.cpp 
    340354 
     355pkgSelect.o: pkgSelect.cpp pkgSelect.h \ 
     356                backend.h \ 
     357                ui_pkgSelect.h 
     358        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o pkgSelect.o pkgSelect.cpp 
     359 
    341360moc_mainGUI.o: moc_mainGUI.cpp  
    342361        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainGUI.o moc_mainGUI.cpp 
     
    350369moc_aboutDialog.o: moc_aboutDialog.cpp  
    351370        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_aboutDialog.o moc_aboutDialog.cpp 
     371 
     372moc_pkgSelect.o: moc_pkgSelect.cpp  
     373        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_pkgSelect.o moc_pkgSelect.cpp 
    352374 
    353375qrc_EasyPBI.o: qrc_EasyPBI.cpp  
  • src-qt4/EasyPBI-devel/backend.cpp

    rd200413 rc8de217  
    5555  QString cmd = "pkg search -o \"/\""; 
    5656  QStringList result = getCmdOutput(cmd); 
     57  result.removeAll(""); //get rid of empty items 
    5758  return result; 
    5859} 
     
    6364  QString cmd = "pkg rquery \"%n\\n%v\\n%w\\n%L\" -e %o "+port; 
    6465  QStringList out = Backend::getCmdOutput(cmd); 
     66  out.removeAll(""); //get rid of empty items 
    6567  return out; 
    6668} 
     
    7173  QString cmd = "pkg rquery \"%Ok=%Ov\" -e %o "+port; 
    7274  QStringList out = Backend::getCmdOutput(cmd); 
     75  out.removeAll(""); //get rid of empty items 
    7376  return out; 
    7477} 
  • src-qt4/EasyPBI-devel/mainGUI.cpp

    rb17f581 rc8de217  
    510510*/ 
    511511void MainGUI::on_push_change_makeport_clicked(){ 
    512   if( !settings->check("isportsavailable") ){ 
    513     //No ports tree available 
    514     QMessageBox::warning(this,tr("EasyPBI: No FreeBSD Ports"), tr("The FreeBSD Ports tree could not be found on your system. You may fetch the ports tree through the EasyPBI menu or manually set the path to the port tree in the EasyPBI preferences if it is installed in a non-standard location.")); 
    515     return; 
    516   } 
    517   //Prompt for a new port 
    518   QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), settings->value("portsdir")); 
    519   if(portSel.isEmpty()){return;} //action cancelled or closed    
     512  pkgSelect dlg(this); 
     513  dlg.exec(); 
     514  if(!dlg.selected){ return; } 
     515  QString portSel = dlg.portSelected;      
     516  if(portSel.isEmpty()){return;}         
    520517 
    521518  //Save the port info to the GUI 
    522   ui->line_makeport->setText(portSel.remove(settings->value("portsdir")+"/")); 
     519  ui->line_makeport->setText(portSel); 
    523520  ui->push_config_save->setEnabled(TRUE); 
    524521} 
  • src-qt4/EasyPBI-devel/mainGUI.h

    r85e9308 rc8de217  
    2222#include "PBIModule.h" 
    2323#include "ModuleUtils.h" 
     24#include "pkgSelect.h" 
    2425 
    2526namespace Ui { 
  • src-qt4/EasyPBI-devel/mainGUI.ui

    r85e9308 rc8de217  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>547</width> 
     9    <width>575</width> 
    1010    <height>467</height> 
    1111   </rect> 
     
    271271             <x>0</x> 
    272272             <y>0</y> 
    273              <width>500</width> 
    274              <height>648</height> 
     273             <width>528</width> 
     274             <height>659</height> 
    275275            </rect> 
    276276           </property> 
     
    16501650     <x>0</x> 
    16511651     <y>0</y> 
    1652      <width>547</width> 
    1653      <height>20</height> 
     1652     <width>575</width> 
     1653     <height>21</height> 
    16541654    </rect> 
    16551655   </property> 
  • src-qt4/EasyPBI-devel/pkgSelect.cpp

    rd200413 rc8de217  
    44pkgSelect::pkgSelect(QWidget *parent) : QDialog(parent), ui(new Ui::pkgSelect) { 
    55  ui->setupUi(this); //load the pkgSelect.ui file 
     6  selected = false; 
     7  portSelected.clear(); 
    68  timer = new QTimer(); 
    79        timer->setSingleShot(true); 
    810        timer->setInterval(500); //0.5 seconds 
    911         
    10   //setup the icons for the buttons 
    11   ui->tool_search->setIcon(Backend::icon("search")); 
    12    
    1312  //connect the signals/slots 
    1413  connect(timer, SIGNAL(timeout()), this, SLOT(slotSearch()) ); 
     
    1615  connect(ui->line_search, SIGNAL(returnPressed()), this, SLOT(slotSearch()) ); 
    1716  connect(ui->line_search, SIGNAL(textChanged(QString)), timer, SLOT(start()) ); 
     17  connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckPkg()) ); 
     18  connect(ui->push_ok, SIGNAL(clicked()), this, SLOT(slotAccept()) ); 
     19  connect(ui->push_cancel, SIGNAL(clicked()), this, SLOT(slotCancel()) ); 
    1820         
    1921  //Now fill the GUI 
     
    2830  QStringList PL = Backend::getPkgList(); //in <cat>/<pkg> format 
    2931  ui->treeWidget->clear(); 
    30   QTreeWidgetItem cCat; 
     32  QTreeWidgetItem* cCat = new QTreeWidgetItem(QStringList() << "gobbledegook"); 
    3133  for(int i=0; i<PL.length(); i++){ 
    3234    QString cat = PL[i].section("/",0,0,QString::SectionSkipEmpty); 
    3335    QString pkg = PL[i].section("/",-1); 
    34     if(cat != cCat.text(0)){ 
     36    if(cat != cCat->text(0)){ 
    3537      //Create a new parent item for this category 
    3638      cCat = new QTreeWidgetItem(QStringList() << cat); 
     
    3941    //Add the item to the current category 
    4042    QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << pkg); 
    41       item->setWhatsThis(PL[i]); 
     43      item->setWhatsThis(0,PL[i]); 
    4244    cCat->addChild(item); 
     45  } 
     46  if(PL.length() < 1){ 
     47    QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << tr("No Packages Available")); 
     48    ui->treeWidget->addTopLevelItem(item); 
     49    ui->line_search->setEnabled(false); 
     50    ui->tool_search->setEnabled(false); 
     51  } 
     52  ui->push_ok->setEnabled(false); 
     53} 
     54 
     55void pkgSelect::slotCheckPkg(){ 
     56  ui->push_ok->setEnabled(!ui->treeWidget->currentItem()->whatsThis(0).isEmpty()); 
     57} 
     58 
     59void pkgSelect::slotSearch(){ 
     60  if(ui->line_search->text().isEmpty()){ return; } 
     61  //Get the currently selected item 
     62  QTreeWidgetItem *CI = ui->treeWidget->currentItem(); 
     63  if( (CI==0) && (ui->treeWidget->topLevelItemCount() > 0) ){ 
     64    CI = ui->treeWidget->topLevelItem(0); //get the first item available           
     65  } 
     66  bool found = performSearch(ui->line_search->text(), ui->treeWidget, CI); 
     67  if( !found ){ 
     68    //Start over at the top 
     69    CI = ui->treeWidget->topLevelItem(0); 
     70    found = performSearch(ui->line_search->text(), ui->treeWidget, CI); 
     71  } 
     72  if(!found){ 
     73    QMessageBox::information(this,tr("Search Finished"), tr("No package found with that term"));           
    4374  } 
    4475} 
    4576 
    46 void pkgSelect::slotSearch(){ 
    47  
    48 } 
    49  
    5077void pkgSelect::slotAccept(){ 
    51   portSelected = "something"; 
     78  portSelected = ui->treeWidget->currentItem()->whatsThis(0); 
    5279  selected = true; 
    5380  this->close(); 
     
    5986  this->close(); 
    6087} 
     88 
     89// ======================== 
     90bool pkgSelect::performSearch(QString pkgSearch, QTreeWidget *TW, QTreeWidgetItem *SI){ 
     91  //Start Iterating over the tree 
     92  bool found=false; 
     93  bool started = false; 
     94  //if(SI==0){ started = true; } 
     95  for(int p=0; (p<TW->topLevelItemCount()) && !found; p++){ 
     96    //Check the actual item itself 
     97    QTreeWidgetItem *CI = TW->topLevelItem(p); 
     98    if(started && CI->text(0).contains(pkgSearch, Qt::CaseInsensitive)){ 
     99      TW->setCurrentItem(CI); 
     100      TW->scrollToItem(CI); 
     101      found=true;          
     102    }else{     
     103      found = searchChildren(pkgSearch, TW, CI, started, SI); 
     104    } 
     105  } 
     106  return found; 
     107} 
     108 
     109bool pkgSelect::searchChildren(QString srch, QTreeWidget *TW, QTreeWidgetItem *CI, bool &started, QTreeWidgetItem *SI){ 
     110  //This is a recursive function for searching all the children of a particular item 
     111  // TW - TreeWidget pointer 
     112  // CI - Current TreeWidget Item (to search the children of) 
     113  // SI - Start Item (Try to start searching right after this item - optional) 
     114  // bool started - Start Item found and search has been started (optional input/output) 
     115         
     116  //qDebug() << "Search Children of:" << CI->text(0) << srch << started; 
     117  //Check for the start position 
     118  int start = -1; 
     119  if(SI == 0 || SI == CI){ 
     120    //No search item to start at 
     121    start = 0; 
     122    started = true; 
     123  }else if( !started){ 
     124    QTreeWidgetItem *PI = SI; 
     125      while( (start == -1) && (PI!=0) ){ 
     126        start = CI->indexOfChild(PI); 
     127        PI = PI->parent(); //look up one more layer to make sure it is not a child of one of these items 
     128      } 
     129  }else{ start = 0; } //start with the first child 
     130  //Now quit if the start item is not found here 
     131  if(start == -1){ started = false; return false; } 
     132   
     133  //Now start searching 
     134  bool found = false; 
     135  for(int i=start; (i<CI->childCount()) && !found ; i++){ 
     136    if(started){ 
     137      //Check this item  
     138      if(CI->child(i)->text(0).contains(srch, Qt::CaseInsensitive)){ 
     139        TW->setCurrentItem(CI->child(i)); 
     140        TW->scrollToItem(CI->child(i)); 
     141        found=true; 
     142        break; 
     143      } 
     144    }else if( SI == CI->child(i) ){ 
     145      started = true; //but don't look at this item, continue on to the next one (or children) 
     146    } 
     147    if(found){ break; } 
     148    else if(CI->child(i)->childCount() > 0){ 
     149      //recursively search this items children 
     150      found = searchChildren(srch, TW, CI->child(i), started, SI);  
     151    } 
     152  } 
     153  return found; 
     154} 
  • src-qt4/EasyPBI-devel/pkgSelect.h

    rd200413 rc8de217  
    55#include <QStringList> 
    66#include <QDialog> 
     7#include <QTimer> 
    78#include <QTreeWidget> 
    89#include <QTreeWidgetItem> 
     10#include <QMessageBox> 
    911 
    1012#include "backend.h" 
     
    1820         
    1921public: 
    20         pkgSelect(); 
     22        pkgSelect(QWidget *parent = 0); 
    2123        ~pkgSelect(); 
    2224        //outputs 
    23         QString portSelected 
     25        QString portSelected; 
    2426        bool selected; 
    2527 
     
    3032        void loadPackageList(); 
    3133 
     34        bool performSearch(QString, QTreeWidget*, QTreeWidgetItem*); 
     35        bool searchChildren(QString, QTreeWidget*, QTreeWidgetItem*, bool&, QTreeWidgetItem*); 
     36         
    3237private slots: 
     38        void slotCheckPkg(); 
    3339        void slotSearch(); 
    3440        void slotAccept(); 
  • src-qt4/EasyPBI-devel/pkgSelect.ui

    rd200413 rc8de217  
    3535     </item> 
    3636     <item> 
    37       <widget class="QLineEdit" name="line_search"/> 
     37      <widget class="QLineEdit" name="line_search"> 
     38       <property name="placeholderText"> 
     39        <string>Search</string> 
     40       </property> 
     41      </widget> 
    3842     </item> 
    3943     <item> 
     
    4145       <property name="text"> 
    4246        <string>...</string> 
     47       </property> 
     48       <property name="icon"> 
     49        <iconset resource="EasyPBI.qrc"> 
     50         <normaloff>:/png/icons/search.png</normaloff>:/png/icons/search.png</iconset> 
    4351       </property> 
    4452      </widget> 
     
    7886        <string>Cancel</string> 
    7987       </property> 
     88       <property name="icon"> 
     89        <iconset resource="EasyPBI.qrc"> 
     90         <normaloff>:/png/icons/cancel.png</normaloff>:/png/icons/cancel.png</iconset> 
     91       </property> 
    8092      </widget> 
    8193     </item> 
     
    8496       <property name="text"> 
    8597        <string>Accept</string> 
     98       </property> 
     99       <property name="icon"> 
     100        <iconset resource="EasyPBI.qrc"> 
     101         <normaloff>:/png/icons/accept.png</normaloff>:/png/icons/accept.png</iconset> 
    86102       </property> 
    87103      </widget> 
Note: See TracChangeset for help on using the changeset viewer.