Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
30class vtkMRMLNode;
31class vtkMRMLTextNode;
32class qMRMLTextWidgetPrivate;
33class QTextEdit;
34
35class Q_SLICER_MODULE_TEXTS_WIDGETS_EXPORT qMRMLTextWidget : public qSlicerWidget
36{
37 Q_OBJECT
38
39public:
41 qMRMLTextWidget(QWidget *parent=nullptr);
42 ~qMRMLTextWidget() override;
43
44 Q_PROPERTY(bool autoSave READ isAutoSave WRITE setAutoSave);
45 Q_PROPERTY(bool editing READ isEditing);
46 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly);
47 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap);
48
50 Q_INVOKABLE vtkMRMLTextNode* mrmlTextNode() const;
51 Q_INVOKABLE vtkMRMLNode* mrmlNode() const;
52
56 bool isReadOnly();
57
64 bool isAutoSave();
65
67 bool isEditing();
68
71 bool wordWrap();
72
74 Q_INVOKABLE QTextEdit* textEditWidget();
75
76public slots:
78 void setMRMLScene(vtkMRMLScene* scene) override;
79
84
92
96
100
103 void setMRMLNode(vtkMRMLNode* textNode);
104
105public slots:
108
111
113 void saveEdits();
114
115signals:
119
123
127
131
135
137 void readOnlyChanged(bool);
138
140 bool autoSaveChanged(bool);
141
143 void editingChanged(bool);
144
145protected slots:
148
151
154
157
158protected:
159 QScopedPointer<qMRMLTextWidgetPrivate> d_ptr;
160
161 // Setup the UI and establish connections
162 virtual void setup();
163
164private:
165 Q_DECLARE_PRIVATE(qMRMLTextWidget);
166 Q_DISABLE_COPY(qMRMLTextWidget);
167
168protected:
169 bool AutoSave{false};
170 bool ReadOnly{false};
171
172};
173
174#endif
void saveEdits()
Finish editing, saving edited contents to the text node.
void editingChanged(bool)
This signal is emitted when the user starts/stops the widget edit mode.
qSlicerWidget Superclass
void updateWidgetFromMRMLRequested()
void mrmlNodeChanged(vtkMRMLNode *)
void setReadOnly(bool readOnly)
void updateMRMLFromWidget()
Update the MRML node to reflect the currently state of the GUI.
void readOnlyChanged(bool)
This signal is emitted if the read only property is changed.
bool autoSaveChanged(bool)
This signal is emitted if the autoSave property is changed.
virtual void setup()
void setMRMLNode(vtkMRMLNode *textNode)
void updateMRMLFromWidgetFinished()
Q_INVOKABLE vtkMRMLTextNode * mrmlTextNode() const
Get the text node.
QScopedPointer< qMRMLTextWidgetPrivate > d_ptr
void startEdits()
Start editing mode.
void setWordWrap(bool wordWrap)
~qMRMLTextWidget() override
void cancelEdits()
Finish editing, discarding all changes.
qMRMLTextWidget(QWidget *parent=nullptr)
Q_INVOKABLE vtkMRMLNode * mrmlNode() const
void updateWidgetFromMRML()
Update the GUI to reflect the currently selected text node.
void updateWidgetFromMRMLFinished()
void setAutoSave(bool autoSave)
void updateMRMLFromWidgetRequested()
void setMRMLScene(vtkMRMLScene *scene) override
Reimplemented from qSlicerWidget.
Q_INVOKABLE QTextEdit * textEditWidget()
Returns the internal text editor widget to allow low-level access and customization.
void onTextNodeContentsModified()
Method invoked when the contents of the text node is modified.
void setMRMLTextNode(vtkMRMLTextNode *textNode)
void onTextEditChanged()
Method invoked when the contents of the text edit is changed.
bool isEditing()
Returns true if the text box is in edit mode.
qSlicerWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.