From cbc17bd39f4ef245183e5a54509ff3fbd4125ca6 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sat, 6 Jun 2020 21:45:41 +0200 Subject: Fixes bug in outline generation, adds application icon to mainwindow, adds more README, adds save settings on closing settings dialog. --- documentoutlinemodel.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'documentoutlinemodel.cpp') diff --git a/documentoutlinemodel.cpp b/documentoutlinemodel.cpp index b44ceff..a47dafa 100644 --- a/documentoutlinemodel.cpp +++ b/documentoutlinemodel.cpp @@ -22,8 +22,8 @@ void DocumentOutlineModel::beginBuild() root = Node { nullptr, "", - 0, - QVector { }, + 0, 0, + QList { }, }; } @@ -32,8 +32,8 @@ void DocumentOutlineModel::appendH1(const QString &title) root.children.append(Node { &root, title, - 1, - QVector { }, + 1, 0, + QList { }, }); } @@ -43,16 +43,16 @@ void DocumentOutlineModel::appendH2(const QString &title) root.children.append(Node { &root, "", - 1, - QVector { }, + 1, 0, + QList { }, }); } auto & parent = root.children.last(); parent.children.append(Node { &parent, title, - 2, - QVector { }, + 2, parent.children.size() - 1, + QList { }, }); } @@ -63,6 +63,21 @@ void DocumentOutlineModel::appendH3(const QString &title) void DocumentOutlineModel::endBuild() { + for(auto const & h1 : this->root.children) + { + assert(h1.depth == 1); + assert(h1.parent == &this->root); + for(auto const & h2 : h1.children) + { + assert(h2.depth == 2); + assert(h2.parent == &h1); + for(auto const & h3 : h2.children) + { + assert(h3.depth == 3); + assert(h3.parent == &h2); + } + } + } endResetModel(); } @@ -97,7 +112,7 @@ QModelIndex DocumentOutlineModel::parent(const QModelIndex &child) const return QModelIndex(); return createIndex( - parent - parent->parent->children.data(), + parent->index, 0, reinterpret_cast(parent)); } -- cgit v1.2.3