| 9 | #include <vector> |
| 10 | |
| 11 | class VarTableModel : public QAbstractTableModel { |
| 12 | Q_OBJECT |
| 13 | |
| 14 | public: |
| 15 | enum { |
| 16 | VAR_NAME_COL, |
| 17 | VAR_LOCATION_COL, |
| 18 | VAR_TYPE_COL, |
| 19 | VAR_SIZE_COL, |
| 20 | VAR_PREVIEW_COL, |
| 21 | VAR_NUM_COLS |
| 22 | }; |
| 23 | |
| 24 | explicit VarTableModel(QObject *parent = Q_NULLPTR); |
| 25 | |
| 26 | void clear(); |
| 27 | void refresh(); |
| 28 | void retranslate(); |
| 29 | |
| 30 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 31 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; |
| 32 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
| 33 | Qt::ItemFlags flags(const QModelIndex &index) const override; |
| 34 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 35 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; |
| 36 | |
| 37 | private: |
| 38 | enum class PreviewState : uint8_t { |
| 39 | Outdated, |
| 40 | Invalid, |
| 41 | Valid |
| 42 | }; |
| 43 | |
| 44 | struct VarData { |
| 45 | VarData(const calc_var_t &var); |
| 46 | ~VarData(); |
| 47 | VarData(VarData &&other) noexcept; |
| 48 | VarData &operator=(VarData &&other) noexcept; |
| 49 | |
| 50 | uint8_t updateInfo(const calc_var_t &var); |
| 51 | void updatePreview(); |
| 52 | |
| 53 | calc_var_t info; |
| 54 | QString preview; |
| 55 | PreviewState previewState; |
| 56 | bool checked; |
| 57 | }; |
| 58 | |
| 59 | mutable std::vector<VarData> vars; |
| 60 | QFont varPreviewItalicFont; |
| 61 | QFont varPreviewCEFont; |
| 62 | }; |
| 63 | |
| 64 | class VarTableSortFilterModel : public QSortFilterProxyModel { |
| 65 | Q_OBJECT |
nothing calls this directly
no outgoing calls
no test coverage detected