dyntablemodel.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef DYNTABLEMODEL_H
  2. #define DYNTABLEMODEL_H
  3. #include <QAbstractTableModel>
  4. #include <NoteEvents.h>
  5. class DynTableModel : public QAbstractTableModel
  6. {
  7. Q_OBJECT
  8. public:
  9. DynTableModel();
  10. void loadOne(quint64 sel1,QJsonObject o);
  11. void reset();
  12. bool hasChanges(QVector<quint64> sel);
  13. void saveChanges();
  14. protected:
  15. Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
  16. Q_INVOKABLE virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
  17. Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
  18. Q_INVOKABLE virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
  19. virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
  20. Qt::ItemFlags flags(const QModelIndex &index) const override;
  21. private:
  22. struct DynTableData
  23. {
  24. QString key;
  25. QString value;
  26. QString valueOrig;
  27. bool updated=false;
  28. };
  29. QVector<DynTableData*> _data;
  30. quint64 _sel1=-1;
  31. signals:
  32. void noteEffect(qtauEvent* e);
  33. };
  34. #endif // DYNTABLEMODEL_H