You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmSubWxs/nmWxResultParameters.h

98 lines
3.3 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef NMWXRESULTPARAMETERS_H
#define NMWXRESULTPARAMETERS_H
#include "nmSubWxs_global.h"
#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "nmDataAttribute.h"
#include <QVBoxLayout>
#include <QMouseEvent>
// 扩展QTreeWidget类实现点击某一行时触发第二列的编辑框
class CustomTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
explicit CustomTreeWidget(QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
private:
bool m_isResizing;
int m_resizeColumn;
int m_resizeStartX;
int m_resizeStartWidth;
};
#include <QStyledItemDelegate>
#include <QPixmap>
// 自定义委托类处理QTreeWidget类的Item交互
class CustomTreeDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit CustomTreeDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
bool editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index) override;
// 绘制背景
void drawBackground(QPainter* painter, QStyleOptionViewItem& opt, const QModelIndex& index) const;
// 绘制第一列(带图标)
void drawFirstColumn(QPainter* painter, QStyleOptionViewItem& opt, const QModelIndex& index, const QFont& font) const;
// 绘制第二列(数值+单位)
void drawSecondColumn(QPainter* painter, const QStyleOptionViewItem& opt, const QModelIndex& index, const QFont& baseFont, bool isSelected) const;
// 绘制网格线
void drawGridLines(QPainter* painter, const QStyleOptionViewItem& opt, const QModelIndex& index) const;
private:
// 判断当前节点是不是最后一个节点
bool isLastSibling(const QModelIndex& index) const;
// 格式化显示值的辅助方法
QString formatDisplayValue(const QVariant& value) const;
QSize m_iconSize; // 图标大小
QPixmap m_expandIcon; // 左侧展开图标
QPixmap m_collapseIcon; // 左侧折叠图标
};
class nmDataReservoir;
class nmDataWellBase;
class nmDataMixedResults;
class nmDataPvtParaForPebi;
// 结果参数Widget
class NM_SUB_WXS_EXPORT nmWxResultParameters : public QWidget
{
Q_OBJECT
public:
explicit nmWxResultParameters(QWidget *parent = nullptr);
~nmWxResultParameters();
void initUI();
void initLayout();
void initComponents();
// 加载结果数据
void loadResultDatas();
// 添加混合结果参数到树
void appendMixedResultsToTree(nmDataMixedResults* mixedResults,nmDataWellBase* well,nmDataReservoir* reservoir,nmDataPvtParaForPebi* pvtPara);
// 添加井的结果参数到树控件(当前是默认井,即第一口井)
void appendWellToTree(nmDataWellBase* well);
// 添加储层结果参数到树控件
void appendReservoirToTree(nmDataReservoir* reservoir);
// 辅助函数:添加属性到树
void addAttributeToTree(QTreeWidgetItem* parent,const nmDataAttribute& attr);
private:
// 保留原有方法(可选,如果需要兼容性)
QString formatAttributeValue(const QVariant& value, const QString& unit);
signals:
private:
// 布局
QVBoxLayout* m_pLayout;
CustomTreeWidget* m_pTreeWidget;
};
#endif // NMWXRESULTPARAMETERS_H