2018-07-13 13:56:11 +09:00
|
|
|
// XlsxTableModel.h
|
2018-07-12 18:15:23 +09:00
|
|
|
|
2018-08-14 09:07:09 +09:00
|
|
|
// QXlsx
|
|
|
|
// MIT License
|
|
|
|
// https://github.com/j2doll/QXlsx
|
|
|
|
|
2018-07-12 18:15:23 +09:00
|
|
|
#ifndef XLSX_MODEL_H
|
|
|
|
#define XLSX_MODEL_H
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2018-07-13 09:17:28 +09:00
|
|
|
typedef QList<QVariant> VLIST;
|
|
|
|
|
2018-07-13 13:56:11 +09:00
|
|
|
class XlsxTableModel : public QAbstractTableModel
|
2018-07-12 18:15:23 +09:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-07-13 09:17:28 +09:00
|
|
|
// method that is called by QML script
|
|
|
|
Q_PROPERTY(QStringList customRoleNames READ customRoleNames CONSTANT)
|
|
|
|
public: QStringList customRoleNames();
|
2018-07-12 18:15:23 +09:00
|
|
|
|
2018-07-13 09:17:28 +09:00
|
|
|
public: // constrcutor
|
2018-07-13 13:56:11 +09:00
|
|
|
XlsxTableModel(QList<QString> colTitle, QList<VLIST> data, QObject *parent = NULL);
|
2018-07-12 18:15:23 +09:00
|
|
|
|
2018-07-13 09:17:28 +09:00
|
|
|
public: // virtual function of parent object
|
2018-07-12 18:15:23 +09:00
|
|
|
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:
|
2018-07-13 09:17:28 +09:00
|
|
|
void testData(); // test function.
|
2018-07-12 18:15:23 +09:00
|
|
|
|
|
|
|
protected:
|
2018-07-13 09:17:28 +09:00
|
|
|
QList<VLIST> m_the_data; // table cell data
|
|
|
|
QList<QString> m_colNames; // column name
|
|
|
|
quint32 m_roleCount; // role count (same as column count)
|
2018-07-12 18:15:23 +09:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|