Ignore:
Timestamp:
Jun 21, 2013 12:59:43 PM (10 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
4069c7b
Parents:
b215278
git-author:
Ken Moore <ken@…> (06/21/13 12:58:40)
git-committer:
Ken Moore <ken@…> (06/21/13 12:59:43)
Message:

A couple minor graphical adjustments to the AppCafe?, and setup case-insensitive sorting of installed applications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-softwaremanager/mainUI.cpp

    r0314e57 r9a7d00b8  
    188188    if(ui->tree_install_apps->topLevelItem(i)->checkState(0) == Qt::Checked){ 
    189189      output << ui->tree_install_apps->topLevelItem(i)->whatsThis(0); 
    190       //ui->tree_install_apps->topLevelItem(i)->setCheckState(0,Qt::Unchecked); 
    191190    } 
    192191  } 
     
    197196void MainUI::slotRefreshInstallTab(){ 
    198197  //Update the list of installed PBI's w/o clearing the list (loses selections) 
     198   //Get the list we need (in order) 
    199199  QStringList installList = PBI->installedList(); 
    200   //Update the currently shown list 
     200  installList.sort(); //sort in ascending order 
     201   //Get the list we have now 
     202  QStringList cList; 
    201203  for(int i=0; i<ui->tree_install_apps->topLevelItemCount(); i++){ 
    202     QString itemID = ui->tree_install_apps->topLevelItem(i)->whatsThis(0); 
    203     int index = installList.indexOf(itemID); 
    204     if( index != -1 ){ //item is still installed 
    205       //Update the widget item 
     204    cList << ui->tree_install_apps->topLevelItem(i)->whatsThis(0); 
     205  } 
     206   //Now make adjustments as necessary 
     207  for(int i=0; i<installList.length(); i++){ 
     208    //Detemine what action should be done with this item location 
     209    int todo = 0; //0=insert new item, 1=update current item, 2=remove current item 
     210    if(i < cList.length()){ 
     211      if(installList[i] == cList[i]){ todo=1; } 
     212      else if( installList.contains(cList[i]) && !cList.contains(installList[i]) ){ todo=0; } //new item to be inserted here 
     213      else if( !installList.contains(cList[i]) ){ todo=2; } //current item in this location should be removed 
     214    } 
     215    //Now perform the action on this location 
     216    if(todo==0){  
     217      //insert new item 
     218      QTreeWidgetItem *item = new QTreeWidgetItem; //create the item 
     219      item->setWhatsThis(0,installList[i]); 
     220      //Now format the display 
     221      formatInstalledItemDisplay(item); 
     222      //Now insert this item onto the list 
     223      ui->tree_install_apps->insertTopLevelItem(i,item); 
     224      cList.insert(i,installList[i]); //reflect this inclusion into the current list 
     225    }else if(todo==1){ 
     226      //Update current item 
    206227      formatInstalledItemDisplay( ui->tree_install_apps->topLevelItem(i) ); 
    207       //Now remove the item from the installed list - already done with it 
    208       installList.removeAt(index); 
    209228    }else{ 
    210       //Remove the item from the UI list - no longer installed 
     229      //Remove current item 
    211230      ui->tree_install_apps->takeTopLevelItem(i); 
    212       i--; //Make sure we don't miss an item by changing the count 
    213     } 
    214   } 
    215   //Now Create new widget items as necessary (anything left on the installed list) 
    216   for(int i=0; i<installList.length();i++){ 
    217     QTreeWidgetItem *item = new QTreeWidgetItem; //create the item 
    218       item->setWhatsThis(0,installList[i]); 
    219     //Now format the display 
    220     formatInstalledItemDisplay(item); 
    221     //Now add this item to the list 
    222     ui->tree_install_apps->addTopLevelItem(item); 
    223   } 
    224   //Now re-sort the items 
     231      cList.removeAt(i); //reflect the change to the current list 
     232      i--; //Re-check the item that should be in this location 
     233    } 
     234  } 
     235  //Now makesure that there are no extra items at the end 
     236  int il = installList.length(); 
     237  while(il < cList.length()){ 
     238   ui->tree_install_apps->takeTopLevelItem(il); 
     239   cList.removeAt(il); //reflect the change to the current list  
     240  } 
     241   
     242  //Make sure that there is an item selected 
    225243  if(ui->tree_install_apps->topLevelItemCount() > 0 ){ 
    226     ui->tree_install_apps->sortItems(0,Qt::AscendingOrder); 
    227     //Make sure that there is an item selected 
    228244    if( ui->tree_install_apps->selectedItems().isEmpty() ){ 
    229245      ui->tree_install_apps->setCurrentItem( ui->tree_install_apps->topLevelItem(0) ); 
Note: See TracChangeset for help on using the changeset viewer.