1 /* 2 outline_tree_presenter.cpp 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_PRESENTER_H 20 #define M8RUI_OUTLINE_TREE_PRESENTER_H 21 22 #include <set> 23 24 #include "../../lib/src/model/outline.h" 25 #include "../../lib/src/mind/mind.h" 26 27 #include <QtWidgets> 28 29 #include "orloj_presenter.h" 30 #include "outline_tree_view.h" 31 #include "outline_tree_model.h" 32 33 namespace m8r { 34 35 class OrlojPresenter; 36 37 class OutlineTreePresenter : public QObject 38 { 39 Q_OBJECT 40 41 public: 42 static const int NO_ROW = -1; 43 44 private: 45 OutlineTreeView* view; 46 OutlineTreeModel* model; 47 48 Mind* mind; 49 50 public: 51 explicit OutlineTreePresenter(OutlineTreeView* view, MainWindowPresenter* mwp, QObject* parent); 52 OutlineTreePresenter(const OutlineTreePresenter&) = delete; 53 OutlineTreePresenter(const OutlineTreePresenter&&) = delete; 54 OutlineTreePresenter &operator=(const OutlineTreePresenter&) = delete; 55 OutlineTreePresenter &operator=(const OutlineTreePresenter&&) = delete; 56 getView()57 OutlineTreeView* getView() const { return view; } getModel()58 OutlineTreeModel* getModel() const { return model; } 59 60 void refresh(Outline* outline, Outline::Patch* patch=nullptr); 61 void refresh(Note* note); 62 void insertAndSelect(Note* note); 63 64 void clearSelection(); focus()65 void focus() { view->setFocus(); } 66 void selectRowByNote(const Note* note); 67 68 int getCurrentRow() const; 69 Note* getCurrentNote() const; 70 71 ~OutlineTreePresenter(); 72 73 public slots: 74 void slotSelectNextRow(); 75 void slotSelectPreviousRow(); 76 }; 77 78 } 79 #endif // M8RUI_OUTLINE_TREE_PRESENTER_H 80