VPTissue Reference Manual
PTreeEditorWindow.h
Go to the documentation of this file.
1 #ifndef PTREE_EDITOR_WINDOW_H_INCLUDED
2 #define PTREE_EDITOR_WINDOW_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "IHasPTreeState.h"
23 #include "gui/HasUnsavedChanges.h"
24 
25 #include <QMainWindow>
26 #include <boost/property_tree/ptree.hpp>
27 
28 class QAction;
29 class QCloseEvent;
30 class QStatusBar;
31 class QToolBar;
32 
33 namespace SimShell {
34 namespace Gui {
35 
36 class PTreeView;
37 class PTreeModel;
38 
44 {
45  Q_OBJECT
46 public:
48  PTreeEditorWindow(QWidget* parent = nullptr);
49 
51  virtual ~PTreeEditorWindow() {}
52 
59  std::string GetEditPath() const;
60 
62  virtual boost::property_tree::ptree GetPTreeState() const;
63 
69  bool IsOnlyEditData() const;
70 
72  virtual bool IsOpened() const;
73 
75  void Redo();
76 
78  virtual QSize sizeHint() const;
79 
84  void SetOnlyEditData(bool);
85 
87  virtual void SetPTreeState(const boost::property_tree::ptree&);
88 
90  void Undo();
91 
92 
93 public slots:
95  void Apply();
96 
103  bool OpenPath(const QString & edit_path);
104 
110  bool OpenPTree(const boost::property_tree::ptree&, QString const& edit_path = "");
111 
112 signals:
114  void StatusChanged(const QString&);
115 
117  void ApplyTriggered(const boost::property_tree::ptree& pt);
118 
119 protected:
121  virtual void InternalForceClose();
122 
124  virtual bool InternalIsClean() const;
125 
127  virtual bool InternalSave();
128 
129 private:
130  boost::property_tree::ptree m_pt;
131  std::string m_edit_path;
132  bool m_only_edit_data;
133 
134 private:
135  PTreeModel* m_model; // equal to zero <=> unopened state
136  PTreeView* m_treeview;
137  QToolBar* m_toolbar_main;
138 
139  QAction* m_action_show_toolbar_main;
140 
141 private:
142  static int const g_column_width;
143 };
144 
145 } // namespace
146 } // namespace
147 
148 #endif // end_of_inclde_guard
std::string GetEditPath() const
Get the current edit path.
bool OpenPTree(const boost::property_tree::ptree &, QString const &edit_path="")
Set ptree to show in editor.
PTreeEditorWindow(QWidget *parent=nullptr)
virtual ~PTreeEditorWindow()
Virtual destructor.
void SetOnlyEditData(bool)
Set the "only edit values" option.
bool OpenPath(const QString &edit_path)
Set subtree to show in editor.
void StatusChanged(const QString &)
Emitted when the window has information available, for e.g. a statusbar.
Qt model reflecting hierarchical structure of a ptree.
Definition: PTreeModel.h:37
void Undo()
Undo last manipulation by the user.
void Redo()
Redo last manipulation by the user.
Interface for objects that have non-critical state (metadata) information representable as a ptree...
TreeView widget that presents an editable ptree to the user.
Definition: PTreeView.h:37
virtual QSize sizeHint() const
Reimplemented from QWidget.
bool IsOnlyEditData() const
Test whether the "only edit data" option is set.
see the online Qt documentation
Interface for HasUnsavedChanges.
Abstract class that represents the ability be in closed or opened state, and, if the latter...
see the online Qt documentation
void ApplyTriggered(const boost::property_tree::ptree &pt)
Emitted when changes are applied to ptree.
virtual void SetPTreeState(const boost::property_tree::ptree &)
HasPtreeState interface.
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Small editor widget for a Boost Property Tree object.
void Apply()
Write changes to ptree object. Clean state is achieved as a side effect.
virtual boost::property_tree::ptree GetPTreeState() const