Back to index

salome-gui  6.5.0
QDS_TextEdit.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "QDS_TextEdit.h"
00024 
00025 #include <QTextEdit>
00026 
00027 /*
00028   \class QDS_TextEdit
00029   \brief Datum with control corresponding to the text edit. 
00030 
00031   User can enter parameter value in multi line editor.
00032 */
00033 
00051 QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
00052 : QDS_Datum( id, parent, flags, comp )
00053 {
00054 }
00055 
00059 QDS_TextEdit::~QDS_TextEdit()
00060 {
00061 }
00062 
00067 QString QDS_TextEdit::getString() const
00068 {
00069   QString res;
00070   if ( textEdit() )
00071     res = textEdit()->toPlainText();
00072   return res;
00073 }
00074 
00079 void QDS_TextEdit::setString( const QString& txt )
00080 {
00081   if ( textEdit() )
00082     textEdit()->setText( txt );
00083 }
00084 
00089 QTextEdit* QDS_TextEdit::textEdit() const
00090 {
00091   return ::qobject_cast<QTextEdit*>( controlWidget() );
00092 }
00093 
00099 QWidget* QDS_TextEdit::createControl( QWidget* parent )
00100 {
00101   QTextEdit* te = new QTextEdit( parent );
00102   connect( te, SIGNAL( textChanged() ), this, SLOT( onTextChanged() ) );
00103   return te;
00104 }
00105 
00111 void QDS_TextEdit::onTextChanged()
00112 {
00113   invalidateCache();
00114 
00115   onParamChanged();
00116 
00117   QString str = getString();
00118 
00119   emit paramChanged();
00120   emit paramChanged( str );
00121 }
00122