MatrixTableWidget.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef MATRIXTABLEWIDGET_H
  2. #define MATRIXTABLEWIDGET_H
  3. #include <QStandardItemModel>
  4. #include <QTableView>
  5. #include "dbService/ClassSet.h"
  6. struct MatrixDataSource
  7. {
  8. QString node; //节点
  9. QString abscissa; //横坐标
  10. QString ordinate; //纵坐标
  11. QString nodeValue; //节点值
  12. int row = -1;
  13. int col = -1;
  14. bool changed = false;
  15. };
  16. class MatrixTableWidget : public QTableView
  17. {
  18. Q_OBJECT
  19. public:
  20. explicit MatrixTableWidget(bool diagonalOne = true, QWidget *parent = nullptr);
  21. ~MatrixTableWidget();
  22. void addRowNode(QString node, QString name, QString remark);
  23. void addColNode(QString node, QString name, QString remark);
  24. QList<MatrixDataSource> getSource() const;
  25. bool isDataReady() const;
  26. void paintMatrixTable(QList<NodeMatrixInfo *> nodeValueInfoList);
  27. void setCurrentPage(int page);
  28. void setTableIndexAndTableMsg(int index, int engineerId, int expertId, QString tableMsg);
  29. void setMsgName(QString msgName);
  30. signals:
  31. void dataReady(bool status);
  32. void autoSave();
  33. void returnModel(QStandardItemModel *item);
  34. void returnModelName(QString itemName);
  35. private slots:
  36. void nodeValueChanged(QStandardItem *item);
  37. void itemClicked(const QModelIndex &index);
  38. private:
  39. /**
  40. * @brief 遍历表格是否为空
  41. */
  42. void pollCellsData();
  43. void editItemData(const QModelIndex &index, const QString &val);
  44. struct MatrixNode
  45. {
  46. MatrixNode(QString no, QString na, QString re) : node(no), name(na), remark(re) { }
  47. QString node;
  48. QString name;
  49. QString remark;
  50. };
  51. bool paintDone = false;
  52. QList<MatrixNode> matrixRows;
  53. QList<MatrixNode> matrixCols;
  54. QList<MatrixDataSource> dataSource;
  55. QStandardItemModel *model;
  56. bool diagonalIsOne;
  57. int currentPage;
  58. int m_tableIndex = 0;
  59. int m_engineerId; // 工程id
  60. int m_expertId; // 专家id
  61. QString m_engineer_name;
  62. QString m_expert_name;
  63. QString m_table_msg;
  64. QString m_msg_name;
  65. };
  66. #endif // MATRIXTABLEWIDGET_H