@@ -394,82 +394,77 @@ class InterSpec : public Wt::WContainerWidget
394394
395395
396396#if ( USE_DB_TO_STORE_SPECTRA )
397- // measurmentFromDb (...): returns the measurment that has been, or will be
397+ // measurementFromDb (...): returns the measurement that has been, or will be
398398 // serialized to the database. If 'update' is false, then just the last
399399 // serialization will be returned and in fact may be null. If 'update'
400- // is true, then the measurment will be saved to the database first (unless
400+ // is true, then the measurement will be saved to the database first (unless
401401 // it hasnt been modified since last saving) and then returned; if the user
402402 // preference is to not save spectra to the database, then it will not be
403403 // be saved. In the case the user preference is to not save to the database,
404- // but the file is already in there, but has been modified in memmorry , then
404+ // but the file is already in there, but has been modified in memory , then
405405 // the file will not be re-saved to the database.
406406 // Function wont throw, but may return a null pointer
407- Wt::Dbo::ptr<UserFileInDb> measurmentFromDb ( SpecUtils::SpectrumType type, bool update );
407+ Wt::Dbo::ptr<UserFileInDb> measurementFromDb ( SpecUtils::SpectrumType type, bool update );
408408
409409 // saveStateToDb( entry ): saves the application state to the pointer passed
410410 // in. Note that pointer passed in must be a valid pointer associated with
411- // this m_user. If entry->stateType is specified for testing, then every
412- // thing will be copied and write protected so it cant be changed in the
413- // future. May throw exception. std::runtime_error exceptions will contain
411+ // this m_user. If `entry->stateType` is specified for as end of session,
412+ // or `entry->snapshotTagParent` is non-null, then things will be copied
413+ // to unique entries in the database.
414+ // May throw exception. std::runtime_error exceptions will contain
414415 // messages that are reasonably okay to send to users.
415416 void saveStateToDb ( Wt::Dbo::ptr<UserState> entry );
416417
417- // serializeStateToDb(...): a convience function for saveStateToDb(...).
418- Wt::Dbo::ptr<UserState> serializeStateToDb ( const Wt::WString &name,
419- const Wt::WString &desc,
420- const bool forTesting,
421- Wt::Dbo::ptr<UserState> parent);
422-
423418 // loadStateFromDb( entry ): sets the applications state to that in 'entry'
424419 void loadStateFromDb ( Wt::Dbo::ptr<UserState> entry );
425420
426- // testLoadSaveState(): a temporary function to help develop the loading and
427- // saving of the applications state
428- // void testLoadSaveState();
429-
430- void stateSave ();
431- void stateSaveAs ();
432- void stateSaveTag ();
433- void stateSaveAsAction ( Wt::WLineEdit *nameedit,
434- Wt::WTextArea *descriptionarea,
435- AuxWindow *window,
436- const bool forTesting);
437- void stateSaveTagAction (Wt::WLineEdit *nameedit,
438- AuxWindow *window);
439-
440- // startStoreStateInDb(...): If state hasn't been saved yet,
441- // e.g. `m_dataMeasurement->dbStateId(m_displayedSamples) < 0`,
442- // then a dialog will be popped up allowing user to enter a title and
443- // description.
444- // If the state is already in the database, and either the state is not
445- // readonly, or 'allowOverWrite' is specified true, then the database will be
446- // updated.
447- // If 'asNewState' is specified, then even if the current state is already in
448- // the database, the process (e.g. user dialog) for saving a new state in the
449- // database will be started.
450- // Specifying 'forTesting' will cause the for testing flag to be set, as well
451- // as for the state to be marked as read only.
452- void startStoreStateInDb ( const bool forTesting,
453- const bool asNewState,
454- const bool allowOverWrite,
455- const bool endOfSessionNoDelete );
456-
457- void finishStoreStateInDb ( Wt::WLineEdit *name, Wt::WTextArea *description,
458- AuxWindow *window, const bool forTesting , Wt::Dbo::ptr<UserState> parent);
459- void browseDatabaseStates ( bool testStates );
421+
422+ /* * Called from the "Store As..." menu item.
423+ If state is already saved in the DB, updates it.
424+ This function should only be called when we are already connected to a state in the DB,
425+ but if not, will then call `stateSaveAs()` (but again, this shouldn't happen).
426+ */
427+ void stateSave ();
428+ /* * Called from the "Store As..." menu item - creates a dialog to store current state under new name/desc. */
429+ void stateSaveAs ();
430+ /* * Called from the "Store As..." dialog to save things to DB. */
431+ void stateSaveAsFinish ( Wt::WLineEdit *name, Wt::WTextArea *desc, AuxWindow *window );
432+ /* * Called from the "Tag..." menu item, to create a tag of the current state. */
433+ void stateSaveTag ();
434+ /* * Called from the "Tag..." dialog to actually create the tag in the DB. */
435+ void stateSaveTagFinish ( Wt::WLineEdit *name, AuxWindow *window );
436+
437+ /* * Saves the Act/Shield and Rel Eff tool states to the in-memory `SpecMeas` objects, then updates
438+ the database with either the current app state, or the current SpecMeas object, depending if we are
439+ connected to a app-state or not.
440+ If connected to an app state, will create, or replace the states `kEndOfSessionHEAD` state in DB.
441+ */
442+ void saveStateAtForegroundChange ();
443+
444+ /* * Removes all previous `kEndOfSessionTemp` sessions for the user from the database, and then
445+ if the "AutoSaveSpectraToDb" preference is true, will create the new `kEndOfSessionTemp` state
446+ that will be loaded next time the app is started.
447+ */
448+ void saveStateForEndOfSession ();
449+
450+ /* * Called by #InterSpec::stateSaveTagFinish and #InterSpec::stateSaveAsFinish, to actually create
451+ the db user state, and then call `saveStateToDb(...)` and update menu items.
452+ */
453+ void finishStoreStateInDb ( const Wt::WString &name,
454+ const Wt::WString &description,
455+ Wt::Dbo::ptr<UserState> parent );
460456
461457#if ( INCLUDE_ANALYSIS_TEST_SUITE )
462458 void startStateTester ();
463459
464- // startStoreTestStateInDb(): a convience function that makes a dialog to give
465- // the user an option to overwrite their current state or create a new one .
466- void startStoreTestStateInDb ();
460+ // Creates a dialog that allows user to name and describe the state; when
461+ // user then clicks save, will pass off to `storeTestStateToN42(...)` .
462+ void startStoreTestState ();
467463
468464 // storeTestStateToN42(): stores foreground, background, and shielding/source
469465 // model into a since 2012 N42 file. Does not throw, but will notify the
470466 // user via the GUI upon error.
471- void storeTestStateToN42 ( std::ostream &output,
472- const std::string &name, const std::string &descr );
467+ void storeTestStateToN42 ( const Wt::WString name, const Wt::WString descr );
473468
474469 // loadTestStateFromN42(): Attempts to load a state previously saved to an
475470 // XML file via storeTestStateToN42
0 commit comments