LibrePCB Developers Documentation
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_CORE_COMPONENTSYMBOLVARIANT_H
21 #define LIBREPCB_CORE_COMPONENTSYMBOLVARIANT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../serialization/serializablekeyvaluemap.h"
27 #include "../../serialization/serializableobjectlist.h"
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class ComponentSymbolVariant
39  ******************************************************************************/
40 
54 public:
55  // Signals
56  enum class Event {
62  };
65 
66  // Constructors / Destructor
67  ComponentSymbolVariant() = delete;
68  ComponentSymbolVariant(const ComponentSymbolVariant& other) noexcept;
69  ComponentSymbolVariant(const Uuid& uuid, const QString& norm,
70  const ElementName& name_en_US,
71  const QString& desc_en_US) noexcept;
72  explicit ComponentSymbolVariant(const SExpression& node);
73  ~ComponentSymbolVariant() noexcept;
74 
75  // Getters: Attributes
76  const Uuid& getUuid() const noexcept { return mUuid; }
77  const QString& getNorm() const noexcept { return mNorm; }
78  const ElementName& getName() const noexcept {
79  return mNames.getDefaultValue(); // Used for SerializableObjectList
80  }
81  const LocalizedNameMap& getNames() const noexcept { return mNames; }
82  const LocalizedDescriptionMap& getDescriptions() const noexcept {
83  return mDescriptions;
84  }
85 
86  // Setters
87  bool setNorm(const QString& norm) noexcept;
88  bool setName(const QString& locale, const ElementName& name) noexcept;
89  bool setDescription(const QString& locale, const QString& desc) noexcept;
90  bool setNames(const LocalizedNameMap& names) noexcept;
91  bool setDescriptions(const LocalizedDescriptionMap& descriptions) noexcept;
92 
93  // Symbol Item Methods
95  return mSymbolItems;
96  }
98  return mSymbolItems;
99  }
100  QSet<Uuid> getAllSymbolUuids() const noexcept {
102  mSymbolItems);
103  }
104 
105  // General Methods
106 
112  void serialize(SExpression& root) const;
113 
114  // Operator Overloadings
115  bool operator==(const ComponentSymbolVariant& rhs) const noexcept;
116  bool operator!=(const ComponentSymbolVariant& rhs) const noexcept {
117  return !(*this == rhs);
118  }
120 
121 private: // Methods
122  void itemsEdited(
123  const ComponentSymbolVariantItemList& list, int index,
124  const std::shared_ptr<const ComponentSymbolVariantItem>& item,
126 
127 private: // Data
129  QString mNorm;
133 
134  // Slots
136 };
137 
138 /*******************************************************************************
139  * Class ComponentSymbolVariantList
140  ******************************************************************************/
141 
143  static constexpr const char* tagname = "variant";
144 };
149 
150 /*******************************************************************************
151  * End of File
152  ******************************************************************************/
153 
154 } // namespace librepcb
155 
156 #endif
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentsymbolvariant.cpp:138
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariant.h:76
LocalizedNameMap mNames
Definition: componentsymbolvariant.h:130
Uuid mUuid
Definition: componentsymbolvariant.h:128
bool setDescription(const QString &locale, const QString &desc) noexcept
Definition: componentsymbolvariant.cpp:102
Definition: occmodel.cpp:77
ComponentSymbolVariantItemList mSymbolItems
Definition: componentsymbolvariant.h:132
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:160
ComponentSymbolVariantItemList & getSymbolItems() noexcept
Definition: componentsymbolvariant.h:94
bool operator!=(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.h:116
Definition: componentsymbolvariant.h:142
bool setDescriptions(const LocalizedDescriptionMap &descriptions) noexcept
Definition: componentsymbolvariant.cpp:123
const QString & getNorm() const noexcept
Definition: componentsymbolvariant.h:77
Event
Definition: componentsymbolvariant.h:56
const T::ValueType & getDefaultValue() const noexcept
Definition: serializablekeyvaluemap.h:105
LocalizedDescriptionMap mDescriptions
Definition: componentsymbolvariant.h:131
Slot< ComponentSymbolVariant, Event > OnEditedSlot
Definition: componentsymbolvariant.h:64
ComponentSymbolVariant & operator=(const ComponentSymbolVariant &rhs) noexcept
Definition: componentsymbolvariant.cpp:164
void itemsEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition: componentsymbolvariant.cpp:181
const ComponentSymbolVariantItemList & getSymbolItems() const noexcept
Definition: componentsymbolvariant.h:97
QString mNorm
Definition: componentsymbolvariant.h:129
bool setNorm(const QString &norm) noexcept
Definition: componentsymbolvariant.cpp:81
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition: componentsymbolvariant.h:82
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
ComponentSymbolVariantItemList::OnEditedSlot mOnItemsEditedSlot
Definition: componentsymbolvariant.h:135
~ComponentSymbolVariant() noexcept
Definition: componentsymbolvariant.cpp:74
QSet< Uuid > getAllSymbolUuids() const noexcept
Definition: componentsymbolvariant.h:100
bool setNames(const LocalizedNameMap &names) noexcept
Definition: componentsymbolvariant.cpp:113
const ElementName & getName() const noexcept
Definition: componentsymbolvariant.h:78
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:53
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Signal< ComponentSymbolVariant, Event > onEdited
Definition: componentsymbolvariant.h:63
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
bool setName(const QString &locale, const ElementName &name) noexcept
Definition: componentsymbolvariant.cpp:91
The SExpression class.
Definition: sexpression.h:69
bool operator==(const ComponentSymbolVariant &rhs) const noexcept
Definition: componentsymbolvariant.cpp:154
const LocalizedNameMap & getNames() const noexcept
Definition: componentsymbolvariant.h:81
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84