Salome HOME
b3c50c56ce16ec09610180ef399a61c56ab6cbb5
[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/
18 //
19 #include "QDS_TextEdit.h"
20
21 #include <qtextedit.h>
22
23 /*!
24   Constructor.
25 */
26 QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
27 : QDS_Datum( id, parent, flags, comp )
28 {
29 }
30
31 /*!
32   Destructor.
33 */
34 QDS_TextEdit::~QDS_TextEdit()
35 {
36 }
37
38 /*!
39   Returns string from QTextEdit widget.
40 */
41 QString QDS_TextEdit::getString() const
42 {
43   QString res;
44   if ( textEdit() )
45     res = textEdit()->text();
46   return res;
47 }
48
49 /*!
50   Sets the string into QTextEdit widget.
51 */
52 void QDS_TextEdit::setString( const QString& txt )
53 {
54   if ( textEdit() )
55     textEdit()->setText( txt );
56 }
57
58 /*!
59   Returns pointer to QTextEdit widget.
60 */
61 QTextEdit* QDS_TextEdit::textEdit() const
62 {
63   return ::qt_cast<QTextEdit*>( controlWidget() );
64 }
65
66 /*!
67   Create QTextEdit widget as control subwidget.
68 */
69 QWidget* QDS_TextEdit::createControl( QWidget* parent )
70 {
71   QTextEdit* te = new QTextEdit( parent );
72   connect( te, SIGNAL( textChanged() ), this, SLOT( onTextChanged() ) );
73   return te;
74 }
75
76 /*!
77   Notify about text changing in line edit.
78 */
79 void QDS_TextEdit::onTextChanged()
80 {
81   invalidateCache();
82
83   onParamChanged();
84
85   QString str = getString();
86
87   emit paramChanged();
88   emit paramChanged( str );
89 }