VTableControl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include "Common.h"
  3. #include "VControlObject.h"
  4. // 扩展属性相关数量
  5. // #define TABLE_PROPERTY_EX_MAINLINK_COUNT 1
  6. //#define TABLE_PROPERTY_EX_SUBGROUPLINK_COUNT 1
  7. //#define TABLE_PROPERTY_EX_GROUP_COUNT 1
  8. // 扩展属性的组名
  9. #define TABLE_PROPERTY_EX_NAME "表格"
  10. #define TABLE_PROPERTY_EX_REFRESHLINK_NAME "索引链接"
  11. #define TABLE_PROPERTY_EX_GROUP_NAME "列信息"
  12. #define TABLE_PROPERTY_EX_SUBGROUP_NAME "列"
  13. #define TABLE_PROPERTY_EX_VALUE_NAME "列名"
  14. #define TABLE_PROPERTY_EX_LINK_NAME "数据链接"
  15. // 列数和行数的属性名称
  16. #define TABLE_COL_COUNT_NAME "colCount"
  17. #define TABLE_ROW_COUNT_NAME "rowCount"
  18. // Table属性子分组编号(Table目前只有一个扩展属性组)
  19. #define GROUP_INDEX_TABLE 0
  20. class VTableControl : public QTableWidget, public VControlObject
  21. {
  22. Q_OBJECT
  23. Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
  24. Q_PROPERTY(int rowCount READ getRowCount WRITE setRowCount);
  25. Q_PROPERTY(int colCount READ getColCount WRITE setColCount);
  26. //Q_PROPERTY(QFont font READ getFont WRITE setFont)
  27. //Q_PROPERTY(bool enable READ getEnable WRITE setEnable)
  28. // Q_PROPERTY(DataLink dataLink READ getDataLink WRITE setDataLink)
  29. public:
  30. VTableControl
  31. (
  32. QWidget* parent,
  33. const QPoint& pos,
  34. const QSize& size,
  35. CONTROL_PROPERTY* pProperty = nullptr,
  36. CONTROL_PROPERTY_EX* pPropertyEx = nullptr
  37. );
  38. ~VTableControl();
  39. public:
  40. // 属性的实现函数
  41. //void setText(const QString& title);
  42. //void setTip(const QString& tip);
  43. void setTextColor(const QColor& color);
  44. //void setBgColor(const QColor& color);
  45. void setFont(const QFont& font);
  46. void setEnable(const bool enable);
  47. // 函数
  48. int getRowCount();
  49. void setRowCount(const int row);
  50. // 列数
  51. int getColCount();
  52. void setColCount(const int row);
  53. // 初始化Table表头
  54. void initTableHeader();
  55. // 更新列标题
  56. void updateColTitle(const QString& newValue, const int nIndex);
  57. // 刷新一整行数据
  58. void updateRowFromVariables(const RUNTIME_SYNC_VARS& sync_vars, int nRowIndex);
  59. //// 更新数据链接
  60. //void updatePropertyExDataLink(const QString& strPropertyName, const DataLink& datalink);
  61. //// 更新数据链接
  62. //void updatePropertyExDataLink(const QString& strPropertyName, const QString& strLinkString);
  63. // 更新列属性数量(虚函数)
  64. virtual void updateExPropertyCount(const int fixCount, const QString& strPropName);
  65. // 修改扩展属性(虚函数)
  66. virtual void changeExProperties(QString strValueTitle, const QVariant& newValue);
  67. private:
  68. // 初始化扩展属性
  69. void initPropertyEx();
  70. // 初始化UI风格
  71. void initStyle();
  72. // 初始化子属性组
  73. void initSubGroup(PROPERTY_EX_SUBGROUP& subGroup, int nIndex, int nSubGroupID);
  74. };