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.
nmWATI/Include/iGui/iGuiGridPty/iGridResultItem.h

173 lines
4.6 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.

#pragma once
#include "iDlgBase.h"
#include "iParameter.h"
#include "iGuiGridPty_global.h"
class iParameter;
// 列表区每一项Item的基类应用于模型选择
class X_GUI_GRIDPTY_EXPORT iGridResultItem : public QObject
{
Q_OBJECT
public:
explicit iGridResultItem(iGridResultItem* pParent = NULL);
~iGridResultItem();
enum ResultItemState
{
LIS_Activate = 0, //激活,鼠标选中,即为激活
LIS_Selected, //选用,即进行了处理解释
LIS_Visible, //是否可见
LIS_Expanded, //是否扩展只对Group有效
LIS_Unknown
};
public:
// 序列化
virtual void onSerialize(ZxSerializer* ser);
virtual void onDeserialize(ZxSerializer* ser);
// 父子关系处理
virtual void setDlgBase(QWidget* p);//父窗体、位置控制
iGridResultItem* getParent(); //父
bool isParentCollapsed(); //父级节点是否折叠
int appendChild(iGridResultItem* p); //添加孩子
int getChildCount(); //孩子数目
iGridResultItem* getChildAt(int n); //获取
void removeAllChilds(); //Clear
bool getAllItems(QVector<iGridResultItem*>& vec);//不考虑层级
int getItemLevel(); //获取层次级别
virtual QString getShowValue(); //非激活时显示在右侧的文本
virtual QString getUnit();
public:
// 位置相关Bounds
virtual void setBounds(QRectF& rt); //全局
virtual QRectF getBounds(); //
virtual QRectF getLeftBounds(); //左
virtual QRectF getRightBounds_Main();
virtual QRectF getRightBounds_Unt();
virtual float getItemHeight(); //当前节点高度
virtual void setSplitPos(float f); //中间分隔
public:
// 绘图
virtual void paint(QPainter* pPainter);
protected:
virtual bool isPaintNeeded();
virtual void paintItem(QPainter* pPainter);
virtual void _paintItemTag(QPainter* pPainter, QString s);
virtual void _paintItemValue(QPainter* pPainter);
virtual void _paintItemGrid(QPainter* pPainter);
virtual void _paintItemUnit(QPainter* pPainter, QString s);
public:
// 当前节点及孩子中的特定状态的节点(唯一)
virtual iGridResultItem* getItemOfState(ResultItemState o);
virtual bool isStateOf(ResultItemState o);
void setStateOf(ResultItemState o, bool bReverse = false);
// 是否激活,鼠标选中,即为激活
bool isActive();
virtual void setActive(bool b);
// 是否选用,即进行了处理解释
bool isSelected();
virtual void setSelected(bool b);
// 是否可见
bool isVisible();
virtual void setVisible(bool b);
// 是否扩展只对Group有效
bool isExpanded();
virtual void setExpanded(bool b);
// 20181228与参数载体的readonly不是一回事
// 允许外界动态修改
bool isReadonly();
virtual void setReadonly(bool b);
// 其实就是是否分组标识(但是有些不是),需要注意
bool isSeparator();
public:
// HitTest
virtual bool hitTest(QPoint pt, GridTickPos& ht, \
iGridResultItem*& pItem);
virtual bool hitTest_SelfOnly(QPoint pt, GridTickPos& ht, \
iGridResultItem*& pItem);
// virtual void onItemDoubleCliked(GridTickPos o);
signals:
void sigUnableSP(bool&);
void sigValueChanged(QString sPara, QVariant o);
//void sigActiveItem(iGridResultItem*);
protected slots:
// QLineEdit 类型的数据change响应
//virtual void slotItemNeedActivate(bool);
public:
// 设置各个参数
iParameter* getDataObj(); //数据载体体
virtual void setDataObj(iParameter* p);
QString getTag(bool bSimple = false);//左侧标识
protected:
virtual bool isUnableSP();
protected:
// 对应的参数
iParameter* m_pParameter;
// 父子关系
QWidget* m_pDlgBase; //承载的Wx
iGridResultItem* m_pParent; //父级节点
QVector<iGridResultItem*> m_vecChildren; //孩子节点
// 内嵌组件
QWidget* m_pEditor;
QVector<QWidget*> m_vecEditors;
// 状态
bool m_bActive; //是否激活,鼠标选中,即为激活
bool m_bSelected; //是否选用,即进行了处理解释
bool m_bVisible; //是否可见
bool m_bExpanded; //是否扩展只对Group有效
// 20181228与参数载体的readonly不是一回事
// 允许外界动态修改
bool m_bReadonly;
// 位置信息
QRectF m_rtBounds;
float m_fSplitPos;
public:
// 其它常量
float m_fRowHeight;
float m_fSplitPading;
};