LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_COMPONENTCATEGORYEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_COMPONENTCATEGORYEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../common/editorwidgetbase.h"
27 
28 #include <librepcb/common/uuid.h>
29 #include <optional/tl/optional.hpp>
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 namespace library {
39 
40 class ComponentCategory;
41 
42 namespace editor {
43 
44 namespace Ui {
45 class ComponentCategoryEditorWidget;
46 }
47 
48 /*******************************************************************************
49  * Class ComponentCategoryEditorWidget
50  ******************************************************************************/
51 
56  Q_OBJECT
57 
58 public:
59  // Constructors / Destructor
62  delete;
63  ComponentCategoryEditorWidget(const Context& context, const FilePath& fp,
64  QWidget* parent = nullptr);
66 
67  // Operator Overloadings
69  const ComponentCategoryEditorWidget& rhs) = delete;
70 
71 public slots:
72  bool save() noexcept override;
73 
74 private: // Methods
75  void updateMetadata() noexcept;
76  QString commitMetadata() noexcept;
77  bool isInterfaceBroken() const noexcept override { return false; }
78  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
79  template <typename MessageType>
80  void fixMsg(const MessageType& msg);
81  template <typename MessageType>
82  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
83  bool applyFix);
85  std::shared_ptr<const LibraryElementCheckMessage> msg,
86  bool applyFix) override;
87  void btnChooseParentCategoryClicked() noexcept;
88  void btnResetParentCategoryClicked() noexcept;
89  void updateCategoryLabel() noexcept;
90 
91 private: // Data
92  QScopedPointer<Ui::ComponentCategoryEditorWidget> mUi;
93  QScopedPointer<ComponentCategory> mCategory;
94  tl::optional<Uuid> mParentUuid;
95 };
96 
97 /*******************************************************************************
98  * End of File
99  ******************************************************************************/
100 
101 } // namespace editor
102 } // namespace library
103 } // namespace librepcb
104 
105 #endif // LIBREPCB_LIBRARY_EDITOR_COMPONENTCATEGORYEDITORWIDGET_H
~ComponentCategoryEditorWidget() noexcept
Definition: componentcategoryeditorwidget.cpp:86
bool save() noexceptoverride
Definition: componentcategoryeditorwidget.cpp:93
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
QString commitMetadata() noexcept
Definition: componentcategoryeditorwidget.cpp:129
The ComponentCategory class.
Definition: componentcategory.h:43
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: componentcategoryeditorwidget.cpp:160
void updateCategoryLabel() noexcept
Definition: componentcategoryeditorwidget.cpp:212
tl::optional< Uuid > mParentUuid
Definition: componentcategoryeditorwidget.h:94
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: componentcategoryeditorwidget.cpp:181
void updateMetadata() noexcept
Definition: componentcategoryeditorwidget.cpp:116
QScopedPointer< Ui::ComponentCategoryEditorWidget > mUi
Definition: componentcategoryeditorwidget.h:92
bool isInterfaceBroken() const noexceptoverride
Definition: componentcategoryeditorwidget.h:77
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
ComponentCategoryEditorWidget & operator=(const ComponentCategoryEditorWidget &rhs)=delete
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: componentcategoryeditorwidget.cpp:192
The ComponentCategoryEditorWidget class.
Definition: componentcategoryeditorwidget.h:55
void btnResetParentCategoryClicked() noexcept
Definition: componentcategoryeditorwidget.cpp:207
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The EditorWidgetBase class.
Definition: editorwidgetbase.h:65
QScopedPointer< ComponentCategory > mCategory
Definition: componentcategoryeditorwidget.h:93
void btnChooseParentCategoryClicked() noexcept
Definition: componentcategoryeditorwidget.cpp:199