MCPcopy Create free account
hub / github.com/KDE/labplot / save

Method save

src/frontend/widgets/FITSHeaderEditWidget.cpp:221–265  ·  view source on GitHub ↗

! * \brief Triggered when clicking the Save button * Saves the modifications (new keywords, new keyword units, keyword modifications, * deleted keywords, deleted extensions) to the FITS files. * \return \c true if there was something saved, otherwise false */

Source from the content-addressed store, hash-verified

219 * \return \c true if there was something saved, otherwise false
220 */
221bool FITSHeaderEditWidget::save() {
222 bool saved = false;
223
224 QMap<QString, ExtensionData>::const_iterator it = m_extensionData.constBegin();
225 while (it != m_extensionData.constEnd()) {
226 const QString& fileName = it.key();
227 const auto& data = it.value();
228 if (data.updates.newKeywords.size() > 0) {
229 m_fitsFilter->addNewKeyword(fileName, data.updates.newKeywords);
230 if (!saved)
231 saved = true;
232 }
233 if (data.updates.removedKeywords.size() > 0) {
234 m_fitsFilter->deleteKeyword(fileName, data.updates.removedKeywords);
235 if (!saved)
236 saved = true;
237 }
238 if (!saved) {
239 for (const FITSFilter::Keyword& key : data.updates.updatedKeywords) {
240 if (!key.isEmpty()) {
241 saved = true;
242 break;
243 }
244 }
245 }
246
247 m_fitsFilter->updateKeywords(fileName, data.keywords, data.updates.updatedKeywords);
248 m_fitsFilter->addKeywordUnit(fileName, data.keywords);
249 m_fitsFilter->addKeywordUnit(fileName, data.updates.newKeywords);
250
251 ++it;
252 }
253
254 if (m_removedExtensions.size() > 0) {
255 m_fitsFilter->removeExtensions(m_removedExtensions);
256 if (!saved)
257 saved = true;
258 }
259 if (saved) {
260 // to reset the window title
261 Q_EMIT changed(false);
262 }
263
264 return saved;
265}
266
267/*!
268 * \brief Initializes the context menu's actions.

Callers

nothing calls this directly

Calls 8

addNewKeywordMethod · 0.80
deleteKeywordMethod · 0.80
updateKeywordsMethod · 0.80
addKeywordUnitMethod · 0.80
removeExtensionsMethod · 0.80
valueMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected