Debian Codegraph @

src/Gui/TextDocumentEditorView.h

raw
1 /***************************************************************************
2 * Copyright (c) 2017 Markus Hovorka <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library 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 Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_TEXTDOCUMENTEDITORVIEW_H
24 #define GUI_TEXTDOCUMENTEDITORVIEW_H
25
26 #include <QPlainTextEdit>
27
28 #include <App/TextDocument.h>
29 #include <Gui/MDIView.h>
30
31
32 namespace Gui
33 {
34
35 class GuiExport TextDocumentEditorView: public MDIView
36 {
37 Q_OBJECT
38 Q_DISABLE_COPY_MOVE(TextDocumentEditorView)
39 TYPESYSTEM_HEADER_WITH_OVERRIDE(); // NOLINT
40
41 public:
42 TextDocumentEditorView(App::TextDocument* textDocument, QPlainTextEdit* editor, QWidget* parent);
43 ~TextDocumentEditorView() override;
44 const char* getName() const override
45 {
46 return "TextDocumentEditorView";
47 }
48 bool onMsg(const char* msg, const char** output) override;
49 bool onHasMsg(const char* msg) const override;
50
51 QPlainTextEdit* getEditor() const
52 {
53 return editor;
54 }
55 App::TextDocument* getTextObject() const
56 {
57 return textDocument;
58 }
59 QStringList undoActions() const override;
60 QStringList redoActions() const override;
61
62 protected:
63 void showEvent(QShowEvent* event) override;
64 void closeEvent(QCloseEvent* event) override;
65
66 private:
67 void setupEditor();
68 void setupConnection();
69 void saveToObject();
70 void sourceChanged();
71 void textChanged();
72 void labelChanged();
73 void refresh();
74
75 private:
76 QPlainTextEdit* const editor;
77 App::TextDocument* const textDocument;
78 boost::signals2::connection textConnection;
79 boost::signals2::connection labelConnection;
80 bool aboutToClose = false;
81 };
82
83 } // namespace Gui
84
85 #endif