-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjulia_itemmodel.hpp
More file actions
73 lines (60 loc) · 2.64 KB
/
julia_itemmodel.hpp
File metadata and controls
73 lines (60 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef QML_JULIAITEMMODEL_H
#define QML_JULIAITEMMODEL_H
#include <map>
#include <string>
#include <QAbstractTableModel>
#include "jlcxx/functions.hpp"
namespace qmlwrap
{
/// Wrap Julia composite types
class JuliaItemModel : public QAbstractTableModel
{
Q_OBJECT
public:
static jl_module_t* m_qml_mod;
JuliaItemModel(jl_value_t* data, QObject* parent = nullptr);
~JuliaItemModel();
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QHash<int,QByteArray> roleNames() const override;
// Same interface as in Qt6 labs QQmlTableModel
Q_INVOKABLE void clear();
Q_INVOKABLE void appendRow(const QVariant& row);
Q_INVOKABLE void insertRow(int rowIndex, const QVariant& row);
Q_INVOKABLE void moveRow(int fromRowIndex, int toRowIndex, int rows = 1);
Q_INVOKABLE void removeRow(int rowIndex, int rows = 1);
Q_INVOKABLE void setRow(int rowIndex, const QVariant& row);
Q_INVOKABLE void appendColumn(const QVariant& column);
Q_INVOKABLE void insertColumn(int columnIndex, const QVariant& column);
Q_INVOKABLE void moveColumn(int fromColumnIndex, int toColumnIndex, int columns = 1);
Q_INVOKABLE void removeColumn(int columnIndex, int columns = 1);
Q_INVOKABLE void setColumn(int columnIndex, const QVariant& column);
// Called from Julia
void emit_data_changed(int startrow, int startcol, int endrow, int endcol);
void emit_header_data_changed(Qt::Orientation orientation, int first, int last);
void begin_reset_model();
void end_reset_model();
void begin_insert_rows(int first, int last);
void end_insert_rows();
bool begin_move_rows(int fromIndex, int toIndex, int count);
void end_move_rows();
void begin_remove_rows(int fromIndex, int count);
void end_remove_rows();
void begin_insert_columns(int first, int last);
void end_insert_columns();
bool begin_move_columns(int fromIndex, int toIndex, int count);
void end_move_columns();
void begin_remove_columns(int fromIndex, int count);
void end_remove_columns();
QHash<int,QByteArray> default_role_names() const;
jl_value_t* get_julia_data() const;
private:
jl_value_t* m_data;
};
}
#endif