]> SALOME platform Git repositories - modules/gui.git/blob - src/QDS/QDS_TextEdit.cxx
Salome HOME
61ff1044deb6f937730b0d409f0e607b8d3398b3
[modules/gui.git] / src / QDS / QDS_TextEdit.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 #include "QDS_TextEdit.h"
23
24 #include <QTextEdit>
25
26 /*
27   \class QDS_TextEdit
28   \brief Datum with control corresponding to the text edit. 
29
30   User can enter parameter value in multi line editor.
31 */
32
33 /*!
34   \brief Constructor. 
35
36   Create combobox datum object with datum identifier \a id 
37   and parent widget \a parent. 
38
39   Parameter \a flags defines behaviour of datum and set of created
40   subwidgets. Default value of this parameter is QDS::All.
41
42   Parameter \a comp specifies the component name which will be used
43   when searching the dictionary item.
44
45   \param id datum identifier
46   \param parent parent widget
47   \param flags datum flags
48   \param comp component
49 */
50 QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
51 : QDS_Datum( id, parent, flags, comp )
52 {
53 }
54
55 /*!
56   \brief Destructor.
57 */
58 QDS_TextEdit::~QDS_TextEdit()
59 {
60 }
61
62 /*!
63   \brief Get string value from datum.
64   \return datum string value
65 */
66 QString QDS_TextEdit::getString() const
67 {
68   QString res;
69   if ( textEdit() )
70     res = textEdit()->toPlainText();
71   return res;
72 }
73
74 /*!
75   \brief Set string value to datum.
76   \param txt new datum string value
77 */
78 void QDS_TextEdit::setString( const QString& txt )
79 {
80   if ( textEdit() )
81     textEdit()->setText( txt );
82 }
83
84 /*!
85   \brief Get text edit widget.
86   \return internaltext edit widget
87 */
88 QTextEdit* QDS_TextEdit::textEdit() const
89 {
90   return ::qobject_cast<QTextEdit*>( controlWidget() );
91 }
92
93 /*!
94   \brief Create text edit widget as control subwidget.
95   \param parent parent widget
96   \return created text edit widget
97 */
98 QWidget* QDS_TextEdit::createControl( QWidget* parent )
99 {
100   QTextEdit* te = new QTextEdit( parent );
101   connect( te, SIGNAL( textChanged() ), this, SLOT( onTextChanged() ) );
102   return te;
103 }
104
105 /*!
106   \brief Called when text is changed by the user.
107
108   Notify about text changing in text edit.
109 */
110 void QDS_TextEdit::onTextChanged()
111 {
112   invalidateCache();
113
114   onParamChanged();
115
116   QString str = getString();
117
118   emit paramChanged();
119   emit paramChanged( str );
120 }
121
122 /*!
123   \fn void QDS_TextEdit::returnPressed();
124   \brief The signal is emitted when user presses \c Enter key in the text edit.
125 */