Changeset View
Changeset View
Standalone View
Standalone View
src/exportdialog.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 147 | { | |||
---|---|---|---|---|---|
174 | // close the dialog | 174 | // close the dialog | ||
175 | done(0); | 175 | done(0); | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | void ExportDialog::exportToHtml() | 178 | void ExportDialog::exportToHtml() | ||
179 | { | 179 | { | ||
180 | *m_outputStream << HTML_HEADER << "<table>\n"; | 180 | *m_outputStream << HTML_HEADER << "<table>\n"; | ||
181 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | 181 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | ||
182 | ElementListEntry* element_entry = static_cast<ElementListEntry*>(element); | ||||
182 | *m_outputStream << "<tr>\n<th colspan=\"2\">" | 183 | *m_outputStream << "<tr>\n<th colspan=\"2\">" | ||
183 | << ((ElementListEntry*)element)->m_element->dataAsString(ChemicalDataObject::name) | 184 | << element_entry->m_element->dataAsString(ChemicalDataObject::name) | ||
184 | << "</th>\n</tr>\n"; | 185 | << "</th>\n</tr>\n"; | ||
185 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | 186 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | ||
187 | PropertyListEntry* property_entry = static_cast<PropertyListEntry*>(property); | ||||
186 | *m_outputStream << "<tr>\n<td class=\"property\">" | 188 | *m_outputStream << "<tr>\n<td class=\"property\">" | ||
187 | << ((PropertyListEntry*) property)->text() | 189 | << property_entry->text() | ||
188 | << "</td>\n<td class=\"value\">" | 190 | << "</td>\n<td class=\"value\">" | ||
189 | << KalziumUtils::prettyUnit( | 191 | << KalziumUtils::prettyUnit( | ||
190 | ((ElementListEntry*) element)->m_element, | 192 | element_entry->m_element, | ||
191 | ((PropertyListEntry*) property)->m_type) | 193 | property_entry->m_type) | ||
192 | << "</td>\n</tr>\n"; | 194 | << "</td>\n</tr>\n"; | ||
193 | } | 195 | } | ||
194 | } | 196 | } | ||
195 | *m_outputStream << "</table>\n" << HTML_FOOTER; | 197 | *m_outputStream << "</table>\n" << HTML_FOOTER; | ||
196 | } | 198 | } | ||
197 | 199 | | |||
198 | void ExportDialog::exportToXml() | 200 | void ExportDialog::exportToXml() | ||
199 | { | 201 | { | ||
200 | *m_outputStream << XML_HEADER << "<elements>\n"; | 202 | *m_outputStream << XML_HEADER << "<elements>\n"; | ||
201 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | 203 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | ||
204 | ElementListEntry* element_entry = static_cast<ElementListEntry*>(element); | ||||
202 | *m_outputStream << " <element name=\"" | 205 | *m_outputStream << " <element name=\"" | ||
203 | << ((ElementListEntry*) element)->m_element->dataAsString(ChemicalDataObject::name) | 206 | << element_entry->m_element->dataAsString(ChemicalDataObject::name) | ||
204 | << "\">\n"; | 207 | << "\">\n"; | ||
205 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | 208 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | ||
209 | PropertyListEntry* property_entry = static_cast<PropertyListEntry*>(property); | ||||
206 | *m_outputStream << " <property name=\"" | 210 | *m_outputStream << " <property name=\"" | ||
207 | << ((PropertyListEntry*) property)->text() | 211 | << property_entry->text() | ||
208 | << "\">" | 212 | << "\">" | ||
209 | << KalziumUtils::prettyUnit( | 213 | << KalziumUtils::prettyUnit( | ||
210 | ((ElementListEntry*) element)->m_element, | 214 | element_entry->m_element, | ||
211 | ((PropertyListEntry*) property)->m_type) | 215 | property_entry->m_type) | ||
212 | << "</property>\n"; | 216 | << "</property>\n"; | ||
213 | } | 217 | } | ||
214 | *m_outputStream << " </element>\n"; | 218 | *m_outputStream << " </element>\n"; | ||
215 | } | 219 | } | ||
216 | *m_outputStream << "</elements>\n"; | 220 | *m_outputStream << "</elements>\n"; | ||
217 | } | 221 | } | ||
218 | 222 | | |||
219 | void ExportDialog::exportToCsv() | 223 | void ExportDialog::exportToCsv() | ||
220 | { | 224 | { | ||
221 | *m_outputStream << "Name"; | 225 | *m_outputStream << "Name"; | ||
222 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | 226 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | ||
223 | *m_outputStream << ", \"" | 227 | *m_outputStream << ", \"" | ||
224 | << ((PropertyListEntry*) property)->text() | 228 | << static_cast<PropertyListEntry*>(property)->text() | ||
225 | << "\""; | 229 | << "\""; | ||
226 | } | 230 | } | ||
227 | *m_outputStream << "\n"; | 231 | *m_outputStream << "\n"; | ||
228 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | 232 | foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { | ||
233 | ElementListEntry* element_entry = static_cast<ElementListEntry*>(element); | ||||
229 | *m_outputStream << "\"" | 234 | *m_outputStream << "\"" | ||
230 | << ((ElementListEntry*) element)->m_element->dataAsString(ChemicalDataObject::name) | 235 | << element_entry->m_element->dataAsString(ChemicalDataObject::name) | ||
231 | << "\""; | 236 | << "\""; | ||
232 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | 237 | foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { | ||
233 | *m_outputStream << ", \"" | 238 | *m_outputStream << ", \"" | ||
234 | << KalziumUtils::prettyUnit( | 239 | << KalziumUtils::prettyUnit( | ||
235 | ((ElementListEntry*) element)->m_element, | 240 | element_entry->m_element, | ||
236 | ((PropertyListEntry*) property)->m_type) | 241 | static_cast<PropertyListEntry*>(property)->m_type) | ||
237 | << "\""; | 242 | << "\""; | ||
238 | } | 243 | } | ||
239 | *m_outputStream << "\n"; | 244 | *m_outputStream << "\n"; | ||
240 | } | 245 | } | ||
241 | } | 246 | } |