LibrePCB Developers Documentation
packagemodel.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_PACKAGEMODEL_H
21#define LIBREPCB_CORE_PACKAGEMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../serialization/serializableobjectlist.h"
27#include "../../types/elementname.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36/*******************************************************************************
37 * Class PackageModel
38 ******************************************************************************/
39
43class PackageModel final {
44 Q_DECLARE_TR_FUNCTIONS(PackageModel)
45
46public:
47 // Signals
48 enum class Event {
49 UuidChanged,
50 NameChanged,
51 };
54
55 // Constructors / Destructor
56 PackageModel() = delete;
57 PackageModel(const PackageModel& other) noexcept;
58 PackageModel(const Uuid& uuid, const ElementName& name) noexcept;
59 explicit PackageModel(const SExpression& node);
60 ~PackageModel() noexcept;
61
62 // Getters
63 const Uuid& getUuid() const noexcept { return mUuid; }
64 const ElementName& getName() const noexcept { return mName; }
65 QString getFileName() const noexcept { return mUuid.toStr() % ".step"; }
66
67 // Setters
68 bool setName(const ElementName& name) noexcept;
69
70 // General Methods
71
77 void serialize(SExpression& root) const;
78
79 // Operator Overloadings
80 bool operator==(const PackageModel& rhs) const noexcept;
81 bool operator!=(const PackageModel& rhs) const noexcept {
82 return !(*this == rhs);
83 }
84 PackageModel& operator=(const PackageModel& rhs) noexcept;
85
86private: // Data
89};
90
91/*******************************************************************************
92 * Class PackageModelList
93 ******************************************************************************/
94
96 static constexpr const char* tagname = "3d_model";
97};
101
102/*******************************************************************************
103 * End of File
104 ******************************************************************************/
105
106} // namespace librepcb
107
108#endif
Represents a 3D model of a librepcb::Package.
Definition: packagemodel.h:43
Slot< PackageModel, Event > OnEditedSlot
Definition: packagemodel.h:53
PackageModel & operator=(const PackageModel &rhs) noexcept
Definition: packagemodel.cpp:86
QString getFileName() const noexcept
Definition: packagemodel.h:65
const ElementName & getName() const noexcept
Definition: packagemodel.h:64
Uuid mUuid
Definition: packagemodel.h:87
~PackageModel() noexcept
Definition: packagemodel.cpp:50
Event
Definition: packagemodel.h:48
bool operator==(const PackageModel &rhs) const noexcept
Definition: packagemodel.cpp:80
ElementName mName
Definition: packagemodel.h:88
bool setName(const ElementName &name) noexcept
Definition: packagemodel.cpp:57
bool operator!=(const PackageModel &rhs) const noexcept
Definition: packagemodel.h:81
Signal< PackageModel, Event > onEdited
Definition: packagemodel.h:52
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: packagemodel.cpp:71
const Uuid & getUuid() const noexcept
Definition: packagemodel.h:63
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 Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
QString toStr() const noexcept
Get the UUID as a string (without braces)
Definition: uuid.h:88
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84
Definition: packagemodel.h:95
static constexpr const char * tagname
Definition: packagemodel.h:96