LibrePCB Developers Documentation
Loading...
Searching...
No Matches
devicetab.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_DEVICETAB_H
21#define LIBREPCB_EDITOR_DEVICETAB_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 Component;
40class Device;
41class Package;
42class Symbol;
43
44namespace editor {
45
46class AttributeListModel;
47class CategoryTreeModel;
48class ComponentSignalNameListModel;
49class DevicePinoutBuilder;
50class DevicePinoutListModel;
51class FootprintGraphicsItem;
52class GraphicsScene;
53class LibraryEditor;
54class LibraryElementCategoriesModel;
55class PartListModel;
56class SymbolGraphicsItem;
57
58/*******************************************************************************
59 * Class DeviceTab
60 ******************************************************************************/
61
65class DeviceTab final : public LibraryEditorTab {
66 Q_OBJECT
67
68public:
69 // Signals
71
72 // Types
73 enum class Mode { Open, New, Duplicate };
74
75 // Constructors / Destructor
76 DeviceTab() = delete;
77 DeviceTab(const DeviceTab& other) = delete;
78 explicit DeviceTab(LibraryEditor& editor, std::unique_ptr<Device> dev,
79 Mode mode, QObject* parent = nullptr) noexcept;
80 ~DeviceTab() noexcept;
81
82 // General Methods
83 FilePath getDirectoryPath() const noexcept override;
84 ui::TabData getUiData() const noexcept override;
85 ui::DeviceTabData getDerivedUiData() const noexcept;
86 void setDerivedUiData(const ui::DeviceTabData& data) noexcept;
87 void trigger(ui::TabAction a) noexcept override;
88 slint::Image renderScene(float width, float height,
89 int scene) noexcept override;
90 bool requestClose() noexcept override;
91
92 // Operator Overloadings
93 DeviceTab& operator=(const DeviceTab& rhs) = delete;
94
95protected:
96 std::optional<std::pair<RuleCheckMessageList, QSet<SExpression>>>
97 runChecksImpl() override;
98 bool autoFixImpl(const std::shared_ptr<const RuleCheckMessage>& msg,
99 bool checkOnly) override;
100 template <typename MessageType>
101 bool autoFixHelper(const std::shared_ptr<const RuleCheckMessage>& msg,
102 bool checkOnly);
103 template <typename MessageType>
104 bool autoFix(const MessageType& msg);
105 void messageApprovalChanged(const SExpression& approval,
106 bool approved) noexcept override;
107 void notifyDerivedUiDataChanged() noexcept override;
108
109private:
110 bool isWritable() const noexcept;
111 void refreshUiData() noexcept;
112 void refreshDependentElements() noexcept;
113 void commitUiData() noexcept;
114 bool save() noexcept;
115 void selectComponent() noexcept;
116 void selectPackage() noexcept;
117
118private:
119 // References
120 std::unique_ptr<Device> mDevice;
121 const Mode mMode;
122 const bool mIsNewElement;
123 QCollator mCollator;
128
129 // State
135
136 // Library metadata to be applied
137 slint::SharedString mName;
138 slint::SharedString mNameError;
140 slint::SharedString mDescription;
141 slint::SharedString mKeywords;
142 slint::SharedString mAuthor;
143 slint::SharedString mVersion;
144 slint::SharedString mVersionError;
149 slint::SharedString mDatasheetUrl;
150 slint::SharedString mDatasheetUrlError;
153 std::shared_ptr<slint::SortModel<ui::DevicePinoutData>> mPinoutSorted;
155
161
162 // Referenced library elements
163 std::shared_ptr<const Component> mComponent; // May be nullptr!
164 QString mComponentDescription; // Error message on failure
165 QList<std::shared_ptr<const Symbol>> mSymbols;
167 std::shared_ptr<const Package> mPackage; // May be nullptr!
168 QString mPackageDescription; // Error message on failure
170};
171
172/*******************************************************************************
173 * End of File
174 ******************************************************************************/
175
176} // namespace editor
177} // namespace librepcb
178
179#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
The Device class represents an instance of a component (a "real" component)
Definition device.h:55
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Image class.
Definition image.h:49
The Package class represents a package of a component (including footprint and 3D model)
Definition package.h:59
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 Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:56
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 ComponentSignalNameListModel class.
Definition componentsignalnamelistmodel.h:50
The DevicePinoutBuilder class.
Definition devicepinoutbuilder.h:49
The DevicePinoutListModel class.
Definition devicepinoutlistmodel.h:51
The DeviceTab class.
Definition devicetab.h:65
slint::Image renderScene(float width, float height, int scene) noexcept override
Definition devicetab.cpp:492
DeviceTab(const DeviceTab &other)=delete
slint::SharedString mVersionError
Definition devicetab.h:144
std::shared_ptr< LibraryElementCategoriesModel > mCategories
Definition devicetab.h:147
bool requestClose() noexcept override
Request to close the tab.
Definition devicetab.cpp:509
std::optional< std::pair< RuleCheckMessageList, QSet< SExpression > > > runChecksImpl() override
Definition devicetab.cpp:537
slint::SharedString mDatasheetUrlError
Definition devicetab.h:150
bool save() noexcept
Definition devicetab.cpp:789
std::unique_ptr< FootprintGraphicsItem > mFootprintGraphicsItem
Definition devicetab.h:169
std::shared_ptr< ComponentSignalNameListModel > mSignalNames
Definition devicetab.h:125
void selectComponent() noexcept
Definition devicetab.cpp:826
slint::SharedString mName
Definition devicetab.h:137
void setDerivedUiData(const ui::DeviceTabData &data) noexcept
Definition devicetab.cpp:313
QString mComponentDescription
Definition devicetab.h:164
QList< std::shared_ptr< SymbolGraphicsItem > > mSymbolGraphicsItems
Definition devicetab.h:166
ui::DeviceTabData getDerivedUiData() const noexcept
Definition devicetab.cpp:238
slint::SharedString mDescription
Definition devicetab.h:140
Mode
Definition devicetab.h:73
std::shared_ptr< const Component > mComponent
Definition devicetab.h:163
slint::SharedString mVersion
Definition devicetab.h:143
bool mWizardMode
Definition devicetab.h:130
bool mDeprecated
Definition devicetab.h:146
const bool mIsNewElement
Definition devicetab.h:122
std::shared_ptr< const Package > mPackage
Definition devicetab.h:167
Uuid mOriginalComponentUuid
Definition devicetab.h:158
void messageApprovalChanged(const SExpression &approval, bool approved) noexcept override
Definition devicetab.cpp:569
void selectPackage() noexcept
Definition devicetab.cpp:862
bool autoFixImpl(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly) override
Definition devicetab.cpp:546
bool mPackageSelected
Definition devicetab.h:133
std::shared_ptr< DevicePinoutListModel > mPinout
Definition devicetab.h:152
DevicePadSignalMap mOriginalPadSignalMap
Definition devicetab.h:160
FilePath getDirectoryPath() const noexcept override
Definition devicetab.cpp:212
bool autoFixHelper(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)
Definition devicetab.cpp:555
slint::SharedString mDatasheetUrl
Definition devicetab.h:149
std::shared_ptr< AttributeListModel > mAttributes
Definition devicetab.h:151
std::unique_ptr< GraphicsScene > mPackageScene
Definition devicetab.h:127
Version mVersionParsed
Definition devicetab.h:145
std::unique_ptr< DevicePinoutBuilder > mPinoutBuilder
Definition devicetab.h:124
void commitUiData() noexcept
Definition devicetab.cpp:739
bool autoFix(const MessageType &msg)
std::shared_ptr< slint::SortModel< ui::DevicePinoutData > > mPinoutSorted
Definition devicetab.h:153
slint::SharedString mNameError
Definition devicetab.h:138
std::unique_ptr< GraphicsScene > mComponentScene
Definition devicetab.h:126
slint::SharedString mKeywords
Definition devicetab.h:141
Signal< DeviceTab > onDerivedUiDataChanged
Definition devicetab.h:70
std::unique_ptr< Device > mDevice
Definition devicetab.h:120
void trigger(ui::TabAction a) noexcept override
Definition devicetab.cpp:347
std::shared_ptr< CategoryTreeModel > mCategoriesTree
Definition devicetab.h:148
QCollator mCollator
Definition devicetab.h:123
bool mComponentSelected
Definition devicetab.h:132
void notifyDerivedUiDataChanged() noexcept override
Definition devicetab.cpp:579
bool mChooseCategory
Definition devicetab.h:134
ElementName mNameParsed
Definition devicetab.h:139
std::shared_ptr< PartListModel > mParts
Definition devicetab.h:154
Uuid mOriginalPackageUuid
Definition devicetab.h:159
slint::SharedString mAuthor
Definition devicetab.h:142
QList< std::shared_ptr< const Symbol > > mSymbols
Definition devicetab.h:165
bool isWritable() const noexcept
Definition devicetab.cpp:617
const Mode mMode
Definition devicetab.h:121
ui::TabData getUiData() const noexcept override
Definition devicetab.cpp:216
QString mPackageDescription
Definition devicetab.h:168
int mCurrentPageIndex
Definition devicetab.h:131
void refreshDependentElements() noexcept
Definition devicetab.cpp:666
void refreshUiData() noexcept
Definition devicetab.cpp:625
bool mIsInterfaceBroken
Broken interface detection.
Definition devicetab.h:157
The FootprintGraphicsItem class.
Definition footprintgraphicsitem.h:66
The GraphicsScene class.
Definition graphicsscene.h:64
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
The PartListModel class.
Definition partlistmodel.h:49
The SymbolGraphicsItem class.
Definition symbolgraphicsitem.h:55
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