Changeset View
Changeset View
Standalone View
Standalone View
src/kalziumdataobject.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | Q_GLOBAL_STATIC(StaticKalziumDataObject, s_kdo) | 45 | Q_GLOBAL_STATIC(StaticKalziumDataObject, s_kdo) | ||
46 | 46 | | |||
47 | KalziumDataObject* KalziumDataObject::instance() | 47 | KalziumDataObject* KalziumDataObject::instance() | ||
48 | { | 48 | { | ||
49 | return &s_kdo->kdo; | 49 | return &s_kdo->kdo; | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | KalziumDataObject::KalziumDataObject() | 52 | KalziumDataObject::KalziumDataObject() | ||
53 | : m_search(0) | 53 | : m_search(nullptr) | ||
54 | { | 54 | { | ||
55 | // reading elements | 55 | // reading elements | ||
56 | ElementSaxParser * parser = new ElementSaxParser(); | 56 | ElementSaxParser * parser = new ElementSaxParser(); | ||
57 | 57 | | |||
58 | QFile xmlFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "libkdeedu/data/elements.xml")); | 58 | QFile xmlFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "libkdeedu/data/elements.xml")); | ||
59 | QXmlInputSource source(&xmlFile); | 59 | QXmlInputSource source(&xmlFile); | ||
60 | QXmlSimpleReader reader; | 60 | QXmlSimpleReader reader; | ||
61 | 61 | | |||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 119 | { | |||
130 | //Delete the spectra | 130 | //Delete the spectra | ||
131 | qDeleteAll(m_spectra); | 131 | qDeleteAll(m_spectra); | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | Element* KalziumDataObject::element(int number) | 134 | Element* KalziumDataObject::element(int number) | ||
135 | { | 135 | { | ||
136 | // checking that we are requesting a valid element | 136 | // checking that we are requesting a valid element | ||
137 | if ((number <= 0) || (number > m_numOfElements)) | 137 | if ((number <= 0) || (number > m_numOfElements)) | ||
138 | return 0; | 138 | return nullptr; | ||
139 | return ElementList[ number-1 ]; | 139 | return ElementList[ number-1 ]; | ||
140 | } | 140 | } | ||
141 | 141 | | |||
142 | QString KalziumDataObject::unitAsString(const int unit) const | 142 | QString KalziumDataObject::unitAsString(const int unit) const | ||
143 | { | 143 | { | ||
144 | return KUnitConversion::Converter().unit(KUnitConversion::UnitId(unit)).symbol(); | 144 | return KUnitConversion::Converter().unit(KUnitConversion::UnitId(unit)).symbol(); | ||
145 | } | 145 | } | ||
146 | 146 | | |||
Show All 20 Lines | |||||
167 | Spectrum * KalziumDataObject::spectrum(int number) | 167 | Spectrum * KalziumDataObject::spectrum(int number) | ||
168 | { | 168 | { | ||
169 | foreach (Spectrum * s, m_spectra) { | 169 | foreach (Spectrum * s, m_spectra) { | ||
170 | if (s->parentElementNumber() == number) { | 170 | if (s->parentElementNumber() == number) { | ||
171 | return s; | 171 | return s; | ||
172 | } | 172 | } | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | return 0; | 175 | return nullptr; | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | 178 | | |||
179 | void KalziumDataObject::setSearch(Search *srch) | 179 | void KalziumDataObject::setSearch(Search *srch) | ||
180 | { | 180 | { | ||
181 | m_search = srch; | 181 | m_search = srch; | ||
182 | } | 182 | } | ||
183 | 183 | | |||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |