LibrePCB Developers Documentation
symboleditorwidget.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_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../common/categorylisteditorwidget.h"
27 #include "../common/editorwidgetbase.h"
28 
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class GridProperties;
40 class GraphicsScene;
41 
42 namespace library {
43 
44 class Symbol;
45 class SymbolGraphicsItem;
46 
47 namespace editor {
48 
49 class SymbolEditorFsm;
50 
51 namespace Ui {
52 class SymbolEditorWidget;
53 }
54 
55 /*******************************************************************************
56  * Class SymbolEditorWidget
57  ******************************************************************************/
58 
62 class SymbolEditorWidget final : public EditorWidgetBase,
64  Q_OBJECT
65 
66 public:
67  // Constructors / Destructor
68  SymbolEditorWidget() = delete;
69  SymbolEditorWidget(const SymbolEditorWidget& other) = delete;
70  SymbolEditorWidget(const Context& context, const FilePath& fp,
71  QWidget* parent = nullptr);
72  ~SymbolEditorWidget() noexcept;
73 
74  // Getters
75  virtual bool hasGraphicalEditor() const noexcept override { return true; }
76 
77  // Setters
78  void setToolsActionGroup(ExclusiveActionGroup* group) noexcept override;
79  void setStatusBar(StatusBar* statusbar) noexcept override;
80 
81  // Operator Overloadings
82  SymbolEditorWidget& operator=(const SymbolEditorWidget& rhs) = delete;
83 
84 public slots:
85  bool save() noexcept override;
86  bool selectAll() noexcept override;
87  bool cut() noexcept override;
88  bool copy() noexcept override;
89  bool paste() noexcept override;
90  bool rotateCw() noexcept override;
91  bool rotateCcw() noexcept override;
92  bool mirror() noexcept override;
93  bool remove() noexcept override;
94  bool zoomIn() noexcept override;
95  bool zoomOut() noexcept override;
96  bool zoomAll() noexcept override;
97  bool abortCommand() noexcept override;
98  bool editGridProperties() noexcept override;
99 
100 private: // Methods
101  void updateMetadata() noexcept;
102  QString commitMetadata() noexcept;
104  bool graphicsViewEventHandler(QEvent* event) noexcept override;
105  bool toolChangeRequested(Tool newTool) noexcept override;
106  bool isInterfaceBroken() const noexcept override;
107  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
108  template <typename MessageType>
109  void fixMsg(const MessageType& msg);
110  template <typename MessageType>
111  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
112  bool applyFix);
113  bool processCheckMessage(
114  std::shared_ptr<const LibraryElementCheckMessage> msg,
115  bool applyFix) override;
116 
117 private: // Data
118  QScopedPointer<Ui::SymbolEditorWidget> mUi;
119  QScopedPointer<ComponentCategoryListEditorWidget> mCategoriesEditorWidget;
120  QScopedPointer<GraphicsScene> mGraphicsScene;
121  QScopedPointer<Symbol> mSymbol;
122  QScopedPointer<SymbolGraphicsItem> mGraphicsItem;
123  QScopedPointer<SymbolEditorFsm> mFsm;
124 
125  // broken interface detection
127 };
128 
129 /*******************************************************************************
130  * End of File
131  ******************************************************************************/
132 
133 } // namespace editor
134 } // namespace library
135 } // namespace librepcb
136 
137 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
The SymbolEditorWidget class.
Definition: symboleditorwidget.h:62
Definition: mainwindow.h:10
Definition: airwiresbuilder.cpp:32
QScopedPointer< Symbol > mSymbol
Definition: symboleditorwidget.h:121
The ExclusiveActionGroup class groups multiple QAction&#39;s together.
Definition: exclusiveactiongroup.h:50
QScopedPointer< ComponentCategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:119
Tool
Definition: editorwidgetbase.h:77
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:122
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:44
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:120
virtual bool hasGraphicalEditor() const noexcept override
Definition: symboleditorwidget.h:75
QSet< Uuid > mOriginalSymbolPinUuids
Definition: symboleditorwidget.h:126
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:118
QScopedPointer< SymbolEditorFsm > mFsm
Definition: symboleditorwidget.h:123
The EditorWidgetBase class.
Definition: editorwidgetbase.h:63