Changeset d9a5889 in observatorio for simulacion
- Timestamp:
- Sep 10, 2014, 10:32:34 AM (10 years ago)
- Branches:
- simulacion
- Children:
- 866cc41
- Parents:
- 02f75fa
- Location:
- simulacion
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
simulacion/SimEscenariosEconomicos-Qtgui/tempFilter.ui
r5a9b82a rd9a5889 110 110 <property name="text"> 111 111 <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>142 112 </property> 143 113 </item> -
simulacion/SimEscenariosEconomicos-Qtgui/tempFilterForm.C
r560bc4d rd9a5889 40 40 # include <simType.H> 41 41 42 struct 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 56 void 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 67 void 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 42 76 TempFilterForm::TempFilterForm(QWidget *parent) 43 : QWidget(parent, Qt::Tool) 44 { 77 : QWidget(parent, Qt::Tool) { 78 45 79 ui.setupUi(this); 46 80 81 moveToCenter(parent); 82 47 83 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);56 84 57 85 ui.btnAddProductToSelectedList->setEnabled(false); … … 306 334 if (not ui.productList->selectedItems().isEmpty()) 307 335 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(); 308 355 } 309 356 … … 321 368 else 322 369 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(); 323 389 } 324 390 -
simulacion/SimEscenariosEconomicos-Qtgui/tempFilterForm.H
r7bbc686 rd9a5889 49 49 QListWidgetItem * selectedItem; 50 50 51 Tree <long> productIdSet; 51 Tree<long> productIdSet; 52 53 Map<std::string, unsigned short> yearsMap; 52 54 53 55 WaitingPanel waitingPanel; 54 56 55 57 QProcess process; 58 59 void moveToCenter(QWidget *); 60 61 void updateComboYear(); 56 62 57 63 protected: -
simulacion/SimEscenariosEconomicos/queries.C
r6c0bcde rd9a5889 1283 1283 } 1284 1284 1285 void getProductionYears(const long productId, List<std::string> & years) { 1286 1287 AutoConnection conn; 1288 1289 DBQuery query(conn); 1290 1291 StrQuery strQuery; 1292 1293 strQuery.addSelect(DB::YEAR); 1294 1295 strQuery.addFrom(DB::PRODUCTION_QUANTITIES_TABLE_NAME); 1296 1297 strQuery.addWhere(op(DB::PRODUCT_ID, idToStr(productId))); 1298 1299 if (not query.exec(strQuery)) { 1300 1301 std::string msg = "Cannot execute query: " + std::string(strQuery); 1302 1303 throw std::logic_error(msg); 1304 } 1305 1306 while (query.next()) { 1307 std::string date = query.getValue(0); 1308 years.append(date.substr(0, 4)); 1309 } 1310 } 1311 -
simulacion/SimEscenariosEconomicos/queries.H
r6c0bcde rd9a5889 311 311 real getTotalAmount(const std::string & rif, const std::string & year); 312 312 313 /** Extrae los años para los cuales existe una producción. 314 * 315 * @param[in] productId Id del producto del cual se quiere consultar. 316 * @param[out] years Lista de años para los cuales hay producción declarada. 317 */ 318 void getProductionYears(const long productId, List<std::string> & years); 319 313 320 struct CompanyRifName { 314 321 std::string rif;
Note: See TracChangeset
for help on using the changeset viewer.