kalzium
kalziumnumerationtype.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License * 00015 * along with this program; if not, write to the * 00016 * Free Software Foundation, Inc., * 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00018 ***************************************************************************/ 00019 00020 #include "kalziumnumerationtype.h" 00021 00022 #include "kalziumdataobject.h" 00023 #include "kalziumtabletype.h" 00024 00025 #include <klocale.h> 00026 00027 KalziumNumerationTypeFactory::KalziumNumerationTypeFactory() 00028 { 00029 m_numerations << KalziumNoneNumerationType::instance(); 00030 m_numerations << KalziumIUPACNumerationType::instance(); 00031 m_numerations << KalziumCASNumerationType::instance(); 00032 m_numerations << KalziumOldIUPACNumerationType::instance(); 00033 } 00034 00035 KalziumNumerationTypeFactory* KalziumNumerationTypeFactory::instance() 00036 { 00037 static KalziumNumerationTypeFactory kntf; 00038 return &kntf; 00039 } 00040 00041 KalziumNumerationType* KalziumNumerationTypeFactory::build( int id ) const 00042 { 00043 if ( ( id < 0 ) || ( id >= m_numerations.count() ) ) 00044 return 0; 00045 00046 return m_numerations.at( id ); 00047 } 00048 00049 KalziumNumerationType* KalziumNumerationTypeFactory::build( const QByteArray& id ) const 00050 { 00051 for ( int i = 0; i < m_numerations.count(); i++ ) 00052 { 00053 if ( m_numerations.at( i )->name() == id ) 00054 return m_numerations.at( i ); 00055 } 00056 00057 // not found 00058 return 0; 00059 } 00060 00061 QStringList KalziumNumerationTypeFactory::numerations() const 00062 { 00063 QStringList l; 00064 for ( int i = 0; i < m_numerations.count(); i++ ) 00065 { 00066 l << m_numerations.at( i )->description(); 00067 } 00068 return l; 00069 } 00070 00071 00072 KalziumNumerationType* KalziumNumerationType::instance() 00073 { 00074 return 0; 00075 } 00076 00077 KalziumNumerationType::KalziumNumerationType() 00078 { 00079 } 00080 00081 KalziumNumerationType::~KalziumNumerationType() 00082 { 00083 } 00084 00085 QString KalziumNumerationType::item( const int num ) const 00086 { 00087 if ( ( num < 0 ) || ( num >= m_items.count() ) ) 00088 return QString(); 00089 00090 return m_items.at( num ); 00091 } 00092 00093 QStringList KalziumNumerationType::items() const 00094 { 00095 return m_items; 00096 } 00097 00098 00099 KalziumNoneNumerationType* KalziumNoneNumerationType::instance() 00100 { 00101 static KalziumNoneNumerationType knnt; 00102 return &knnt; 00103 } 00104 00105 KalziumNoneNumerationType::KalziumNoneNumerationType() 00106 : KalziumNumerationType() 00107 { 00108 } 00109 00110 QByteArray KalziumNoneNumerationType::name() const 00111 { 00112 return "None"; 00113 } 00114 00115 QString KalziumNoneNumerationType::description() const 00116 { 00117 return i18n( "No Numeration" ); 00118 } 00119 00120 QString KalziumNoneNumerationType::item( const int num ) const 00121 { 00122 Q_UNUSED( num ); 00123 return QString(); 00124 } 00125 00126 QStringList KalziumNoneNumerationType::items() const 00127 { 00128 return QStringList(); 00129 } 00130 00131 KalziumIUPACNumerationType* KalziumIUPACNumerationType::instance() 00132 { 00133 static KalziumIUPACNumerationType kint; 00134 return &kint; 00135 } 00136 00137 KalziumIUPACNumerationType::KalziumIUPACNumerationType() 00138 : KalziumNumerationType() 00139 { 00140 // cache them 00141 m_items << QString( "1" ); 00142 m_items << QString( "2" ); 00143 m_items << QString( "3" ); 00144 m_items << QString( "4" ); 00145 m_items << QString( "5" ); 00146 m_items << QString( "6" ); 00147 m_items << QString( "7" ); 00148 m_items << QString( "8" ); 00149 m_items << QString( "9" ); 00150 m_items << QString( "10" ); 00151 m_items << QString( "11" ); 00152 m_items << QString( "12" ); 00153 m_items << QString( "13" ); 00154 m_items << QString( "14" ); 00155 m_items << QString( "15" ); 00156 m_items << QString( "16" ); 00157 m_items << QString( "17" ); 00158 m_items << QString( "18" ); 00159 } 00160 00161 QByteArray KalziumIUPACNumerationType::name() const 00162 { 00163 return "IUPAC"; 00164 } 00165 00166 QString KalziumIUPACNumerationType::description() const 00167 { 00168 return i18n( "IUPAC" ); 00169 } 00170 00171 KalziumCASNumerationType* KalziumCASNumerationType::instance() 00172 { 00173 static KalziumCASNumerationType kcnt; 00174 return &kcnt; 00175 } 00176 00177 KalziumCASNumerationType::KalziumCASNumerationType() 00178 : KalziumNumerationType() 00179 { 00180 // cache them 00181 m_items << QString( "IA" ); 00182 m_items << QString( "IIA" ); 00183 m_items << QString( "IIIB" ); 00184 m_items << QString( "IVB" ); 00185 m_items << QString( "VB" ); 00186 m_items << QString( "VIB" ); 00187 m_items << QString( "VIIB" ); 00188 m_items << QString( "VIII" ); 00189 m_items << QString( "VIII" ); 00190 m_items << QString( "VIII" ); 00191 m_items << QString( "IB" ); 00192 m_items << QString( "IIB" ); 00193 m_items << QString( "IIIA" ); 00194 m_items << QString( "IVA" ); 00195 m_items << QString( "VA" ); 00196 m_items << QString( "VIA" ); 00197 m_items << QString( "VIIA" ); 00198 m_items << QString( "VIIIA" ); 00199 } 00200 00201 QByteArray KalziumCASNumerationType::name() const 00202 { 00203 return "CAS"; 00204 } 00205 00206 QString KalziumCASNumerationType::description() const 00207 { 00208 return i18n( "CAS" ); 00209 } 00210 00211 KalziumOldIUPACNumerationType* KalziumOldIUPACNumerationType::instance() 00212 { 00213 static KalziumOldIUPACNumerationType koint; 00214 return &koint; 00215 } 00216 00217 KalziumOldIUPACNumerationType::KalziumOldIUPACNumerationType() 00218 : KalziumNumerationType() 00219 { 00220 // cache them 00221 m_items << QString( "1A" ); 00222 m_items << QString( "2A" ); 00223 m_items << QString( "3A" ); 00224 m_items << QString( "4A" ); 00225 m_items << QString( "5A" ); 00226 m_items << QString( "6A" ); 00227 m_items << QString( "7A" ); 00228 m_items << QString( "8" ); 00229 m_items << QString( "8" ); 00230 m_items << QString( "8" ); 00231 m_items << QString( "1B" ); 00232 m_items << QString( "2B" ); 00233 m_items << QString( "3B" ); 00234 m_items << QString( "4B" ); 00235 m_items << QString( "5B" ); 00236 m_items << QString( "6B" ); 00237 m_items << QString( "7B" ); 00238 m_items << QString( "0" ); 00239 } 00240 00241 QByteArray KalziumOldIUPACNumerationType::name() const 00242 { 00243 return "OldIUPAC"; 00244 } 00245 00246 QString KalziumOldIUPACNumerationType::description() const 00247 { 00248 return i18n( "Old IUPAC" ); 00249 }
KDE 4.0 API Reference