update highline setting
This commit is contained in:
@@ -239,10 +239,17 @@ void QBigOrderViewer::onBigOrderAdded(const BigOrderInfo &order)
|
||||
m_model->insertRow(row);
|
||||
setRowData(row, newOrder);
|
||||
|
||||
// 为订单生成唯一标识
|
||||
QString orderId = QString("%1_%2_%3")
|
||||
.arg(order.code)
|
||||
.arg(QString::number(order.price, 'f', 2))
|
||||
.arg(QDateTime::currentMSecsSinceEpoch());
|
||||
|
||||
// 设置高亮标记
|
||||
for (int col = 0; col < m_model->columnCount(); ++col) {
|
||||
QModelIndex index = m_model->index(row, col);
|
||||
m_model->setData(index, true, IsHighlightedRole);
|
||||
m_model->setData(index, true, IsHighlightedRole);
|
||||
m_model->setData(index, orderId, Qt::UserRole + 102); // 存储唯一标识
|
||||
}
|
||||
|
||||
// 通知视图更新
|
||||
@@ -251,16 +258,32 @@ void QBigOrderViewer::onBigOrderAdded(const BigOrderInfo &order)
|
||||
emit m_model->dataChanged(topLeft, bottomRight);
|
||||
|
||||
// 2秒后取消高亮
|
||||
QTimer::singleShot(2000, this, [this, row]() {
|
||||
for (int col = 0; col < m_model->columnCount(); ++col) {
|
||||
QModelIndex index = m_model->index(row, col);
|
||||
QTimer::singleShot(2000, this, [this, orderId]() {
|
||||
for (int row = 0; row < m_model->rowCount(); ++row) {
|
||||
QModelIndex index = m_model->index(row, 0);
|
||||
m_model->setData(index, false, IsHighlightedRole);
|
||||
QString currentOrderId = index.data(Qt::UserRole + 102).toString();
|
||||
|
||||
if (currentOrderId == orderId) {
|
||||
|
||||
for (int col = 0; col < m_model->columnCount(); ++col) {
|
||||
QModelIndex cellIndex = m_model->index(row, col);
|
||||
m_model->setData(cellIndex, false, IsHighlightedRole);
|
||||
}
|
||||
|
||||
// 通知视图更新
|
||||
QModelIndex topLeft = m_model->index(row, 0);
|
||||
QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
|
||||
emit m_model->dataChanged(topLeft, bottomRight);
|
||||
|
||||
break; // 找到后退出循环
|
||||
}
|
||||
}
|
||||
|
||||
// 通知视图更新
|
||||
QModelIndex topLeft = m_model->index(row, 0);
|
||||
QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
|
||||
emit m_model->dataChanged(topLeft, bottomRight);
|
||||
//// 通知视图更新
|
||||
//QModelIndex topLeft = m_model->index(row, 0);
|
||||
//QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
|
||||
//emit m_model->dataChanged(topLeft, bottomRight);
|
||||
});
|
||||
|
||||
// 确保代理模型按时间降序排序,新数据在顶部
|
||||
|
||||
Reference in New Issue
Block a user