aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-06 21:57:09 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-06 21:57:09 +0200
commit87d787bc2c50eb00c6b86957efaa71e07f9acc07 (patch)
tree9a367f24b54ea8a79f66ac06d3bdb69cb3eed0cf
parentcbc17bd39f4ef245183e5a54509ff3fbd4125ca6 (diff)
downloadkristall-87d787bc2c50eb00c6b86957efaa71e07f9acc07.tar.gz
Fixes outline generation, adds 3-layer outlines.
-rw-r--r--README.md4
-rw-r--r--documentoutlinemodel.cpp47
-rw-r--r--documentoutlinemodel.hpp3
3 files changed, 42 insertions, 12 deletions
diff --git a/README.md b/README.md
index 3e1b697..b49cd6b 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ A high-quality visual cross-platform gemini browser.
- `text/markdown`
- `text/*`
- `image/*`
-- [Outline generation](https://mq32.de/public/d3cdeb38c55ce8100a631bbf761e7bc17b6806bb.png)
+- [Outline generation](https://mq32.de/public/a50ef327f4150d870393b1989c5b41db495b56f7.png)
- Favourite Sites
- Tabbed interface
- Survives [ConMans torture suite](gemini://gemini.conman.org/test/torture/)
@@ -30,7 +30,7 @@ A high-quality visual cross-platform gemini browser.
### Generates Outlines
-![Outline Generation](https://mq32.de/public/d3cdeb38c55ce8100a631bbf761e7bc17b6806bb.png)
+![Outline Generation](https://mq32.de/public/a50ef327f4150d870393b1989c5b41db495b56f7.png)
### Fully Customizable Site Theme
diff --git a/documentoutlinemodel.cpp b/documentoutlinemodel.cpp
index a47dafa..47ff3b5 100644
--- a/documentoutlinemodel.cpp
+++ b/documentoutlinemodel.cpp
@@ -39,15 +39,7 @@ void DocumentOutlineModel::appendH1(const QString &title)
void DocumentOutlineModel::appendH2(const QString &title)
{
- if(root.children.size() == 0) {
- root.children.append(Node {
- &root,
- "<missing layer>",
- 1, 0,
- QList<Node> { },
- });
- }
- auto & parent = root.children.last();
+ auto & parent = ensureLevel1();
parent.children.append(Node {
&parent,
title,
@@ -58,7 +50,13 @@ void DocumentOutlineModel::appendH2(const QString &title)
void DocumentOutlineModel::appendH3(const QString &title)
{
-
+ auto & parent = ensureLevel2();
+ parent.children.append(Node {
+ &parent,
+ title,
+ 3, parent.children.size() - 1,
+ QList<Node> { },
+ });
}
void DocumentOutlineModel::endBuild()
@@ -151,3 +149,32 @@ QVariant DocumentOutlineModel::data(const QModelIndex &index, int role) const
return item->title;
}
+
+DocumentOutlineModel::Node & DocumentOutlineModel::ensureLevel1()
+{
+ if(root.children.size() == 0) {
+ root.children.append(Node {
+ &root,
+ "<missing layer>",
+ 1, 0,
+ QList<Node> { },
+ });
+ }
+ return root.children.last();
+}
+
+DocumentOutlineModel::Node & DocumentOutlineModel::ensureLevel2()
+{
+ auto & parent = ensureLevel1();
+
+ if(parent.children.size() == 0) {
+ root.children.append(Node {
+ &parent,
+ "<missing layer>",
+ 2, 0,
+ QList<Node> { },
+ });
+ }
+
+ return parent.children.last();
+}
diff --git a/documentoutlinemodel.hpp b/documentoutlinemodel.hpp
index 2161c42..52e5f48 100644
--- a/documentoutlinemodel.hpp
+++ b/documentoutlinemodel.hpp
@@ -45,6 +45,9 @@ private:
};
Node root;
+
+ Node & ensureLevel1();
+ Node & ensureLevel2();
};
#endif // DOCUMENTOUTLINEMODEL_HPP