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 
80  // Operator Overloadings
81  SymbolEditorWidget& operator=(const SymbolEditorWidget& rhs) = delete;
82 
83 public slots:
84  bool save() noexcept override;
85  bool cut() noexcept override;
86  bool copy() noexcept override;
87  bool paste() noexcept override;
88  bool rotateCw() noexcept override;
89  bool rotateCcw() noexcept override;
90  bool mirror() noexcept override;
91  bool remove() noexcept override;
92  bool zoomIn() noexcept override;
93  bool zoomOut() noexcept override;
94  bool zoomAll() noexcept override;
95  bool abortCommand() noexcept override;
96  bool editGridProperties() noexcept override;
97 
98 private: // Methods
99  void updateMetadata() noexcept;
100  QString commitMetadata() noexcept;
102  bool graphicsViewEventHandler(QEvent* event) noexcept override;
103  bool toolChangeRequested(Tool newTool) noexcept override;
104  bool isInterfaceBroken() const noexcept override;
105  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
106  template <typename MessageType>
107  void fixMsg(const MessageType& msg);
108  template <typename MessageType>
109  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
110  bool applyFix);
111  bool processCheckMessage(
112  std::shared_ptr<const LibraryElementCheckMessage> msg,
113  bool applyFix) override;
114 
115 private: // Data
116  QScopedPointer<Ui::SymbolEditorWidget> mUi;
117  QScopedPointer<ComponentCategoryListEditorWidget> mCategoriesEditorWidget;
118  QScopedPointer<GraphicsScene> mGraphicsScene;
119  QScopedPointer<Symbol> mSymbol;
120  QScopedPointer<SymbolGraphicsItem> mGraphicsItem;
121  QScopedPointer<SymbolEditorFsm> mFsm;
122 
123  // broken interface detection
125 };
126 
127 /*******************************************************************************
128  * End of File
129  ******************************************************************************/
130 
131 } // namespace editor
132 } // namespace library
133 } // namespace librepcb
134 
135 #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: alignment.cpp:30
QScopedPointer< Symbol > mSymbol
Definition: symboleditorwidget.h:119
The ExclusiveActionGroup class groups multiple QAction&#39;s together.
Definition: exclusiveactiongroup.h:50
QScopedPointer< ComponentCategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:117
Tool
Definition: editorwidgetbase.h:76
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:120
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:118
virtual bool hasGraphicalEditor() const noexcept override
Definition: symboleditorwidget.h:75
QSet< Uuid > mOriginalSymbolPinUuids
Definition: symboleditorwidget.h:124
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:116
QScopedPointer< SymbolEditorFsm > mFsm
Definition: symboleditorwidget.h:121
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62