LibrePCB Developers Documentation
categorylisteditorwidget.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_CATEGORYLISTEDITORWIDGET_H
21#define LIBREPCB_EDITOR_CATEGORYLISTEDITORWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "categorytreebuilder.h"
27
30
31#include <QtCore>
32#include <QtWidgets>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Workspace;
40
41namespace editor {
42
43namespace Ui {
44class CategoryListEditorWidget;
45}
46
47/*******************************************************************************
48 * Class CategoryListEditorWidget
49 ******************************************************************************/
50
54class CategoryListEditorWidget : public QWidget {
55 Q_OBJECT
56
57public:
58 enum class Categories {
60 Package,
61 };
62
63 // Constructors / Destructor
65 explicit CategoryListEditorWidget(const Workspace& ws, Categories categories,
66 QWidget* parent = nullptr) noexcept;
68 virtual ~CategoryListEditorWidget() noexcept;
69
70 // Getters
71 const QSet<Uuid>& getUuids() const noexcept { return mUuids; }
72
73 // Setters
74 void setReadOnly(bool readOnly) noexcept;
75 void setRequiresMinimumOneEntry(bool v) noexcept;
76 void setUuids(const QSet<Uuid>& uuids) noexcept;
77
78 // General Methods
79 void openAddCategoryDialog() noexcept { btnAddClicked(); }
80
81 // Operator Overloadings
83 delete;
84
85signals:
86 void edited();
87 void categoryAdded(const Uuid& category);
88 void categoryRemoved(const Uuid& category);
89
90private: // Methods
91 void btnAddClicked() noexcept;
92 void btnRemoveClicked() noexcept;
93 void addItem(const tl::optional<Uuid>& category) noexcept;
94 void addItem(const tl::optional<Uuid>& category,
95 const QStringList& lines) noexcept;
96 void addItem(const tl::optional<Uuid>& category,
97 const QString& text) noexcept;
98 void updateColor() noexcept;
99 QStringList buildTree(const tl::optional<Uuid>& category) const;
100 tl::optional<Uuid> chooseCategoryWithDialog() noexcept;
101
102private: // Data
105 QScopedPointer<Ui::CategoryListEditorWidget> mUi;
108};
109
110/*******************************************************************************
111 * End of File
112 ******************************************************************************/
113
114} // namespace editor
115} // namespace librepcb
116
117#endif
The Component class represents a "generic" device in the library.
Definition: component.h:73
The Package class represents a package of a component (including footprint and 3D model)
Definition: package.h:59
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition: workspace.h:54
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:54
void btnAddClicked() noexcept
Definition: categorylisteditorwidget.cpp:88
void openAddCategoryDialog() noexcept
Definition: categorylisteditorwidget.h:79
bool mRequiresMinimumOneEntry
Definition: categorylisteditorwidget.h:106
void updateColor() noexcept
Definition: categorylisteditorwidget.cpp:146
void setReadOnly(bool readOnly) noexcept
Definition: categorylisteditorwidget.cpp:66
const Categories mCategories
Definition: categorylisteditorwidget.h:104
tl::optional< Uuid > chooseCategoryWithDialog() noexcept
Definition: categorylisteditorwidget.cpp:170
const Workspace & mWorkspace
Definition: categorylisteditorwidget.h:103
QScopedPointer< Ui::CategoryListEditorWidget > mUi
Definition: categorylisteditorwidget.h:105
void categoryAdded(const Uuid &category)
Categories
Definition: categorylisteditorwidget.h:58
void categoryRemoved(const Uuid &category)
QSet< Uuid > mUuids
Definition: categorylisteditorwidget.h:107
void setUuids(const QSet< Uuid > &uuids) noexcept
Definition: categorylisteditorwidget.cpp:76
const QSet< Uuid > & getUuids() const noexcept
Definition: categorylisteditorwidget.h:71
CategoryListEditorWidget & operator=(const CategoryListEditorWidget &rhs)=delete
void btnRemoveClicked() noexcept
Definition: categorylisteditorwidget.cpp:98
void setRequiresMinimumOneEntry(bool v) noexcept
Definition: categorylisteditorwidget.cpp:71
void addItem(const tl::optional< Uuid > &category) noexcept
Definition: categorylisteditorwidget.cpp:114
QStringList buildTree(const tl::optional< Uuid > &category) const
Definition: categorylisteditorwidget.cpp:154
Definition: occmodel.cpp:77
Definition: uuid.h:183