-
-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathXlsxTableModel.h
53 lines (41 loc) · 1.32 KB
/
XlsxTableModel.h
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
// XlsxTableModel.h
// QXlsx
// MIT License
// https://github.com/j2doll/QXlsx
#ifndef XLSX_MODEL_H
#define XLSX_MODEL_H
#include <cstdlib>
#include <string>
#include <vector>
#include <QAbstractTableModel>
#include <QList>
#include <QMap>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QVariant>
#include <QVector>
#include <QtGlobal>
typedef QList<QVariant> VLIST;
class XlsxTableModel : public QAbstractTableModel
{
Q_OBJECT
// method that is called by QML script
Q_PROPERTY(QStringList customRoleNames READ customRoleNames CONSTANT)
public:
QStringList customRoleNames();
public: // constructor
XlsxTableModel(const QList<QString> &colTitle, QList<VLIST> data, QObject *parent = NULL);
public: // virtual function of parent object
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
protected:
void testData(); // test function.
protected:
QList<VLIST> m_the_data; // table cell data
QList<QString> m_colNames; // column name
quint32 m_roleCount; // role count (same as column count)
};
#endif