diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-05-30 19:33:47 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-05-30 19:33:47 +0200 |
| commit | ea39cc542e17ce592dc3c4f2053d534bc458d88e (patch) | |
| tree | c3c6a369d5b6d8a6a4e0b3e3667a56ca19e93173 /documentoutlinemodel.hpp | |
| parent | 79ff338a3427a236ef53adf806c56616faa3426c (diff) | |
| download | kristall-ea39cc542e17ce592dc3c4f2053d534bc458d88e.tar.gz | |
More usability, survives conmans torture nearly with 100%
Diffstat (limited to 'documentoutlinemodel.hpp')
| -rw-r--r-- | documentoutlinemodel.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/documentoutlinemodel.hpp b/documentoutlinemodel.hpp new file mode 100644 index 0000000..802bd86 --- /dev/null +++ b/documentoutlinemodel.hpp @@ -0,0 +1,46 @@ +#ifndef DOCUMENTOUTLINEMODEL_HPP +#define DOCUMENTOUTLINEMODEL_HPP + +#include <QAbstractItemModel> + +class DocumentOutlineModel : + public QAbstractItemModel +{ + Q_OBJECT +public: + DocumentOutlineModel(); + + void beginBuild(); + + void appendH1(QString const & title); + + void appendH2(QString const & title); + + void appendH3(QString const & title); + + void endBuild(); + +public: + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + + QModelIndex parent(const QModelIndex &child) const override; + + 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; + + +private: + struct Node + { + Node * parent; + QString title; + int depth = 0; + QVector<Node> children; + }; + + Node root; +}; + +#endif // DOCUMENTOUTLINEMODEL_HPP |
