|
@@ -573,53 +573,45 @@ void MatterElementConfigWidget::onSaveBtnClick()
|
|
|
qDeleteAll(gradeIndexInfoList);
|
|
|
}
|
|
|
|
|
|
+/// 第一个区间或最后一个区间更新时, 同时更新节域
|
|
|
void MatterElementConfigWidget::onTableItemChanged(QStandardItem *item)
|
|
|
{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << item->column() << endl;
|
|
|
- if (item->column() >= m_domainLevel * 4 || item->column() % 4 != 3) {
|
|
|
+ /// 判断是否为第一个或最后一个区间
|
|
|
+ int index1 = 3;
|
|
|
+ int index2 = (m_domainLevel - 1) * 4 + 3;
|
|
|
+ if (item->column() != index1 && item->column() != index2) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- QTableView *table = (QTableView *)item->model()->parent();
|
|
|
- int current = ui->tabWidget->indexOf(table);
|
|
|
- if (current < 0 || current >= m_allConfigItems.size()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (m_allConfigItems.at(current).childs.size() <= item->row()) {
|
|
|
+ QStandardItem *item1 = item->model()->item(item->row(), index1);
|
|
|
+ QStandardItem *item2 = item->model()->item(item->row(), index2);
|
|
|
+ if (item1 == nullptr || item2 == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- MEDomain d = m_allConfigItems.at(current).childs[item->row()];
|
|
|
- QString left = QString("%1").arg(d.leftValues.first());
|
|
|
- QString left1 = QString("%1").arg(d.rightValues.first());
|
|
|
- ;
|
|
|
- if (item->column() / 4 == 0 && item->text().length() > 2) {
|
|
|
- QStringList valueList = item->text().mid(1, item->text().length() - 2).split(", ");
|
|
|
- left = valueList.first();
|
|
|
- left1 = valueList.last();
|
|
|
+ /// 求节域值
|
|
|
+ QString left1, right1, left2, right2;
|
|
|
+ QString sep = ", ";
|
|
|
+ if (item1->text().length() > 2 && item1->text().contains(sep)) {
|
|
|
+ left1 = item1->text().mid(1, item1->text().length() - 2).split(sep).first();
|
|
|
+ right1 = item1->text().mid(1, item1->text().length() - 2).split(sep).last();
|
|
|
}
|
|
|
-
|
|
|
- QString right = QString("%1").arg(d.rightValues[d.rightValues.size() - 1]);
|
|
|
- QString right1 = QString("%1").arg(d.leftValues[d.leftValues.size() - 1]);
|
|
|
- ;
|
|
|
- if (item->column() / 4 == m_domainLevel - 1 && item->text().length() > 2) {
|
|
|
- QStringList valueList = item->text().mid(1, item->text().length() - 2).split(", ");
|
|
|
- right = valueList.last();
|
|
|
- right1 = valueList.first();
|
|
|
+ if (item2->text().length() > 2 && item2->text().contains(sep)) {
|
|
|
+ left2 = item2->text().mid(1, item2->text().length() - 2).split(sep).first();
|
|
|
+ right2 = item2->text().mid(1, item2->text().length() - 2).split(sep).last();
|
|
|
}
|
|
|
-
|
|
|
- QString text = QString("(%1, %2)").arg(left).arg(right);
|
|
|
- if (left.toDouble() > right.toDouble()) {
|
|
|
- text = QString("(%1, %2)").arg(left1).arg(right1);
|
|
|
+ QString range = QString("(%1, %2)").arg(left1).arg(right2);
|
|
|
+ if (left1.toDouble() > right2.toDouble()) {
|
|
|
+ range = QString("(%1, %2)").arg(right1).arg(left2);
|
|
|
}
|
|
|
|
|
|
- QStandardItem *i = item->model()->item(item->row(), m_domainLevel * 4 + 3);
|
|
|
-
|
|
|
- if (i) {
|
|
|
- i->setText(text);
|
|
|
+ /// 显示节域值
|
|
|
+ QStandardItem *rangeItem = item->model()->item(item->row(), m_domainLevel * 4 + 3);
|
|
|
+ if (rangeItem) {
|
|
|
+ rangeItem->setText(range);
|
|
|
} else {
|
|
|
- i = new QStandardItem(text);
|
|
|
- item->model()->setItem(item->row(), m_domainLevel * 4 + 3, i);
|
|
|
+ rangeItem = new QStandardItem(range);
|
|
|
+ rangeItem->setEditable(false);
|
|
|
+ item->model()->setItem(item->row(), m_domainLevel * 4 + 3, rangeItem);
|
|
|
}
|
|
|
}
|
|
|
|