|
|
|
|
|
#include "qworkmgrui.h"
|
|
|
|
|
|
#include "DetectState.h"
|
|
|
|
|
|
#include "IWheelCtrl.h"
|
|
|
|
|
|
#include "qpushbutton.h"
|
|
|
|
|
|
#include "qlabel.h"
|
|
|
|
|
|
#include "qlistview.h"
|
|
|
|
|
|
#include "ModelTableView.h"
|
|
|
|
|
|
#include "qlineedit.h"
|
|
|
|
|
|
#include "ModelManager.h"
|
|
|
|
|
|
#include "InfoFile.h"
|
|
|
|
|
|
#include "QCheckBox"
|
|
|
|
|
|
#include "QListWidget"
|
|
|
|
|
|
#include "IWheelModel.h"
|
|
|
|
|
|
#include "qpulpewidget.h"
|
|
|
|
|
|
#include "WheelCtrl.h"
|
|
|
|
|
|
#include "WheelNet.h"
|
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
|
#include "qworkItemdlg.h"
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
QWorkMgrUI::QWorkMgrUI(QWorkMgrCtlr *pWork, IWheelCtrl *pCtrl)
|
|
|
|
|
|
: m_pCtrl(pCtrl), m_pWorkCtrl(pWork), ptrModel(NULL), tableModel(NULL)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
m_pWidgetMain = NULL;
|
|
|
|
|
|
connect(this, SIGNAL(sgShowMsg(QString)), this, SLOT(onShowMsg(QString)));
|
|
|
|
|
|
bEdit = false;
|
|
|
|
|
|
setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
|
setWindowTitle(tr("检测模板管理"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWorkMgrUI::~QWorkMgrUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pWidgetMain) {
|
|
|
|
|
|
m_pWidgetMain->close();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ptrModel){
|
|
|
|
|
|
while (ptrModel->rowCount())
|
|
|
|
|
|
{
|
|
|
|
|
|
QList<QStandardItem*> lptr = ptrModel->takeRow(0);
|
|
|
|
|
|
for (int n = 0; n < lptr.size(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete lptr.at(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ptrModel->clear();
|
|
|
|
|
|
delete ptrModel;
|
|
|
|
|
|
ptrModel = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (tableModel){
|
|
|
|
|
|
while (tableModel->rowCount())
|
|
|
|
|
|
{
|
|
|
|
|
|
QList<QStandardItem*> lptr = tableModel->takeRow(0);
|
|
|
|
|
|
for (int n = 0; n < lptr.size(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete lptr.at(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
tableModel->clear();
|
|
|
|
|
|
delete tableModel;
|
|
|
|
|
|
tableModel = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::InitUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
//connect(ui.work_SaveAll_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
m_UseDiameter = ui.work_mode_UseDiameter;
|
|
|
|
|
|
m_UseDiameter->setChecked(DetectState::instance()->bUseDiameter == 1);
|
|
|
|
|
|
|
|
|
|
|
|
m_UseThickness = ui.work_mode_UseThickness;
|
|
|
|
|
|
m_UseThickness->setChecked(DetectState::instance()->bUseThickness == 1);
|
|
|
|
|
|
|
|
|
|
|
|
m_pEditFilter = ui.work_mode_edit_models_filter;
|
|
|
|
|
|
connect(m_pEditFilter, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui.work_showSelect_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
connect(ui.work_ShowNoSelect_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
connect(ui.work_ShowALL_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
CM_Edit_pb = ui.work_Edit_pb;
|
|
|
|
|
|
m_pbEditState = false;
|
|
|
|
|
|
connect(ui.work_Edit_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
CM_SelectALL_pb = ui.work_SelectALL_pb;
|
|
|
|
|
|
connect(ui.work_SelectALL_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
CM_SelectALLR_pb = ui.work_SelectALLR_pb;
|
|
|
|
|
|
connect(ui.work_SelectALLR_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
// CM_onSelectALL_pb = ui.work_onSelectALL_pb;
|
|
|
|
|
|
// CM_onSelectALL_pb->setDisabled(true);
|
|
|
|
|
|
// connect(ui.work_onSelectALL_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
CM_models_listWidget = ui.work_models_listWidget;
|
|
|
|
|
|
CM_models_listWidget->setViewMode(QListView::IconMode);
|
|
|
|
|
|
CM_models_listWidget->setResizeMode(QListView::Adjust);
|
|
|
|
|
|
CM_models_listWidget->setSpacing(20);
|
|
|
|
|
|
CM_models_listWidget->setAcceptDrops(false);
|
|
|
|
|
|
CM_models_listWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
|
connect(CM_models_listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*)));
|
|
|
|
|
|
connect(ui.work_SendModelLib_pb, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
ptableview = ui.tableView_work;
|
|
|
|
|
|
connect(ptableview, SIGNAL(sgRowChange(int, int)), this, SLOT(onRowChange(int, int)));
|
|
|
|
|
|
connect(ptableview, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTableClick(const QModelIndex &)));
|
|
|
|
|
|
|
|
|
|
|
|
//设置各种属性
|
|
|
|
|
|
ptableview->setAcceptDrops(true);
|
|
|
|
|
|
ptableview->horizontalHeader()->hide(); //隐藏列头(带列头的情况需要修改代码,重新计算高度偏移)
|
|
|
|
|
|
ptableview->verticalHeader()->hide(); //隐藏行头
|
|
|
|
|
|
ptableview->verticalHeader()->setDefaultSectionSize(30); //默认列高度
|
|
|
|
|
|
ptableview->horizontalHeader()->setStretchLastSection(true); //最后一列自适应宽度
|
|
|
|
|
|
ptableview->setEditTriggers(QTableView::NoEditTriggers); //不能编辑
|
|
|
|
|
|
ptableview->setSelectionBehavior(QTableView::SelectRows); //一次选中整行
|
|
|
|
|
|
ptableview->setSelectionMode(QTableView::SingleSelection); //单行选中
|
|
|
|
|
|
ptableview->setAlternatingRowColors(true); //行间隔色
|
|
|
|
|
|
ptableview->setShowGrid(false); //去掉网格线
|
|
|
|
|
|
ptableview->setFocusPolicy(Qt::NoFocus); //去掉item选中时虚线框
|
|
|
|
|
|
ptableview->hideColumn(1);
|
|
|
|
|
|
ptrModel = new QStandardItemModel();
|
|
|
|
|
|
ptableview->SetModel(ptrModel);
|
|
|
|
|
|
|
|
|
|
|
|
ptableview->setStyleSheet("QTableView {\
|
|
|
|
|
|
border: 1px solid rgb(111, 156, 207);\
|
|
|
|
|
|
background: rgb(224, 238, 255);\
|
|
|
|
|
|
gridline - color: rgb(111, 156, 207);\
|
|
|
|
|
|
}\
|
|
|
|
|
|
QTableView::item{\
|
|
|
|
|
|
padding - left: 5px;\
|
|
|
|
|
|
padding - right: 5px;\
|
|
|
|
|
|
border: none;\
|
|
|
|
|
|
background: white;\
|
|
|
|
|
|
border - right: 1px solid rgb(111, 156, 207);\
|
|
|
|
|
|
border - bottom: 1px solid rgb(111, 156, 207);\
|
|
|
|
|
|
}\
|
|
|
|
|
|
QTableView::item:selected{\
|
|
|
|
|
|
background: rgba(111, 111, 46, 100);\
|
|
|
|
|
|
}\
|
|
|
|
|
|
QTableView::item : selected : !active{\
|
|
|
|
|
|
color: rgb(65, 65, 65);\
|
|
|
|
|
|
}\
|
|
|
|
|
|
QTableView::indicator{\
|
|
|
|
|
|
width: 20px;\
|
|
|
|
|
|
height: 20px;\
|
|
|
|
|
|
}\
|
|
|
|
|
|
");
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui.workmgr_Add, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
connect(ui.workmgr_Del, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
connect(ui.workmgr_Mod, SIGNAL(clicked()), this, SLOT(onClickButton()));
|
|
|
|
|
|
|
|
|
|
|
|
tableModel = new QStandardItemModel;
|
|
|
|
|
|
ui.tableView_work_2->setModel(tableModel);
|
|
|
|
|
|
ui.tableView_work_2->horizontalHeader()->hide(); //隐藏列头(带列头的情况需要修改代码,重新计算高度偏移)
|
|
|
|
|
|
ui.tableView_work_2->verticalHeader()->hide(); //隐藏行头
|
|
|
|
|
|
ui.tableView_work_2->verticalHeader()->setDefaultSectionSize(30); //默认列高度
|
|
|
|
|
|
ui.tableView_work_2->horizontalHeader()->setStretchLastSection(true); //最后一列自适应宽度
|
|
|
|
|
|
ui.tableView_work_2->setEditTriggers(QTableView::NoEditTriggers); //不能编辑
|
|
|
|
|
|
ui.tableView_work_2->setAlternatingRowColors(true); //行间隔色
|
|
|
|
|
|
|
|
|
|
|
|
tableModel->setColumnCount(1);
|
|
|
|
|
|
work_Name_lineEdit = ui.work_Name_lineEdit;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::UpdateTableView(QString str){
|
|
|
|
|
|
|
|
|
|
|
|
while (tableModel->rowCount()){
|
|
|
|
|
|
tableModel->removeRow(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
// QStringList AllModels = m_pCtrl->getAllModelName();
|
|
|
|
|
|
QStringList AllTrainModels = m_pCtrl->getAllTrainModelName();
|
|
|
|
|
|
SimuItem *pWorkItem = m_pWorkCtrl->getItem(str);
|
|
|
|
|
|
if (pWorkItem){
|
|
|
|
|
|
//Add check not in list model's name
|
|
|
|
|
|
QStringList pList = pWorkItem->strDefectList;
|
|
|
|
|
|
int nCounter = 0;
|
|
|
|
|
|
for (int nIndex = 0; nIndex < pList.size(); nIndex++){
|
|
|
|
|
|
QString str = pList.at(nIndex);
|
|
|
|
|
|
if (!AllTrainModels.contains(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
pWorkItem->strDefectList.removeAll(str);//add
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
QStandardItem *itemID = new QStandardItem(str);
|
|
|
|
|
|
tableModel->setItem(nCounter++, 0, itemID);
|
|
|
|
|
|
}
|
|
|
|
|
|
QString str = tr("共 %1 个").arg(nCounter);
|
|
|
|
|
|
ui.work_Num_label->setText(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onSaveItemState(QString m_str)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pCtrl){
|
|
|
|
|
|
m_pCtrl->getModelMgr()->saveModel(m_str);
|
|
|
|
|
|
emit m_pCtrl->sgModelChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onTextChanged(QString text)
|
|
|
|
|
|
{
|
|
|
|
|
|
QStringList models = m_pCtrl->getAllModelMapPtr()->keys();
|
|
|
|
|
|
if (text.isEmpty() || text == "*") {
|
|
|
|
|
|
UpdateTab2(models);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
UpdateTab2(models.filter(text));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QWorkMgrUI::onExec()
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateTableView(m_pWorkCtrl->getDetectStr());
|
|
|
|
|
|
if (work_Name_lineEdit)
|
|
|
|
|
|
{
|
|
|
|
|
|
work_Name_lineEdit->setText(m_pWorkCtrl->getDetectStr());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onUserRole();
|
|
|
|
|
|
setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
|
show();
|
|
|
|
|
|
|
|
|
|
|
|
ui.work_showSelect_pb->setDisabled(true);
|
|
|
|
|
|
ui.work_ShowNoSelect_pb->setDisabled(false);
|
|
|
|
|
|
ui.work_ShowALL_pb->setDisabled(false);
|
|
|
|
|
|
nTySelectModel = TY_OnlySel;
|
|
|
|
|
|
UpdateTabView(m_pWorkCtrl->getDetectStr(), nTySelectModel);
|
|
|
|
|
|
|
|
|
|
|
|
QString strShow = tr("当前使用的工单为 %1 ").arg(m_pWorkCtrl->getDetectStr());
|
|
|
|
|
|
setData2Show(strShow);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QWorkMgrUI::onClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pWidgetMain) {
|
|
|
|
|
|
m_pWidgetMain->close();
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QWorkMgrUI::onStateChanged(QObject* watched, int state)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ("work_mode_UseDiameter" == watched->objectName()) {
|
|
|
|
|
|
DetectState::instance()->bUseDiameter = state == 2;
|
|
|
|
|
|
DetectState::instance()->save();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ("work_mode_UseThickness" == watched->objectName()) {
|
|
|
|
|
|
DetectState::instance()->bUseThickness = state == 2;
|
|
|
|
|
|
DetectState::instance()->save();
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QWorkMgrUI::onUserRole()
|
|
|
|
|
|
{
|
|
|
|
|
|
int nLevel = m_pCtrl->getUserLevel();
|
|
|
|
|
|
if (9 == nLevel) {
|
|
|
|
|
|
m_UseDiameter->setVisible(true);
|
|
|
|
|
|
m_UseThickness->setVisible(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (5 == nLevel) {
|
|
|
|
|
|
m_UseDiameter->setVisible(true);
|
|
|
|
|
|
m_UseThickness->setVisible(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (4 == nLevel) {
|
|
|
|
|
|
m_UseDiameter->setVisible(false);
|
|
|
|
|
|
m_UseThickness->setVisible(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (1 == nLevel){
|
|
|
|
|
|
m_UseDiameter->setVisible(false);
|
|
|
|
|
|
m_UseThickness->setVisible(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onClickButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
|
if (strObj == "work_SelectALL_pb"){//添加检测模型
|
|
|
|
|
|
QList<QListWidgetItem*> listpItem = CM_models_listWidget->selectedItems();
|
|
|
|
|
|
if (listpItem.size() <= 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
QStringList falseAddStr;
|
|
|
|
|
|
QString strName = work_Name_lineEdit->text();
|
|
|
|
|
|
for (int nIndex = 0; nIndex < listpItem.size(); nIndex++){
|
|
|
|
|
|
QListWidgetItem *pItem = listpItem.at(nIndex);
|
|
|
|
|
|
if (pItem){
|
|
|
|
|
|
|
|
|
|
|
|
SimuItem *pWorkItem = m_pWorkCtrl->getItem(strName);
|
|
|
|
|
|
if (pWorkItem){
|
|
|
|
|
|
QString textName = pItem->text();
|
|
|
|
|
|
if (pWorkItem->strDefectList.contains(textName)){
|
|
|
|
|
|
falseAddStr.append(pItem->text());
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
pWorkItem->strDefectList.append(pItem->text());
|
|
|
|
|
|
UpdateTableView(strName);
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (nTySelectModel == TY_OnlyNoSel||nTySelectModel == TY_OnlySel)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateTabView(strName, nTySelectModel);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (falseAddStr.size()>0){
|
|
|
|
|
|
QString str;
|
|
|
|
|
|
for (int i = 0; i < falseAddStr.size(); i++){
|
|
|
|
|
|
str.append(falseAddStr.at(i));
|
|
|
|
|
|
str.append("\n");
|
|
|
|
|
|
if (i >= 10){
|
|
|
|
|
|
str.append(".......\n");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
QString finalStr = tr("以下型号为重复添加:\n%1已被忽略.").arg(str);
|
|
|
|
|
|
QMessageBox infodlg(QMessageBox::Information, tr("提醒"), finalStr, QMessageBox::Ok);
|
|
|
|
|
|
infodlg.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
|
infodlg.setButtonText(QMessageBox::Ok, tr("确定"));
|
|
|
|
|
|
infodlg.exec();
|
|
|
|
|
|
}
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strObj == "work_SelectALLR_pb"){//删除检测模型
|
|
|
|
|
|
QItemSelectionModel *selections = ui.tableView_work_2->selectionModel();
|
|
|
|
|
|
if (selections){
|
|
|
|
|
|
QModelIndexList selected = selections->selectedIndexes();
|
|
|
|
|
|
QMap<int, int> rowMap;
|
|
|
|
|
|
QStringList strList;
|
|
|
|
|
|
foreach(QModelIndex index, selected)
|
|
|
|
|
|
{
|
|
|
|
|
|
rowMap.insert(index.row(), 0);
|
|
|
|
|
|
QString str = index.data().toString();
|
|
|
|
|
|
strList.append(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
int rowToDel = 0;
|
|
|
|
|
|
QMapIterator<int, int> rowMapIterator(rowMap);
|
|
|
|
|
|
rowMapIterator.toBack();
|
|
|
|
|
|
while (rowMapIterator.hasPrevious())
|
|
|
|
|
|
{
|
|
|
|
|
|
rowMapIterator.previous();
|
|
|
|
|
|
rowToDel = rowMapIterator.key();
|
|
|
|
|
|
tableModel->removeRow(rowToDel);
|
|
|
|
|
|
}
|
|
|
|
|
|
QString strName = work_Name_lineEdit->text();
|
|
|
|
|
|
SimuItem *pWorkItem = m_pWorkCtrl->getItem(strName);
|
|
|
|
|
|
if (pWorkItem){
|
|
|
|
|
|
for (int nIndex = 0; nIndex < strList.size(); nIndex++){
|
|
|
|
|
|
QString str = strList.at(nIndex);
|
|
|
|
|
|
pWorkItem->strDefectList.removeAll(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
|
|
|
|
|
|
if (nTySelectModel == TY_OnlyNoSel || nTySelectModel == TY_OnlySel)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateTabView(strName, nTySelectModel);
|
|
|
|
|
|
}
|
|
|
|
|
|
UpdateTableView(strName);
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strObj == "work_showSelect_pb"){
|
|
|
|
|
|
QString strName = work_Name_lineEdit->text();
|
|
|
|
|
|
UpdateTabView(strName,TY_OnlySel);
|
|
|
|
|
|
nTySelectModel = TY_OnlySel;
|
|
|
|
|
|
ui.work_showSelect_pb->setDisabled(true);
|
|
|
|
|
|
ui.work_ShowNoSelect_pb->setDisabled(false);
|
|
|
|
|
|
ui.work_ShowALL_pb->setDisabled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strObj == "work_ShowNoSelect_pb"){
|
|
|
|
|
|
QString strName = work_Name_lineEdit->text();
|
|
|
|
|
|
UpdateTabView(strName, TY_OnlyNoSel);
|
|
|
|
|
|
nTySelectModel = TY_OnlyNoSel;
|
|
|
|
|
|
|
|
|
|
|
|
ui.work_showSelect_pb->setDisabled(false);
|
|
|
|
|
|
ui.work_ShowNoSelect_pb->setDisabled(true);
|
|
|
|
|
|
ui.work_ShowALL_pb->setDisabled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strObj == "work_ShowALL_pb"){
|
|
|
|
|
|
UpdateTabView("", TY_All);
|
|
|
|
|
|
nTySelectModel = TY_All;
|
|
|
|
|
|
ui.work_showSelect_pb->setDisabled(false);
|
|
|
|
|
|
ui.work_ShowNoSelect_pb->setDisabled(false);
|
|
|
|
|
|
ui.work_ShowALL_pb->setDisabled(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strObj == "work_Edit_pb"){
|
|
|
|
|
|
QModelIndex mIndex = ui.tableView_work->currentIndex();
|
|
|
|
|
|
QString str = ptrModel->data(mIndex.sibling(mIndex.row(), 1)).toString();
|
|
|
|
|
|
if (!str.isEmpty()){
|
|
|
|
|
|
m_pWorkCtrl->setDefectStr(str);
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
QString strShow = tr("工单 %1 被设为应用").arg(str);
|
|
|
|
|
|
setData2Show(strShow);
|
|
|
|
|
|
}
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
// else if (strObj == "work_SaveAll_pb"){
|
|
|
|
|
|
// if (m_pCtrl){
|
|
|
|
|
|
// m_pCtrl->getModelMgr()->saveAllModel();
|
|
|
|
|
|
// emit(sgShowMsg("保存完成"));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
else if (strObj == "work_SendModelLib_pb"){
|
|
|
|
|
|
WheelCtrl* m_pWheelCtrl = (WheelCtrl*)m_pCtrl;
|
|
|
|
|
|
m_pWheelCtrl->getNet()->sendClearLib();
|
|
|
|
|
|
emit(sgShowMsg(tr("发送模板库")));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ("workmgr_Mod" == strObj){//修改工作单
|
|
|
|
|
|
QModelIndex mIndex = ptableview->currentIndex();
|
|
|
|
|
|
QString str = ptrModel->data(mIndex.sibling(mIndex.row(), 1)).toString();
|
|
|
|
|
|
SimuItem *ptr = m_pWorkCtrl->getItem(str);
|
|
|
|
|
|
if (ptr){
|
|
|
|
|
|
QWorkItemDlg dlg;
|
|
|
|
|
|
dlg.setListPtr(m_pWorkCtrl->getItemKeysPtr());
|
|
|
|
|
|
QString oldKey = ptr->key;
|
|
|
|
|
|
dlg.setItemData(ptr);
|
|
|
|
|
|
if (dlg.exec() == QDialog::Accepted){
|
|
|
|
|
|
SimuItem nItem = dlg.getItemData();
|
|
|
|
|
|
m_pWorkCtrl->ModItem(oldKey, nItem);
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ("workmgr_Del" == strObj){//删除工作单
|
|
|
|
|
|
QModelIndex mIndex = ptableview->currentIndex();
|
|
|
|
|
|
QString str = ptrModel->data(mIndex.sibling(mIndex.row(), 1)).toString();
|
|
|
|
|
|
if (str == m_pWorkCtrl->getDetectStr())
|
|
|
|
|
|
{
|
|
|
|
|
|
QMessageBox infodlg(QMessageBox::Warning, tr("警告"), tr("%1任务单正在使用不能被删除,请先切换到其他任务单,再删除该任务单?").arg(str), QMessageBox::Ok | QMessageBox::No);
|
|
|
|
|
|
infodlg.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
|
infodlg.setButtonText(QMessageBox::Ok, tr("确定"));
|
|
|
|
|
|
infodlg.setButtonText(QMessageBox::Cancel, tr("取消"));
|
|
|
|
|
|
infodlg.exec();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
QMessageBox infodlg(QMessageBox::Warning, tr("警告"), tr("是否要删除 %1 模型?").arg(str), QMessageBox::Ok | QMessageBox::No);
|
|
|
|
|
|
infodlg.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
|
infodlg.setButtonText(QMessageBox::Ok, tr("确定"));
|
|
|
|
|
|
infodlg.setButtonText(QMessageBox::Cancel, tr("取消"));
|
|
|
|
|
|
if (infodlg.exec() == QMessageBox::Ok){
|
|
|
|
|
|
m_pWorkCtrl->delItem(str);
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ("workmgr_Add" == strObj){//新建工作单
|
|
|
|
|
|
QWorkItemDlg dlg;
|
|
|
|
|
|
dlg.setListPtr(m_pWorkCtrl->getItemKeysPtr());
|
|
|
|
|
|
if (QDialog::Accepted == dlg.exec())
|
|
|
|
|
|
{
|
|
|
|
|
|
SimuItem mItem = dlg.getItemData();
|
|
|
|
|
|
m_pWorkCtrl->AddItem(mItem.key, mItem);
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
bEdit = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onSelectItem(QString strModel)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onItemDoubleClicked(class QListWidgetItem *p)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::SetItemBGColor(QListWidgetItem *pItem, bool state)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (state)
|
|
|
|
|
|
{
|
|
|
|
|
|
pItem->setBackgroundColor(QColor(0, 250, 0, 100));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pItem->setBackgroundColor(QColor(200, 0, 0, 100));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::UpdateTab2(QStringList m_strList)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int nIndex = (CM_models_listWidget->count() - 1); nIndex >= 0; nIndex--) {
|
|
|
|
|
|
QListWidgetItem *pItem = CM_models_listWidget->takeItem(nIndex);
|
|
|
|
|
|
delete pItem;
|
|
|
|
|
|
}
|
|
|
|
|
|
QString str;
|
|
|
|
|
|
CM_models_listWidget->setViewMode(QListView::IconMode);
|
|
|
|
|
|
CM_models_listWidget->clear();
|
|
|
|
|
|
CM_models_listWidget->setProperty("model", str);
|
|
|
|
|
|
CM_models_listWidget->setIconSize(QSize(80, 80));
|
|
|
|
|
|
CM_models_listWidget->setAcceptDrops(false);
|
|
|
|
|
|
QStringList strList = m_strList;
|
|
|
|
|
|
if (strList.contains("NG"))
|
|
|
|
|
|
strList.removeAll("NG");
|
|
|
|
|
|
int nCountIndex = 0;
|
|
|
|
|
|
for (int j = 0; j < strList.size(); j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strName = strList.at(j);
|
|
|
|
|
|
IWheelModel *pModel = m_pCtrl->getModel(strName);
|
|
|
|
|
|
if(pModel==NULL)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
nCountIndex++;
|
|
|
|
|
|
QString strFilePath = pModel->getPicPath();
|
|
|
|
|
|
if (strFilePath.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
strFilePath = ":/image/none.jpg";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
strFilePath = m_pCtrl->appRoot() + pModel->getPicPath();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap pix = QPixmap(strFilePath);
|
|
|
|
|
|
if (pix.isNull())
|
|
|
|
|
|
pix = QPixmap(":/image/none.jpg");
|
|
|
|
|
|
QIcon icon(pix.scaled(QSize(100, 100)));
|
|
|
|
|
|
QListWidgetItem* pItem = new QListWidgetItem(icon, strName);
|
|
|
|
|
|
|
|
|
|
|
|
CM_models_listWidget->addItem(pItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
QString m_str = tr("共 %1 个").arg(nCountIndex);
|
|
|
|
|
|
ui.work_num_Listlabel->setText(m_str);
|
|
|
|
|
|
setData2Show(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onShowMsg(QString str)
|
|
|
|
|
|
{
|
|
|
|
|
|
QPulpewidget *pw = new QPulpewidget();
|
|
|
|
|
|
pw->setParent(m_pWidgetMain);
|
|
|
|
|
|
pw->showmessage(str);
|
|
|
|
|
|
connect(pw, SIGNAL(finished()), pw, SLOT(deleteLater()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onRowChange(int from, int to)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pWorkCtrl){
|
|
|
|
|
|
m_pWorkCtrl->RowChange(from, to);
|
|
|
|
|
|
UpTableModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
int a = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void QWorkMgrUI::onTableClick(const QModelIndex &index)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString str = ptrModel->data(index.sibling(index.row(), 1)).toString();
|
|
|
|
|
|
SimuItem *ptr = m_pWorkCtrl->getItem(str);
|
|
|
|
|
|
if (ptr){
|
|
|
|
|
|
UpdateTableView(ptr->key);
|
|
|
|
|
|
if (work_Name_lineEdit)
|
|
|
|
|
|
{
|
|
|
|
|
|
work_Name_lineEdit->setText(ptr->key);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (nTySelectModel == TY_OnlyNoSel || nTySelectModel == TY_OnlySel){
|
|
|
|
|
|
UpdateTabView(ptr->key, nTySelectModel);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::UpTableModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
while (ptrModel->rowCount())
|
|
|
|
|
|
{
|
|
|
|
|
|
QList<QStandardItem*> lptr = ptrModel->takeRow(0);
|
|
|
|
|
|
for (int n = 0; n < lptr.size(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete lptr.at(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ptrModel->clear();
|
|
|
|
|
|
QStringList strHeaderList;
|
|
|
|
|
|
strHeaderList << tr("序号") << tr("内容");
|
|
|
|
|
|
ptrModel->setHorizontalHeaderLabels(strHeaderList);
|
|
|
|
|
|
//ptrModel->setHorizontalHeaderItem(0, new QStandardItem(tr("序号")));
|
|
|
|
|
|
//ptrModel->setHorizontalHeaderItem(1, new QStandardItem(tr("内容")));
|
|
|
|
|
|
QStringList strs;
|
|
|
|
|
|
if (m_pWorkCtrl)
|
|
|
|
|
|
strs = m_pWorkCtrl->getItemKeys();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < strs.size(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strName = strs.at(i);
|
|
|
|
|
|
ptrModel->setItem(i, 0, new QStandardItem(QString::number(i + 1)));
|
|
|
|
|
|
ptrModel->setItem(i, 1, new QStandardItem(strName/*strs[i]*/));
|
|
|
|
|
|
if (strName == m_pWorkCtrl->getDetectStr())
|
|
|
|
|
|
{
|
|
|
|
|
|
ptrModel->item(i, 1)->setBackground(QColor(100, 255, 0, 90));
|
|
|
|
|
|
ptrModel->item(i, 1)->setCheckState(Qt::Checked);
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
ptrModel->item(i, 1)->setBackground(QColor(0, 0, 0, 90));
|
|
|
|
|
|
ptrModel->item(i, 1)->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ptableview->hideColumn(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::closeEvent(QCloseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (bEdit){
|
|
|
|
|
|
//QMessageBox infodlg(QMessageBox::Warning, "提醒", "你已做了相关修改,是否更新保存?", QMessageBox::Ok | QMessageBox::Cancel);
|
|
|
|
|
|
//infodlg.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
|
//infodlg.setButtonText(QMessageBox::Ok, "确定");
|
|
|
|
|
|
//infodlg.setButtonText(QMessageBox::Cancel, "取消");
|
|
|
|
|
|
//if (infodlg.exec() == QMessageBox::Ok)
|
|
|
|
|
|
{
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
emit sgUpdatedefect();
|
|
|
|
|
|
bEdit = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//else
|
|
|
|
|
|
// event->ignore();
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::setData2Show(QString str){
|
|
|
|
|
|
ui.state_lineEdit->setText(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::modWorkMgr(const QString &str)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pWorkCtrl->ModAllItem(str);;
|
|
|
|
|
|
m_pWorkCtrl->saveManageFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkMgrUI::UpdateTabView(QString strName, TypeSelect enTymodel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (enTymodel == TY_All){
|
|
|
|
|
|
// QStringList m_models = m_pCtrl->getModelMgr()->getAllModelName();
|
|
|
|
|
|
QStringList m_models = m_pCtrl->getModelMgr()->getAllTrainModelName();
|
|
|
|
|
|
|
|
|
|
|
|
UpdateTab2(m_models);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (enTymodel == TY_OnlySel||enTymodel==TY_OnlyNoSel){
|
|
|
|
|
|
SimuItem *pWorkItem = m_pWorkCtrl->getItem(strName);
|
|
|
|
|
|
if (pWorkItem){
|
|
|
|
|
|
if (enTymodel == TY_OnlySel)
|
|
|
|
|
|
UpdateTab2(pWorkItem->strDefectList);
|
|
|
|
|
|
else{
|
|
|
|
|
|
// QStringList strList = m_pCtrl->getModelMgr()->getAllModelName();
|
|
|
|
|
|
QStringList strList = m_pCtrl->getModelMgr()->getAllTrainModelName();
|
|
|
|
|
|
for (int n = 0; n < pWorkItem->strDefectList.size(); n++){
|
|
|
|
|
|
QString str = pWorkItem->strDefectList.at(n);
|
|
|
|
|
|
strList.removeAll(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
UpdateTab2(strList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|