Changeset d9a5889 in observatorio for simulacion/SimEscenariosEconomicos-Qtgui


Ignore:
Timestamp:
Sep 10, 2014, 10:32:34 AM (10 years ago)
Author:
Alejandro <amujica@…>
Branches:
simulacion
Children:
866cc41
Parents:
02f75fa
Message:

Agregada la funcionalidad de carga de year dinamicamente al seleccionar productos en la Interfaz

Location:
simulacion/SimEscenariosEconomicos-Qtgui
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • simulacion/SimEscenariosEconomicos-Qtgui/tempFilter.ui

    r5a9b82a rd9a5889  
    110110    <property name="text">
    111111     <string>Seleccione Año</string>
    112     </property>
    113    </item>
    114    <item>
    115     <property name="text">
    116      <string>2010</string>
    117     </property>
    118    </item>
    119    <item>
    120     <property name="text">
    121      <string>2011</string>
    122     </property>
    123    </item>
    124    <item>
    125     <property name="text">
    126      <string>2012</string>
    127     </property>
    128    </item>
    129    <item>
    130     <property name="text">
    131      <string>2013</string>
    132     </property>
    133    </item>
    134    <item>
    135     <property name="text">
    136      <string>2014</string>
    137     </property>
    138    </item>
    139    <item>
    140     <property name="text">
    141      <string>2015</string>
    142112    </property>
    143113   </item>
  • simulacion/SimEscenariosEconomicos-Qtgui/tempFilterForm.C

    r560bc4d rd9a5889  
    4040# include <simType.H>
    4141
     42struct FillComboYear
     43{
     44    QComboBox * ptrComboYear;
     45
     46    FillComboYear(QComboBox * _ptrComboYear)
     47        : ptrComboYear(_ptrComboYear) {
     48        // Empty
     49    }
     50
     51    void operator () (const std::string & year, const unsigned short &) {
     52        ptrComboYear->addItem(year.c_str());
     53    }
     54};
     55
     56void TempFilterForm::moveToCenter(QWidget * parent) {
     57
     58    QPoint halfForm(int(width() / 2), int(height() / 2));
     59
     60    QPoint halfParent(int(parent->width() / 2), int(parent->height() / 2));
     61
     62    QPoint position = parent->pos() + halfParent - halfForm;
     63
     64    move(position);
     65}
     66
     67void TempFilterForm::updateComboYear() {
     68
     69    ui.comboYear->clear();
     70
     71    ui.comboYear->addItem("Seleccione Año");
     72
     73    yearsMap.for_each<FillComboYear>(FillComboYear(ui.comboYear));
     74}
     75
    4276TempFilterForm::TempFilterForm(QWidget *parent)
    43     : QWidget(parent, Qt::Tool)
    44 {
     77    : QWidget(parent, Qt::Tool) {
     78
    4579    ui.setupUi(this);
    4680
     81    moveToCenter(parent);
     82
    4783    selectedItem = NULL;
    48 
    49     QPoint halfForm(int(width() / 2), int(height() / 2));
    50 
    51     QPoint halfParent(int(parent->width() / 2), int(parent->height() / 2));
    52 
    53     QPoint position = parent->pos() + halfParent - halfForm;
    54 
    55     move(position);
    5684
    5785    ui.btnAddProductToSelectedList->setEnabled(false);
     
    306334    if (not ui.productList->selectedItems().isEmpty())
    307335        ui.productList->selectedItems().at(0)->setSelected(false);
     336
     337    List<std::string> years;
     338
     339    getProductionYears(id, years);
     340
     341    for (List<std::string>::Iterator it(years); it.has_current(); it.next()) {
     342
     343        const std::string & year = it.get_current();
     344
     345        unsigned short * ptrQuantity = yearsMap.search(year);
     346
     347        if (ptrQuantity == NULL) {
     348            ptrQuantity = yearsMap.insert(year, 0);
     349        }
     350
     351        ++(*ptrQuantity);
     352    }
     353
     354    updateComboYear();
    308355}
    309356
     
    321368    else
    322369        selectedItem = ui.selectedProductList->selectedItems().at(0);
     370
     371    List<std::string> years;
     372
     373    getProductionYears(id, years);
     374
     375    for (List<std::string>::Iterator it(years); it.has_current(); it.next()) {
     376
     377        const std::string & year = it.get_current();
     378
     379        unsigned short * ptrQuantity = yearsMap.search(year);
     380
     381        --(*ptrQuantity);
     382
     383        if (*ptrQuantity == 0) {
     384            yearsMap.remove(year);
     385        }
     386    }
     387
     388    updateComboYear();
    323389}
    324390
  • simulacion/SimEscenariosEconomicos-Qtgui/tempFilterForm.H

    r7bbc686 rd9a5889  
    4949    QListWidgetItem * selectedItem;
    5050
    51     Tree <long> productIdSet;
     51    Tree<long> productIdSet;
     52
     53    Map<std::string, unsigned short> yearsMap;
    5254
    5355    WaitingPanel waitingPanel;
    5456
    5557    QProcess process;
     58
     59    void moveToCenter(QWidget *);
     60
     61    void updateComboYear();
    5662
    5763protected:
Note: See TracChangeset for help on using the changeset viewer.