#pragma once #include "iDlgBase.h" #include "iResultInfo.h" class iModelInfoBase; class iGridLineItem; // 列表区统一处理的Utils(应用于模型选择) class X_GUI_GRIDPTY_EXPORT iGridLineUtils : public iDlgBase { Q_OBJECT public: explicit iGridLineUtils(QWidget *parent = 0); ~iGridLineUtils(); public: // 初始化 virtual void initUI(); // 对外暴露接口 void setLineItems(QVector& vec, \ QWidget* pWxDlg); bool buildLineUtils(QVector vecDataObjs, \ QWidget* pWxDlg); iGridLineItem* buildLineItemOf(iModelInfoBase* pDataObj, \ iGridLineItem* pParent); // 边界相关 void setBounds(QRectF& rt); float getUtilHeight(); void connectSignalsOf(iGridLineItem* p); void bkAllItems(); QStringList getAllTags(); //不考虑层级 void resetLayout(); //重置 // 根据名字获取 iGridLineItem* getItemByPara(QString sPara); // 根据名字取数据 QVariant getItemValueByPara(QString sPara); // 清空 void clearAllItems(); // 对Items进行检测,正确输入 bool checkItems(); // 刷新 void updateItem(iGridLineItem* p); private: // 搭建过程 QStringList getParaTypes(QStringList listParas); iGridLineItem* createAndAddItem(iGridLineItem* pParent, \ iModelInfoBase* pDataObj, \ bool bGroup); void insertItem(int nIndex, iGridLineItem* pItem); // 把所有Item从上到下(不考虑层级记录下来) bool getAllItems(QVector& 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); public slots: void slotActivateItem(iGridLineItem* p); void onActiveItemChanged(iGridLineItem* p); signals: void sigHelpMsg(QString& s); protected: // 节点操作及属性更改 GridTickPos hitTest(QPoint pt); void expand(iGridLineItem* p); void collapse(iGridLineItem* p); iGridLineItem* getLastActive(); public: // 组织数据 // 序列化 virtual void onSerialize(ZxSerializer* ser); virtual void onDeserialize(ZxSerializer* ser); private: // 窗体载体 QWidget* m_pWxDlg; // 子项 QVector m_vecLineItems; QVector m_vecAllItems;// 从上到下不考虑层级,所有 iGridLineItem* m_pItemSel; // 位置及布局 QRectF m_rtBounds; bool m_bNeedLayout; // Header bool m_bHeaderVisible; float m_fRowHeight; };