VPTissue Reference Manual
WorkspaceController.h
Go to the documentation of this file.
1 #ifndef GUI_WORKSPACECONTROLLER_H_INCLUDED
2 #define GUI_WORKSPACECONTROLLER_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 "ProjectController.h"
23 
24 #include "gui/EnabledActions.h"
25 #include "gui/HasUnsavedChanges.h"
26 #include "gui/IHasPTreeState.h"
27 #include "workspace/IWorkspace.h"
29 
30 #include <QWidget>
31 #include <memory>
32 
33 namespace SimShell {
34 namespace Gui {
35 
36 class PTreeContainerPreferencesObserver;
37 class WorkspaceView;
38 class WorkspaceQtModel;
39 
40 namespace Controller {
41 
42 class AppController;
43 
54  public IHasPTreeState,
56 {
57  Q_OBJECT
58 public:
59  WorkspaceController(std::shared_ptr<Ws::IWorkspaceFactory> f, AppController* m);
60 
61  bool Open(const std::string& path);
62 
63  QAction* GetActionNewProject() const;
64 
65  QAction* GetActionRefreshWorkspace() const;
66 
67  QDockWidget* GetPreferencesDock() const;
68 
69  QMenu* GetPreferencesMenu() const;
70 
72  virtual boost::property_tree::ptree GetPTreeState() const;
73 
74  WorkspaceView* GetView() const;
75 
77  virtual bool IsOpened() const;
78 
80 
81  const ProjectController& Project() const;
82 
84  virtual void SetPTreeState(const boost::property_tree::ptree&);
85 
87  operator bool() const;
88 
89  Ws::IWorkspace* operator->();
90  const Ws::IWorkspace* operator->() const;
91 
92  std::shared_ptr<Ws::IWorkspace> operator*();
93  std::shared_ptr<const Ws::IWorkspace> operator*() const;
94 
95 protected:
97  virtual void InternalForceClose();
98 
100  virtual bool InternalIsClean() const;
101 
103  virtual void InternalPreForceClose();
104 
106  virtual bool InternalSave();
107 
108 private slots:
109  void SLOT_ApplyPreferences(const boost::property_tree::ptree &);
110  void SLOT_NewProjectDialog();
111  void SLOT_RefreshWorkspace();
112 
113 private:
114  void InitActions();
115  void InitBaseClasses();
116  void InitWidgets();
117 
118 private:
119  std::shared_ptr<Ws::IWorkspaceFactory> m_factory;
120  AppController* m_main_controller;
121 
122  // These shared ptrs will only contain objects if we are in opened state.
123  std::shared_ptr<WorkspaceQtModel> m_model;
124 
125  // Widgets
126  WorkspaceView* m_view;
127  std::shared_ptr<PTreeContainerPreferencesObserver> m_container_preferences;
128 
129  // Actions and menus
130  QAction* m_a_new_project;
131  QAction* m_a_refresh_workspace;
132 
133  // Sub-state
134  ProjectController m_project_controller;
135 
136  EnabledActions m_enabled_actions;
137 };
138 
139 } // namespace
140 } // namespace
141 } // namespace
142 
143 #endif // end_of_inclde_guard
virtual boost::property_tree::ptree GetPTreeState() const
Helper class to enable or disable a collection of QAction and QMenu objects at once.
HasUnsavedChanges with the ability of displaying a "save-discard-cancel" dialog to the user before cl...
EnabledActions interface.
Abstraction of project in workspace on file system.
Interface for workspace-like behavior.
Definition: IWorkspace.h:48
Interface for IWorkspaceFactory.
see the online Qt documentation
Interface for objects that have non-critical state (metadata) information representable as a ptree...
see the online Qt documentation
Interface for IWorkspace.
virtual void SetPTreeState(const boost::property_tree::ptree &)
ProjectController header.
Interface for HasUnsavedChanges.
see the online Qt documentation
TreeView widget that uses WorkspaceQtModel as a model.
Definition: WorkspaceView.h:39
HasPtreeState interface.
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32