1 /*
2  outline_header_edit_presenter.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_HEADER_EDIT_PRESENTER_H
20 #define M8RUI_OUTLINE_HEADER_EDIT_PRESENTER_H
21 
22 #include "../../lib/src/model/outline.h"
23 #include "../../lib/src/representations/markdown/markdown_outline_representation.h"
24 
25 #include "main_window_presenter.h"
26 #include "outline_header_edit_view.h"
27 #include "dialogs/outline_header_edit_dialog.h"
28 
29 #include <QtWidgets>
30 
31 namespace m8r {
32 
33 class OutlineHeaderEditPresenter : public QObject
34 {
35     Q_OBJECT
36 
37 private:
38     // IMPROVE to model
39     Outline* currentOutline;
40     Note* outlineHeader;
41 
42     OutlineHeaderEditView* view;
43     MainWindowPresenter* mwp;
44     OutlineHeaderEditDialog* outlineHeaderEditDialog;
45 
46 public:
47     explicit OutlineHeaderEditPresenter(OutlineHeaderEditView* view, MainWindowPresenter* mwp, QObject* parent);
48     OutlineHeaderEditPresenter(const OutlineHeaderEditPresenter&) = delete;
49     OutlineHeaderEditPresenter(const OutlineHeaderEditPresenter&&) = delete;
50     OutlineHeaderEditPresenter &operator=(const OutlineHeaderEditPresenter&) = delete;
51     OutlineHeaderEditPresenter &operator=(const OutlineHeaderEditPresenter&&) = delete;
52     ~OutlineHeaderEditPresenter();
53 
getView()54     OutlineHeaderEditView* getView() { return view; }
55 
56     void setOutline(Outline* outline);
getCurrentOutline()57     Outline* getCurrentOutline() const { return currentOutline; }
getSelectedText()58     QString getSelectedText() const { return view->getSelectedText(); }
59 
getRelevantWords()60     QString getRelevantWords() const { return view->getHeaderEditor()->getRelevantWords(); }
getHitCounter()61     int getHitCounter() const { return view->getHeaderEditor()->getHitCounter(); }
clearHitCounter()62     void clearHitCounter() { return view->getHeaderEditor()->clearHitCounter(); }
63 
64 private slots:
65     void slotKeyPressed();
66 
67 public slots:
68     void slotSaveAndCloseEditor();
69     void slotCloseEditor();
70     void slotSaveOutlineHeader();
71 };
72 
73 }
74 #endif // M8RUI_OUTLINE_HEADER_EDIT_PRESENTER_H
75