00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #include "QmitkStringPropertyEditor.h" 00018 00019 QmitkStringPropertyEditor::QmitkStringPropertyEditor( mitk::StringProperty* property, QWidget* parent ) 00020 : QLineEdit( parent ), 00021 PropertyEditor( property ), 00022 m_StringProperty(property) 00023 { 00024 PropertyChanged(); 00025 connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); 00026 } 00027 00028 QmitkStringPropertyEditor::~QmitkStringPropertyEditor() 00029 { 00030 } 00031 00032 void QmitkStringPropertyEditor::PropertyChanged() 00033 { 00034 if ( m_Property ) 00035 setText( m_StringProperty->GetValue() ); 00036 } 00037 00038 void QmitkStringPropertyEditor::PropertyRemoved() 00039 { 00040 m_Property = NULL; 00041 m_StringProperty = NULL; 00042 setText("n/a"); 00043 } 00044 00045 void QmitkStringPropertyEditor::onTextChanged(const QString& text) 00046 { 00047 BeginModifyProperty(); // deregister from events 00048 00049 m_StringProperty->SetValue(text.toStdString()); 00050 00051 EndModifyProperty(); // again register for events 00052 } 00053