From 04214bc543c085af7175d447aa8c105c84cee736 Mon Sep 17 00:00:00 2001 From: bobpan Date: Thu, 24 Jun 2021 09:17:49 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=9E=8B=E5=8F=B7=20=E6=98=AF=E5=90=A6=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E8=AE=AD=E7=BB=83=E6=A0=87=E5=BF=97=E4=BD=8D=E5=88=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8A=A0=E4=B8=AD=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=202=E3=80=81=E6=98=AF=E5=90=A6=E5=8A=A0=E5=85=A5=E8=AE=AD?= =?UTF-8?q?=E7=BB=83=E5=8F=82=E6=95=B0=20=E5=9C=A8=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E5=B1=95=E7=A4=BA=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E9=A2=9C=E8=89=B2=20=E7=94=A8=E4=BA=8E=E6=A0=87?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tpMain/ModelTableView.cpp | 22 ++++++++++++++++------ src/tpMain/WheelModel.cpp | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tpMain/ModelTableView.cpp b/src/tpMain/ModelTableView.cpp index e2c0287..754ada3 100644 --- a/src/tpMain/ModelTableView.cpp +++ b/src/tpMain/ModelTableView.cpp @@ -90,13 +90,11 @@ QVariant ModelsModel::data(const QModelIndex &index, int role /*= Qt::DisplayRol // return QVariant(); // } // } - if (Qt::DecorationRole == role) { + if (Qt::DecorationRole == role) { //根据训练模板的是否成功标志位 设置列表中型号字符串前面的颜色块 绿色表示成功 红色表示失败 黄色表示没有训练 /*The data to be rendered as a decoration in the form of an icon. (QColor, QIcon or QPixmap)*/ QString str = m_lstHeader.at(nCol); if ("modelID" == str){ QString strModel = m_list.at(nRow); - //if (!m_pData->contains(strModel)) - // return QVariant(); if (m_pData->contains(strModel)) { int nTypeModel = m_pData->value(strModel)->getImageModel(); @@ -111,7 +109,7 @@ QVariant ModelsModel::data(const QModelIndex &index, int role /*= Qt::DisplayRol } } } - if (Qt::TextColorRole == role){ + if (Qt::TextColorRole == role){//根据训练模板的图片数量 判断数量是否低于指定的数值,如果低于设定的数值,修改字体颜色 提醒用户 QString str = m_lstHeader.at(nCol); if ("modelID" == str){ QString strModel = m_list.at(nRow); @@ -123,8 +121,20 @@ QVariant ModelsModel::data(const QModelIndex &index, int role /*= Qt::DisplayRol else return QColor(0, 0, 0); } - //if (!m_pData->contains(strModel)) - // return QVariant(); + } + } + if (Qt::BackgroundColorRole == role) {//根据是否加入训练标志位 设置列表对应元素的背景颜色为淡黄色 方便识别被修改的型号 + QString str = m_lstHeader.at(nCol); + if ("modelID" == str) { + QString strModel = m_list.at(nRow); + if (m_pData->contains(strModel)) + { + bool bAddTrain = m_pData->value(strModel)->getAddTrainFlag(); + if (bAddTrain == false) + return QColor(250, 250, 0,50); + else + return QVariant(); + } } } return QVariant(); diff --git a/src/tpMain/WheelModel.cpp b/src/tpMain/WheelModel.cpp index 6fbd915..23a3df3 100644 --- a/src/tpMain/WheelModel.cpp +++ b/src/tpMain/WheelModel.cpp @@ -87,6 +87,7 @@ void WheelModel::readJson(QJsonObject *pJson) if (!obj.empty()) { m_passageway = obj.value("channel").toInt(); bDetect = obj.value("detect").toBool(); + m_bAddTrain = obj.value("addTrain").toBool(true); } } @@ -98,6 +99,7 @@ void WheelModel::saveJson(class QJsonObject *pJson) QJsonObject obj; obj.insert("channel", m_passageway); obj.insert("detect", bDetect); + obj.insert("addTrain", m_bAddTrain); pJson->insert(m_strModelID, obj); }