1 /*
2  status_bar_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_STATUS_BAR_PRESENTER_H
20 #define M8RUI_STATUS_BAR_PRESENTER_H
21 
22 #include "../../lib/src/mind/mind.h"
23 
24 #include <QtWidgets>
25 
26 #include "gear/qutils.h"
27 #include "status_bar_view.h"
28 
29 namespace m8r {
30 
31 class StatusBarPresenter : public QObject
32 {
33     Q_OBJECT
34 
35 private:
36     QString status;
37 
38     const StatusBarView* view;
39     Mind* mind;
40 
41 public:
42     StatusBarPresenter(const StatusBarView* view, Mind* mind);
43     StatusBarPresenter(const StatusBarPresenter&) = delete;
44     StatusBarPresenter(const StatusBarPresenter&&) = delete;
45     StatusBarPresenter &operator=(const StatusBarPresenter&) = delete;
46     StatusBarPresenter &operator=(const StatusBarPresenter&&) = delete;
47 
48     void showMindStatistics();
49 
showInfo(const char * message)50     void showInfo(const char* message) { showInfo(QString::fromUtf8(message)); }
showInfo(const std::string & message)51     void showInfo(const std::string& message) { showInfo(QString::fromStdString(message)); }
52     void showInfo(const QString& message);
showWarning(const char * message)53     void showWarning(const char* message) { showWarning(QString::fromUtf8(message)); }
showWarning(const std::string & message)54     void showWarning(const std::string& message) { showWarning(QString::fromStdString(message)); }
55     void showWarning(const QString& message);
showError(const char * message)56     void showError(const char* message) { showError(QString::fromUtf8(message)); }
showError(const std::string & message)57     void showError(const std::string& message) { showError(QString::fromStdString(message)); }
58     void showError(const QString& message);
59 
getView()60     const StatusBarView* getView() const { return view; }
61 
62 public slots:
slotShowInfo(QString message)63     void slotShowInfo(QString message) { showInfo(message); }
slotShowStatistics()64     void slotShowStatistics() { showMindStatistics(); }
65 };
66 
67 }
68 #endif // M8RUI_STATUS_BAR_PRESENTER_H
69