Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGQFieldEditor_qt.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #include "OSGQFieldEditor_qt.h"
00040 
00041 #include "OSGQFieldView_qt.h"
00042 
00043 #include <qlineedit.h>
00044 #include <qevent.h>
00045 
00046 OSG_USING_NAMESPACE
00047 
00048 #ifdef __sgi
00049 #pragma set woff 1174
00050 #endif
00051 
00052 namespace
00053 {
00054     static Char8 cvsid_cpp[] = "@(#)$Id: OSGQFieldEditor_qt.cpp,v 1.1 2003/05/07 14:03:40 neumannc Exp $";
00055     static Char8 cvsid_hpp[] = OSGQFIELDEDITOR_HEADER_CVSID;
00056     static Char8 cvsid_inl[] = OSGQFIELDEDITOR_INLINE_CVSID;
00057 }
00058 
00059 #ifdef __sgi
00060 #pragma reset woff 1174
00061 #endif
00062 
00063 QFieldEditorBase::QFieldEditorBase(      QFieldViewBase *pView,
00064                                    const char           *name  )
00065     : Inherited(pView, name),
00066       _pView   (pView      ),
00067       _uiIndex (0          ),
00068       _bActive (false      )
00069 {
00070 }
00071 
00072 QFieldEditorBase::QFieldEditorBase(UInt32          uiIndex,
00073                                    QFieldViewBase *pView,   const char *name)
00074     : Inherited(pView, name),
00075       _pView   (pView      ),
00076       _uiIndex (uiIndex    ),
00077       _bActive (false      )
00078 {
00079 }
00080 
00081 QFieldEditorBase::~QFieldEditorBase(void)
00082 {
00083 }
00084 
00085 void
00086 QFieldEditorBase::activate(void)
00087 {
00088     _bActive = true;
00089 
00090     show();
00091 }
00092 
00093 void
00094 QFieldEditorBase::deactivate(void)
00095 {
00096     hide();
00097 
00098     _bActive = false;
00099 }
00100 
00101 void
00102 QFieldEditorBase::setIndex(UInt32 uiIndex)
00103 {
00104     _uiIndex = uiIndex;
00105 }
00106 
00107 //
00108 // QGenericFieldEditor
00109 //
00110 
00111 QGenericFieldEditor::QGenericFieldEditor(      QFieldViewBase *pView,
00112                                          const char           *name  )
00113     : Inherited(pView, name)
00114 {
00115     _pLineEdit = new QLineEdit(this, "QGenericFieldEditor::_pLineEdit");
00116 
00117     connect(_pLineEdit, SIGNAL(returnPressed  (void)),
00118             this,       SLOT  (onReturnPressed(void)));
00119 
00120     hide();
00121 }
00122 
00123 QGenericFieldEditor::QGenericFieldEditor(      UInt32          uiIndex,
00124                                                QFieldViewBase *pView, 
00125                                          const char           *name    )
00126     : Inherited(uiIndex, pView, name)
00127 {
00128     _pLineEdit = new QLineEdit(this, "QGenericFieldEditor::_pLineEdit");
00129 
00130     connect(_pLineEdit, SIGNAL(returnPressed  (void)),
00131             this,       SLOT  (onReturnPressed(void)));
00132 
00133     hide();
00134 }
00135 
00136 QGenericFieldEditor::~QGenericFieldEditor(void)
00137 {
00138 }
00139 
00140 void
00141 QGenericFieldEditor::updateField(void)
00142 {
00143     // TODO: fix for MFields
00144 
00145     getFieldPtr()->pushValueByStr(_pLineEdit->text().latin1());
00146 
00147     emit fieldUpdated(getIndex());
00148 }
00149 
00150 void
00151 QGenericFieldEditor::updateEditor(void)
00152 {
00153     std::string strTmpVal;
00154 
00155     getFieldPtr()->getValueByStr(strTmpVal, getIndex());
00156 
00157     _pLineEdit->setText(QString(strTmpVal.c_str()));
00158 }
00159 
00160 void
00161 QGenericFieldEditor::activate(void)
00162 {
00163     Inherited::activate();
00164 
00165     updateEditor();
00166 
00167     _pLineEdit->setActiveWindow();
00168     _pLineEdit->setFocus();
00169 }
00170 
00171 void
00172 QGenericFieldEditor::deactivate(void)
00173 {
00174     updateField();
00175 
00176     Inherited::deactivate();
00177 }
00178 
00179 void
00180 QGenericFieldEditor::resizeEvent(QResizeEvent *pEvent)
00181 {
00182     _pLineEdit->resize(pEvent->size());
00183 }
00184 
00185 void
00186 QGenericFieldEditor::onReturnPressed(void)
00187 {
00188     emit editorDone();
00189 }
00190 
00191 
00192 #include "OSGQFieldEditor_qt_moc.cpp"

Generated on Thu Aug 25 04:08:59 2005 for OpenSG by  doxygen 1.4.3