LibrePCB Developers Documentation
Loading...
Searching...
No Matches
packagecategorytab.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_PACKAGECATEGORYTAB_H
21#define LIBREPCB_EDITOR_PACKAGECATEGORYTAB_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../libraryeditortab.h"
27
31
32#include <QtCore>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class PackageCategory;
40
41namespace editor {
42
43class CategoryTreeModel;
44
45/*******************************************************************************
46 * Class PackageCategoryTab
47 ******************************************************************************/
48
53 Q_OBJECT
54
55public:
56 // Signals
58
59 // Types
60 enum class Mode { Open, New, Duplicate };
61
62 // Constructors / Destructor
64 PackageCategoryTab(const PackageCategoryTab& other) = delete;
65 explicit PackageCategoryTab(LibraryEditor& editor,
66 std::unique_ptr<PackageCategory> cat, Mode mode,
67 QObject* parent = nullptr) noexcept;
68 ~PackageCategoryTab() noexcept;
69
70 // General Methods
71 FilePath getDirectoryPath() const noexcept override;
72 ui::TabData getUiData() const noexcept override;
73 ui::CategoryTabData getDerivedUiData() const noexcept;
74 void setDerivedUiData(const ui::CategoryTabData& data) noexcept;
75 void trigger(ui::TabAction a) noexcept override;
76 bool requestClose() noexcept override;
77
78 // Operator Overloadings
79 PackageCategoryTab& operator=(const PackageCategoryTab& rhs) = delete;
80
81protected:
82 std::optional<std::pair<RuleCheckMessageList, QSet<SExpression>>>
83 runChecksImpl() override;
84 bool autoFixImpl(const std::shared_ptr<const RuleCheckMessage>& msg,
85 bool checkOnly) override;
86 template <typename MessageType>
87 bool autoFixHelper(const std::shared_ptr<const RuleCheckMessage>& msg,
88 bool checkOnly);
89 template <typename MessageType>
90 bool autoFix(const MessageType& msg);
91 void messageApprovalChanged(const SExpression& approval,
92 bool approved) noexcept override;
93 void notifyDerivedUiDataChanged() noexcept override;
94
95private:
96 bool isWritable() const noexcept;
97 void refreshUiData() noexcept;
98 void commitUiData() noexcept;
99 bool save() noexcept;
100
101private:
102 // References
104
105 // State
107
108 // Library metadata to be applied
109 slint::SharedString mName;
110 slint::SharedString mNameError;
112 slint::SharedString mDescription;
113 slint::SharedString mKeywords;
114 slint::SharedString mAuthor;
115 slint::SharedString mVersion;
116 slint::SharedString mVersionError;
119 std::optional<Uuid> mParent;
120 std::shared_ptr<slint::VectorModel<slint::SharedString>> mParents;
122};
123
124/*******************************************************************************
125 * End of File
126 ******************************************************************************/
127
128} // namespace editor
129} // namespace librepcb
130
131#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The PackageCategory class.
Definition packagecategory.h:44
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The SExpression class.
Definition sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Version class represents a version number in the format "1.42.7".
Definition version.h:58
The CategoryTreeModel class.
Definition categorytreemodel.h:50
The LibraryEditor class.
Definition libraryeditor.h:56
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:55
The PackageCategoryTab class.
Definition packagecategorytab.h:52
std::unique_ptr< PackageCategory > mCategory
Definition packagecategorytab.h:103
slint::SharedString mVersionError
Definition packagecategorytab.h:116
bool requestClose() noexcept override
Request to close the tab.
Definition packagecategorytab.cpp:232
std::optional< std::pair< RuleCheckMessageList, QSet< SExpression > > > runChecksImpl() override
Definition packagecategorytab.cpp:260
bool save() noexcept
Definition packagecategorytab.cpp:384
std::shared_ptr< slint::VectorModel< slint::SharedString > > mParents
Definition packagecategorytab.h:120
slint::SharedString mName
Definition packagecategorytab.h:109
std::shared_ptr< CategoryTreeModel > mParentsModel
Definition packagecategorytab.h:121
void setDerivedUiData(const ui::CategoryTabData &data) noexcept
Definition packagecategorytab.cpp:162
slint::SharedString mDescription
Definition packagecategorytab.h:112
Mode
Definition packagecategorytab.h:60
slint::SharedString mVersion
Definition packagecategorytab.h:115
bool mDeprecated
Definition packagecategorytab.h:118
void messageApprovalChanged(const SExpression &approval, bool approved) noexcept override
Definition packagecategorytab.cpp:287
bool autoFixImpl(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly) override
Definition packagecategorytab.cpp:265
PackageCategoryTab(const PackageCategoryTab &other)=delete
FilePath getDirectoryPath() const noexcept override
Definition packagecategorytab.cpp:108
bool autoFixHelper(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)
Definition packagecategorytab.cpp:273
Version mVersionParsed
Definition packagecategorytab.h:117
void commitUiData() noexcept
Definition packagecategorytab.cpp:358
bool autoFix(const MessageType &msg)
slint::SharedString mNameError
Definition packagecategorytab.h:110
slint::SharedString mKeywords
Definition packagecategorytab.h:113
bool mChooseParent
Definition packagecategorytab.h:106
Signal< PackageCategoryTab > onDerivedUiDataChanged
Definition packagecategorytab.h:57
void trigger(ui::TabAction a) noexcept override
Definition packagecategorytab.cpp:189
void notifyDerivedUiDataChanged() noexcept override
Definition packagecategorytab.cpp:297
ElementName mNameParsed
Definition packagecategorytab.h:111
std::optional< Uuid > mParent
Definition packagecategorytab.h:119
slint::SharedString mAuthor
Definition packagecategorytab.h:114
bool isWritable() const noexcept
Definition packagecategorytab.cpp:324
ui::TabData getUiData() const noexcept override
Definition packagecategorytab.cpp:112
ui::CategoryTabData getDerivedUiData() const noexcept
Definition packagecategorytab.cpp:134
void refreshUiData() noexcept
Definition packagecategorytab.cpp:328
Definition occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84
Definition uuid.h:186