LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
componentsymbolvariant.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_COMPONENTSYMBOLVARIANT_H
21 #define LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
33 
34 #include <QtCore>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 namespace library {
41 
42 /*******************************************************************************
43  * Class ComponentSymbolVariant
44  ******************************************************************************/
45 
59 public:
60  // Signals
61  enum class Event {
67  };
70 
71  // Constructors / Destructor
72  ComponentSymbolVariant() = delete;
73  ComponentSymbolVariant(const ComponentSymbolVariant& other) noexcept;
74  ComponentSymbolVariant(const Uuid& uuid, const QString& norm,
75  const ElementName& name_en_US,
76  const QString& desc_en_US) noexcept;
77  explicit ComponentSymbolVariant(const SExpression& node);
78  ~ComponentSymbolVariant() noexcept;
79 
80  // Getters: Attributes
81  const Uuid& getUuid() const noexcept { return mUuid; }
82  const QString& getNorm() const noexcept { return mNorm; }
83  const ElementName& getName() const noexcept {
84  return mNames.getDefaultValue(); // Used for SerializableObjectList
85  }
86  const LocalizedNameMap& getNames() const noexcept { return mNames; }
87  const LocalizedDescriptionMap& getDescriptions() const noexcept {
88  return mDescriptions;
89  }
90 
91  // Setters
92  bool setNorm(const QString& norm) noexcept;
93  bool setName(const QString& locale, const ElementName& name) noexcept;
94  bool setDescription(const QString& locale, const QString& desc) noexcept;
95  bool setNames(const LocalizedNameMap& names) noexcept;
96  bool setDescriptions(const LocalizedDescriptionMap& descriptions) noexcept;
97 
98  // Symbol Item Methods
100  return mSymbolItems;
101  }
103  return mSymbolItems;
104  }
105  QSet<Uuid> getAllSymbolUuids() const noexcept {
107  mSymbolItems);
108  }
109 
110  // General Methods
111 
113  void serialize(SExpression& root) const override;
114 
115  // Operator Overloadings
116  bool operator==(const ComponentSymbolVariant& rhs) const noexcept;
117  bool operator!=(const ComponentSymbolVariant& rhs) const noexcept {
118  return !(*this == rhs);
119  }
121 
122 private: // Methods
123  void itemsEdited(
124  const ComponentSymbolVariantItemList& list, int index,
125  const std::shared_ptr<const ComponentSymbolVariantItem>& item,
127 
128 private: // Data
130  QString mNorm;
134 
135  // Slots
137 };
138 
139 /*******************************************************************************
140  * Class ComponentSymbolVariantList
141  ******************************************************************************/
142 
144  static constexpr const char* tagname = "variant";
145 };
162 
163 /*******************************************************************************
164  * End of File
165  ******************************************************************************/
166 
167 } // namespace library
168 } // namespace librepcb
169 
170 #endif // LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANT_H
ComponentSymbolVariant & operator=(const ComponentSymbolVariant &rhs) noexcept
Definition: componentsymbolvariant.cpp:161
Slot< ComponentSymbolVariant, Event > OnEditedSlot
Definition: componentsymbolvariant.h:69
Slot< SerializableObjectList< ComponentSymbolVariantItem, ComponentSymbolVariantItemListNameProvider, OnEditedArgs...>, int, const std::shared_ptr< const ComponentSymbolVariantItem > &, Event > OnEditedSlot
Definition: serializableobjectlist.h:132
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
ComponentSymbolVariantItemList::OnEditedSlot mOnItemsEditedSlot
Definition: componentsymbolvariant.h:136
QSet< Uuid > getAllSymbolUuids() const noexcept
Definition: componentsymbolvariant.h:105
QString mNorm
Definition: componentsymbolvariant.h:130
LocalizedNameMap mNames
Definition: componentsymbolvariant.h:131
Definition: componentsymbolvariant.h:143
ComponentSymbolVariantItemList mSymbolItems
Definition: componentsymbolvariant.h:133
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: componentsymbolvariant.h:87
Signal< ComponentSymbolVariant, Event > onEdited
Definition: componentsymbolvariant.h:68
~ComponentSymbolVariant() noexcept
Definition: componentsymbolvariant.cpp:75
bool setNorm(const QString &norm) noexcept
Definition: componentsymbolvariant.cpp:82
bool setDescriptions(const LocalizedDescriptionMap &descriptions) noexcept
Definition: componentsymbolvariant.cpp:124
static constexpr const char * tagname
Definition: componentsymbolvariant.h:144
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:170
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
const T::ValueType & getDefaultValue() const noexcept
Definition: serializablekeyvaluemap.h:105
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
bool setName(const QString &locale, const ElementName &name) noexcept
Definition: componentsymbolvariant.cpp:92
const ComponentSymbolVariantItemList & getSymbolItems() const noexcept
Definition: componentsymbolvariant.h:102
LocalizedDescriptionMap mDescriptions
Definition: componentsymbolvariant.h:132
Event
Definition: componentsymbolvariant.h:61
bool setNames(const LocalizedNameMap &names) noexcept
Definition: componentsymbolvariant.cpp:114
ComponentSymbolVariantItemList & getSymbolItems() noexcept
Definition: componentsymbolvariant.h:99
Uuid mUuid
Definition: componentsymbolvariant.h:129
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariant.h:81
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:58
bool setDescription(const QString &locale, const QString &desc) noexcept
Definition: componentsymbolvariant.cpp:103
const QString & getNorm() const noexcept
Definition: componentsymbolvariant.h:82
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool operator!=(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.h:117
const LocalizedNameMap & getNames() const noexcept
Definition: componentsymbolvariant.h:86
const ElementName & getName() const noexcept
Definition: componentsymbolvariant.h:83
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:57
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsymbolvariant.cpp:139
bool operator==(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.cpp:151
void itemsEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition: componentsymbolvariant.cpp:178
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92