Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLTextWidget.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16  and was supported through CANARIE's Research Software Program, and Cancer
17  Care Ontario.
18 
19 ==============================================================================*/
20 
21 #ifndef __qMRMLTextWidget_h
22 #define __qMRMLTextWidget_h
23 
24 // Slicer includes
25 #include "qSlicerWidget.h"
26 
27 // Text widgets includes
28 #include "qSlicerTextsModuleWidgetsExport.h"
29 #include "ui_qMRMLTextWidget.h"
30 
31 class vtkMRMLNode;
32 class vtkMRMLTextNode;
33 class qMRMLTextWidgetPrivate;
34 class QTextEdit;
35 
37 class Q_SLICER_MODULE_TEXTS_WIDGETS_EXPORT qMRMLTextWidget : public qSlicerWidget
38 {
39  Q_OBJECT
40 
41 public:
43  qMRMLTextWidget(QWidget *parent=nullptr);
44  ~qMRMLTextWidget() override;
45 
46  Q_PROPERTY(bool autoSave READ isAutoSave WRITE setAutoSave);
47  Q_PROPERTY(bool editing READ isEditing);
48  Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly);
49  Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap);
50 
52  Q_INVOKABLE vtkMRMLTextNode* mrmlTextNode() const;
53  Q_INVOKABLE vtkMRMLNode* mrmlNode() const;
54 
58  bool isReadOnly();
59 
66  bool isAutoSave();
67 
69  bool isEditing();
70 
73  bool wordWrap();
74 
76  Q_INVOKABLE QTextEdit* textEditWidget();
77 
78 public slots:
80  void setMRMLScene(vtkMRMLScene* scene) override;
81 
85  void setReadOnly(bool readOnly);
86 
93  void setAutoSave(bool autoSave);
94 
97  void setWordWrap(bool wordWrap);
98 
101  void setMRMLTextNode(vtkMRMLTextNode* textNode);
102 
105  void setMRMLNode(vtkMRMLNode* textNode);
106 
107 public slots:
109  void startEdits();
110 
112  void cancelEdits();
113 
115  void saveEdits();
116 
117 signals:
120  void updateWidgetFromMRMLRequested();
121 
124  void updateMRMLFromWidgetRequested();
125 
128  void updateWidgetFromMRMLFinished();
129 
132  void updateMRMLFromWidgetFinished();
133 
136  void mrmlNodeChanged(vtkMRMLNode*);
137 
139  void readOnlyChanged(bool);
140 
142  bool autoSaveChanged(bool);
143 
145  void editingChanged(bool);
146 
147 protected slots:
149  void updateWidgetFromMRML();
150 
152  void updateMRMLFromWidget();
153 
155  void onTextNodeContentsModified();
156 
158  void onTextEditChanged();
159 
160 protected:
161  QScopedPointer<qMRMLTextWidgetPrivate> d_ptr;
162 
163  // Setup the UI and establish connections
164  virtual void setup();
165 
166 private:
167  Q_DECLARE_PRIVATE(qMRMLTextWidget);
168  Q_DISABLE_COPY(qMRMLTextWidget);
169 
170 protected:
171  bool AutoSave{false};
172  bool ReadOnly{false};
173 
174 };
175 
176 #endif
qSlicerWidget Superclass
void setMRMLScene(vtkMRMLScene *scene) override
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
QScopedPointer< qMRMLTextWidgetPrivate > d_ptr
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167