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 QObject,
60  public SerializableObject,
61  private ComponentSymbolVariantItemList::IF_Observer {
62  Q_OBJECT
63 
64 public:
65  // Constructors / Destructor
66  ComponentSymbolVariant() = delete;
67  ComponentSymbolVariant(const ComponentSymbolVariant& other) noexcept;
68  ComponentSymbolVariant(const Uuid& uuid, const QString& norm,
69  const ElementName& name_en_US,
70  const QString& desc_en_US) noexcept;
71  explicit ComponentSymbolVariant(const SExpression& node);
72  ~ComponentSymbolVariant() noexcept;
73 
74  // Getters: Attributes
75  const Uuid& getUuid() const noexcept { return mUuid; }
76  const QString& getNorm() const noexcept { return mNorm; }
77  const LocalizedNameMap& getNames() const noexcept { return mNames; }
78  const LocalizedDescriptionMap& getDescriptions() const noexcept {
79  return mDescriptions;
80  }
81 
82  // Setters
83  void setNorm(const QString& norm) noexcept;
84  void setName(const QString& locale, const ElementName& name) noexcept;
85  void setDescription(const QString& locale, const QString& desc) noexcept;
86  void setNames(const LocalizedNameMap& names) noexcept;
87  void setDescriptions(const LocalizedDescriptionMap& descriptions) noexcept;
88 
89  // Symbol Item Methods
91  return mSymbolItems;
92  }
94  return mSymbolItems;
95  }
96  QSet<Uuid> getAllSymbolUuids() const noexcept {
98  mSymbolItems);
99  }
100 
101  // General Methods
102 
104  void serialize(SExpression& root) const override;
105 
106  // Operator Overloadings
107  bool operator==(const ComponentSymbolVariant& rhs) const noexcept;
108  bool operator!=(const ComponentSymbolVariant& rhs) const noexcept {
109  return !(*this == rhs);
110  }
112 
113 signals:
114  void edited();
115 
116 private: // Methods
117  void listObjectAdded(
118  const ComponentSymbolVariantItemList& list, int newIndex,
119  const std::shared_ptr<ComponentSymbolVariantItem>& ptr) noexcept override;
120  void listObjectRemoved(
121  const ComponentSymbolVariantItemList& list, int oldIndex,
122  const std::shared_ptr<ComponentSymbolVariantItem>& ptr) noexcept override;
123 
124 private: // Data
126  QString mNorm;
130 };
131 
132 /*******************************************************************************
133  * Class ComponentSymbolVariantList
134  ******************************************************************************/
135 
137  static constexpr const char* tagname = "variant";
138 };
151 
152 /*******************************************************************************
153  * End of File
154  ******************************************************************************/
155 
156 } // namespace library
157 } // namespace librepcb
158 
159 #endif // LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANT_H
ComponentSymbolVariant & operator=(const ComponentSymbolVariant &rhs) noexcept
Definition: componentsymbolvariant.cpp:134
void setName(const QString &locale, const ElementName &name) noexcept
Definition: componentsymbolvariant.cpp:81
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
void listObjectAdded(const ComponentSymbolVariantItemList &list, int newIndex, const std::shared_ptr< ComponentSymbolVariantItem > &ptr) noexceptoverride
Definition: componentsymbolvariant.cpp:154
void setDescriptions(const LocalizedDescriptionMap &descriptions) noexcept
Definition: componentsymbolvariant.cpp:101
QSet< Uuid > getAllSymbolUuids() const noexcept
Definition: componentsymbolvariant.h:96
QString mNorm
Definition: componentsymbolvariant.h:126
LocalizedNameMap mNames
Definition: componentsymbolvariant.h:127
Definition: componentsymbolvariant.h:136
void setNames(const LocalizedNameMap &names) noexcept
Definition: componentsymbolvariant.cpp:95
ComponentSymbolVariantItemList mSymbolItems
Definition: componentsymbolvariant.h:129
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: componentsymbolvariant.h:78
~ComponentSymbolVariant() noexcept
Definition: componentsymbolvariant.cpp:69
static constexpr const char * tagname
Definition: componentsymbolvariant.h:137
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:149
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
const ComponentSymbolVariantItemList & getSymbolItems() const noexcept
Definition: componentsymbolvariant.h:93
LocalizedDescriptionMap mDescriptions
Definition: componentsymbolvariant.h:128
void listObjectRemoved(const ComponentSymbolVariantItemList &list, int oldIndex, const std::shared_ptr< ComponentSymbolVariantItem > &ptr) noexceptoverride
Definition: componentsymbolvariant.cpp:164
ComponentSymbolVariantItemList & getSymbolItems() noexcept
Definition: componentsymbolvariant.h:90
Uuid mUuid
Definition: componentsymbolvariant.h:125
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariant.h:75
void setNorm(const QString &norm) noexcept
Definition: componentsymbolvariant.cpp:76
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:58
const QString & getNorm() const noexcept
Definition: componentsymbolvariant.h:76
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setDescription(const QString &locale, const QString &desc) noexcept
Definition: componentsymbolvariant.cpp:88
bool operator!=(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.h:108
const LocalizedNameMap & getNames() const noexcept
Definition: componentsymbolvariant.h:77
The SExpression class.
Definition: sexpression.h:60
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsymbolvariant.cpp:112
bool operator==(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.cpp:124
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92