LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componenttab.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_COMPONENTTAB_H
21#define LIBREPCB_EDITOR_COMPONENTTAB_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../libraryeditortab.h"
27
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Component;
41
42namespace editor {
43
44class AttributeListModel;
45class CategoryTreeModel;
46class ComponentSignalListModel;
47class ComponentSignalNameListModel;
48class ComponentVariantListModel;
49class LibraryEditor;
50class LibraryElementCategoriesModel;
51
52/*******************************************************************************
53 * Class ComponentTab
54 ******************************************************************************/
55
59class ComponentTab final : public LibraryEditorTab {
60 Q_OBJECT
61
62public:
63 // Signals
65
66 // Types
67 enum class Mode { Open, New, Duplicate };
68
69 // Constructors / Destructor
70 ComponentTab() = delete;
71 ComponentTab(const ComponentTab& other) = delete;
72 explicit ComponentTab(LibraryEditor& editor, std::unique_ptr<Component> cmp,
73 Mode mode, QObject* parent = nullptr) noexcept;
74 ~ComponentTab() noexcept;
75
76 // General Methods
77 FilePath getDirectoryPath() const noexcept override;
78 ui::TabData getUiData() const noexcept override;
79 ui::ComponentTabData getDerivedUiData() const noexcept;
80 void setDerivedUiData(const ui::ComponentTabData& data) noexcept;
81 void trigger(ui::TabAction a) noexcept override;
82 slint::Image renderScene(float width, float height,
83 int scene) noexcept override;
84 bool requestClose() noexcept override;
85
86 // Operator Overloadings
87 ComponentTab& operator=(const ComponentTab& rhs) = delete;
88
89protected:
90 std::optional<std::pair<RuleCheckMessageList, QSet<SExpression>>>
91 runChecksImpl() override;
92 bool autoFixImpl(const std::shared_ptr<const RuleCheckMessage>& msg,
93 bool checkOnly) override;
94 template <typename MessageType>
95 bool autoFixHelper(const std::shared_ptr<const RuleCheckMessage>& msg,
96 bool checkOnly);
97 template <typename MessageType>
98 bool autoFix(const MessageType& msg);
99 void messageApprovalChanged(const SExpression& approval,
100 bool approved) noexcept override;
101 void notifyDerivedUiDataChanged() noexcept override;
102
103private:
104 bool isWritable() const noexcept;
105 bool isInterfaceBroken() const noexcept;
106 void refreshUiData() noexcept;
107 void commitUiData() noexcept;
108 bool save() noexcept;
109
110private:
111 // References
113 const bool mIsNewElement;
114
115 // State
119
120 // Library metadata to be applied
121 slint::SharedString mName;
122 slint::SharedString mNameError;
124 slint::SharedString mDescription;
125 slint::SharedString mKeywords;
126 slint::SharedString mAuthor;
127 slint::SharedString mVersion;
128 slint::SharedString mVersionError;
133 slint::SharedString mDatasheetUrl;
134 slint::SharedString mDatasheetUrlError;
136 slint::SharedString mPrefix;
137 slint::SharedString mPrefixError;
139 slint::SharedString mDefaultValue;
140 slint::SharedString mDefaultValueError;
143 std::shared_ptr<slint::SortModel<ui::ComponentSignalData>> mSignalsSorted;
145 slint::SharedString mNewSignalName;
146 slint::SharedString mNewSignalNameError;
148
154};
155
156/*******************************************************************************
157 * End of File
158 ******************************************************************************/
159
160} // namespace editor
161} // namespace librepcb
162
163#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Image class.
Definition image.h:49
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 AttributeListModel class.
Definition attributelistmodel.h:49
The CategoryTreeModel class.
Definition categorytreemodel.h:50
The ComponentSignalListModel class.
Definition componentsignallistmodel.h:53
The ComponentSignalNameListModel class.
Definition componentsignalnamelistmodel.h:50
The ComponentTab class.
Definition componenttab.h:59
slint::Image renderScene(float width, float height, int scene) noexcept override
Definition componenttab.cpp:365
slint::SharedString mVersionError
Definition componenttab.h:128
std::shared_ptr< LibraryElementCategoriesModel > mCategories
Definition componenttab.h:131
bool requestClose() noexcept override
Request to close the tab.
Definition componenttab.cpp:372
slint::SharedString mNewSignalName
Definition componenttab.h:145
std::optional< std::pair< RuleCheckMessageList, QSet< SExpression > > > runChecksImpl() override
Definition componenttab.cpp:400
slint::SharedString mDatasheetUrlError
Definition componenttab.h:134
bool save() noexcept
Definition componenttab.cpp:686
std::shared_ptr< ComponentSignalNameListModel > mSignalNames
Definition componenttab.h:144
bool isInterfaceBroken() const noexcept
Definition componenttab.cpp:551
slint::SharedString mName
Definition componenttab.h:121
std::shared_ptr< slint::SortModel< ui::ComponentSignalData > > mSignalsSorted
Definition componenttab.h:143
slint::SharedString mDefaultValueError
Definition componenttab.h:140
slint::SharedString mDescription
Definition componenttab.h:124
Mode
Definition componenttab.h:67
slint::SharedString mVersion
Definition componenttab.h:127
slint::SharedString mPrefixError
Definition componenttab.h:137
bool mWizardMode
Definition componenttab.h:116
bool mDeprecated
Definition componenttab.h:130
const bool mIsNewElement
Definition componenttab.h:113
slint::SharedString mPrefix
Definition componenttab.h:136
void messageApprovalChanged(const SExpression &approval, bool approved) noexcept override
Definition componenttab.cpp:439
ComponentPrefix mPrefixParsed
Definition componenttab.h:138
bool autoFixImpl(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly) override
Definition componenttab.cpp:410
FilePath getDirectoryPath() const noexcept override
Definition componenttab.cpp:154
bool autoFixHelper(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)
Definition componenttab.cpp:425
slint::SharedString mDatasheetUrl
Definition componenttab.h:133
std::shared_ptr< AttributeListModel > mAttributes
Definition componenttab.h:141
Version mVersionParsed
Definition componenttab.h:129
void commitUiData() noexcept
Definition componenttab.cpp:630
bool autoFix(const MessageType &msg)
slint::SharedString mDefaultValue
Definition componenttab.h:139
slint::SharedString mNameError
Definition componenttab.h:122
slint::SharedString mKeywords
Definition componenttab.h:125
std::unique_ptr< Component > mComponent
Definition componenttab.h:112
QSet< Uuid > mOriginalSignalUuids
Definition componenttab.h:152
ComponentSymbolVariantList mOriginalSymbolVariants
Definition componenttab.h:153
bool mSchematicOnly
Definition componenttab.h:135
ui::ComponentTabData getDerivedUiData() const noexcept
Definition componenttab.cpp:180
void trigger(ui::TabAction a) noexcept override
Definition componenttab.cpp:278
std::shared_ptr< CategoryTreeModel > mCategoriesTree
Definition componenttab.h:132
void setDerivedUiData(const ui::ComponentTabData &data) noexcept
Definition componenttab.cpp:225
Signal< ComponentTab > onDerivedUiDataChanged
Definition componenttab.h:64
bool mOriginalIsSchematicOnly
Definition componenttab.h:151
void notifyDerivedUiDataChanged() noexcept override
Definition componenttab.cpp:449
bool mChooseCategory
Definition componenttab.h:118
ElementName mNameParsed
Definition componenttab.h:123
slint::SharedString mAuthor
Definition componenttab.h:126
std::shared_ptr< ComponentVariantListModel > mVariants
Definition componenttab.h:147
bool isWritable() const noexcept
Definition componenttab.cpp:547
ui::TabData getUiData() const noexcept override
Definition componenttab.cpp:158
int mCurrentPageIndex
Definition componenttab.h:117
std::shared_ptr< ComponentSignalListModel > mSignals
Definition componenttab.h:142
slint::SharedString mNewSignalNameError
Definition componenttab.h:146
void refreshUiData() noexcept
Definition componenttab.cpp:594
ComponentTab(const ComponentTab &other)=delete
bool mIsInterfaceBroken
Broken interface detection.
Definition componenttab.h:150
The ComponentVariantListModel class.
Definition componentvariantlistmodel.h:58
The LibraryEditor class.
Definition libraryeditor.h:56
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:55
The LibraryElementCategoriesModel class.
Definition libraryelementcategoriesmodel.h:50
Definition occmodel.cpp:77
type_safe::constrained_type< QString, ComponentPrefixConstraint, ComponentPrefixVerifier > ComponentPrefix
Definition componentprefix.h:81
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