update highline setting
This commit is contained in:
Binary file not shown.
@@ -99,10 +99,10 @@ void HighlightDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
|
|||||||
if (isHighlighted) {
|
if (isHighlighted) {
|
||||||
// 设置高亮背景
|
// 设置高亮背景
|
||||||
painter->fillRect(opt.rect, QColor(255, 192, 203)); // 浅黄色背景
|
painter->fillRect(opt.rect, QColor(255, 192, 203)); // 浅黄色背景
|
||||||
// 设置加粗字体
|
|
||||||
QFont boldFont = opt.font;
|
//QFont boldFont = opt.font;// 设置加粗字体
|
||||||
boldFont.setBold(true);
|
//boldFont.setBold(true);
|
||||||
painter->setFont(boldFont);
|
//painter->setFont(boldFont);
|
||||||
|
|
||||||
// 绘制文本
|
// 绘制文本
|
||||||
painter->setPen(opt.palette.color(QPalette::Text));
|
painter->setPen(opt.palette.color(QPalette::Text));
|
||||||
|
|||||||
@@ -239,10 +239,17 @@ void QBigOrderViewer::onBigOrderAdded(const BigOrderInfo &order)
|
|||||||
m_model->insertRow(row);
|
m_model->insertRow(row);
|
||||||
setRowData(row, newOrder);
|
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) {
|
for (int col = 0; col < m_model->columnCount(); ++col) {
|
||||||
QModelIndex index = m_model->index(row, 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);
|
emit m_model->dataChanged(topLeft, bottomRight);
|
||||||
|
|
||||||
// 2秒后取消高亮
|
// 2秒后取消高亮
|
||||||
QTimer::singleShot(2000, this, [this, row]() {
|
QTimer::singleShot(2000, this, [this, orderId]() {
|
||||||
for (int col = 0; col < m_model->columnCount(); ++col) {
|
for (int row = 0; row < m_model->rowCount(); ++row) {
|
||||||
QModelIndex index = m_model->index(row, col);
|
QModelIndex index = m_model->index(row, 0);
|
||||||
m_model->setData(index, false, IsHighlightedRole);
|
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 topLeft = m_model->index(row, 0);
|
||||||
QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
|
QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
|
||||||
emit m_model->dataChanged(topLeft, bottomRight);
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 确保代理模型按时间降序排序,新数据在顶部
|
// 确保代理模型按时间降序排序,新数据在顶部
|
||||||
|
|||||||
@@ -90,6 +90,11 @@ QVector<BigOrderInfo> QOrderProcessor::findMaxVolumeItem(const OrderBookData & d
|
|||||||
const OrderBookEntry* maxItem;
|
const OrderBookEntry* maxItem;
|
||||||
QVector<OrderBookEntry> items = data.asks;
|
QVector<OrderBookEntry> items = data.asks;
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
|
||||||
|
// 不处理刚打开程序时,推送过来的摆盘数据
|
||||||
|
if (data.askTime == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
|
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
|
||||||
if (volume < items[i].volume) {
|
if (volume < items[i].volume) {
|
||||||
for (int j = 0; j< items[i].details.size(); j++) // 超过list的最大数量,就不会返回数据了
|
for (int j = 0; j< items[i].details.size(); j++) // 超过list的最大数量,就不会返回数据了
|
||||||
@@ -121,6 +126,11 @@ QVector<BigOrderInfo> QOrderProcessor::findMaxVolumeItem(const OrderBookData & d
|
|||||||
|
|
||||||
items = data.bids;
|
items = data.bids;
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
|
||||||
|
// 不处理刚打开程序时,推送过来的摆盘数据
|
||||||
|
if (data.bidTime == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
|
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
|
||||||
if (volume < items[i].volume) {
|
if (volume < items[i].volume) {
|
||||||
for (int j = 0; j< items[i].details.size(); j++)
|
for (int j = 0; j< items[i].details.size(); j++)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
09885,200000
|
09885,200000
|
||||||
00581,30000
|
00581,1.02e+06
|
||||||
03383,800000
|
03383,800000
|
||||||
02666,500000
|
02666,500000
|
||||||
00839,500000
|
00839,500000
|
||||||
06098,600000
|
06098,600000
|
||||||
06865,10000
|
06865,50000
|
||||||
00700,1000
|
00700,8000
|
||||||
|
|||||||
|
Reference in New Issue
Block a user