LibrePCB Developers Documentation
Loading...
Searching...
No Matches
categorytreemodel.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_CATEGORYTREEMODEL_H
21#define LIBREPCB_EDITOR_CATEGORYTREEMODEL_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 WorkspaceLibraryDb;
38class WorkspaceSettings;
39
40namespace editor {
41
42/*******************************************************************************
43 * Class CategoryTreeModel
44 ******************************************************************************/
45
49class CategoryTreeModel : public QObject,
50 public slint::Model<ui::TreeViewItemData> {
51 Q_OBJECT
52
53public:
54 // Types
55 enum class Filter {
57 CmpCat = 1 << 0,
59 PkgCat = 1 << 4,
60 };
61 Q_DECLARE_FLAGS(Filters, Filter)
62
63 // Constructors / Destructor
65 CategoryTreeModel(const CategoryTreeModel& other) = delete;
66 explicit CategoryTreeModel(
67 const WorkspaceLibraryDb& db, const WorkspaceSettings& ws,
68 Filters filters, const std::optional<Uuid>& hiddenCategory = std::nullopt,
69 QObject* parent = nullptr) noexcept;
70 virtual ~CategoryTreeModel() noexcept;
71
72 // Implementations
73 std::size_t row_count() const override;
74 std::optional<ui::TreeViewItemData> row_data(std::size_t i) const override;
75
76 // Operator Overloadings
77 CategoryTreeModel& operator=(const CategoryTreeModel& rhs) = delete;
78
79private: // Methods
80 void refresh() noexcept;
81 template <typename T>
82 void loadChilds(const std::optional<Uuid>& parent, int level);
83
84private: // Data
87 const Filters mFilters;
88 const std::optional<Uuid> mHiddenCategory;
89 const slint::Image mIcon;
90 std::vector<ui::TreeViewItemData> mItems;
91};
92
93/*******************************************************************************
94 * End of File
95 ******************************************************************************/
96
97} // namespace editor
98} // namespace librepcb
99
100#endif
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The WorkspaceLibraryDb class.
Definition workspacelibrarydb.h:58
Container for all workspace related settings.
Definition workspacesettings.h:60
The CategoryTreeModel class.
Definition categorytreemodel.h:50
void loadChilds(const std::optional< Uuid > &parent, int level)
Definition categorytreemodel.cpp:109
const slint::Image mIcon
Definition categorytreemodel.h:89
const WorkspaceLibraryDb & mDb
Definition categorytreemodel.h:85
std::optional< ui::TreeViewItemData > row_data(std::size_t i) const override
Definition categorytreemodel.cpp:71
void refresh() noexcept
Definition categorytreemodel.cpp:80
std::size_t row_count() const override
Definition categorytreemodel.cpp:67
const WorkspaceSettings & mSettings
Definition categorytreemodel.h:86
const Filters mFilters
Definition categorytreemodel.h:87
Filter
Definition categorytreemodel.h:55
@ CmpCat
Show all component categories, even empty ones.
@ PkgCat
Show all package categories, even empty ones.
std::vector< ui::TreeViewItemData > mItems
Definition categorytreemodel.h:90
const std::optional< Uuid > mHiddenCategory
Definition categorytreemodel.h:88
Definition occmodel.cpp:77
Definition uuid.h:186