LibrePCB Developers Documentation
projecteditor.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_PROJECT_PROJECTEDITOR_H
21 #define LIBREPCB_PROJECT_PROJECTEDITOR_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
28 
29 #include <QtCore>
30 
31 #include <memory>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 class QMainWindow;
37 
38 namespace librepcb {
39 
40 class UndoStack;
41 class LengthUnit;
42 
43 namespace workspace {
44 class Workspace;
45 }
46 
47 namespace project {
48 
49 class Project;
50 
51 namespace editor {
52 
53 class SchematicEditor;
54 class BoardEditor;
55 
56 /*******************************************************************************
57  * Class ProjectEditor
58  ******************************************************************************/
59 
63 class ProjectEditor final : public QObject {
64  Q_OBJECT
65 
66 public:
67  // Constructors / Destructor
68  ProjectEditor() = delete;
69  ProjectEditor(const Project& other) = delete;
70 
74  ProjectEditor(workspace::Workspace& workspace, Project& project);
75 
79  ~ProjectEditor() noexcept;
80 
81  // Getters: General
82 
83  workspace::Workspace& getWorkspace() const noexcept { return mWorkspace; }
84  Project& getProject() const noexcept { return mProject; }
85  const LengthUnit& getDefaultLengthUnit() const noexcept;
86 
92  UndoStack& getUndoStack() const noexcept { return *mUndoStack; }
93 
94  // General Methods
95 
114  bool windowIsAboutToClose(QMainWindow& window) noexcept;
115 
116  // Operator Overloadings
117  ProjectEditor& operator=(const Project& rhs) = delete;
118 
119 public slots:
120 
129  void showAllRequiredEditors() noexcept;
130 
134  void showSchematicEditor() noexcept;
135 
139  void showBoardEditor() noexcept;
140 
146  void execProjectSettingsDialog(QWidget* parent = nullptr) noexcept;
147 
153  void execNetClassesEditorDialog(QWidget* parent = nullptr) noexcept;
154 
160  void execLppzExportDialog(QWidget* parent = nullptr) noexcept;
161 
169  bool saveProject() noexcept;
170 
178  bool autosaveProject() noexcept;
179 
206  bool closeAndDestroy(bool askForSave, QWidget* msgBoxParent = 0) noexcept;
207 
208 signals:
209 
210  void showControlPanelClicked();
211  void openProjectLibraryUpdaterClicked(const FilePath& fp);
212  void projectEditorClosed();
213 
214 private: // Methods
215  int getCountOfVisibleEditorWindows() const noexcept;
216 
217 private: // Data
220  QTimer mAutoSaveTimer;
221  UndoStack* mUndoStack;
225 };
226 
227 /*******************************************************************************
228  * End of File
229  ******************************************************************************/
230 
231 } // namespace editor
232 } // namespace project
233 } // namespace librepcb
234 
235 #endif // LIBREPCB_PROJECT_PROJECTEDITOR_H
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:62
workspace::Workspace & mWorkspace
Definition: projecteditor.h:218
The BoardEditor class.
Definition: boardeditor.h:68
BoardEditor * mBoardEditor
The board editor (GUI)
Definition: projecteditor.h:224
Definition: airwiresbuilder.cpp:32
The Project class represents a whole (opened) project with all its content.
Definition: project.h:80
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:107
The ProjectEditor class.
Definition: projecteditor.h:63
Project & getProject() const noexcept
Definition: projecteditor.h:84
QTimer mAutoSaveTimer
Definition: projecteditor.h:220
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
UndoStack & getUndoStack() const noexcept
Get a reference to the undo stack of the project.
Definition: projecteditor.h:92
The SchematicEditor class.
Definition: schematiceditor.h:63
workspace::Workspace & getWorkspace() const noexcept
Definition: projecteditor.h:83
Project & mProject
Definition: projecteditor.h:219
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition: lengthunit.h:62
SchematicEditor * mSchematicEditor
The schematic editor (GUI)
Definition: projecteditor.h:223