VPTissue Reference Manual
WorkspaceView.h
Go to the documentation of this file.
1 #ifndef WORKSPACE_VIEW_H_INCLUDED
2 #define WORKSPACE_VIEW_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 "MyTreeView.h"
23 #include "workspace/IProject.h"
24 
25 #include <QAction>
26 #include <QItemSelectionModel>
27 
28 namespace SimShell {
29 namespace Gui {
30 
31 class WorkspaceQtModel;
32 
39 class WorkspaceView : public MyTreeView
40 {
41  Q_OBJECT
42 public:
43  WorkspaceView(QWidget* parent = 0);
44  virtual ~WorkspaceView() {}
45 
51  virtual void setModel(QAbstractItemModel*);
52 
58  QAction* GetOpenAction() const;
59 
65  QAction* GetRenameAction() const;
66 
72  QAction* GetRemoveAction() const;
73 
74 private slots:
80  void SLOT_Close();
81 
87  void SLOT_Open();
88 
89  void SLOT_ProjectWidgetAction();
90 
96  void SLOT_RenameDialog();
97 
103  void SLOT_Remove();
104 
110  void SLOT_SelectionChanged(QItemSelection const & selected, QItemSelection const & deselected);
111 
112 signals:
116  void ProjectRenamed(const std::string& old_name, const std::string& new_name);
117 
121  void ProjectRemoved(const std::string& project);
122 
123 protected:
128  virtual void contextMenuEvent(QContextMenuEvent*);
129 
136  virtual void mouseDoubleClickEvent(QMouseEvent*);
137 
138 private:
139  WorkspaceQtModel* model; // this is here so i don't have to cast model() every time.
140 
141  QAction* action_open;
142  QAction* action_rename;
143  QAction* action_remove;
144  QAction* action_close;
145 
146  std::shared_ptr<QWidget> project_widget;
147  std::string project_widget_project_name;
148  struct CallbackMapEntry {
149  Ws::IProject::WidgetCallback::Type callback;
150  std::string project_name;
151  };
152  std::map<QObject*, CallbackMapEntry> object_to_callback_map;
153 };
154 
155 } // namespace
156 } // namespace
157 
158 #endif // end_of_inclde_guard
virtual void mouseDoubleClickEvent(QMouseEvent *)
Reimplemented from QTreeView.
QAction * GetOpenAction() const
Get 'open' action object.
see the online Qt documentation
QAction * GetRemoveAction() const
Get 'remove' action object.
Interface for MyTreeView.
Interface for IProject.
void ProjectRemoved(const std::string &project)
Emitted when user selected "delete" option on a project.
QTreeView with methods to import/export widget layout (x,y,width, ...) in ptree format.
Definition: MyTreeView.h:35
virtual void contextMenuEvent(QContextMenuEvent *)
Reimplemented from QWidget.
QAction * GetRenameAction() const
Get 'rename' action object.
see the online Qt documentation
TreeView widget that uses WorkspaceQtModel as a model.
Definition: WorkspaceView.h:39
virtual void setModel(QAbstractItemModel *)
Set the model.
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
void ProjectRenamed(const std::string &old_name, const std::string &new_name)
Emitted when user renamed a project.
Abstraction of workspace on the filesystem.