Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / QDS / QDS_TextEdit.cxx
1 // Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "QDS_TextEdit.h"
20
21 #include <qtextedit.h>
22
23 /*
24   \class QDS_TextEdit
25
26   Datum with control corresponding to text edit. User can enter parameter value in multiple line editor.
27 */
28
29 /*!
30   Constructor. Create text edit datum object with datum identifier \aid under widget \aparent.
31   Parameter \aflags define behaviour of datum and set of created subwidgets. Default value of this
32   parameter is QDS::All. Parameter \acomp specify the component name which will be used during search
33   of dictionary item.
34 */
35 QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
36 : QDS_Datum( id, parent, flags, comp )
37 {
38 }
39
40 /*!
41   Destructor.
42 */
43 QDS_TextEdit::~QDS_TextEdit()
44 {
45 }
46
47 /*!
48   Returns string from QTextEdit widget. Reimplemented from QDS_Datum.
49 */
50 QString QDS_TextEdit::getString() const
51 {
52   QString res;
53   if ( textEdit() )
54     res = textEdit()->text();
55   return res;
56 }
57
58 /*!
59   Sets the string into QTextEdit widget. Reimplemented from QDS_Datum.
60 */
61 void QDS_TextEdit::setString( const QString& txt )
62 {
63   if ( textEdit() )
64     textEdit()->setText( txt );
65 }
66
67 /*!
68   Returns pointer to QTextEdit widget.
69 */
70 QTextEdit* QDS_TextEdit::textEdit() const
71 {
72   return ::qt_cast<QTextEdit*>( controlWidget() );
73 }
74
75 /*!
76   Create QTextEdit widget as control subwidget.
77 */
78 QWidget* QDS_TextEdit::createControl( QWidget* parent )
79 {
80   QTextEdit* te = new QTextEdit( parent );
81   connect( te, SIGNAL( textChanged() ), this, SLOT( onTextChanged() ) );
82   return te;
83 }
84
85 /*!
86   Notify about text changing in text edit.
87 */
88 void QDS_TextEdit::onTextChanged()
89 {
90   invalidateCache();
91
92   onParamChanged();
93
94   QString str = getString();
95
96   emit paramChanged();
97   emit paramChanged( str );
98 }