优化属性编辑,对编辑单元格进行加粗展示
This commit is contained in:
parent
8256e3f964
commit
f714397241
|
|
@ -95,6 +95,7 @@ private:
|
|||
{
|
||||
//QSqlRecord record;
|
||||
QVector<QVariant> values;
|
||||
QHash<int, bool> cellModified; //记录单元格是否被修改
|
||||
EditState state = Clean;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -88,14 +88,20 @@ QVariant AttributeTableModel::data(const QModelIndex& index, int role) const
|
|||
const QString& dataTypeText = m_dataTypes.value(dataTypeID).type;
|
||||
if(!dataTypeText.isEmpty())
|
||||
return dataTypeText;
|
||||
else
|
||||
return dataTypeID;
|
||||
// else
|
||||
// return dataTypeID;
|
||||
}
|
||||
else
|
||||
return rowData.values.value(dataCol);
|
||||
}
|
||||
else if (role == Qt::UserRole + AttributeEidt::EditStatus) //在相关代理Delegate类实现中同步进行处理(文字加粗等效果)
|
||||
return (rowData.state != Clean);
|
||||
{
|
||||
//return (rowData.state != Clean);
|
||||
if(rowData.state == New) //新增列,整行加粗
|
||||
return true;
|
||||
else //其它情况只对修改单元格加粗
|
||||
return rowData.cellModified.value(dataCol, false);
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
|
@ -126,6 +132,7 @@ bool AttributeTableModel::setData(const QModelIndex &index, const QVariant &valu
|
|||
}
|
||||
else
|
||||
modifiedRow.values[dataCol] = value;
|
||||
modifiedRow.cellModified[dataCol] = true; //标记单元格
|
||||
modifiedRow.state = (modifiedRow.state == New) ? New : Modified;
|
||||
|
||||
m_modifiedRows[globalRow] = modifiedRow;
|
||||
|
|
@ -409,6 +416,7 @@ void AttributeTableModel::insertRecord(int row)
|
|||
RowData newRow;
|
||||
newRow.state = New;
|
||||
newRow.values.resize(m_displayField.count());
|
||||
//newRow.values[2] = 11;
|
||||
|
||||
int globalRow = (m_paginationInfo.currentPage - 1) * m_paginationInfo.entriesPerPage + row;
|
||||
m_modifiedRows[globalRow] = newRow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue