/// Отфильтровать//=============================================================================void WgtLabPrn::slotFilter(){ filter = ""; filter_pos = ""; //Фильтр по видам if (!TypeFindBox) { return; } QString typeflter= TypeFindBox->currentText(); QString IDflter; if ((typeflter !="-Все-")&(typeflter !="")) { IDflter = GetCurrentByName("type","DATA_VALUE", typeflter); if (IDflter != "") { filter += " AND TYPE_ID = " + IDflter; filter_pos += " AND TYPE_ID = " + IDflter; } } //Фильтр по ГОСТам if (!GOSTFindBox) { return; } QString gostflter= GOSTFindBox->currentText(); if ((gostflter !="-Все-")&(gostflter!="")) { IDflter = GetCurrentByName("gost","DATA_VALUE", gostflter); if (IDflter != "") { filter += " AND GOST_ID = " + IDflter; filter_pos += " AND GOST_ID = " + IDflter; } } //Фильтр по димаметрам if (!DiamFindBox) { return; } QString diamflter= DiamFindBox->currentText(); if ((diamflter !="-Все-")&(diamflter!="")) { IDflter = GetCurrentByName("diameter","DATA_VALUE", diamflter); if (IDflter != "") { filter += " AND DIAMETER_ID = " + IDflter; filter_pos += " AND DIAMETER_ID = " + IDflter; } } //Фильтр по очисткам if (!AnnealFindBox) { return; } QString annflter= AnnealFindBox->currentText(); if ((annflter !="-Все-")&(annflter!="")) { IDflter = GetCurrentByName("annealing","NAME_SHORT", annflter ); if (IDflter != "") { filter += " AND ANNEALING_ID = " + IDflter; filter_pos += " AND ANNEALING_ID = " + IDflter; } } //Фильтр по осадкам if (!UpsetFindBox) { return; } QString upsetflter= UpsetFindBox->currentText(); if ((upsetflter !="-Все-")&(upsetflter!="")) { IDflter = GetCurrentByName("upset","NAME_SHORT", upsetflter ); if (IDflter != "") { filter += " AND UPSET_ID = " + IDflter; filter_pos += " AND UPSET_ID = " + IDflter; } } QString query ; QSqlQuery data_set; filter += page_str + QString::number(numBox->value()); page_str = " ORDER BY ID DESC LIMIT "; // MB_ERR(QString::number(numBox->value())); try { data_set = arm::Kernel::inst().getNomenclature(filter); } catch(arm::EDBCon& ex) { MB_ERR("Нет соединения с базой данных"); return; } col_pool.fill_model(data_set,model); col_pool.fill_table(table,model); //Смотрим начало и конец end_pos = model.data(model.index(0, col_pool.getColIndex("ID"))).toInt(); start_pos = model.data(model.index((numBox->value()-1), col_pool.getColIndex("ID"))).toInt(); int pos; if (end_pos < start_pos) { pos = end_pos; end_pos = start_pos; start_pos = pos; } try { data_set = arm::Kernel::inst().getPage_Pos("nomenclature",start_pos,end_pos, filter_pos); QMap<QString, int> indexes = arm::Kernel::inst().checkResult("BEFOR, AFT", data_set); if(data_set.next()) { before_pos = data_set.value(indexes["BEFOR"]).toInt(); after_pos = data_set.value(indexes["AFT"]).toInt(); } } catch(arm::EDBCon& ex) { MB_ERR("Нет соединения с базой данных"); return; } /**/ table->verticalHeader()->setDefaultSectionSize(arm::GUIMgr::inst().getStyleCfg(arm::GUIMgr::inst().getStyle()).row_height); // if (ID_b) table->setColumnWidth(col_pool.getColIndex("ID"), ID_i); //if (NNAME_ID_b) table->setColumnWidth(col_pool.getColIndex("NNAME_ID"), NNAME_ID_i); // if (NNAME_FULL_b) table->setColumnWidth(col_pool.getColIndex("NNAME_FULL"), NNAME_FULL_i); // if (MODIFY_DATE_b) table->setColumnWidth(col_pool.getColIndex("MODIFY_DATE"), MODIFY_DATE_i); // if (STATUS_b) table->setColumnWidth(col_pool.getColIndex("STATUS"), STATUS_i); // if (AUTOCOMPLETE_b) table->setColumnWidth(col_pool.getColIndex("AUTOCOMPLETE"), AUTOCOMPLETE_i); // if (TYPE_ID_b) table->setColumnWidth(col_pool.getColIndex("TYPE_ID"), TYPE_ID_i); // if (TYPE_COMPLETE_b) table->setColumnWidth(col_pool.getColIndex("TYPE_COMPLETE"), TYPE_COMPLETE_i); // if (GOST_ID_b) table->setColumnWidth(col_pool.getColIndex("GOST_ID"), GOST_ID_i); // if (GOST_COMPLETE_b) table->setColumnWidth(col_pool.getColIndex("GOST_COMPLETE"), GOST_COMPLETE_i); // if (DIAMETER_ID_b) table->setColumnWidth(col_pool.getColIndex("DIAMETER_ID"), DIAMETER_ID_i); // if (DIAMETER_COMPLETE_b) table->setColumnWidth(col_pool.getColIndex("DIAMETER_COMPLETE"), DIAMETER_COMPLETE_i); // if (ANNEALING_ID_b) table->setColumnWidth(col_pool.getColIndex("ANNEALING_ID"), ANNEALING_ID_i); // if (ANNEALING_COMPLETE_b) table->setColumnWidth(col_pool.getColIndex("ANNEALING_COMPLETE"), ANNEALING_COMPLETE_i); // if (UPSET_ID_b) table->setColumnWidth(col_pool.getColIndex("UPSET_ID"), UPSET_ID_i); // if (UPSET_COMPLETE_b) table->setColumnWidth(col_pool.getColIndex("UPSET_COMPLETE"), UPSET_COMPLETE_i); // if (PACK_ID_b) table->setColumnWidth(col_pool.getColIndex("PACK_ID"), PACK_ID_i);// if (FILE_ID_b) table->setColumnWidth(col_pool.getColIndex("FILE_ID"), FILE_ID_i); // //Определяем число страниц QString mum_pages = QString::number(1 + ceil(1.0*before_pos/numBox->value())+ ceil(1.0*after_pos/numBox->value())); QString cur_pages = QString::number(1 + ceil(1.0*before_pos/numBox->value())); ui.pageNum->setText(cur_pages + "/" + mum_pages); // одизабливаем Вперед назад if (after_pos > 0 ) { btn_next->setEnabled(true); btn_last->setEnabled(true); } else { btn_next->setEnabled(false); btn_last->setEnabled(false); } if (before_pos > 0 ) { btn_previous->setEnabled(true); btn_first->setEnabled(true); } else { btn_previous->setEnabled(false); btn_first->setEnabled(false); } if (model.rowCount() < 1) return;}
void WgtGetLabFiltr::subscribeTbl(QTableView* p_table){ if (!p_table) { qCritical("ERROR!!! NULL table ptr. \nFile: %s \nLine: %d",__FILE__,__LINE__) ; return; } table = p_table; table->setSortingEnabled(true); table->setAlternatingRowColors(true); table->setSelectionMode(QAbstractItemView::SingleSelection); table->setSelectionBehavior(QAbstractItemView::SelectRows); table->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); table->verticalHeader()->setVisible(false);// connect( table->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(slotHdrWidthChanged(int, int, int)) ); //установка цвета текущей ячейки в таблице потерявшей фокус QPalette palette = table->palette(); palette.setColor(QPalette::Inactive,QPalette::Highlight, arm::GUIMgr::inst().getInactiveColor()); palette.setColor(QPalette::Inactive,QPalette::HighlightedText,Qt::white); table->setPalette(palette);}