2025-08-15 15:56:40 +08:00
|
|
|
|
#ifndef ORDERTYPEDELEGATE_H
|
|
|
|
|
|
#define ORDERTYPEDELEGATE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
#include <QStyledItemDelegate>
|
2025-08-31 23:07:06 +08:00
|
|
|
|
#include <QSortFilterProxyModel>
|
2025-08-15 15:56:40 +08:00
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
2025-08-31 23:07:06 +08:00
|
|
|
|
|
|
|
|
|
|
// 在文件顶部添加高亮角色定义
|
|
|
|
|
|
enum CustomRoles {
|
|
|
|
|
|
IsHighlightedRole = Qt::UserRole + 100
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-15 15:56:40 +08:00
|
|
|
|
/* 订单类型单元格渲染委托 */
|
|
|
|
|
|
class OrderTypeDelegate : public QStyledItemDelegate
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit OrderTypeDelegate(QObject *parent = nullptr);
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
|
|
// 可选:添加颜色自定义接口
|
|
|
|
|
|
void setBuyColor(const QColor &color);
|
|
|
|
|
|
void setSellColor(const QColor &color);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QColor m_buyColor = QColor(255, 230, 230); // 买入订单浅红背景
|
|
|
|
|
|
QColor m_sellColor = QColor(230, 255, 230); // 卖出订单浅绿背景
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NumberFormatDelegate : public QStyledItemDelegate
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit NumberFormatDelegate(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-31 23:07:06 +08:00
|
|
|
|
|
|
|
|
|
|
// 新大单高亮委托
|
|
|
|
|
|
class HighlightDelegate : public QStyledItemDelegate
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit HighlightDelegate(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
|
|
// 可选:如果需要编辑器,可以重写createEditor等方法
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HIGHLIGHTDELEGATE_H
|
|
|
|
|
|
|