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 00040 #include "OSGQFieldLabelFactory.h" 00041 #include "OSGQFieldView_qt.h" 00042 00043 #include "OSGQFieldValueLabel.h" 00044 00045 OSG_USING_NAMESPACE 00046 00047 #ifdef __sgi 00048 #pragma set woff 1174 00049 #endif 00050 00051 namespace 00052 { 00053 static Char8 cvsid_cpp[] = "@(#)$Id: OSGQFieldLabelFactory.cpp,v 1.1 2003/05/07 14:03:40 neumannc Exp $"; 00054 static Char8 cvsid_hpp[] = OSGQFIELDLABELFACTORY_HEADER_CVSID; 00055 static Char8 cvsid_inl[] = OSGQFIELDLABELFACTORY_INLINE_CVSID; 00056 } 00057 00058 #ifdef __sgi 00059 #pragma reset woff 1174 00060 #endif 00061 00062 QFieldLabelFactory *QFieldLabelFactory::_the = 0; 00063 00064 QFieldLabelFactory::~QFieldLabelFactory(void) 00065 { 00066 } 00067 00068 QFieldLabelFactory & 00069 QFieldLabelFactory::the(void) 00070 { 00071 if(!_the) 00072 _the = new QFieldLabelFactory; 00073 00074 return *_the; 00075 } 00076 00077 bool 00078 QFieldLabelFactory::registerLabel(const std::string &strFieldContentName, 00079 LabelCreateF labelCreateFunc ) 00080 { 00081 _labelMap[strFieldContentName] = labelCreateFunc; 00082 00083 return true; 00084 } 00085 00086 QFieldValueLabelBase * 00087 QFieldLabelFactory::createLabel(QFieldViewBase *pView, UInt32 uiIndex) 00088 { 00089 const Char8 *szContentTypeName = 00090 pView->getFieldPtr()->getContentType().getCName(); 00091 00092 LabelMapIt iter = _labelMap.find(szContentTypeName); 00093 00094 if(iter != _labelMap.end()) 00095 { 00096 return (*iter).second(pView, uiIndex); 00097 } 00098 else 00099 { 00100 return _defaultLabelCreateFunc(pView, uiIndex); 00101 } 00102 } 00103 00104 QFieldLabelFactory::QFieldLabelFactory(void) 00105 : _labelMap ( ), 00106 _defaultLabelCreateFunc(&QGenericFieldValueLabel::create) 00107 { 00108 } 00109
1.5.5