LibrePCB Developers Documentation
componentcategoryeditorwidget.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_EDITOR_COMPONENTCATEGORYEDITORWIDGET_H
21 #define LIBREPCB_EDITOR_COMPONENTCATEGORYEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../editorwidgetbase.h"
27 
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 #include <memory>
34 #include <optional.hpp>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 
41 class ComponentCategory;
42 
43 namespace editor {
44 
45 namespace Ui {
46 class ComponentCategoryEditorWidget;
47 }
48 
49 /*******************************************************************************
50  * Class ComponentCategoryEditorWidget
51  ******************************************************************************/
52 
57  Q_OBJECT
58 
59 public:
60  // Constructors / Destructor
63  delete;
64  ComponentCategoryEditorWidget(const Context& context, const FilePath& fp,
65  QWidget* parent = nullptr);
67 
68  // Getters
69  QSet<Feature> getAvailableFeatures() const noexcept override;
70 
71  // Operator Overloadings
73  const ComponentCategoryEditorWidget& rhs) = delete;
74 
75 public slots:
76  bool save() noexcept override;
77 
78 private: // Methods
79  void updateMetadata() noexcept;
80  QString commitMetadata() noexcept;
81  bool isInterfaceBroken() const noexcept override { return false; }
82  bool runChecks(RuleCheckMessageList& msgs) const override;
83  template <typename MessageType>
84  void fixMsg(const MessageType& msg);
85  template <typename MessageType>
86  bool fixMsgHelper(std::shared_ptr<const RuleCheckMessage> msg, bool applyFix);
87  bool processRuleCheckMessage(std::shared_ptr<const RuleCheckMessage> msg,
88  bool applyFix) override;
89  void ruleCheckApproveRequested(std::shared_ptr<const RuleCheckMessage> msg,
90  bool approve) noexcept override;
91  void btnChooseParentCategoryClicked() noexcept;
92  void btnResetParentCategoryClicked() noexcept;
93  void updateCategoryLabel() noexcept;
94 
95 private: // Data
96  QScopedPointer<Ui::ComponentCategoryEditorWidget> mUi;
97  std::unique_ptr<ComponentCategory> mCategory;
98  tl::optional<Uuid> mParentUuid;
99 };
100 
101 /*******************************************************************************
102  * End of File
103  ******************************************************************************/
104 
105 } // namespace editor
106 } // namespace librepcb
107 
108 #endif
QScopedPointer< Ui::ComponentCategoryEditorWidget > mUi
Definition: componentcategoryeditorwidget.h:96
Definition: occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
bool isInterfaceBroken() const noexcept override
Definition: componentcategoryeditorwidget.h:81
std::unique_ptr< ComponentCategory > mCategory
Definition: componentcategoryeditorwidget.h:97
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The ComponentCategoryEditorWidget class.
Definition: componentcategoryeditorwidget.h:56
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
tl::optional< Uuid > mParentUuid
Definition: componentcategoryeditorwidget.h:98
Definition: editorwidgetbase.h:68