Salome HOME
Updated copyright comment
[modules/gui.git] / src / QDS / QDS_TextEdit.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 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 GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "QDS_TextEdit.h"
24
25 #include <QTextEdit>
26
27 /*
28   \class QDS_TextEdit
29   \brief Datum with control corresponding to the text edit. 
30
31   User can enter parameter value in multi line editor.
32 */
33
34 /*!
35   \brief Constructor. 
36
37   Create combobox datum object with datum identifier \a id 
38   and parent widget \a parent. 
39
40   Parameter \a flags defines behaviour of datum and set of created
41   subwidgets. Default value of this parameter is QDS::All.
42
43   Parameter \a comp specifies the component name which will be used
44   when searching the dictionary item.
45
46   \param id datum identifier
47   \param parent parent widget
48   \param flags datum flags
49   \param comp component
50 */
51 QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
52 : QDS_Datum( id, parent, flags, comp )
53 {
54 }
55
56 /*!
57   \brief Destructor.
58 */
59 QDS_TextEdit::~QDS_TextEdit()
60 {
61 }
62
63 /*!
64   \brief Get string value from datum.
65   \return datum string value
66 */
67 QString QDS_TextEdit::getString() const
68 {
69   QString res;
70   if ( textEdit() )
71     res = textEdit()->toPlainText();
72   return res;
73 }
74
75 /*!
76   \brief Set string value to datum.
77   \param txt new datum string value
78 */
79 void QDS_TextEdit::setString( const QString& txt )
80 {
81   if ( textEdit() )
82     textEdit()->setText( txt );
83 }
84
85 /*!
86   \brief Get text edit widget.
87   \return internaltext edit widget
88 */
89 QTextEdit* QDS_TextEdit::textEdit() const
90 {
91   return ::qobject_cast<QTextEdit*>( controlWidget() );
92 }
93
94 /*!
95   \brief Create text edit widget as control subwidget.
96   \param parent parent widget
97   \return created text edit widget
98 */
99 QWidget* QDS_TextEdit::createControl( QWidget* parent )
100 {
101   QTextEdit* te = new QTextEdit( parent );
102   connect( te, SIGNAL( textChanged() ), this, SLOT( onTextChanged() ) );
103   return te;
104 }
105
106 /*!
107   \brief Called when text is changed by the user.
108
109   Notify about text changing in text edit.
110 */
111 void QDS_TextEdit::onTextChanged()
112 {
113   invalidateCache();
114
115   onParamChanged();
116
117   QString str = getString();
118
119   emit paramChanged();
120   emit paramChanged( str );
121 }
122
123 /*!
124   \fn void QDS_TextEdit::returnPressed();
125   \brief The signal is emitted when user presses \c Enter key in the text edit.
126 */