LibrePCB Developers Documentation
onlinelibrarylistwidgetitem.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_EDITOR_ONLINELIBRARYLISTWIDGETITEM_H
21#define LIBREPCB_EDITOR_ONLINELIBRARYLISTWIDGETITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
29
30#include <QtCore>
31#include <QtWidgets>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Workspace;
39
40namespace editor {
41
42class LibraryDownload;
43
44namespace Ui {
45class OnlineLibraryListWidgetItem;
46}
47
48/*******************************************************************************
49 * Class OnlineLibraryListWidgetItem
50 ******************************************************************************/
51
55class OnlineLibraryListWidgetItem final : public QWidget {
56 Q_OBJECT
57
58public:
59 // Constructors / Destructor
62 delete;
63 OnlineLibraryListWidgetItem(Workspace& ws, const QJsonObject& obj) noexcept;
65
66 // Getters
67 const tl::optional<Uuid>& getUuid() const noexcept { return mUuid; }
68 const QString& getName() const noexcept { return mName; }
69 const QSet<Uuid>& getDependencies() const noexcept { return mDependencies; }
70 bool isChecked() const noexcept;
71
72 // Setters
73 void setChecked(bool checked) noexcept;
74
75 // General Methods
76 void startDownloadIfSelected() noexcept;
77
78 // Operator Overloadings
80 const OnlineLibraryListWidgetItem& rhs) = delete;
81
82signals:
83 void checkedChanged(bool checked);
84
85private: // Methods
86 void downloadFinished(bool success, const QString& errMsg) noexcept;
87 void iconReceived(const QByteArray& data) noexcept;
88 void updateInstalledStatus() noexcept;
89
90private: // Data
92 QJsonObject mJsonObject;
93 tl::optional<Uuid> mUuid;
94 QString mName;
95 tl::optional<Version> mVersion;
98 QScopedPointer<Ui::OnlineLibraryListWidgetItem> mUi;
101};
102
103/*******************************************************************************
104 * End of File
105 ******************************************************************************/
106
107} // namespace editor
108} // namespace librepcb
109
110#endif
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition: workspace.h:54
The LibraryDownload class.
Definition: librarydownload.h:46
The OnlineLibraryListWidgetItem class.
Definition: onlinelibrarylistwidgetitem.h:55
tl::optional< Uuid > mUuid
Definition: onlinelibrarylistwidgetitem.h:93
void startDownloadIfSelected() noexcept
Definition: onlinelibrarylistwidgetitem.cpp:123
~OnlineLibraryListWidgetItem() noexcept
Definition: onlinelibrarylistwidgetitem.cpp:99
const QString & getName() const noexcept
Definition: onlinelibrarylistwidgetitem.h:68
bool mIsRecommended
Definition: onlinelibrarylistwidgetitem.h:96
QJsonObject mJsonObject
Definition: onlinelibrarylistwidgetitem.h:92
bool mAutoCheck
Definition: onlinelibrarylistwidgetitem.h:100
QString mName
Definition: onlinelibrarylistwidgetitem.h:94
void setChecked(bool checked) noexcept
Definition: onlinelibrarylistwidgetitem.cpp:114
bool isChecked() const noexcept
Definition: onlinelibrarylistwidgetitem.cpp:106
const QSet< Uuid > & getDependencies() const noexcept
Definition: onlinelibrarylistwidgetitem.h:69
const tl::optional< Uuid > & getUuid() const noexcept
Definition: onlinelibrarylistwidgetitem.h:67
OnlineLibraryListWidgetItem(const OnlineLibraryListWidgetItem &other)=delete
void downloadFinished(bool success, const QString &errMsg) noexcept
Definition: onlinelibrarylistwidgetitem.cpp:162
void iconReceived(const QByteArray &data) noexcept
Definition: onlinelibrarylistwidgetitem.cpp:183
QSet< Uuid > mDependencies
Definition: onlinelibrarylistwidgetitem.h:97
Workspace & mWorkspace
Definition: onlinelibrarylistwidgetitem.h:91
tl::optional< Version > mVersion
Definition: onlinelibrarylistwidgetitem.h:95
QScopedPointer< LibraryDownload > mLibraryDownload
Definition: onlinelibrarylistwidgetitem.h:99
void updateInstalledStatus() noexcept
Definition: onlinelibrarylistwidgetitem.cpp:190
QScopedPointer< Ui::OnlineLibraryListWidgetItem > mUi
Definition: onlinelibrarylistwidgetitem.h:98
Definition: occmodel.cpp:77
Definition: uuid.h:183