LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componentvariantlistmodel.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_COMPONENTVARIANTLISTMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTVARIANTLISTMODEL_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 Component;
38class Workspace;
39
40namespace editor {
41
42class ComponentSignalNameListModel;
43class ComponentVariantEditor;
44class GraphicsLayerList;
45class LibraryElementCache;
46class UndoCommand;
47class UndoStack;
48
49/*******************************************************************************
50 * Class ComponentVariantListModel
51 ******************************************************************************/
52
57 : public QObject,
58 public slint::Model<ui::ComponentVariantData> {
59 Q_OBJECT
60
61public:
62 // Constructors / Destructor
65 explicit ComponentVariantListModel(const Workspace& ws,
66 const GraphicsLayerList& layers,
67 const LibraryElementCache& cache,
68 QObject* parent = nullptr) noexcept;
69 ~ComponentVariantListModel() noexcept;
70
71 // General Methods
73 QPointer<Component> component,
74 const std::shared_ptr<ComponentSignalNameListModel>& sigs,
75 UndoStack* stack, const bool* wizardMode) noexcept;
76 slint::Image renderScene(int variant, int gate, float width,
77 float height) noexcept;
78 void add() noexcept;
79
80 // Implementations
81 std::size_t row_count() const override;
82 std::optional<ui::ComponentVariantData> row_data(
83 std::size_t i) const override;
84 void set_row_data(std::size_t i,
85 const ui::ComponentVariantData& data) noexcept override;
86
87 // Operator Overloadings
89 delete;
90
91private:
92 void trigger(int index, std::shared_ptr<ComponentSymbolVariant> obj,
93 ui::ComponentVariantAction a) noexcept;
94 void listEdited(const ComponentSymbolVariantList& list, int index,
95 const std::shared_ptr<const ComponentSymbolVariant>& variant,
96 ComponentSymbolVariantList::Event event) noexcept;
97 void variantUiDataChanged() noexcept;
98 void execCmd(UndoCommand* cmd);
99
100private:
108 const bool* mWizardMode;
109
110 QList<std::shared_ptr<ComponentVariantEditor>> mItems;
111
112 // Slots
114};
115
116/*******************************************************************************
117 * End of File
118 ******************************************************************************/
119
120} // namespace editor
121} // namespace librepcb
122
123#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition componentsymbolvariant.h:53
The Image class.
Definition image.h:49
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The ComponentSignalNameListModel class.
Definition componentsignalnamelistmodel.h:50
The ComponentVariantEditor class.
Definition componentvarianteditor.h:56
The ComponentVariantListModel class.
Definition componentvariantlistmodel.h:58
void listEdited(const ComponentSymbolVariantList &list, int index, const std::shared_ptr< const ComponentSymbolVariant > &variant, ComponentSymbolVariantList::Event event) noexcept
Definition componentvariantlistmodel.cpp:223
void setReferences(ComponentSymbolVariantList *list, QPointer< Component > component, const std::shared_ptr< ComponentSignalNameListModel > &sigs, UndoStack *stack, const bool *wizardMode) noexcept
Definition componentvariantlistmodel.cpp:71
std::optional< ui::ComponentVariantData > row_data(std::size_t i) const override
Definition componentvariantlistmodel.cpp:161
void add() noexcept
Definition componentvariantlistmodel.cpp:118
void execCmd(UndoCommand *cmd)
Definition componentvariantlistmodel.cpp:267
const GraphicsLayerList & mLayers
Definition componentvariantlistmodel.h:102
void trigger(int index, std::shared_ptr< ComponentSymbolVariant > obj, ui::ComponentVariantAction a) noexcept
Definition componentvariantlistmodel.cpp:192
QPointer< Component > mComponent
Definition componentvariantlistmodel.h:104
const Workspace & mWorkspace
Definition componentvariantlistmodel.h:101
const LibraryElementCache & mCache
Definition componentvariantlistmodel.h:103
std::size_t row_count() const override
Definition componentvariantlistmodel.cpp:157
ComponentVariantListModel(const ComponentVariantListModel &other)=delete
const bool * mWizardMode
Definition componentvariantlistmodel.h:108
QList< std::shared_ptr< ComponentVariantEditor > > mItems
Definition componentvariantlistmodel.h:110
QPointer< UndoStack > mUndoStack
Definition componentvariantlistmodel.h:107
ComponentSymbolVariantList * mList
Definition componentvariantlistmodel.h:106
std::shared_ptr< ComponentSignalNameListModel > mSignals
Definition componentvariantlistmodel.h:105
void variantUiDataChanged() noexcept
Definition componentvariantlistmodel.cpp:259
slint::Image renderScene(int variant, int gate, float width, float height) noexcept
Definition componentvariantlistmodel.cpp:108
void set_row_data(std::size_t i, const ui::ComponentVariantData &data) noexcept override
Definition componentvariantlistmodel.cpp:170
ComponentSymbolVariantList::OnEditedSlot mOnEditedSlot
Definition componentvariantlistmodel.h:113
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
Cache for fast access to library elements.
Definition libraryelementcache.h:56
The UndoCommand class represents a command which you can undo/redo.
Definition undocommand.h:46
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
Definition uuid.h:186