1 /* 2 outline_tree_model.h MindForger thinking notebook 3 4 Copyright (C) 2016-2020 Martin Dvorak <martin.dvorak@mindforger.com> 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef M8RUI_OUTLINE_TREE_MODEL_H 20 #define M8RUI_OUTLINE_TREE_MODEL_H 21 22 #include <string> 23 24 #include <QtWidgets> 25 26 #include "../../lib/src/model/note.h" 27 #include "../../lib/src/representations/html/html_outline_representation.h" 28 29 #include "notes_table_model.h" 30 #include "gear/qutils.h" 31 32 namespace m8r { 33 34 class OutlineTreeModel : public QStandardItemModel 35 { 36 Q_OBJECT 37 38 private: 39 HtmlOutlineRepresentation* htmlRepresentation; 40 QList<QModelIndex> noselection; 41 42 public: 43 OutlineTreeModel(QObject *parent, HtmlOutlineRepresentation* htmlRepresentation); 44 OutlineTreeModel(const OutlineTreeModel&) = delete; 45 OutlineTreeModel(const OutlineTreeModel&&) = delete; 46 OutlineTreeModel &operator=(const OutlineTreeModel&) = delete; 47 OutlineTreeModel &operator=(const OutlineTreeModel&&) = delete; 48 49 void removeAllRows(); 50 void addNote(Note* note); 51 int insertNote(Note* note); 52 int getRowByNote(const Note* note); refresh(Note * note)53 void refresh(Note* note) { refresh(note, noselection); } 54 void refresh(Note* note, int row, bool set=false); 55 void refresh(Note* note, QModelIndexList selection); 56 57 private: 58 void createNameText(std::string& name, Note* note); 59 void createRowFor(Note* note, QList<QStandardItem*>& rowItems); 60 }; 61 62 } 63 64 #endif // M8RUI_OUTLINE_TREE_MODEL_H 65