#pragma once #include "Common.h" // 各个控件的默认尺寸 #define DEFAULT_CONTROL_SIZE QSize(0, 0) #define DEFAULT_LABEL_SIZE QSize(100, 18) #define DEFAULT_BUTTON_SIZE QSize(75, 23) #define DEFAULT_CHECKBOX_SIZE QSize(100, 18) #define DEFAULT_RADIO_SIZE QSize(100, 18) #define DEFAULT_GROUP_SIZE QSize(120, 80) #define DEFAULT_IMAGE_SIZE QSize(500, 400) #define DEFAULT_EDIT_SIZE QSize(130, 20) #define DEFAULT_LIST_SIZE QSize(256, 192) #define DEFAULT_COMBO_SIZE QSize(100, 22) #define DEFAULT_VALUE_SIZE QSize(104, 70) #define DEFAULT_PIE_SIZE QSize(200, 200) #define DEFAULT_WAVE_SIZE QSize(500, 300) #define DEFAULT_TABLE_SIZE QSize(400, 250) /// /// 所有自定义控件的基类型 /// class VControlObject { public: VControlObject( CONTROL_PROPERTY* pProperty = nullptr ); ~VControlObject(); public: QString getText() const; QString getTip() const; QColor getTextColor() const; QColor getBgColor() const; QFont getFont() const; bool getEnable() const; DataLink getDataLink() const; void setDataLink(const DataLink& datalink); // 获得扩展属性的子分组数量 // 2022-1-10,由于有多个子分组,所以此处需要传入ID int getExPropertyCountByID( const int groupID = 0 ); // 根据对应的子属性关联Key的名字来获取子分组数量 int getExPropertyCountByName( const QString& strKey); // 根据属性名字获取当前子属性组的ID int getGroupIDByName(const QString& strKey); // 更新扩展属性的数量(虚函数) virtual void updateExPropertyCount(const int newCount, const QString& strPropName); // 修改扩展属性(虚函数) virtual void changeExProperties(const QString strValueTile, const QVariant& newValue); // 更新数据链接 void updateExPropertyDataLink(const QString& strPropertyName, const DataLink& datalink); // 更新数据链接 void updateExPropertyDataLink(const QString& strPropertyName, const QString& strLinkString); // 是否是复杂控件(Table、Pie、Wave、Image 等) bool isComplexControl(); // 是否是复杂控件(Table、Pie、Wave、Image 等) static bool isComplexControl(VALUE_TYPE type); // 根据属性名找到对应的DataLink DataLink getDataLinkByProperty(const QString& strPropertyName); //// 根据属性名设置对应的DataLink //bool setDataLinkByProperty(const QString& strPropertyName, const DataLink dataLink); // 将QObect*转换为VControlObject* static VControlObject* controlPtr(QObject* object); // 2022-9-10,为简单控件设置默认的DataLink void bindDefaultDataLink(); // 2022-9-10,为复杂控件设置默认的刷新索引链接(refreshLink) void bindDefaultRefreshDataLink(); // 获取控件的Item QGraphicsProxyWidget* getItem(); protected: QString textColorQss(const QColor& color); QString bgColorQss(const QColor& color); // 从属性标题中获取序号 int indexOfProperty(const QString& propertyName); public: // 控件的所有属性信息 CONTROL_PROPERTY m_Property; // 控件的扩展属性信息(仅复杂控件所特有) CONTROL_PROPERTY_EX m_PropertyEx; // 控件的Widget指针 QWidget* m_pWidget; // Widget控件在Scene中的操作指针 QGraphicsProxyWidget* m_pProxyWidget; // 2022-10-16,为每一个控件增加一个ID号,用于识别控件(目前用于Undo体系中) QString m_strID; // 控件本身的类型 VALUE_TYPE m_Type; //// 主链接的数量 //int m_nMainLinkCount; //// 扩展属性分组的数量 //int m_nGroupCount; //// 扩展属性子分组的数量 //int m_nSubGroupCount; };