BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
undostack.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/commands/undostack.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_MODEL_MVVM_COMMANDS_UNDOSTACK_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_COMMANDS_UNDOSTACK_H
17 
19 #include "mvvm/model_export.h"
20 #include <memory>
21 
22 class QUndoStack;
23 
24 namespace ModelView {
25 
26 //! Default undo stack implementation. Internally relies on QUndoStack.
27 //! It serves two goals: a) hides Qt usage b) simplifies future refactoring toward Qt-independent
28 //! libmvvm_model library.
29 
30 class MVVM_MODEL_EXPORT UndoStack : public UndoStackInterface {
31 public:
32  UndoStack();
33  ~UndoStack() override;
34 
35  //! Executes the command, then pushes it in the stack for possible undo.
36  void execute(std::shared_ptr<AbstractItemCommand> command) override;
37 
38  bool isActive() const override;
39  bool canUndo() const override;
40  bool canRedo() const override;
41  int index() const override;
42  int count() const override;
43  void undo() override;
44  void redo() override;
45  void clear() override;
46  void setUndoLimit(int limit) override;
47 
48  static QUndoStack* qtUndoStack(UndoStackInterface* stack_interface);
49 
50  void beginMacro(const std::string& name) override;
51  void endMacro() override;
52 
53 private:
54  struct UndoStackImpl;
55  std::unique_ptr<UndoStackImpl> p_impl;
56 };
57 
58 } // namespace ModelView
59 
60 #endif // BORNAGAIN_MVVM_MODEL_MVVM_COMMANDS_UNDOSTACK_H
Interface class for undo/redo stack.
Default undo stack implementation.
Definition: undostack.h:30
std::unique_ptr< UndoStackImpl > p_impl
Definition: undostack.h:54
materialitems.h Collection of materials to populate MaterialModel.
QString const & name(EShape k)
Definition: particles.cpp:21
Defines class CLASS?