LibrePCB Developers Documentation
Loading...
Searching...
No Matches
libraryelementcategoriesmodel.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_LIBRARYELEMENTCATEGORIESMODEL_H
21#define LIBREPCB_EDITOR_LIBRARYELEMENTCATEGORIESMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Workspace;
38
39namespace editor {
40
41/*******************************************************************************
42 * Class LibraryElementCategoriesModel
43 ******************************************************************************/
44
49 : public QObject,
50 public slint::Model<ui::LibraryElementCategoryData> {
51 Q_OBJECT
52
53public:
54 // Types
55 enum class Type {
58 };
59
60 // Constructors / Destructor
63 delete;
64 explicit LibraryElementCategoriesModel(const Workspace& ws, Type type,
65 QObject* parent = nullptr) noexcept;
66 virtual ~LibraryElementCategoriesModel() noexcept;
67
68 // General Methods
69 const QSet<Uuid>& getCategories() const noexcept { return mCategories; }
70 void setCategories(const QSet<Uuid>& categories) noexcept;
71 void add(const Uuid& category) noexcept;
72
73 // Implementations
74 std::size_t row_count() const override;
75 std::optional<ui::LibraryElementCategoryData> row_data(
76 std::size_t i) const override;
77 void set_row_data(
78 std::size_t i,
79 const ui::LibraryElementCategoryData& data) noexcept override;
80
81 // Operator Overloadings
83 const LibraryElementCategoriesModel& rhs) = delete;
84
85signals:
86 void modified(const QSet<Uuid>& categories);
87
88private:
89 void refresh() noexcept;
90 template <typename T>
91 void loadItems();
92
93 const Workspace& mWs;
94 const Type mType;
96 std::vector<ui::LibraryElementCategoryData> mItems;
97};
98
99/*******************************************************************************
100 * End of File
101 ******************************************************************************/
102
103} // namespace editor
104} // namespace librepcb
105
106#endif
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The LibraryElementCategoriesModel class.
Definition libraryelementcategoriesmodel.h:50
void add(const Uuid &category) noexcept
Definition libraryelementcategoriesmodel.cpp:68
void set_row_data(std::size_t i, const ui::LibraryElementCategoryData &data) noexcept override
Definition libraryelementcategoriesmodel.cpp:89
Type
Definition libraryelementcategoriesmodel.h:55
std::vector< ui::LibraryElementCategoryData > mItems
Definition libraryelementcategoriesmodel.h:96
const Workspace & mWs
Definition libraryelementcategoriesmodel.h:93
void modified(const QSet< Uuid > &categories)
void refresh() noexcept
Definition libraryelementcategoriesmodel.cpp:104
LibraryElementCategoriesModel & operator=(const LibraryElementCategoriesModel &rhs)=delete
std::size_t row_count() const override
Definition libraryelementcategoriesmodel.cpp:80
void setCategories(const QSet< Uuid > &categories) noexcept
Definition libraryelementcategoriesmodel.cpp:60
LibraryElementCategoriesModel(const LibraryElementCategoriesModel &other)=delete
const QSet< Uuid > & getCategories() const noexcept
Definition libraryelementcategoriesmodel.h:69
std::optional< ui::LibraryElementCategoryData > row_data(std::size_t i) const override
Definition libraryelementcategoriesmodel.cpp:85
QSet< Uuid > mCategories
Definition libraryelementcategoriesmodel.h:95
const Type mType
Definition libraryelementcategoriesmodel.h:94
void loadItems()
Definition libraryelementcategoriesmodel.cpp:139
Definition occmodel.cpp:77
Definition uuid.h:186