LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packagecategoryeditorwidget.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_PACKAGECATEGORYEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGECATEGORYEDITORWIDGET_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 PackageCategory;
41 
42 namespace editor {
43 
44 namespace Ui {
45 class PackageCategoryEditorWidget;
46 }
47 
48 /*******************************************************************************
49  * Class PackageCategoryEditorWidget
50  ******************************************************************************/
51 
56  Q_OBJECT
57 
58 public:
59  // Constructors / Destructor
60  PackageCategoryEditorWidget() = delete;
62  delete;
63  PackageCategoryEditorWidget(const Context& context, const FilePath& fp,
64  QWidget* parent = nullptr);
66 
67  // Operator Overloadings
69  const PackageCategoryEditorWidget& 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::PackageCategoryEditorWidget> mUi;
93  QSharedPointer<PackageCategory> 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_PACKAGECATEGORYEDITORWIDGET_H
tl::optional< Uuid > mParentUuid
Definition: packagecategoryeditorwidget.h:94
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
void btnChooseParentCategoryClicked() noexcept
Definition: packagecategoryeditorwidget.cpp:197
QScopedPointer< Ui::PackageCategoryEditorWidget > mUi
Definition: packagecategoryeditorwidget.h:92
QString commitMetadata() noexcept
Definition: packagecategoryeditorwidget.cpp:127
void updateCategoryLabel() noexcept
Definition: packagecategoryeditorwidget.cpp:210
void updateMetadata() noexcept
Definition: packagecategoryeditorwidget.cpp:114
bool isInterfaceBroken() const noexceptoverride
Definition: packagecategoryeditorwidget.h:77
The PackageCategoryEditorWidget class.
Definition: packagecategoryeditorwidget.h:55
~PackageCategoryEditorWidget() noexcept
Definition: packagecategoryeditorwidget.cpp:85
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: packagecategoryeditorwidget.cpp:190
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: packagecategoryeditorwidget.cpp:158
PackageCategoryEditorWidget & operator=(const PackageCategoryEditorWidget &rhs)=delete
void btnResetParentCategoryClicked() noexcept
Definition: packagecategoryeditorwidget.cpp:205
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: packagecategoryeditorwidget.cpp:179
QSharedPointer< PackageCategory > mCategory
Definition: packagecategoryeditorwidget.h:93
bool save() noexceptoverride
Definition: packagecategoryeditorwidget.cpp:92
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The PackageCategory class.
Definition: packagecategory.h:43
The EditorWidgetBase class.
Definition: editorwidgetbase.h:66