LibrePCB Developers Documentation
Loading...
Searching...
No Matches
library.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_LIBRARY_H
21#define LIBREPCB_CORE_LIBRARY_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/simplestring.h"
27#include "../types/uuid.h"
28#include "librarybaseelement.h"
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39/*******************************************************************************
40 * Class Library
41 ******************************************************************************/
42
46class Library final : public LibraryBaseElement {
47 Q_OBJECT
48
49public:
50 // Constructors / Destructor
51 Library() = delete;
52 Library(const Library& other) = delete;
53 Library(const Uuid& uuid, const Version& version, const QString& author,
54 const ElementName& name_en_US, const QString& description_en_US,
55 const QString& keywords_en_US);
56 ~Library() noexcept;
57
58 // Getters
59 template <typename ElementType>
60 QString getElementsDirectoryName() const noexcept;
61 const QUrl& getUrl() const noexcept { return mUrl; }
62 const QSet<Uuid>& getDependencies() const noexcept { return mDependencies; }
63 const QByteArray& getIcon() const noexcept { return mIcon; }
64 QPixmap getIconAsPixmap() const noexcept;
65 const SimpleString& getManufacturer() const noexcept { return mManufacturer; }
66
67 // Setters
68 void setUrl(const QUrl& url) noexcept { mUrl = url; }
69 void setDependencies(const QSet<Uuid>& deps) noexcept {
70 mDependencies = deps;
71 }
72 void setIcon(const QByteArray& png) noexcept { mIcon = png; }
73 void setManufacturer(const SimpleString& value) noexcept {
74 if (value != mManufacturer) {
75 mManufacturer = value;
77 }
78 }
79
80 // General Methods
81 virtual void save() override;
82 virtual void moveTo(TransactionalDirectory& dest) override;
83 template <typename ElementType>
84 QStringList searchForElements() const noexcept;
85
86 // Operator Overloadings
87 Library& operator=(const Library& rhs) = delete;
88
89 // Static Methods
90 static std::unique_ptr<Library> open(
91 std::unique_ptr<TransactionalDirectory> directory,
92 bool abortBeforeMigration = false);
93 static QString getShortElementName() noexcept {
94 return QStringLiteral("lib");
95 }
96 static QString getLongElementName() noexcept {
97 return QStringLiteral("library");
98 }
99
100signals:
102
103protected:
104 virtual void serialize(SExpression& root) const override;
105
106private: // Methods
107 Library(std::unique_ptr<TransactionalDirectory> directory,
108 const SExpression& root);
109
110private: // Data
111 QUrl mUrl;
112 QSet<Uuid> mDependencies;
113 QByteArray mIcon;
115};
116
117/*******************************************************************************
118 * End of File
119 ******************************************************************************/
120
121} // namespace librepcb
122
123#endif
The LibraryBaseElement class.
Definition librarybaseelement.h:48
The Library class represents a library directory.
Definition library.h:46
void setIcon(const QByteArray &png) noexcept
Definition library.h:72
void setManufacturer(const SimpleString &value) noexcept
Definition library.h:73
void setUrl(const QUrl &url) noexcept
Definition library.h:68
QUrl mUrl
Definition library.h:111
SimpleString mManufacturer
Definition library.h:114
void setDependencies(const QSet< Uuid > &deps) noexcept
Definition library.h:69
const SimpleString & getManufacturer() const noexcept
Definition library.h:65
void manufacturerChanged(const SimpleString &mfr)
static std::unique_ptr< Library > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition library.cpp:173
QByteArray mIcon
Definition library.h:113
const QSet< Uuid > & getDependencies() const noexcept
Definition library.h:62
virtual void save() override
Definition library.cpp:120
QSet< Uuid > mDependencies
Definition library.h:112
static QString getLongElementName() noexcept
Definition library.h:96
QStringList searchForElements() const noexcept
Definition library.cpp:145
Library(const Library &other)=delete
QPixmap getIconAsPixmap() const noexcept
Definition library.cpp:110
~Library() noexcept
Definition library.cpp:86
const QUrl & getUrl() const noexcept
Definition library.h:61
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition library.cpp:205
QString getElementsDirectoryName() const noexcept
Definition library.cpp:94
const QByteArray & getIcon() const noexcept
Definition library.h:63
virtual void moveTo(TransactionalDirectory &dest) override
Definition library.cpp:131
static QString getShortElementName() noexcept
Definition library.h:93
The SExpression class.
Definition sexpression.h:69
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
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
Definition occmodel.cpp:77
type_safe::constrained_type< QString, SimpleStringConstraint, SimpleStringVerifier > SimpleString
Definition simplestring.h:79
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84
Definition uuid.h:186