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/iGridResultUtils.h

155 lines
3.7 KiB
C

#pragma once
#include "iDlgBase.h"
#include "iParameter.h"
#include "iGridResultItem.h"
//class iGridResultItem;
// 列表区统一处理的Utils应用于模型选择
class X_GUI_GRIDPTY_EXPORT iGridResultUtils : public iDlgBase
{
Q_OBJECT
public:
explicit iGridResultUtils(QWidget *parent = 0);
~iGridResultUtils();
public:
// 初始化
virtual void initUI();
// 对外暴露接口
// void setLineItems(QVector<iGridResultItem*>& vec, \
// QWidget* pWxDlg);
bool buildResultUtils(QVector<iParameter*>& vecResults, \
QStringList& listTypes, \
QWidget* pWxDlg);
iGridResultItem* buildResultItemOf(iParameter* pDataObj, \
iGridResultItem* pParent, \
QString sLastItem);
void setModelType(QString s);
// 边界相关
void setBounds(QRectF& rt);
float getUtilHeight();
void connectSignalsOf(iGridResultItem* p);
void bkAllItems();
QStringList getAllTags(); //不考虑层级
void setSplitPos(float f);
void resetLayout(); //重置
// 清空
void clearAllItems();
// 刷新
void updateItem(iGridResultItem* p);
/// @brief 改变某个item的状态
/// @note bExclusive表示是否排他性比如只有一种激活
void changeItemState(iGridResultItem* p, \
iGridResultItem::ResultItemState o, \
bool bExclusive = true);
// 模型解释选用了某一项
void setItemAsSelected(QString sAlias, bool bSelected = true);
public slots:
// 右键
virtual void showCustomContextMenu(const QPoint &pos);
virtual void slotCopyCurrentItem();
virtual void slotCopyCurrentGroup();
virtual void slotCopyAllItems();
private:
// 搭建过程
QStringList getParaTypes(QStringList listParas);
iGridResultItem* createAndAddItem(iGridResultItem* pParent, \
iParameter* pDataObj, \
bool bGroup);
void insertItem(int nIndex, iGridResultItem* pItem);
// 把所有Item从上到下不考虑层级记录下来
bool getAllItems(QVector<iGridResultItem*>& vec); //不考虑层级
// 范围及布局
void updateLayout();
void doLayout();
protected:
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseDoubleClickEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
virtual void resizeEvent(QResizeEvent *);
protected:
virtual void paintEvent(QPaintEvent*);
void paintGrid(QPainter* pPainter);
signals:
void sigHelpMsg(QString& s);
protected:
// 节点操作及属性更改
GridTickPos hitTest(QPoint pt);
void expand(iGridResultItem* p);
void collapse(iGridResultItem* p);
// 获取上一个item
iGridResultItem* getLastItemOfState(iGridResultItem::ResultItemState o);
// 位置记录
int getPreferedSplitX();
void saveSplitX();
void loadSplitX();
public:
// 组织数据
// 序列化
virtual void onSerialize(ZxSerializer* ser);
virtual void onDeserialize(ZxSerializer* ser);
private:
// 窗体载体
QWidget* m_pWxDlg;
// 子项
QVector<iGridResultItem*> m_vecGridItems;
QVector<iGridResultItem*> m_vecAllItems;// 从上到下不考虑层级,所有
iGridResultItem* m_pItemSel;
// 位置及布局
QRectF m_rtBounds;
bool m_bNeedLayout;
// 分割线
bool m_bHitSplit;
float m_fSplitPos;
// Header
bool m_bHeaderVisible;
float m_fRowHeight;
QMenu* m_pContextMenu;
bool m_bUnableSP;
};