File indexing completed on 2025-04-20 03:29:05
0001 /* 0002 SPDX-FileCopyrightText: 2005, 2006 Carsten Niehaus <cniehaus@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KALZIUMDATAOBJECT_H 0008 #define KALZIUMDATAOBJECT_H 0009 0010 #include <QHash> 0011 #include <QPixmap> 0012 #include <element.h> 0013 0014 class Search; 0015 class Isotope; 0016 class Spectrum; 0017 /** 0018 * @brief This class contains all Element objects 0019 * 0020 * This singleton class collects all the information about the elements of the 0021 * Periodic Table as list of Element. 0022 * 0023 * Use: 0024 * @code 0025 * KalziumDataObject::instance()->ElementList; 0026 * @endcode 0027 * to get the whole list of Element, while a 0028 * @code 0029 * KalziumDataObject::instance()->element(num); 0030 * @endcode 0031 * will return you the pointer to the num'th element of the Periodic Table. 0032 * 0033 * @author Carsten Niehaus 0034 */ 0035 class KalziumDataObject 0036 { 0037 public: 0038 /** 0039 * @return the instance of this class 0040 */ 0041 static KalziumDataObject *instance(); 0042 0043 /** 0044 * The list of elements 0045 */ 0046 QList<Element *> ElementList; 0047 0048 /** 0049 * Set the main Search to @p srch 0050 */ 0051 void setSearch(Search *srch); 0052 0053 /** 0054 * @return the main Search 0055 */ 0056 Search *search() const; 0057 0058 /** 0059 * @return the Element with the number @p number 0060 * @param number the number of the Element which will be returned 0061 */ 0062 Element *element(int number); 0063 0064 /** 0065 * retunrs the unit symbol from the given KUnitConversion UnitId. 0066 * @param unit KUnitConversion UnitId 0067 * @return unit symbol as string. 0068 */ 0069 QString unitAsString(const int unit) const; 0070 0071 /** 0072 * @return the isotopes of the Element with the number @p number 0073 */ 0074 QList<Isotope *> isotopes(int number); 0075 0076 /** 0077 * @return the isotopes of the Element @p Element 0078 */ 0079 QList<Isotope *> isotopes(Element *element); 0080 0081 /** 0082 * @return the Spectrum of the Element with the number @p number 0083 */ 0084 Spectrum *spectrum(int number); 0085 0086 QPixmap pixmap(int number); 0087 0088 /** 0089 * Use this to get the number of elements we have. It is cached 0090 * so you are strongly suggested to use this instead of hardcode 0091 * the number of elements. 0092 * @return the number of elements we have 0093 */ 0094 int numberOfElements() const 0095 { 0096 return m_numOfElements; 0097 } 0098 0099 private: 0100 KalziumDataObject(); 0101 ~KalziumDataObject(); 0102 0103 static void cleanup(); 0104 0105 void loadIconSet(); 0106 void cleanPixmaps(); 0107 0108 QList<QPixmap> PixmapList; 0109 0110 QHash<int, QList<Isotope *>> m_isotopes; 0111 QList<Spectrum *> m_spectra; 0112 0113 /** 0114 * Caching the number of elements 0115 */ 0116 int m_numOfElements; 0117 0118 Search *m_search = nullptr; 0119 0120 friend struct StaticKalziumDataObject; 0121 }; 0122 0123 #endif // KALZIUMDATAOBJECT_H