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  ******************************************************************************/
37 namespace librepcb {
38 
39 class Workspace;
40 
41 namespace editor {
42 
43 namespace Ui {
44 class CategoryListEditorWidget;
45 }
46 
47 /*******************************************************************************
48  * Class CategoryListEditorWidget
49  ******************************************************************************/
50 
54 class CategoryListEditorWidget : public QWidget {
55  Q_OBJECT
56 
57 public:
58  enum class Categories {
59  Component,
60  Package,
61  };
62 
63  // Constructors / Destructor
64  CategoryListEditorWidget() = delete;
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
82  CategoryListEditorWidget& operator=(const CategoryListEditorWidget& rhs) =
83  delete;
84 
85 signals:
86  void edited();
87  void categoryAdded(const Uuid& category);
88  void categoryRemoved(const Uuid& category);
89 
90 private: // 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 
102 private: // Data
105  QScopedPointer<Ui::CategoryListEditorWidget> mUi;
107  QSet<Uuid> mUuids;
108 };
109 
110 /*******************************************************************************
111  * End of File
112  ******************************************************************************/
113 
114 } // namespace editor
115 } // namespace librepcb
116 
117 #endif
const Categories mCategories
Definition: categorylisteditorwidget.h:104
Definition: occmodel.cpp:77
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:54
Categories
Definition: categorylisteditorwidget.h:58
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:59
const QSet< Uuid > & getUuids() const noexcept
Definition: categorylisteditorwidget.h:71
The Component class represents a "generic" device in the library.
Definition: component.h:73
const Workspace & mWorkspace
Definition: categorylisteditorwidget.h:103
QSet< Uuid > mUuids
Definition: categorylisteditorwidget.h:107
QScopedPointer< Ui::CategoryListEditorWidget > mUi
Definition: categorylisteditorwidget.h:105
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void openAddCategoryDialog() noexcept
Definition: categorylisteditorwidget.h:79
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:54
bool mRequiresMinimumOneEntry
Definition: categorylisteditorwidget.h:106